/* ============================================================
   FlowTime — stili globali (niente framework CSS: una manciata
   di componenti non giustifica Bootstrap nel download WASM)
   ============================================================ */

:root {
    --ft-green: #16a34a;
    --ft-green-dark: #15803d;
    --ft-red: #dc2626;
    --ft-red-dark: #b91c1c;
    --ft-text: #1f2937;
    --ft-text-muted: #6b7280;
    --ft-bg: #f3f4f6;
    --ft-card: #ffffff;
    --ft-border: #e5e7eb;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    background: var(--ft-bg);
    color: var(--ft-text);
    /* Niente zoom accidentali sul doppio tap: è un'app da bottone */
    touch-action: manipulation;
}

/* ---------- Shell ---------- */
.ft-shell {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.ft-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    text-align: center;
}

/* ---------- Card di login ---------- */
.ft-card {
    background: var(--ft-card);
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, .08);
    padding: 32px 24px;
    width: 100%;
    max-width: 400px;
}

.ft-logo {
    text-align: center;
    margin-bottom: 24px;
}

.ft-logo-mark { font-size: 40px; }

.ft-logo h1 {
    margin: 4px 0 0;
    font-size: 28px;
    letter-spacing: -0.5px;
}

.ft-intro {
    color: var(--ft-text-muted);
    line-height: 1.5;
    margin-bottom: 20px;
}

/* ---------- Input e bottoni standard ---------- */
.ft-input {
    width: 100%;
    padding: 14px 16px;
    font-size: 17px;          /* ≥16px: evita lo zoom automatico su iOS */
    border: 1.5px solid var(--ft-border);
    border-radius: 10px;
    margin-bottom: 12px;
    outline: none;
}

.ft-input:focus { border-color: var(--ft-green); }

.ft-button {
    width: 100%;
    padding: 15px;
    font-size: 17px;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
}

.ft-button:disabled { opacity: .55; cursor: default; }

.ft-button-primary { background: var(--ft-green); color: #fff; }
.ft-button-primary:active { background: var(--ft-green-dark); }

.ft-button-secondary {
    background: transparent;
    color: var(--ft-text);
    border: 1.5px solid var(--ft-border);
}

.ft-link {
    background: none;
    border: none;
    color: var(--ft-text-muted);
    font-size: 15px;
    text-decoration: underline;
    cursor: pointer;
    padding: 8px;
}

.ft-password-section {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--ft-border);
    text-align: center;
}

/* ---------- Alert ---------- */
.ft-alert {
    padding: 14px 16px;
    border-radius: 10px;
    line-height: 1.5;
    margin-bottom: 16px;
}

.ft-alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.ft-alert-ok    { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

/* ---------- Home dipendente (D-033) ---------- */
.ft-home {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 22px;
    min-height: 100dvh;
    padding: 0 0 24px;
    justify-content: flex-start;
}

/* Brand bar */
.ft-brandbar {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 4px 0;
}

.ft-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ft-brand-clock {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, #22c55e, var(--ft-green-dark));
    box-shadow: 0 4px 12px rgba(22, 163, 74, .35);
    font-size: 21px;
}

.ft-brand-name {
    font-size: 21px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.ft-brand-name em {
    font-style: normal;
    color: var(--ft-green);
}

.ft-liveclock {
    font-size: 26px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--ft-text);
}

/* Saluto + azioni */
.ft-hello {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0 4px;
}

.ft-greeting { font-size: 24px; margin: 0; }
.ft-date {
    color: var(--ft-text-muted);
    margin: 4px 0 0;
    text-transform: capitalize;
}

/* Pillola di stato con pallino (pulsante quando al lavoro) */
.ft-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--ft-card);
    border: 1px solid var(--ft-border);
    border-radius: 999px;
    padding: 10px 18px;
    font-size: 16px;
    color: var(--ft-text-muted);
}

.ft-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #d1d5db;
    flex-shrink: 0;
}

.ft-status-pill.working {
    border-color: #bbf7d0;
    background: #f0fdf4;
    color: var(--ft-green-dark);
}

.ft-status-pill.working .ft-status-dot {
    background: var(--ft-green);
    animation: ft-pulse 1.6s ease-in-out infinite;
}

@keyframes ft-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, .45); }
    50%      { box-shadow: 0 0 0 7px rgba(22, 163, 74, 0); }
}

/* Stat card informative */
.ft-stats {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.ft-stat {
    background: var(--ft-card);
    border: 1px solid var(--ft-border);
    border-radius: 14px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.ft-stat-value {
    font-size: 22px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.ft-stat-label {
    font-size: 12.5px;
    color: var(--ft-text-muted);
}

.ft-stat-live {
    border-color: #bbf7d0;
    background: #f0fdf4;
}

.ft-stat-live .ft-stat-value { color: var(--ft-green-dark); }

/* ---------- IL bottone ---------- */
.ft-bigbutton {
    width: min(260px, 70vw);
    aspect-ratio: 1;
    border-radius: 50%;
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: transform .1s ease;
    -webkit-tap-highlight-color: transparent;
}

.ft-bigbutton:active:not(:disabled) { transform: scale(.96); }
.ft-bigbutton:disabled { opacity: .6; cursor: default; }

.ft-bigbutton-start {
    background: radial-gradient(circle at 30% 30%, #22c55e, var(--ft-green-dark));
    box-shadow: 0 10px 32px rgba(22, 163, 74, .45);
}

.ft-bigbutton-stop {
    background: radial-gradient(circle at 30% 30%, #ef4444, var(--ft-red-dark));
    box-shadow: 0 10px 32px rgba(220, 38, 38, .45);
}

.ft-bigbutton-label { font-size: 40px; font-weight: 800; letter-spacing: 2px; }
.ft-bigbutton-sub { font-size: 15px; opacity: .9; }

/* ---------- Spinner ---------- */
.ft-spinner {
    width: 36px;
    height: 36px;
    border: 4px solid var(--ft-border);
    border-top-color: var(--ft-green);
    border-radius: 50%;
    animation: ft-spin .8s linear infinite;
}

@keyframes ft-spin { to { transform: rotate(360deg); } }

/* ============================================================
   Infrastruttura Blazor (caricamento iniziale ed errori fatali)
   ============================================================ */

.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem;
}

.loading-progress circle {
    fill: none;
    stroke: var(--ft-border);
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--ft-green);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * .8), 500%;
    transition: stroke-dasharray .05s ease-in-out;
}

.loading-progress-text {
    text-align: center;
    font-weight: bold;
    color: var(--ft-text-muted);
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Caricamento…");
}

#blazor-error-ui {
    background: #fef2f2;
    color: #991b1b;
    bottom: 0;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, .15);
    display: none;
    left: 0;
    padding: .8rem 1.2rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: .75rem;
    top: .5rem;
}

/* ============================================================
   DASHBOARD ADMIN
   ============================================================ */

:root {
    --adm-sidebar-bg: #111827;
    --adm-sidebar-text: #9ca3af;
    --adm-sidebar-active: #1f2937;
    --adm-warn-bg: #fefce8;
    --adm-warn-border: #fde047;
}

.ft-home-actions { display: flex; gap: 12px; align-items: center; }

/* ---------- Shell ---------- */
.adm-shell {
    display: grid;
    grid-template-columns: 230px 1fr;
    min-height: 100dvh;
    width: 100%;
}

/* Il layout admin scavalca il centraggio del ft-shell */
.ft-shell:has(.adm-shell) { padding: 0; display: block; }

.adm-sidebar {
    background: var(--adm-sidebar-bg);
    color: var(--adm-sidebar-text);
    display: flex;
    flex-direction: column;
    padding: 20px 12px;
    position: sticky;
    top: 0;
    height: 100dvh;
}

.adm-brand { display: flex; gap: 10px; align-items: center; padding: 0 10px 20px; }
.adm-brand-mark { font-size: 26px; }
.adm-brand-name { display: block; color: #fff; font-weight: 700; font-size: 18px; }
.adm-brand-sub { display: block; font-size: 12px; }

.adm-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.adm-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--adm-sidebar-text);
    text-decoration: none;
    font-size: 15px;
}

.adm-nav-link:hover { background: var(--adm-sidebar-active); color: #fff; }
.adm-nav-link.active { background: var(--adm-sidebar-active); color: #fff; font-weight: 600; }
.adm-nav-icon { width: 20px; text-align: center; }

.adm-sidebar-footer { border-top: 1px solid #374151; padding-top: 12px; }
.adm-user { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px 0; }
.adm-user-name { font-size: 14px; color: #d1d5db; }
/* Versione dell'installazione (D-043) */
.adm-version { padding: 10px 10px 0; font-size: 12px; color: #6b7280; }

.adm-main { padding: 28px 32px; min-width: 0; }

/* ---------- Pagina ---------- */
.adm-page { max-width: 1100px; margin: 0 auto; }

.adm-page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.adm-page-header h2 { margin: 0; font-size: 24px; }

.adm-card {
    background: var(--ft-card);
    border: 1px solid var(--ft-border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    overflow-x: auto;
}

.adm-card h3 { margin: 0 0 14px; font-size: 16px; }
.adm-card-narrow { max-width: 480px; }

/* Card che contengono popup assoluti (range picker): l'overflow-x
   delle card normali creerebbe un clipping context e taglierebbe
   il calendario (D-040) */
.adm-card-overflow { overflow: visible; }
.adm-empty { color: var(--ft-text-muted); }
.adm-muted { color: var(--ft-text-muted); font-size: 14px; line-height: 1.5; }

/* ---------- Filtri ---------- */
.adm-filterbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.adm-segments {
    display: inline-flex;
    background: #e5e7eb;
    border-radius: 10px;
    padding: 3px;
}

.adm-segment {
    border: none;
    background: transparent;
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    color: var(--ft-text-muted);
}

.adm-segment.active { background: #fff; color: var(--ft-text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

.adm-period-nav { display: flex; align-items: center; gap: 8px; }
.adm-period-label { font-weight: 600; min-width: 180px; text-align: center; text-transform: capitalize; }

.adm-check { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }

/* ---------- KPI ---------- */
.adm-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.adm-kpi {
    background: var(--ft-card);
    border: 1px solid var(--ft-border);
    border-radius: 12px;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.adm-kpi-value { font-size: 24px; font-weight: 700; }
.adm-kpi-label { font-size: 13px; color: var(--ft-text-muted); }
.adm-kpi-warn { border-color: var(--adm-warn-border); background: var(--adm-warn-bg); }

/* ---------- Tabelle ---------- */
.adm-table { width: 100%; border-collapse: collapse; font-size: 14px; }

.adm-table th {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 2px solid var(--ft-border);
    color: var(--ft-text-muted);
    font-weight: 600;
    white-space: nowrap;
}

.adm-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--ft-border);
    vertical-align: middle;
}

.adm-table tbody tr:hover { background: #f9fafb; }
.adm-table .num { text-align: right; }

.adm-row-warn { background: var(--adm-warn-bg); }
.adm-row-warn:hover { background: #fef9c3 !important; }
.adm-row-muted { opacity: .55; }

.adm-hours { display: flex; flex-direction: column; gap: 4px; min-width: 120px; }
.adm-bar { height: 5px; background: var(--ft-border); border-radius: 3px; overflow: hidden; }
.adm-bar-fill { height: 100%; background: var(--ft-green); border-radius: 3px; }

.adm-contact { font-size: 13px; }
.adm-actions { white-space: nowrap; }

/* ---------- Badge ---------- */
.adm-badges { white-space: nowrap; }

.adm-badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    margin-right: 4px;
}

.adm-badge-auto  { background: #ffedd5; color: #9a3412; }
.adm-badge-mod   { background: #dbeafe; color: #1e40af; }
.adm-badge-open  { background: #dcfce7; color: #166534; }
.adm-badge-off   { background: #f3f4f6; color: #6b7280; }
.adm-badge-admin { background: #ede9fe; color: #5b21b6; margin-left: 6px; }

/* ---------- Bottoni admin ---------- */
.adm-btn {
    border: none;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.adm-btn:disabled { opacity: .55; cursor: default; }
.adm-btn-primary { background: var(--ft-green); color: #fff; }
.adm-btn-primary:hover:not(:disabled) { background: var(--ft-green-dark); }
.adm-btn-ghost { background: transparent; color: var(--ft-text); border: 1px solid var(--ft-border); }
.adm-btn-ghost:hover:not(:disabled) { background: #f3f4f6; }
.adm-btn-danger { color: var(--ft-red); border-color: #fecaca; }
.adm-btn-danger:hover:not(:disabled) { background: #fef2f2; }

.adm-report-actions { display: flex; gap: 10px; margin-top: 8px; }

/* ---------- Form nelle modali ---------- */
.adm-form { display: flex; flex-direction: column; gap: 12px; }
.adm-form label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 500; }
.adm-form .ft-input { margin-bottom: 0; }
.adm-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.adm-form-context { font-weight: 600; margin: 0; }
.adm-hint { color: var(--ft-text-muted); font-weight: 400; font-size: 13px; }
/* Avviso nel form (D-046): email assente = consegna manuale via WhatsApp */
.adm-hint-warn { background: #fef9ec; border: 1px solid #fbe6b3; border-radius: 8px;
                 padding: 8px 12px; color: #92600a; margin: 4px 0 0; }

/* ---------- Modale ---------- */
.ft-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, .5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 100;
}

.ft-modal {
    background: #fff;
    border-radius: 14px;
    width: 100%;
    max-width: 520px;
    max-height: 90dvh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}

.ft-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 20px 0;
}

.ft-modal-header h3 { margin: 0; font-size: 18px; }

.ft-modal-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--ft-text-muted);
    padding: 4px 8px;
}

.ft-modal-body { padding: 16px 20px; }

.ft-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 0 20px 18px;
}

/* ---------- Toast ---------- */
.ft-toast-host {
    position: fixed;
    top: 16px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 200;
}

.ft-toast {
    padding: 12px 18px;
    border-radius: 10px;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .2);
    cursor: pointer;
    animation: ft-toast-in .2s ease-out;
    max-width: 340px;
}

.ft-toast-ok { background: var(--ft-green-dark); }
.ft-toast-error { background: var(--ft-red-dark); }

@keyframes ft-toast-in {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ---------- Chips preset periodo (D-029) ---------- */
.adm-filterbar-stack { align-items: center; }
.adm-chips { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.adm-chips-wrap { margin-bottom: 14px; }

.adm-chip {
    border: 1px solid var(--ft-border);
    background: var(--ft-card);
    padding: 7px 14px;
    border-radius: 999px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--ft-text-muted);
    cursor: pointer;
    white-space: nowrap;
}

.adm-chip:hover { border-color: var(--ft-green); color: var(--ft-text); }
.adm-chip.active { background: var(--ft-green); border-color: var(--ft-green); color: #fff; }

.adm-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}
.adm-card-head h3 { margin: 0; }

.adm-report-picker { margin-bottom: 16px; }

/* ---------- DateRangePicker (D-029) ---------- */
.drp { position: relative; display: inline-block; }

.drp-input {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--ft-border);
    background: var(--ft-card);
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.drp-input:hover { border-color: var(--ft-green); }
.drp-icon { font-size: 15px; }

.drp-backdrop { position: fixed; inset: 0; z-index: 140; }

.drp-pop {
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 150;
    background: #fff;
    border: 1px solid var(--ft-border);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .18);
    padding: 12px;
    width: 300px;
}

.drp-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.drp-month { font-weight: 600; text-transform: capitalize; font-size: 14px; }

.drp-nav {
    border: none;
    background: #f3f4f6;
    border-radius: 6px;
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-size: 15px;
}

.drp-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.drp-dow {
    text-align: center;
    font-size: 11px;
    color: var(--ft-text-muted);
    padding: 4px 0;
    text-transform: uppercase;
}

.drp-day {
    border: none;
    background: transparent;
    border-radius: 8px;
    aspect-ratio: 1;
    font-size: 13px;
    cursor: pointer;
    color: var(--ft-text);
}

.drp-day:hover { background: #f3f4f6; }
.drp-day-out { color: #d1d5db; }
.drp-day-today { font-weight: 700; text-decoration: underline; }
.drp-day-range { background: #dcfce7; border-radius: 0; }
.drp-day-sel { background: var(--ft-green); color: #fff; font-weight: 600; }
.drp-day-sel:hover { background: var(--ft-green-dark); }

.drp-hint {
    margin: 10px 0 0;
    font-size: 12px;
    color: var(--ft-text-muted);
    text-align: center;
}

/* Shortcut dentro il pannello (D-032) */
.drp-shortcuts {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--ft-border);
}

.drp-shortcut {
    border: 1px solid var(--ft-border);
    background: #f9fafb;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--ft-text);
    cursor: pointer;
}

.drp-shortcut:hover { border-color: var(--ft-green); background: #f0fdf4; }

/* Selezione corrente in fondo al pannello */
.drp-selected {
    margin-top: 12px;
    padding: 9px 12px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    font-size: 13px;
    text-align: center;
    color: var(--ft-green-dark);
}

/* ---------- Grafici (D-030) ---------- */
.adm-charts {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

/* Donut */
.chart-donut {
    display: flex;
    align-items: center;
    gap: 20px;
}

.chart-donut svg {
    width: 150px;
    height: 150px;
    flex-shrink: 0;
    transform: rotate(0deg);
}

.chart-donut-center {
    font-size: 5.5px;
    font-weight: 700;
    text-anchor: middle;
    fill: var(--ft-text);
}

.chart-donut-sub {
    font-size: 2.8px;
    text-anchor: middle;
    fill: var(--ft-text-muted);
}

.chart-legend {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-width: 0;
    flex: 1;
}

.chart-legend li {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.chart-dot {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    flex-shrink: 0;
}

.chart-legend-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chart-legend-value {
    margin-left: auto;
    color: var(--ft-text-muted);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* Colonne */
.chart-cols { width: 100%; }

.chart-cols-bars {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 150px;
    border-bottom: 1.5px solid var(--ft-border);
    padding-bottom: 1px;
}

.chart-col {
    flex: 1;
    height: 100%;
    display: flex;
    align-items: flex-end;
    min-width: 4px;
    position: relative; /* ancora per i valori sopra le barre (D-038) */
}

.chart-col-value {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    font-weight: 600;
    color: var(--ft-text-muted);
    white-space: nowrap;
    pointer-events: none;
}

.chart-col-fill {
    width: 100%;
    background: linear-gradient(to top, var(--ft-green-dark), #22c55e);
    border-radius: 3px 3px 0 0;
    min-height: 2px;
    transition: height .25s ease;
}

.chart-col:hover .chart-col-fill { filter: brightness(1.15); }
.chart-col-zero { background: var(--ft-border); }

.chart-cols-labels {
    display: flex;
    gap: 3px;
    margin-top: 5px;
}

.chart-cols-labels span {
    flex: 1;
    text-align: center;
    font-size: 10.5px;
    color: var(--ft-text-muted);
    overflow: hidden;
    white-space: nowrap;
    min-width: 4px;
}

/* ---------- Scheda dipendente (D-035) ---------- */
.adm-back {
    display: inline-block;
    margin-bottom: 12px;
    color: var(--ft-text-muted);
    text-decoration: none;
    font-size: 14px;
}

.adm-back:hover { color: var(--ft-text); }

.adm-name-link {
    color: inherit;
    text-decoration: none;
    font-weight: 700;
}

.adm-name-link:hover { color: var(--ft-green-dark); text-decoration: underline; }

.adm-profile {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px 24px;
}

.adm-profile-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 14.5px;
    min-width: 0;
}

.adm-profile-item a { color: var(--ft-green-dark); text-decoration: none; }
.adm-profile-item a:hover { text-decoration: underline; }

.adm-profile-label {
    font-size: 12px;
    color: var(--ft-text-muted);
    text-transform: uppercase;
    letter-spacing: .03em;
}

/* Il KPI "da pagare": è il numero che il titolare cerca */
.adm-kpi-pay {
    border-color: #bbf7d0;
    background: #f0fdf4;
}

.adm-kpi-pay .adm-kpi-value { color: var(--ft-green-dark); }

.adm-detail-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Trend vs periodo precedente (D-037) */
.adm-kpi-trend {
    font-size: 11.5px;
    font-weight: 600;
}

.adm-kpi-trend.up { color: var(--ft-green-dark); }
.adm-kpi-trend.down { color: var(--ft-red-dark); }

/* ---------- Topbar + hamburger (solo mobile, D-031) ---------- */
.adm-topbar { display: none; }

.adm-burger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    padding: 10px;
    background: none;
    border: none;
    cursor: pointer;
}

.adm-burger span {
    display: block;
    height: 2.5px;
    width: 100%;
    background: #fff;
    border-radius: 2px;
    transition: transform .2s ease, opacity .2s ease;
}

/* Burger → X quando il drawer è aperto */
.adm-burger.open span:nth-child(1) { transform: translateY(7.5px) rotate(45deg); }
.adm-burger.open span:nth-child(2) { opacity: 0; }
.adm-burger.open span:nth-child(3) { transform: translateY(-7.5px) rotate(-45deg); }

.adm-drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, .55);
    z-index: 290;
    animation: ft-fade-in .15s ease-out;
}

@keyframes ft-fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .adm-charts { grid-template-columns: 1fr; }
    .chart-donut { flex-direction: column; }

    .adm-shell {
        grid-template-columns: 1fr;
        padding-top: 56px; /* spazio per la topbar fissa */
    }

    /* Topbar fissa con burger */
    .adm-topbar {
        display: flex;
        align-items: center;
        gap: 4px;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 56px;
        background: var(--adm-sidebar-bg);
        z-index: 280;
        padding: 0 8px;
    }

    .adm-topbar-brand {
        color: #fff;
        font-weight: 700;
        font-size: 17px;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    /* La sidebar diventa un drawer off-canvas */
    .adm-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100dvh;
        width: min(280px, 82vw);
        z-index: 300;
        transform: translateX(-100%);
        transition: transform .22s ease;
        box-shadow: 4px 0 24px rgba(0, 0, 0, .35);
        padding-top: max(20px, env(safe-area-inset-top));
    }

    .adm-sidebar.open { transform: translateX(0); }

    .adm-nav-link { padding: 13px 12px; font-size: 16px; } /* tap target pieno */
    .adm-main { padding: 16px; }
    .adm-form-row { grid-template-columns: 1fr; }
    .adm-period-label { min-width: 0; }
}

/* ============================================================
   MOBILE FIRST-CLASS (D-031): il titolare usa il telefono
   quanto i dipendenti. Sotto i 640px tutto si adatta: chips
   scorrevoli, KPI a 2 colonne, tabelle con scroll orizzontale,
   modali a foglio dal basso, bottoni a tutta larghezza.
   ============================================================ */
@media (max-width: 640px) {
    /* Pagina */
    .adm-main { padding: 12px; }
    .adm-page { max-width: none; }

    .adm-page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .adm-page-header h2 { font-size: 20px; }
    .adm-page-header > .adm-btn { width: 100%; padding: 12px; }

    /* Filtri (D-032): su smartphone le chips di pagina SPARISCONO —
       le shortcut vivono dentro il calendario floating, che diventa
       l'unico punto di selezione del periodo. Meno UI, stesso potere. */
    .adm-filterbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        margin-bottom: 14px;
    }

    .adm-chips { display: none; }

    .adm-period-nav { justify-content: space-between; gap: 10px; }

    .adm-period-nav .adm-btn {
        min-width: 46px;
        min-height: 46px;
        font-size: 18px;
        flex-shrink: 0;
    }

    .drp { flex: 1; display: block; }

    .drp-input {
        padding: 12px 14px;
        width: 100%;
        justify-content: center;
        min-height: 46px;
        font-size: 15px;
    }

    /* Bottoni: tap target minimo garantito ovunque */
    .adm-btn { min-height: 42px; }
    .adm-actions .adm-btn { min-height: 40px; }

    /* Shortcut nel foglio: più grandi al tocco */
    .drp-shortcut { padding: 9px 14px; font-size: 13.5px; }

    /* KPI a griglia 2×2 */
    .adm-kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
    .adm-kpi { padding: 12px 14px; }
    .adm-kpi-value { font-size: 19px; }

    .adm-card { padding: 14px; border-radius: 10px; margin-bottom: 14px; }
    .adm-card h3 { font-size: 15px; }

    /* ---- TABELLE → CARD (D-031c) ----
       Niente scroll orizzontale: ogni <tr> diventa una card
       verticale. Le etichette di colonna arrivano da data-label
       via ::before (il <thead> sparisce). Desktop invariato. */
    .adm-table { font-size: 14px; min-width: 0; }
    .adm-table thead { display: none; }

    .adm-table, .adm-table tbody, .adm-table tr, .adm-table td {
        display: block;
        width: 100%;
    }

    .adm-table tr {
        border: 1px solid var(--ft-border);
        border-radius: 12px;
        padding: 12px 14px;
        margin-bottom: 10px;
        background: var(--ft-card);
    }

    .adm-table tbody tr:hover { background: var(--ft-card); }

    .adm-table .adm-row-warn,
    .adm-table .adm-row-warn:hover {
        background: var(--adm-warn-bg) !important;
        border-color: var(--adm-warn-border);
    }

    .adm-table td {
        border: none;
        padding: 5px 0;
        text-align: left;
    }

    .adm-table td.num { text-align: left; }

    /* Coppie etichetta/valore */
    .adm-table td[data-label] {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
    }

    .adm-table td[data-label]::before {
        content: attr(data-label);
        color: var(--ft-text-muted);
        font-size: 12.5px;
        font-weight: 500;
        flex-shrink: 0;
    }

    /* Titolo della card (nome dipendente) */
    .adm-cell-primary {
        font-weight: 700;
        font-size: 15.5px;
        padding-bottom: 8px !important;
        border-bottom: 1px dashed var(--ft-border) !important;
        margin-bottom: 4px;
    }

    .adm-badges { padding-top: 7px !important; }

    .adm-actions {
        display: flex !important;
        flex-wrap: wrap;
        gap: 8px;
        padding-top: 10px !important;
        white-space: normal;
    }

    .adm-actions .adm-btn { flex: 1 1 calc(50% - 8px); padding: 10px; }

    .adm-contact-stack { text-align: right; min-width: 0; }
    .adm-contact-stack .adm-contact { overflow: hidden; text-overflow: ellipsis; }

    .adm-hours { min-width: 0; flex: 1; max-width: 220px; }

    .adm-card-head { flex-direction: column; align-items: stretch; gap: 8px; }
    .adm-card-head .adm-btn { width: 100%; }

    /* Grafici più compatti */
    .chart-cols-bars { height: 110px; }
    .chart-donut svg { width: 130px; height: 130px; }

    /* Modali: foglio dal basso a tutta larghezza (pattern iOS/Android) */
    .ft-modal-backdrop { padding: 0; align-items: flex-end; }

    .ft-modal {
        max-width: none;
        border-radius: 16px 16px 0 0;
        max-height: 92dvh;
    }

    .ft-modal-footer { padding-bottom: max(18px, env(safe-area-inset-bottom)); }
    .ft-modal-footer .adm-btn { flex: 1; padding: 13px; }

    /* Range picker: BOTTOM SHEET (D-031c) — il popup nel flusso su
       smartphone era instabile; il foglio dal basso è il pattern
       nativo, sempre visibile e sempre tappabile. */
    .drp-backdrop {
        background: rgba(17, 24, 39, .5);
        z-index: 400;                  /* sopra topbar (280) e drawer (300) */
        animation: ft-fade-in .15s ease-out;
    }

    .drp-pop {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        transform: none;
        width: auto;
        max-width: none;
        z-index: 410;
        border-radius: 16px 16px 0 0;
        border: none;
        box-shadow: 0 -8px 40px rgba(0, 0, 0, .25);
        padding: 16px 16px max(16px, env(safe-area-inset-bottom));
    }

    .drp-head { margin-bottom: 12px; }
    .drp-month { font-size: 16px; }
    .drp-nav { width: 40px; height: 40px; font-size: 17px; }
    .drp-grid { gap: 4px; }
    .drp-day { font-size: 15px; border-radius: 10px; }
    .drp-hint { font-size: 13px; margin-top: 12px; }

    /* Toast a tutta larghezza */
    .ft-toast-host { left: 12px; right: 12px; top: 12px; }
    .ft-toast { max-width: none; text-align: center; }

    /* Report: bottoni impilati */
    .adm-report-actions { flex-direction: column; gap: 8px; }
    .adm-report-actions .adm-btn { width: 100%; padding: 13px; }

    .adm-card-narrow { max-width: none; }
}
