/* =====================================================================
   Redsped Staff — application styles
   Mobile-first. Breakpoints: tablet 768px, desktop 1024px.
   ===================================================================== */

:root {
    --color-primary: #b91c1c;
    --color-primary-hover: #991b1b;
    --color-primary-soft: #fef2f2;

    --color-bg: #f4f5f7;
    --color-surface: #ffffff;
    --color-surface-alt: #f9fafb;
    --color-border: #e2e5ea;
    --color-border-strong: #c9ced6;
    --color-text: #1b1f24;
    --color-text-muted: #5b6470;
    --color-focus: #2563eb;

    /* Attendance status colours (always paired with a text label) */
    --status-working: #15803d;
    --status-working-bg: #dcfce7;
    --status-break: #b45309;
    --status-break-bg: #fef3c7;
    --status-exit: #1d4ed8;
    --status-exit-bg: #dbeafe;
    --status-off: #4b5563;
    --status-off-bg: #e5e7eb;
    --status-sick: #7e22ce;
    --status-sick-bg: #f3e8ff;
    --status-error: #b91c1c;
    --status-error-bg: #fee2e2;

    --color-success: #15803d;
    --color-success-bg: #ecfdf3;
    --color-info: #1d4ed8;
    --color-info-bg: #eff6ff;
    --color-warning: #b45309;
    --color-warning-bg: #fffbeb;
    --color-error: #b91c1c;
    --color-error-bg: #fef2f2;

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
    --shadow: 0 2px 8px rgba(16, 24, 40, .08);
    --shadow-lg: 0 12px 32px rgba(16, 24, 40, .16);

    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --topbar-height: 60px;
    --sidebar-width: 248px;
    --touch: 44px;
}

/* ---------------------------------------------------------------------
   Base
   --------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; font-weight: 650; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
a { color: var(--color-primary); }
a:hover { color: var(--color-primary-hover); }
img, svg { vertical-align: middle; }

:focus-visible {
    outline: 3px solid var(--color-focus);
    outline-offset: 2px;
}

[hidden] { display: none !important; }

.muted { color: var(--color-text-muted); }
.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}
.plain-list { margin: 0; padding-left: 1.2em; }

.skip-link {
    position: absolute;
    left: -9999px;
    top: 8px;
    z-index: 1000;
    padding: 8px 14px;
    background: var(--color-surface);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}
.skip-link:focus { left: 8px; }

.icon { flex-shrink: 0; }

/* ---------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: var(--touch);
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font: inherit;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .15s, border-color .15s, box-shadow .15s;
    -webkit-tap-highlight-color: transparent;
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: .6; cursor: not-allowed; }

.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--color-primary-hover); color: #fff; }

.btn-secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border-color: var(--color-border-strong);
}
.btn-secondary:hover:not(:disabled) { background: var(--color-surface-alt); color: var(--color-text); }

.btn-danger { background: var(--color-error); color: #fff; }

.btn-block { display: flex; width: 100%; }
.btn-lg { min-height: 52px; font-size: 1.05rem; letter-spacing: .02em; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: .9rem; }

/* Large attendance action buttons (employee dashboard) */
.btn-action {
    display: flex;
    width: 100%;
    min-height: 72px;
    font-size: 1.15rem;
    letter-spacing: .03em;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2.5px solid rgba(255, 255, 255, .5);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
.btn-secondary.is-loading::after { border-color: var(--color-border-strong); border-top-color: var(--color-text); }

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

.icon-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--touch);
    height: var(--touch);
    padding: 0;
    border: 0;
    border-radius: var(--radius);
    background: transparent;
    color: inherit;
    cursor: pointer;
}
.icon-button:hover { background: rgba(0, 0, 0, .06); }
.icon-button span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.link-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--color-primary);
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
}

.inline-form { display: inline; margin: 0; }

/* ---------------------------------------------------------------------
   Forms
   --------------------------------------------------------------------- */
.form { display: grid; gap: 16px; }

.field { display: grid; gap: 6px; }
.field label, .label-like { font-weight: 600; font-size: .95rem; }
.field-hint { margin: 0; font-size: .85rem; color: var(--color-text-muted); }
.field-error { margin: 0; font-size: .875rem; color: var(--color-error); font-weight: 500; }

.field-row { display: grid; gap: 16px; }
@media (min-width: 480px) {
    .field-row { grid-template-columns: 1fr 1fr; }
}

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="time"], input[type="search"], input[type="tel"], select, textarea {
    width: 100%;
    min-height: var(--touch);
    padding: 10px 12px;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
    font: inherit;
    font-size: 16px; /* prevents iOS zoom on focus */
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--color-focus);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .2);
}
[aria-invalid="true"] { border-color: var(--color-error) !important; }

.password-input { position: relative; }
.password-input input { padding-right: 52px; }
.password-toggle {
    position: absolute;
    top: 0;
    right: 0;
    width: var(--touch);
    height: 100%;
    border: 0;
    background: none;
    color: var(--color-text-muted);
    cursor: pointer;
    border-radius: 0 var(--radius) var(--radius) 0;
}
.password-toggle[aria-pressed="true"] { color: var(--color-primary); }

/* ---------------------------------------------------------------------
   Alerts, toasts
   --------------------------------------------------------------------- */
.alert {
    padding: 12px 14px;
    border: 1px solid transparent;
    border-left-width: 4px;
    border-radius: var(--radius);
    font-size: .95rem;
    white-space: pre-line;
}
.alert-success { background: var(--color-success-bg); border-color: var(--color-success); color: #14532d; }
.alert-info { background: var(--color-info-bg); border-color: var(--color-info); color: #1e3a8a; }
.alert-warning { background: var(--color-warning-bg); border-color: var(--color-warning); color: #78350f; }
.alert-error { background: var(--color-error-bg); border-color: var(--color-error); color: #7f1d1d; }

.toast-region {
    position: fixed;
    z-index: 900;
    left: 16px;
    right: 16px;
    bottom: 16px;
    display: grid;
    gap: 8px;
    pointer-events: none;
}
@media (min-width: 768px) {
    .toast-region { left: auto; right: 24px; bottom: 24px; width: 380px; }
}
.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radius);
    background: #1f2937;
    color: #fff;
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    white-space: pre-line;
    animation: toast-in .2s ease-out;
}
.toast-success { background: #14532d; }
.toast-error { background: #7f1d1d; }
.toast-warning { background: #78350f; }
.toast-message { flex: 1; }
.toast-close {
    border: 0;
    background: none;
    color: inherit;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    opacity: .8;
    min-width: 28px;
    min-height: 28px;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------------------------------------------------------------------
   Cards, lists, badges
   --------------------------------------------------------------------- */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 16px;
}
.card-narrow { max-width: 480px; }

.welcome-title { font-size: 1.35rem; margin-bottom: 12px; }

.meta-list { display: grid; gap: 12px; margin: 0; }
.meta-list > div { display: grid; gap: 2px; }
.meta-list dt { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--color-text-muted); }
.meta-list dd { margin: 0; font-weight: 600; }
@media (min-width: 480px) {
    .meta-list { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: .85rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.badge-working { color: var(--status-working); background: var(--status-working-bg); }
.badge-break { color: var(--status-break); background: var(--status-break-bg); }
.badge-exit { color: var(--status-exit); background: var(--status-exit-bg); }
.badge-off { color: var(--status-off); background: var(--status-off-bg); }
.badge-sick { color: var(--status-sick); background: var(--status-sick-bg); }
.badge-error { color: var(--status-error); background: var(--status-error-bg); }

/* ---------------------------------------------------------------------
   Auth layout (login, password reset, setup)
   --------------------------------------------------------------------- */
.layout-auth { background: linear-gradient(180deg, var(--color-primary-soft) 0%, var(--color-bg) 320px); }

.auth-wrap {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 32px 16px;
}
@media (min-height: 700px) and (min-width: 480px) {
    .auth-wrap { align-items: center; }
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 28px 22px;
}
@media (min-width: 480px) {
    .auth-card { padding: 36px 32px; }
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 24px;
    font-weight: 700;
    font-size: 1.1rem;
}
.auth-title { font-size: 1.4rem; margin-bottom: 16px; }
.auth-card .form { margin-bottom: 8px; }
.auth-card > .alert { margin-bottom: 16px; }
.auth-links { margin: 16px 0 0; text-align: center; font-size: .95rem; }

.error-detail {
    padding: 10px;
    background: var(--color-surface-alt);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: .8rem;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ---------------------------------------------------------------------
   Brand
   --------------------------------------------------------------------- */
.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--color-text);
    font-weight: 700;
    text-decoration: none;
    min-height: var(--touch);
}
.brand:hover { color: var(--color-text); }

/* ---------------------------------------------------------------------
   Employee layout (mobile-first top bar)
   --------------------------------------------------------------------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    min-height: var(--topbar-height);
    padding: 8px 16px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

.topnav {
    display: none;
    flex-basis: 100%;
    flex-direction: column;
    gap: 2px;
    padding: 8px 0;
}
.topnav.is-open { display: flex; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: var(--touch);
    padding: 8px 12px;
    border: 0;
    border-radius: var(--radius);
    background: none;
    color: var(--color-text);
    font: inherit;
    font-weight: 500;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}
.nav-link:hover { background: var(--color-surface-alt); color: var(--color-text); }
.nav-link.is-active { background: var(--color-primary-soft); color: var(--color-primary); font-weight: 650; }

@media (min-width: 768px) {
    .topbar { flex-wrap: nowrap; padding: 0 24px; }
    .topbar .nav-toggle { display: none; }
    .topnav { display: flex; flex-direction: row; flex-basis: auto; align-items: center; padding: 0; gap: 4px; }
    .topnav .nav-link { width: auto; }
    .topnav .inline-form { display: block; }
}

.app-main {
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    padding: 16px 16px 96px;
}
@media (min-width: 768px) {
    .app-main { padding-top: 32px; }
}

/* ---------------------------------------------------------------------
   Management layout (sidebar)
   --------------------------------------------------------------------- */
.admin-shell { min-height: 100vh; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 300;
    width: var(--sidebar-width);
    max-width: 85vw;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform .2s ease;
}
.sidebar.is-open { transform: translateX(0); box-shadow: var(--shadow-lg); }
.sidebar .brand { padding: 4px 8px 12px; border-bottom: 1px solid var(--color-border); }
.sidenav { display: grid; gap: 2px; }

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 250;
    background: rgba(15, 23, 42, .4);
}

.admin-body { min-width: 0; }

.admin-topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: var(--topbar-height);
    padding: 8px 16px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}
.page-title { flex: 1; min-width: 0; margin: 0; font-size: 1.15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.topbar-user { display: flex; align-items: center; gap: 6px; }
.user-chip { display: none; flex-direction: column; line-height: 1.2; text-align: right; padding: 0 6px; }
.user-chip small { color: var(--color-text-muted); }
.topbar-user .btn span { display: none; }

.admin-main { padding: 16px; }

@media (min-width: 768px) {
    .user-chip { display: flex; }
    .topbar-user .btn span { display: inline; }
    .admin-main { padding: 24px; }
}

@media (min-width: 1024px) {
    .admin-shell { display: grid; grid-template-columns: var(--sidebar-width) 1fr; }
    .sidebar { position: sticky; top: 0; height: 100vh; transform: none; max-width: none; box-shadow: none !important; }
    .sidebar-backdrop { display: none !important; }
    .admin-topbar .nav-toggle { display: none; }
    .admin-topbar { padding: 0 24px; }
    .admin-main { padding: 28px 32px; }
}

/* ---------------------------------------------------------------------
   Tables (management)
   --------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-surface); }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--color-border); white-space: nowrap; }
.table th { background: var(--color-surface-alt); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-muted); font-weight: 650; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--color-surface-alt); }

/* ---------------------------------------------------------------------
   Reduced motion
   --------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------------------------------------------------------------------
   Management pages: toolbar, filters, pagination
   --------------------------------------------------------------------- */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}
.toolbar-info { margin: 0; color: var(--color-text-muted); }

.filters {
    display: grid;
    gap: 12px;
    margin-bottom: 16px;
    padding: 16px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
}
.filters .field label { font-size: .85rem; }
.filters-actions { display: flex; gap: 8px; align-items: flex-end; }
@media (min-width: 768px) {
    .filters { grid-template-columns: 2fr 1fr 1fr 1fr auto; align-items: end; }
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 12px;
}
.pagination-buttons { display: flex; gap: 8px; align-items: center; }
.pagination select { width: auto; min-height: 36px; padding: 4px 8px; }

.table td.actions { text-align: right; }
.table td.actions .btn + .btn { margin-left: 6px; }
.table .cell-sub { display: block; font-size: .85rem; color: var(--color-text-muted); }
.table .row-inactive td { color: var(--color-text-muted); }
.table-empty { padding: 32px 16px !important; text-align: center !important; color: var(--color-text-muted); white-space: normal !important; }

.badge-active { color: var(--status-working); background: var(--status-working-bg); }
.badge-inactive { color: var(--status-off); background: var(--status-off-bg); }
.badge-suspended { color: var(--status-break); background: var(--status-break-bg); }
.badge-none { color: var(--color-text-muted); background: transparent; border: 1px dashed var(--color-border-strong); }
.badge-none::before { display: none; }

/* ---------------------------------------------------------------------
   Dialogs
   --------------------------------------------------------------------- */
.modal {
    width: min(560px, calc(100vw - 24px));
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
    padding: 0;
    border: 0;
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    color: var(--color-text);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.modal[open] { display: flex; flex-direction: column; }
.modal-sm { width: min(420px, calc(100vw - 24px)); }
.modal-lg { width: min(820px, calc(100vw - 24px)); }
.modal::backdrop { background: rgba(15, 23, 42, .5); }
.modal > form { display: flex; flex-direction: column; min-height: 0; flex: 1; margin: 0; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--color-border);
}
.modal-title { margin: 0; font-size: 1.15rem; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; display: grid; gap: 16px; align-content: start; }
.modal-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 20px;
    border-top: 1px solid var(--color-border);
    background: var(--color-surface-alt);
}
.modal-footer .spacer { flex: 1; }
.confirm-message { margin: 0; white-space: pre-line; }

fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
legend { padding: 0; }
.form-section { display: grid; gap: 16px; }
.form-section + .form-section { padding-top: 16px; border-top: 1px solid var(--color-border); }
.form-section-title { margin: 0; font-size: 1rem; }

.field-row-3 { display: grid; gap: 16px; }
@media (min-width: 640px) {
    .field-row-3 { grid-template-columns: repeat(3, 1fr); }
}

.checkbox { display: inline-flex; align-items: center; gap: 8px; min-height: var(--touch); cursor: pointer; font-weight: 500; }
.checkbox input { width: 20px; height: 20px; margin: 0; accent-color: var(--color-primary); }

/* ---------------------------------------------------------------------
   Map picker (branches)
   --------------------------------------------------------------------- */
.map-picker { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--color-border-strong); }
.map { width: 100%; height: 300px; background: var(--color-surface-alt); }
.map-crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 28px;
    height: 28px;
    margin: -28px 0 0 -14px;
    pointer-events: none;
    color: var(--color-primary);
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .4));
}
.map-message { display: flex; align-items: center; justify-content: center; height: 100%; padding: 16px; text-align: center; color: var(--color-text-muted); }
.map-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }

/* ---------------------------------------------------------------------
   Schedule editor
   --------------------------------------------------------------------- */
.schedule-grid { display: grid; gap: 8px; }
.schedule-row {
    display: grid;
    grid-template-columns: minmax(110px, 1fr) 1fr 1fr;
    gap: 8px;
    align-items: center;
}
.schedule-row input[type="time"]:disabled { background: var(--color-surface-alt); color: var(--color-text-muted); }
.schedule-head { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-muted); }

/* ---------------------------------------------------------------------
   One-time password panel
   --------------------------------------------------------------------- */
.secret-panel {
    display: grid;
    gap: 10px;
    padding: 14px;
    border: 1px solid var(--color-warning);
    border-radius: var(--radius);
    background: var(--color-warning-bg);
}
.secret-value {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    background: var(--color-surface);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 1.15rem;
    letter-spacing: .05em;
    word-break: break-all;
}

/* ---------------------------------------------------------------------
   Employee dashboard
   --------------------------------------------------------------------- */
.eyebrow {
    display: block;
    margin: 0 0 4px;
    font-size: .78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--color-text-muted);
}

.status-card { display: grid; gap: 16px; }
.status-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px; align-items: flex-start; }
.status-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; }
.status-line .badge { font-size: 1rem; padding: 6px 14px; }
.status-since { color: var(--color-text-muted); font-weight: 500; }
.work-clock { text-align: right; }
.work-clock strong { font-size: 2rem; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.meta-compact { padding-top: 12px; border-top: 1px solid var(--color-border); }

.action-list { display: grid; gap: 12px; margin: 0 0 16px; }
.btn-action-start { background: var(--status-working); color: #fff; }
.btn-action-start:hover:not(:disabled) { background: #166534; color: #fff; }
.btn-action-break { background: var(--status-break); color: #fff; }
.btn-action-break:hover:not(:disabled) { background: #92400e; color: #fff; }
.btn-action-exit { background: var(--status-exit); color: #fff; }
.btn-action-exit:hover:not(:disabled) { background: #1e40af; color: #fff; }
.btn-action-end { background: #374151; color: #fff; }
.btn-action-end:hover:not(:disabled) { background: #1f2937; color: #fff; }
@media (min-width: 560px) {
    .action-list { grid-template-columns: 1fr 1fr; }
    .action-list .btn-action-start, .action-list .btn-action-end { grid-column: 1 / -1; }
}

.action-error { display: grid; gap: 12px; margin-bottom: 16px; }
.action-error p { margin: 0; }

.today-list, .totals-list { display: grid; gap: 10px; margin: 0; }
.today-list > div, .totals-list > div {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 8px;
    border-bottom: 1px dashed var(--color-border);
}
.today-list dt, .totals-list dt { color: var(--color-text-muted); }
.today-list dd, .totals-list dd { margin: 0; font-weight: 600; text-align: right; white-space: pre-line; font-variant-numeric: tabular-nums; }
.totals-list { margin-top: 16px; }
.totals-list > div:first-child dd { font-size: 1.15rem; }
.totals-list > div:last-child, .today-list > div:last-child { border-bottom: 0; }

.privacy-note { display: flex; gap: 8px; align-items: flex-start; font-size: .85rem; color: var(--color-text-muted); }

.busy-overlay {
    position: fixed;
    inset: 0;
    z-index: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(15, 23, 42, .45);
}
.busy-box {
    display: flex;
    align-items: center;
    gap: 14px;
    max-width: 360px;
    padding: 18px 22px;
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    box-shadow: var(--shadow-lg);
    font-weight: 600;
}
.spinner {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

/* ---------------------------------------------------------------------
   History / sick leave (employee)
   --------------------------------------------------------------------- */
.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 16px; }
.month-nav h1 { margin: 0; font-size: 1.25rem; text-align: center; flex: 1; }

.summary-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 560px) { .summary-grid { grid-template-columns: repeat(4, 1fr); } }
.summary-item { display: grid; gap: 2px; }
.summary-item strong { font-size: 1.25rem; font-variant-numeric: tabular-nums; }

.day-card { padding: 16px; }
.day-card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.day-card-head h2 { margin: 0; font-size: 1rem; }
.day-card .today-list { gap: 6px; }
.day-card .today-list > div { padding-bottom: 6px; }
.empty-state { padding: 32px 16px; text-align: center; color: var(--color-text-muted); }

.request-list { display: grid; gap: 12px; }
.request-item { display: grid; gap: 6px; }
.request-item-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.badge-pending { color: var(--status-break); background: var(--status-break-bg); }
.badge-approved { color: var(--status-working); background: var(--status-working-bg); }
.badge-rejected { color: var(--status-error); background: var(--status-error-bg); }
.badge-cancelled { color: var(--status-off); background: var(--status-off-bg); }
.badge-incomplete { color: var(--status-error); background: var(--status-error-bg); }
.badge-completed { color: var(--status-off); background: var(--status-off-bg); }
.badge-sick_leave { color: var(--status-sick); background: var(--status-sick-bg); }
.badge-absent { color: var(--status-error); background: var(--status-error-bg); }
.badge-holiday { color: var(--status-exit); background: var(--status-exit-bg); }
.badge-not_started { color: var(--status-off); background: var(--status-off-bg); }
.badge-on_break { color: var(--status-break); background: var(--status-break-bg); }
.badge-official_exit { color: var(--status-exit); background: var(--status-exit-bg); }

/* ---------------------------------------------------------------------
   Management dashboard
   --------------------------------------------------------------------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}
@media (min-width: 640px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1200px) { .stat-grid { grid-template-columns: repeat(7, 1fr); } }

.stat-card {
    display: grid;
    gap: 4px;
    padding: 14px 16px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-border-strong);
    border-radius: var(--radius);
}
.stat-label { font-size: .85rem; color: var(--color-text-muted); }
.stat-value { font-size: 1.75rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-working { border-left-color: var(--status-working); }
.stat-break { border-left-color: var(--status-break); }
.stat-exit { border-left-color: var(--status-exit); }
.stat-sick { border-left-color: var(--status-sick); }
.stat-error { border-left-color: var(--status-error); }

.dash-columns { display: grid; gap: 16px; }
@media (min-width: 1024px) { .dash-columns { grid-template-columns: 1fr 1fr; } }
.dash-columns .card { margin-bottom: 0; }
.dash-columns + section { margin-top: 24px; }

.alert-list, .link-list, .branch-bars { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.alert-list li { display: flex; align-items: center; gap: 10px; }
.alert-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 28px;
    padding: 0 8px;
    border-radius: 999px;
    background: var(--status-error-bg);
    color: var(--status-error);
    font-weight: 700;
}
.alert-ok { color: var(--status-working); font-weight: 600; }

.branch-bar-head { display: flex; justify-content: space-between; gap: 8px; }
.bar { display: block; height: 8px; margin-top: 4px; background: var(--color-surface-alt); border-radius: 999px; overflow: hidden; border: 1px solid var(--color-border); }
.bar-fill { display: block; height: 100%; background: var(--status-working); }

.section-title { margin: 0; font-size: 1.15rem; }
.board-filters { display: flex; flex-wrap: wrap; gap: 8px; }
.board-filters input, .board-filters select { width: auto; min-width: 180px; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
    min-height: 36px;
    padding: 6px 14px;
    border: 1px solid var(--color-border-strong);
    border-radius: 999px;
    background: var(--color-surface);
    color: var(--color-text);
    font: inherit;
    font-size: .9rem;
    cursor: pointer;
}
.chip.is-active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }

/* ---------------------------------------------------------------------
   Attendance (management)
   --------------------------------------------------------------------- */
@media (min-width: 768px) {
    .filters-attendance { grid-template-columns: 1fr 2fr 1fr 1fr 1fr; }
    .filters-compact { grid-template-columns: repeat(4, minmax(0, 220px)); }
}
.table-compact th, .table-compact td { padding: 8px 10px; font-size: .9rem; vertical-align: top; }
.table .cell-wrap { white-space: normal; min-width: 180px; max-width: 360px; }
.row-superseded td { color: var(--color-text-muted); text-decoration: line-through; }
.row-superseded td .badge, .row-superseded td.actions { text-decoration: none; }

/* ---------------------------------------------------------------------
   Reports
   --------------------------------------------------------------------- */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--color-border); }
.tab {
    min-height: var(--touch);
    padding: 8px 16px;
    border: 0;
    border-bottom: 3px solid transparent;
    background: none;
    color: var(--color-text-muted);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.tab:hover { color: var(--color-text); }
.tab.is-active { color: var(--color-primary); border-bottom-color: var(--color-primary); }

@media (min-width: 768px) {
    .filters-reports { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
    .filters-reports .filters-actions { grid-column: 1 / -1; }
}

.table th.num, .table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.table tfoot th, .table tfoot td { background: var(--color-surface-alt); font-weight: 700; border-top: 2px solid var(--color-border-strong); }

@media print {
    .sidebar, .admin-topbar, .filters, .tabs, .toolbar .board-filters, .toast-region, .pagination { display: none !important; }
    .admin-shell { display: block; }
    .admin-main { padding: 0; }
    .table-wrap { border: 0; overflow: visible; }
    .table th, .table td { padding: 4px 6px; font-size: 10pt; }
}

/* ---------------------------------------------------------------------
   Settings, audit log, system health
   --------------------------------------------------------------------- */
.settings-grid { display: grid; gap: 16px; }
@media (min-width: 768px) { .settings-grid { grid-template-columns: 1fr 1fr; } }
.setting-bool { align-content: start; }
.sticky-actions {
    position: sticky;
    bottom: 0;
    z-index: 50;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    background: linear-gradient(180deg, rgba(244, 245, 247, 0) 0%, var(--color-bg) 35%);
}

.changes-table { width: 100%; margin: 8px 0; border-collapse: collapse; font-size: .85rem; }
.changes-table th, .changes-table td { padding: 4px 6px; border: 1px solid var(--color-border); text-align: left; white-space: normal; word-break: break-word; }
.changes-table thead th { background: var(--color-surface-alt); }
.audit-reason { margin: 0 0 6px; font-weight: 500; }
details summary { cursor: pointer; color: var(--color-primary); }

.stat-grid-3 { grid-template-columns: repeat(3, 1fr) !important; }
.card-spaced { margin-top: 16px; }
.code-block {
    padding: 12px;
    overflow-x: auto;
    background: #1f2937;
    color: #f9fafb;
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: .85rem;
    white-space: pre;
}

.checkbox-grid { display: grid; gap: 4px; }
@media (min-width: 640px) { .checkbox-grid { grid-template-columns: 1fr 1fr; } }
