/* Flerza interface primitives. Every selector is opt-in to protect legacy pages. */
.fl-page{box-sizing:border-box;width:min(100%,var(--fl-content-width));margin-inline:auto;padding:var(--fl-space-6) var(--fl-space-4) var(--fl-space-7);color:var(--fl-color-text);font-family:var(--fl-font-family);line-height:var(--fl-line-height);overflow-wrap:anywhere}
.fl-page *,.fl-page *::before,.fl-page *::after{box-sizing:border-box}
.fl-page-header,.fl-action-bar{display:flex;gap:var(--fl-space-4);align-items:flex-start;justify-content:space-between;flex-wrap:wrap}
.fl-page-header{margin-bottom:var(--fl-space-5)}.fl-page-header__content{min-width:0}.fl-page-header__eyebrow{margin:0 0 var(--fl-space-1);color:var(--fl-color-primary);font-size:var(--fl-font-size-sm);font-weight:700;text-transform:uppercase;letter-spacing:.04em}.fl-page-header__title{margin:0;font-size:clamp(1.75rem,4vw,2.25rem);line-height:1.2}.fl-page-header__description{max-width:48rem;margin:var(--fl-space-2) 0 0;color:var(--fl-color-text-muted)}
.fl-button{display:inline-flex;min-height:var(--fl-control-height);max-width:100%;padding:.65rem 1rem;align-items:center;justify-content:center;gap:var(--fl-space-2);border:1px solid transparent;border-radius:var(--fl-radius-sm);background:transparent;color:var(--fl-color-text);font:inherit;font-weight:700;line-height:1.25;text-align:center;text-decoration:none;white-space:normal;cursor:pointer;transition:background-color var(--fl-motion-duration,160ms),border-color var(--fl-motion-duration,160ms),color var(--fl-motion-duration,160ms)}
.fl-button--primary{background:var(--fl-color-primary);color:var(--fl-color-on-primary)}.fl-button--primary:hover{background:var(--fl-color-primary-hover)}.fl-button--secondary{border-color:var(--fl-color-border-strong);background:var(--fl-color-surface)}.fl-button--secondary:hover{border-color:var(--fl-color-primary);color:var(--fl-color-primary)}.fl-button--quiet{color:var(--fl-color-primary)}.fl-button--quiet:hover{background:var(--fl-color-primary-soft)}.fl-button--danger{background:var(--fl-color-danger);color:var(--fl-color-on-danger)}.fl-button--danger:hover{background:var(--fl-color-danger-hover)}.fl-button[disabled],.fl-button[aria-disabled="true"]{opacity:.6;cursor:not-allowed}
.fl-card,.fl-panel{min-width:0;border:1px solid var(--fl-color-border);border-radius:var(--fl-radius-md);background:var(--fl-color-surface)}.fl-card{padding:var(--fl-space-5);box-shadow:var(--fl-shadow-sm)}.fl-panel{padding:var(--fl-space-5);background:var(--fl-color-surface-subtle)}
.fl-field{display:grid;gap:var(--fl-space-2);min-width:0;font-weight:700}.fl-field__required{color:var(--fl-color-danger)}.fl-field__control{width:100%;min-width:0;min-height:var(--fl-control-height);padding:.65rem .75rem;border:1px solid var(--fl-color-border-strong);border-radius:var(--fl-radius-sm);background:var(--fl-color-surface);color:var(--fl-color-text);font:inherit}.fl-field__help{margin:0;color:var(--fl-color-text-muted);font-size:var(--fl-font-size-sm);font-weight:400}.fl-field__error{margin:0;color:var(--fl-color-danger);font-size:var(--fl-font-size-sm);font-weight:700}
.fl-badge{display:inline-flex;min-height:1.75rem;padding:.2rem .65rem;align-items:center;gap:var(--fl-space-1);border-radius:999px;background:var(--fl-color-primary-soft);color:var(--fl-color-primary);font-size:var(--fl-font-size-sm);font-weight:700}.fl-badge::before{content:"";width:.45rem;height:.45rem;border-radius:50%;background:currentColor}.fl-badge--success{background:var(--fl-color-success-surface);color:var(--fl-color-success)}.fl-badge--warning{background:var(--fl-color-warning-surface);color:var(--fl-color-warning)}.fl-badge--danger{background:var(--fl-color-danger-surface);color:var(--fl-color-danger)}
.fl-message{padding:var(--fl-space-4);border:1px solid currentColor;border-radius:var(--fl-radius-sm);color:var(--fl-color-info);background:var(--fl-color-info-surface)}.fl-message--success{color:var(--fl-color-success);background:var(--fl-color-success-surface)}.fl-message--warning{color:var(--fl-color-warning);background:var(--fl-color-warning-surface)}.fl-message--error{color:var(--fl-color-danger);background:var(--fl-color-danger-surface)}
.fl-empty-state{padding:var(--fl-space-7) var(--fl-space-5);border:1px dashed var(--fl-color-border-strong);border-radius:var(--fl-radius-md);background:var(--fl-color-surface-subtle);color:var(--fl-color-text-muted);text-align:center}
.fl-loading{display:inline-flex;align-items:center;gap:var(--fl-space-2);color:var(--fl-color-text-muted)}.fl-loading::before{content:"";width:1rem;height:1rem;border:2px solid var(--fl-color-border-strong);border-top-color:var(--fl-color-primary);border-radius:50%;animation:fl-spin .7s linear infinite}@keyframes fl-spin{to{transform:rotate(360deg)}}
.fl-filters,.fl-tabs{display:flex;gap:var(--fl-space-2);align-items:center;flex-wrap:wrap}.fl-filter,.fl-tab{display:inline-flex;min-height:var(--fl-control-height);padding:.55rem .8rem;align-items:center;border-radius:var(--fl-radius-sm);color:var(--fl-color-primary);font-weight:650;text-decoration:none}.fl-filter:hover,.fl-tab:hover{background:var(--fl-color-primary-soft)}.fl-filter[aria-current="page"],.fl-tab[aria-current="page"]{background:var(--fl-color-primary-soft);font-weight:800}
.fl-save-bar{position:sticky;z-index:20;bottom:0;display:flex;margin-top:var(--fl-space-5);padding:var(--fl-space-3) var(--fl-space-4);align-items:center;justify-content:flex-end;gap:var(--fl-space-3);border:1px solid var(--fl-color-border);border-radius:var(--fl-radius-md) var(--fl-radius-md) 0 0;background:var(--fl-color-surface);box-shadow:var(--fl-shadow-md)}
.fl-dialog{width:min(calc(100% - 2rem),32rem);padding:0;border:0;border-radius:var(--fl-radius-lg);color:var(--fl-color-text);box-shadow:var(--fl-shadow-md)}.fl-dialog::backdrop{background:rgba(15,23,42,.58)}.fl-dialog__content{padding:var(--fl-space-5)}
.fl-page :where(a,button,input,select,textarea,summary,[tabindex]):focus-visible,.fl-dialog :where(a,button,input,select,textarea,summary,[tabindex]):focus-visible{outline:2px solid var(--fl-focus-color);outline-offset:2px;box-shadow:var(--fl-focus-ring)}
@media(max-width:650px){.fl-page{padding:var(--fl-space-5) var(--fl-space-3) var(--fl-space-6)}.fl-page-header,.fl-action-bar{align-items:stretch}.fl-page-header>*,.fl-action-bar>*{max-width:100%}.fl-page-header .fl-button,.fl-action-bar .fl-button{width:100%}.fl-card,.fl-panel{padding:var(--fl-space-4)}.fl-filters,.fl-tabs{align-items:stretch}.fl-filter,.fl-tab{flex:1 1 auto;justify-content:center}.fl-save-bar{margin-inline:calc(-1 * var(--fl-space-3));border-radius:0}}
@media(prefers-reduced-motion:reduce){.fl-loading::before{animation-duration:1.5s}}
@media print{.fl-save-bar,.fl-dialog{display:none!important}}

/* Shared application conventions. Opt in with fl-ui; paper layouts stay separate. */
.fl-page--narrow { max-width: var(--fl-content-width-narrow); }
.fl-page :where(a,button,input,select,textarea,summary,[tabindex]):focus-visible,
.fl-button:focus-visible { outline: 3px solid var(--fl-focus-color); outline-offset: 3px; }
.fl-button--danger { color: var(--fl-color-on-danger); }
.fl-field__help { margin: 0; color: var(--fl-color-text-muted); font-size: var(--fl-font-size-sm); }
.fl-save-bar { background: var(--fl-color-surface); flex-wrap: wrap; }
.fl-dialog { background: var(--fl-color-surface); max-height: calc(100dvh - 2rem); overflow: auto; }
.fl-dialog::backdrop { background: var(--fl-overlay); }
.fl-field__control[readonly] { background: var(--fl-color-surface-subtle); }
.fl-field__control[aria-invalid="true"] { border-color: var(--fl-color-danger); border-width: 2px; }
.fl-badge--info { color: var(--fl-color-info); background: var(--fl-color-info-surface); }
.fl-badge--neutral { color: var(--fl-color-text-muted); background: var(--fl-color-surface-subtle); }
.fl-check { display: flex; align-items: center; gap: var(--fl-space-2); min-height: var(--fl-control-height); }
.fl-stack { display: grid; gap: var(--fl-space-4); }
.fl-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--fl-space-3); }
.fl-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.fl-skip-link { position: fixed; top: .5rem; left: .5rem; z-index: 10001; padding: .75rem 1rem; border: 2px solid var(--fl-focus-color); border-radius: var(--fl-radius-sm); color: var(--fl-color-text); background: var(--fl-color-surface); transform: translateY(-180%); }
.fl-skip-link:focus { transform: none; }

@media screen {
    .fl-ui { min-width: 0; color: var(--fl-color-text); line-height: var(--fl-line-height); overflow-wrap: anywhere; }
    .fl-ui :where(form,fieldset) { min-width: 0; }
    :root .fl-ui :is(button,.fl-button,.primary-button,.secondary-button,.danger-button,.btn,.btn-secondary,.btn-danger,.absence-button,.expense-button) {
        box-sizing: border-box; min-height: var(--fl-control-height); max-width: 100%;
        border-radius: var(--fl-radius-sm); font: inherit; font-weight: 700;
        white-space: normal; overflow-wrap: anywhere; cursor: pointer;
    }
    :root .fl-ui :is(.primary-button,.btn.primary,.btn.premium,.fl-button--primary) {
        background: var(--company-primary, var(--fl-color-primary));
        border-color: var(--company-primary, var(--fl-color-primary));
        color: var(--company-on-primary, var(--fl-color-on-primary));
    }
    :root .fl-ui :is(.secondary-button,.btn-secondary,.btn.secondary,.fl-button--secondary) {
        background: var(--fl-color-surface); color: var(--fl-color-text); border: 1px solid var(--fl-color-border-strong);
    }
    :root .fl-ui :is(.danger-button,.btn-danger,.profile-btn-danger) {
        background: var(--fl-color-danger-surface); color: var(--fl-color-danger); border: 1px solid currentColor;
    }
    :root .fl-ui :is(.primary-button,.btn.primary,.fl-button--primary):hover:not(:disabled),
    :root .fl-ui :is(.primary-button,.btn.primary,.fl-button--primary):active:not(:disabled) { box-shadow: inset 0 0 0 2px currentColor; }
    :root .fl-ui :is(.secondary-button,.btn-secondary,.btn.secondary,.fl-button--secondary):hover:not(:disabled) { background: var(--fl-color-surface-subtle); }
    :root .fl-ui :is(button,input,select,textarea):disabled { cursor: not-allowed; opacity: .65; }
    :root .fl-ui :is(input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="range"]):not([type="submit"]):not([type="button"]):not([type="image"]):not([type="file"]),select,textarea):not(:where(.preview-page *, .invoice-document *, .report-preview-sheet *, .cerfa-preview *)) {
        box-sizing: border-box; min-width: 0; max-width: 100%; min-height: var(--fl-control-height);
        padding: .65rem .75rem; border: 1px solid var(--fl-color-border-strong); border-radius: var(--fl-radius-sm);
        color: var(--fl-color-text); background: var(--fl-color-surface); font: inherit;
    }
    :root .fl-ui textarea { resize: vertical; }
    :root .fl-ui :is(input,textarea)[readonly] { background: var(--fl-color-surface-subtle); }
    :root .fl-ui :is(input,select,textarea)[aria-invalid="true"] { border: 2px solid var(--fl-color-danger); }
    .fl-ui :is(input[type="checkbox"],input[type="radio"]) { width: 1.25rem; height: 1.25rem; flex: 0 0 auto; accent-color: var(--fl-color-primary); }
    .fl-ui input[type="file"] { max-width: 100%; min-width: 0; }
    .fl-ui input[type="file"]::file-selector-button { min-height: var(--fl-control-height); margin-right: .5rem; border: 1px solid var(--fl-color-border-strong); border-radius: var(--fl-radius-sm); background: var(--fl-color-surface); color: var(--fl-color-text); font: inherit; }
    .fl-ui ::placeholder { color: var(--fl-color-text-muted); opacity: 1; }
    :root .fl-ui :is(a,button,input,select,textarea,summary,[tabindex]):focus-visible {
        outline: 3px solid var(--fl-focus-color); outline-offset: 3px;
    }
    .fl-ui :is([aria-current="page"],[aria-selected="true"],[aria-pressed="true"]) { text-decoration: underline; text-underline-offset: .2em; font-weight: 800; }
    :root .fl-ui :is(.dashboard-card,.profile-card,.site-card,.quote-card,.invoice-card,.product-card,.report-card,.absence-card,.expense-card,.crm-card,.crm-sidebar,.crm-history,.mobile-card) {
        min-width: 0; border-radius: var(--fl-radius-md); border-color: var(--fl-color-border);
        background-color: var(--fl-color-surface); box-shadow: var(--fl-shadow-sm);
    }
    .fl-ui :is(.empty-state,.no-results) { color: var(--fl-color-text-muted); }
    .fl-table-region { box-sizing: border-box; max-width: 100%; min-width: 0; overflow-x: auto; overscroll-behavior-x: contain; border-radius: var(--fl-radius-sm); }
    .fl-table-region table { width: 100%; border-collapse: collapse; }
    .fl-table-region :is(th,td) { padding: .75rem; border-bottom: 1px solid var(--fl-color-border); vertical-align: top; }
    .fl-table-region th { color: var(--fl-color-text-muted); background: var(--fl-color-surface-subtle); text-align: left; }
    .fl-table-region tbody tr:is(:hover,:focus-within) { background: var(--fl-color-surface-subtle); }
    .fl-table-region :is(button,.fl-button) { min-height: var(--fl-control-height-compact); }
    .fl-table-region .fl-cell-text { min-width: 12rem; white-space: normal; overflow-wrap: anywhere; }
    .fl-access-card { width: min(calc(100% - 1.5rem), 38rem); margin: clamp(2rem,10vh,6rem) auto; padding: clamp(1rem,4vw,2.5rem); text-align: center; }
    .fl-access-card h1 { color: var(--fl-color-danger); }
    .fl-access-card .fl-actions { justify-content: center; }
    @media (max-width: 650px) {
        :root .fl-ui :is(input,select,textarea) { font-size: max(1rem, 16px); }
        .fl-ui .fl-actions > * { flex: 1 1 auto; }
    }
    @media (pointer: coarse) {
        :root .fl-ui :is(button,.fl-button,.fl-table-region button) { min-height: var(--fl-control-height); }
    }
    @media (prefers-reduced-motion: reduce) {
        .fl-ui *, .fl-ui *::before, .fl-ui *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
    }
}
