:root {
    --menu: #0E3B43; --menu-active: #1C5A63; --menu-ink: #D7E6E8; --menu-sub: #B9D3D6;
    --accent: #0B6E6E; --page: #F4F6F8; --ink: #17212B; --muted: #5B6672; --border: #DDE2E7;
}
html, body { margin: 0; background: var(--page); color: var(--ink); font-family: "IBM Plex Sans Arabic", "Segoe UI", sans-serif; }
/* Side menu + content in one row; only the phone query below stacks them (no flex-wrap, so no second breakpoint). */
.shell { display: flex; min-height: 100vh; }
.menu { flex: 0 0 220px; background: var(--menu); color: var(--menu-ink); padding: 16px 12px; box-sizing: border-box; }
.content { flex: 1 1 auto; min-width: 0; }
.brand { padding: 8px 12px 16px; }
.brand-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.menu-toggle { display: none; min-width: 44px; min-height: 44px; align-items: center; justify-content: center; background: transparent;
    color: #fff; border: 1px solid rgba(255,255,255,.3); border-radius: 8px; font-size: 1.25rem; cursor: pointer; }
.menu-toggle:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.brand-name { color: #fff; font-weight: 700; font-size: 1.25rem; }
.brand-sub { color: var(--menu-sub); font-size: .875rem; }
.menu-item { display: flex; align-items: center; justify-content: space-between; min-height: 44px; padding: 0 12px; margin-bottom: 4px;
    border-radius: 8px; color: var(--menu-ink); text-decoration: none; box-sizing: border-box; }
.menu-item:hover { background: rgba(255,255,255,.08); }
.menu-item.active { background: var(--menu-active); color: #fff; font-weight: 700; }
.badge { background: var(--accent); color: #fff; border-radius: 999px; padding: 0 8px; min-width: 22px; text-align: center; font-size: .8rem; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 24px;
    background: #fff; border-bottom: 1px solid var(--border); }
.page-title { margin: 0; font-size: 1.25rem; }
.user { display: flex; flex-direction: column; text-align: start; }
.user-role { color: var(--muted); font-size: .8rem; }
.user-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.user-link { color: var(--accent); min-height: 44px; display: inline-flex; align-items: center; }
.logout-form { margin: 0; }
.logout { min-height: 44px; padding: 0 16px; background: #fff; color: var(--ink); border: 1px solid var(--border);
    border-radius: 8px; font: inherit; cursor: pointer; }
.page { padding: 24px; }
.card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 16px; }

/* Sign-in pages (static SSR) */
.auth-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; box-sizing: border-box; }
.auth-card { width: 100%; max-width: 420px; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 24px;
    box-sizing: border-box; }
.auth-card h1 { margin: 0 0 4px; font-size: 1.375rem; }
.auth-card .brand-line { color: var(--muted); margin: 0 0 20px; }
.auth-card label { display: block; font-weight: 600; margin: 12px 0 6px; }
.auth-card input:not([type]), .auth-card input[type=text], .auth-card input[type=password] { width: 100%; min-height: 44px; padding: 8px 12px; box-sizing: border-box;
    border: 1px solid var(--border); border-radius: 8px; font: inherit; }
.auth-card .ltr { direction: ltr; text-align: left; }
.auth-card button, .auth-card .button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; width: 100%;
    margin-top: 20px; background: var(--accent); color: #fff; border: 0; border-radius: 8px; font: inherit; font-weight: 600;
    cursor: pointer; text-decoration: none; }
.auth-error { background: #FDECEC; color: #8A1C1C; border-radius: 8px; padding: 10px 12px; margin: 12px 0 0; }
.auth-note { color: var(--muted); font-size: .9rem; }
.totp-qr { display: block; margin: 12px auto; width: 200px; height: 200px; image-rendering: pixelated; }
.totp-key { display: block; direction: ltr; text-align: center; font-family: Consolas, monospace; font-size: 1.05rem;
    letter-spacing: .08em; word-break: break-all; background: var(--page); padding: 8px; border-radius: 8px; }
.recovery-list { direction: ltr; display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; padding: 0; list-style: none; }
.recovery-code { font-family: Consolas, monospace; background: var(--page); border-radius: 8px; padding: 8px; text-align: center; }

/* Results screens (Today board, employee month, month summary) */
.stack { display: flex; flex-direction: column; gap: 20px; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; }
.page-h { margin: 0; font-size: 1.75rem; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: .8125rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; padding: 0 16px; background: #fff;
    color: var(--ink); border: 1px solid #C9D1D8; border-radius: 8px; font: inherit; cursor: pointer; text-decoration: none; box-sizing: border-box; }
.btn.icon { padding: 0; font-size: 1.125rem; }
.btn:disabled { opacity: .6; cursor: default; }
.link-btn { background: none; border: 0; padding: 0; min-height: 44px; font: inherit; font-weight: 600; color: var(--accent); cursor: pointer; text-align: start; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.kpi-label { font-size: .8125rem; color: var(--muted); }
.kpi-value { font-size: 1.75rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi-note { font-size: .75rem; color: var(--muted); }
.c-present { color: #0B5E3C; } .c-late { color: #7A4300; } .c-absent { color: #A12B2B; } .c-excused { color: #1F4E8C; } .c-upcoming { color: #4A5561; }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: .8125rem; color: var(--muted); flex: 1 1 160px; }
.field.grow2 { flex: 2 1 240px; }
.field input, .field select { min-height: 44px; padding: 0 10px; border: 1px solid #C9D1D8; border-radius: 8px; font: inherit; font-size: .9375rem;
    background: #fff; color: var(--ink); }
.table-box { background: #fff; border: 1px solid var(--border); border-radius: 12px; overflow-x: auto; }
.data { width: 100%; border-collapse: collapse; font-size: .875rem; }
.data.wide { min-width: 820px; }
.data thead tr { background: #F0F3F5; color: #3F4A55; text-align: right; }
.data th, .data td { padding: 12px 16px; text-align: start; }
.data tbody tr { border-top: 1px solid #E7EBEE; }
.num { font-variant-numeric: tabular-nums; }
.chip { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .8125rem; font-weight: 600; }
.chip-present { background: #E2F3EA; color: #0B5E3C; }
.chip-late { background: #FDF1DC; color: #7A4300; }
.chip-absent { background: #FBE7E7; color: #A12B2B; }
.chip-upcoming, .chip-none { background: #ECEFF2; color: #4A5561; }
.chip-excused { background: #E6EEF9; color: #1F4E8C; }
.chip-rest { background: #F0F3F5; color: #5B6672; }
.month-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.month-title { font-size: 1.0625rem; font-weight: 700; padding: 0 6px; }
.cal-box { overflow-x: auto; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(96px, 1fr)); gap: 8px; min-width: 720px; }
.cal-head { font-size: .8125rem; font-weight: 600; color: #3F4A55; padding: 4px 6px; }
.day { min-height: 84px; padding: 8px 10px; border-radius: 10px; display: flex; flex-direction: column; gap: 2px; box-sizing: border-box;
    border: 1px solid var(--border); background: #fff; color: var(--ink); font: inherit; text-align: start; }
button.day { cursor: pointer; }
.day-n { font-size: .875rem; font-weight: 700; }
.day-label { font-size: .75rem; font-weight: 600; }
.day-hours { font-size: .75rem; font-variant-numeric: tabular-nums; }
.day-present { background: #fff; }
.day-late { background: #FDF1DC; color: #7A4300; border-color: #F0D29E; }
.day-absent { background: #FBE7E7; color: #A12B2B; border-color: #EBC0C0; }
.day-excused { background: #E6EEF9; color: #1F4E8C; border-color: #BFD0EA; }
.day-upcoming { background: #ECEFF2; color: #4A5561; border-color: #ECEFF2; }
.day-rest { background: #F0F3F5; color: var(--muted); border-color: #F0F3F5; }
.day-none { background: transparent; color: var(--muted); border-color: transparent; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(14,59,67,.45); z-index: 50; }
.modal { position: fixed; z-index: 51; inset-block-start: 5vh; inset-inline: 0; margin-inline: auto; width: min(640px, 94vw); max-height: 90vh; overflow: auto;
    background: #fff; border-radius: 12px; padding: 20px; box-sizing: border-box; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.modal-head h2 { margin: 0; font-size: 1.125rem; }

/* Employees screen */
.emp-layout { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.emp-main { flex: 999 1 520px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.bulk-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; background: #E4EFF0; border: 1px solid #BFD6D8; border-radius: 10px; padding: 8px 12px; }
.bulk-bar .count { font-weight: 600; margin-inline-end: 8px; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.btn.danger { color: #A12B2B; border-color: #EBC0C0; }
.side-panel { flex: 1 1 300px; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 20px; box-sizing: border-box;
    display: flex; flex-direction: column; gap: 14px; }
.side-panel h2, .side-panel h3 { margin: 0; }
.side-panel form { display: flex; flex-direction: column; gap: 14px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: .875rem; }
.check input { width: 18px; height: 18px; }
.row-check { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; }
.row-check input { width: 18px; height: 18px; }
.actions { display: flex; flex-direction: column; gap: 6px; }
.actions .btn { justify-content: flex-start; }
.form-actions { display: flex; gap: 8px; }
.form-actions .btn.primary { flex: 1; }
.notice { background: #E2F3EA; color: #0B5E3C; border-radius: 8px; padding: 10px 14px; margin: 0; }
.cred-table td.pw { font-family: Consolas, monospace; direction: ltr; text-align: start; letter-spacing: .04em; }
@media print {
    .menu, .topbar, .no-print, .modal-backdrop { display: none !important; }
    .modal { position: static; width: auto; max-height: none; }
    /* Printing issued passwords prints the dialog alone, never the employees table behind it. hucPrint sets the
       class; the :has() block below covers the browser's own print command while the dialog is open. */
    body.printing-creds * { visibility: hidden !important; }
    body.printing-creds .cred-dialog, body.printing-creds .cred-dialog * { visibility: visible !important; }
    body.printing-creds .emp-layout, body.printing-creds .page-head, body.printing-creds .filters,
    body.printing-creds .notice, body.printing-creds .auth-error { display: none !important; }
    body.printing-creds .cred-dialog { position: absolute; inset-block-start: 0; inset-inline: 0; width: auto; box-shadow: none; }
}
@media print {
    body:has(.cred-dialog) * { visibility: hidden !important; }
    body:has(.cred-dialog) .cred-dialog, body:has(.cred-dialog) .cred-dialog * { visibility: visible !important; }
    body:has(.cred-dialog) .emp-layout, body:has(.cred-dialog) .page-head, body:has(.cred-dialog) .filters,
    body:has(.cred-dialog) .notice, body:has(.cred-dialog) .auth-error { display: none !important; }
    body:has(.cred-dialog) .cred-dialog { position: absolute; inset-block-start: 0; inset-inline: 0; width: auto; box-shadow: none; }
}
/* Groups, schedules and calendar screens */
.panel { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 16px 20px; box-sizing: border-box;
    display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.page-h.sm { font-size: 1.125rem; margin: 0; }
.personal-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; font-size: .875rem; }
.sub-h { margin: 0; font-size: .9375rem; color: #3F4A55; }
.grp-layout { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.grp-side { flex: 1 1 260px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.grp-main { flex: 3 1 420px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.grp-list { display: flex; flex-direction: column; gap: 8px; }
.grp-item { display: flex; flex-direction: column; align-items: stretch; gap: 4px; text-align: start; width: 100%; min-height: 44px;
    padding: 12px 14px; border-radius: 12px; font: inherit; color: var(--ink); cursor: pointer; background: #fff; border: 1px solid var(--border);
    box-sizing: border-box; }
.grp-item.selected { background: #E4EFF0; border: 2px solid var(--accent); }
.week-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.wk { display: flex; flex-direction: column; gap: 2px; padding: 10px 8px; border-radius: 8px; font-size: .8125rem; }
.wk-on { background: #E4EFF0; color: #0B3F3F; border: 1px solid #BFD6D8; }
.wk-off { background: #F0F3F5; color: #5B6672; border: 1px solid #F0F3F5; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px 20px; margin: 0; }
.kv div { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid #E7EBEE; padding: 6px 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 600; }
.sched { border-top: 1px solid #E7EBEE; padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.history li { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.group-box { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.group-box legend { font-weight: 600; padding: 0 6px; }
.day-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.day-row .check { min-width: 120px; }
.day-picks { display: flex; flex-wrap: wrap; gap: 4px 18px; }
/* Hierarchy and requests screens */
.tree { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.tree .tree { padding-inline-start: 24px; border-inline-start: 2px solid #DDE2E7; margin-top: 6px; }
.tree-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-height: 44px; }
.field textarea { padding: 8px 10px; border: 1px solid #C9D1D8; border-radius: 8px; font: inherit; font-size: .9375rem; resize: vertical; }

/* Phones (last, so it overrides the base rules above): the menu collapses to its brand row + toggle, so the page
   starts on the first screen. */
@media (max-width: 767px) {
    .shell { flex-direction: column; }
    .menu { flex: none; padding: 8px 12px; }
    .brand { padding: 4px; }
    .menu-toggle { display: inline-flex; }
    .menu:not(.open) .menu-items { display: none; }
    .topbar { padding: 12px 16px; }
    .page { padding: 16px; }
}
