@import url('https://fonts.googleapis.com/css2?family=Source+Sans+3:wght@400;500;600;700;800&display=swap');

:root {
    --bg: #f3f5f8;
    --panel: #ffffff;
    --ink: #1c2430;
    --muted: #7b8494;
    --line: #e8edf3;
    --green: #16a34a;
    --green-2: #22c55e;
    --green-soft: #e8f8ee;
    --gold: var(--green);
    --gold-2: var(--green-2);
    --navy: #163024;
    --ok: #16a34a;
    --err: #dc4c3f;
    --in: #16a34a;
    --out: #f59e0b;
    --shadow: 0 10px 30px rgba(28, 36, 48, 0.06);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Source Sans 3", "Noto Sans", "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--ink);
}

a { color: inherit; }
img { max-width: 100%; }

.admin-body { min-height: 100vh; }

.auth-body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 24px 16px;
    background: linear-gradient(180deg, #f3f5f8, #e8f8ee);
}

.auth-card {
    width: min(460px, calc(100% - 32px));
    background: var(--panel);
    border-radius: 28px;
    padding: 32px;
    box-shadow: var(--shadow);
}
.auth-card form .btn { width: 100%; margin-top: 8px; }
.auth-card form .check { margin-bottom: 18px; }

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

.side-brand {
    margin-bottom: 28px;
    flex-direction: column;
    align-items: flex-start;
}
.brand { margin-bottom: 22px; }
.brand-auth {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
}

.brand-logo-link { display: block; width: 100%; }
.brand-logo {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
}
.brand-logo-sidebar { width: 100%; }
.brand-logo-auth { width: min(320px, 100%); }
.topbar-logo-link {
    display: none;
    flex: 0 0 auto;
    line-height: 0;
}
.brand-logo-topbar {
    height: 28px;
    width: auto;
    max-width: 120px;
    object-fit: contain;
}

.brand-mark, .mark {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: linear-gradient(160deg, var(--green-2), var(--green));
    color: #fff;
    font-weight: 800;
}

.side-brand strong, .brand strong { display: block; font-size: 18px; }
.side-brand small, .brand small, .muted, .table-meta { color: var(--muted); }
.side-brand small, .brand-auth small {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
[hidden] { display: none !important; }

.app {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 18px;
    padding: 18px;
}

.sidebar {
    background: var(--panel);
    color: var(--ink);
    padding: 22px 16px;
    display: flex;
    flex-direction: column;
    border-radius: 28px;
    box-shadow: var(--shadow);
}

.menu-toggle, .menu-close {
    display: none;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 14px;
    background: #f3f5f8;
    color: var(--ink);
    cursor: pointer;
    flex: 0 0 42px;
    padding: 0;
}
.menu-toggle svg, .menu-close svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.nav-backdrop { display: none; }

.nav-label {
    margin: 18px 12px 8px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #9aa3b2;
}

.nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #5b6573;
    padding: 11px 12px;
    border-radius: 14px;
    margin-bottom: 4px;
    font-weight: 600;
}

.nav svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: 0 0 18px;
}

.nav a.active, .nav a:hover {
    background: var(--green-soft);
    color: var(--green);
}

.shell {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-height: calc(100vh - 36px);
}

.topbar {
    background: var(--panel);
    border-radius: 24px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    box-shadow: var(--shadow);
}

.top-search {
    flex: 1;
    display: none;
    align-items: center;
    gap: 10px;
    background: #f5f7fa;
    border-radius: 16px;
    padding: 0 14px;
}

.top-search svg {
    width: 18px;
    height: 18px;
    stroke: #8b93a1;
    fill: none;
    stroke-width: 1.8;
}

.top-search input {
    border: 0;
    background: transparent;
    margin: 0;
    padding: 12px 0;
}

.top-search input:focus { outline: none; }
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.top-user {
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

.top-user strong, .top-user small { display: block; }
.top-user small { color: var(--muted); font-size: 12px; }

.avatar-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--green-soft);
    color: var(--green);
    font-weight: 800;
    font-size: 13px;
}

.content { padding: 6px 4px 20px; }
.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 22px;
}

h1, h2, h3 { margin: 0 0 8px; font-weight: 800; }
h1 { font-size: 32px; letter-spacing: -0.03em; }
h2 { font-size: 20px; }

.cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 22px;
}

.card, .panel, table, form.box {
    background: var(--panel);
    border: 0;
    border-radius: 24px;
    box-shadow: var(--shadow);
}

.card, .panel, form.box { padding: 20px; }
.card {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: start;
}
.card strong { font-size: 32px; display: block; letter-spacing: -0.04em; }
.card span { color: var(--muted); font-size: 13px; font-weight: 600; grid-column: 1; }
.card-icon {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: var(--green-soft);
    color: var(--green);
    grid-column: 2;
    grid-row: 1 / span 2;
}
.card-icon svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.table-wrap {
    overflow: auto;
    background: var(--panel);
    border-radius: 24px;
    box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; overflow: hidden; box-shadow: none; }
th, td { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--line); font-size: 14px; }
th { color: var(--muted); font-weight: 700; background: #f8fafc; }

.btn, button.btn, input[type="submit"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: 14px;
    padding: 10px 14px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
}

.btn-primary { background: var(--green); color: #fff; }
.btn-ghost { background: #f3f5f8; color: var(--ink); }
.btn-danger { background: #fdecea; color: var(--err); }

label { display: block; margin-bottom: 14px; font-weight: 600; }
label small { display: block; font-weight: 500; margin-top: 4px; }
input, select, textarea {
    width: 100%;
    margin-top: 6px;
    padding: 11px 12px;
    border-radius: 14px;
    border: 1px solid var(--line);
    font: inherit;
    background: #fff;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filters > * { min-width: 140px; flex: 1; }
.punches-filters .check { min-width: auto; flex: 0 0 auto; }
.punches-filters .btn { flex: 0 0 auto; }
.pager {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    flex-wrap: wrap;
}
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.check input { width: auto; margin: 0; }

.alert { padding: 12px 14px; border-radius: 16px; }
.alert.success { background: var(--green-soft); color: var(--ok); }
.alert.error { background: #fdecea; color: var(--err); }
.alert.warn { background: #fff7e8; color: #9a5b12; }

.ergani-queue { margin-bottom: 20px; }
.ergani-queue-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-top: 1px solid var(--line);
    flex-wrap: wrap;
}
.ergani-queue-row:first-of-type { border-top: 0; }
.ergani-retry-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.ergani-retry-form select { min-width: 220px; }
.activity-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}
.badge.in { background: var(--green-soft); color: var(--in); }
.badge.out { background: #fff7e8; color: var(--out); }
.badge.break { background: #e7f0fb; color: #265b9b; }
.badge.off { background: #eef1f4; color: #666; }

code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.92em; background: #f3f5f8; padding: 1px 5px; border-radius: 6px; }

.who { display: flex; align-items: center; gap: 10px; }
.who .dot {
    width: 10px; height: 10px; border-radius: 50%; background: var(--in);
}

.activity-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.cal-weekdays, .cal {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 8px;
}
.cal-weekdays { margin-bottom: 8px; color: var(--muted); font-size: 13px; font-weight: 700; text-align: center; }
.cal-day {
    min-height: 128px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 8px;
    box-shadow: none;
}
.cal-day.empty { background: transparent; border-color: transparent; }
.cal-day.today { outline: 2px solid var(--green); }
.cal-day header { font-weight: 800; margin-bottom: 6px; }
.cal-chip { font-size: 11px; border-radius: 8px; padding: 4px 6px; margin-bottom: 4px; line-height: 1.3; }
.cal-chip.real { background: var(--green-soft); color: var(--in); }
.cal-chip.local { background: #e7f0fb; color: #265b9b; }
.cal-chip.planned { background: #f4efe4; color: #7a6230; }
.cal-chip.work { background: var(--green-soft); color: var(--in); font-weight: 800; }
.cal-chip.remote { background: #e7f0fb; color: #265b9b; font-weight: 800; }
.cal-chip.off { background: #eef1f4; color: #666; font-weight: 700; }
.cal-chip.none { background: #f4efe4; color: #7a6230; font-weight: 700; }

.hours-layout {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}
.hours-people {
    background: var(--panel);
    border-radius: 24px;
    box-shadow: var(--shadow);
    padding: 12px;
    max-height: calc(100vh - 160px);
    overflow: auto;
    position: sticky;
    top: 12px;
}
.hours-person {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 12px;
    border-radius: 14px;
    text-decoration: none;
    margin-bottom: 4px;
}
.hours-person small { color: var(--muted); font-weight: 600; }
.hours-person.active {
    background: var(--green-soft);
    color: var(--green);
}
.hours-person.active small { color: var(--green); }
.hours-nav > strong { flex: 1; text-align: center; min-width: 180px; }
.hours-toolbar { margin-bottom: 16px; }
.hours-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 4px 0 8px;
}
.hours-actions .btn { flex: 0 0 auto; }
#hours-hint.error { color: var(--err); }
.hours-day { cursor: pointer; min-height: 96px; user-select: none; }
.hours-day.selected {
    outline: 2px solid var(--green);
    background: var(--green-soft);
}
.hours-day.is-off { background: #f6f7f9; }
.hours-day.is-none { background: #f7f3ea; }
.hours-day.is-remote { background: #f3f7fc; }
.hours-ergani-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--line, #e7e4dc);
}
.hours-ergani-bar .muted { flex: 1; min-width: 200px; }
.hours-week-panel { margin-top: 18px; }
.hours-week-panel h2,
.hours-layout .panel h2 { margin: 0 0 8px; font-size: 18px; }
.hours-week-grid { display: grid; gap: 8px; margin: 12px 0; }
.hours-week-row {
    display: grid;
    grid-template-columns: 110px 160px 1fr 1fr;
    gap: 8px;
    align-items: center;
}
.hours-week-row strong { font-size: 14px; }
.hours-result-box { width: min(520px, 100%); }
.hours-result-body { margin: 0 0 10px; white-space: pre-wrap; line-height: 1.45; }
.hours-result-detail {
    margin: 0 0 14px;
    padding: 0;
    list-style: none;
    max-height: 240px;
    overflow: auto;
    font-size: 14px;
    font-weight: 600;
}
.hours-result-detail li { padding: 4px 0; border-bottom: 1px solid var(--line, #eee); }
.hours-result-box.is-error .sync-title { color: var(--err); }
@media (max-width: 720px) {
    .hours-week-row { grid-template-columns: 1fr 1fr; }
    .hours-week-row strong { grid-column: 1 / -1; }
}

.sync-overlay {
    position: fixed;
    inset: 0;
    background: rgba(28, 36, 48, 0.35);
    display: grid;
    place-items: center;
    z-index: 40;
    padding: 20px;
}
.sync-overlay[hidden] { display: none; }
.sync-box {
    width: min(440px, 100%);
    background: var(--panel);
    border-radius: 24px;
    padding: 22px;
    box-shadow: var(--shadow);
}
.sync-title { margin: 0 0 12px; font-weight: 800; }
.sync-track {
    height: 12px;
    background: #eef3ee;
    border-radius: 999px;
    overflow: hidden;
}
.sync-bar {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--green), var(--green-2));
    transition: width 0.25s ease;
}
body.syncing { overflow: hidden; }
.btn[disabled] { opacity: 0.6; cursor: wait; }

.import-box {
    background: var(--panel);
    border: 0;
    border-radius: 20px;
    padding: 14px 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}
.import-box summary {
    cursor: pointer;
    font-weight: 800;
}
.import-box textarea {
    margin: 10px 0;
    min-height: 140px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 13px;
}

.roster-panel { margin-bottom: 22px; }
.roster-row {
    display: grid;
    grid-template-columns: minmax(160px, 1.4fr) 120px 110px minmax(120px, 0.8fr);
    gap: 12px;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}
.roster-row:last-child { border-bottom: 0; }
.roster-hours { font-weight: 800; font-size: 18px; white-space: nowrap; }

.hr-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}
.hr-view h3 { margin: 18px 0 8px; }
.json-preview {
    background: #16181c;
    color: #e8e4d9;
    padding: 16px 18px;
    border-radius: 16px;
    overflow: auto;
    font-size: 12px;
    line-height: 1.45;
    max-height: 420px;
    white-space: pre-wrap;
    word-break: break-word;
}

.hr-steps {
    display: flex;
    gap: 8px;
    list-style: none;
    padding: 0;
    margin: 0 0 16px;
    flex-wrap: wrap;
}
.hr-steps li {
    padding: 8px 12px;
    border-radius: 999px;
    background: #eef1f4;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}
.hr-steps li.active {
    background: var(--green-soft);
    color: var(--green);
}

.settings-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 0 0 16px;
}
.settings-tabs button {
    border: 0;
    background: #eef1f4;
    color: var(--ink);
    padding: 10px 16px;
    border-radius: 999px;
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}
.settings-tabs button.active,
.settings-tabs button:hover {
    background: var(--green-soft);
    color: var(--green);
}
.settings-pane h2 { margin-top: 0; }
.settings-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}
.legal-strip, .legal-box {
    background: #f6f3ea;
    border-radius: 16px;
    padding: 12px 16px;
    margin: 0 0 16px;
    font-size: 13px;
    line-height: 1.45;
}
.legal-box p { margin: 0 0 8px; }
.hr-notes {
    background: #eef6f1;
    border-radius: 16px;
    padding: 12px 16px;
    font-size: 14px;
}
.hr-notes p { margin: 0 0 8px; }
.hr-suggest {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 220px;
    overflow: auto;
}
.hr-suggest button, .spec-quick {
    text-align: left;
}
fieldset.hr-step {
    border: 0;
    padding: 0;
    margin: 0;
}
fieldset.hr-step legend {
    font-weight: 800;
    font-size: 20px;
    margin-bottom: 10px;
}

.designer-credit {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0;
    padding: 12px 4px 10px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}
.shell > .designer-credit { margin-top: auto; }
.designer-credit img {
    height: 48px;
    width: auto;
    display: block;
}

@media (max-width: 980px) {
    .app {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 12px;
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
    .menu-toggle { display: grid; }
    .menu-close {
        display: grid;
        position: absolute;
        top: 16px;
        right: 12px;
    }
    .nav-backdrop:not([hidden]) {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(28, 36, 48, 0.4);
        z-index: 40;
    }
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(300px, 88vw);
        max-height: 100vh;
        overflow: auto;
        z-index: 50;
        border-radius: 0 24px 24px 0;
        padding: 20px 14px max(20px, env(safe-area-inset-bottom));
        padding-left: max(14px, env(safe-area-inset-left));
        transform: translateX(-110%);
        transition: transform 0.22s ease;
        box-shadow: none;
    }
    body.nav-open { overflow: hidden; }
    body.nav-open .sidebar {
        transform: translateX(0);
        box-shadow: 20px 0 40px rgba(28, 36, 48, 0.18);
    }
    .side-brand {
        position: relative;
        width: 100%;
        max-width: none;
        padding-right: 48px;
        margin-bottom: 16px;
    }
    .nav {
        display: flex;
        flex-direction: column;
        flex-wrap: nowrap;
        gap: 0;
    }
    .nav a {
        min-height: 44px;
        margin-bottom: 2px;
    }
    .shell { min-height: auto; gap: 12px; }
    .topbar {
        position: sticky;
        top: 0;
        z-index: 30;
        gap: 10px;
        padding: 8px 10px;
        border-radius: 18px;
    }
    .topbar-logo-link { display: block; }
    .top-search { display: none; min-width: 0; padding: 0 10px; }
    .top-search input { padding: 10px 0; }
    .top-user div { display: none; }
    .page-head { flex-direction: column; gap: 12px; }
    h1 { font-size: 26px; }
    .cards { grid-template-columns: 1fr 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
    .roster-row { grid-template-columns: 1fr 1fr; }
    .hours-layout { grid-template-columns: 1fr; }
    .hours-people {
        position: static;
        max-height: 220px;
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }
    .hours-people .nav-label { width: 100%; }
    .hours-person { margin: 0; }
    .settings-tabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
    .settings-tabs button { flex: 0 0 auto; }
    .assistant-layout { grid-template-columns: 1fr; }
    .assistant-log { min-height: 280px; max-height: 50vh; }
}

.assistant-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 16px;
    align-items: start;
}
.assistant-chat { padding: 16px; }
.assistant-voice-status {
    margin: 0 0 12px;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.03em;
    min-height: 1.4em;
}
.assistant-log {
    min-height: 72px;
    max-height: 140px;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 4px 2px 12px;
    opacity: 0.45;
}
.assistant-msg {
    max-width: 85%;
    padding: 12px 14px;
    border-radius: 18px;
    white-space: pre-wrap;
    line-height: 1.45;
    font-size: 15px;
}
.assistant-msg.user {
    align-self: flex-end;
    background: var(--green);
    color: #fff;
    border-bottom-right-radius: 6px;
}
.assistant-msg.bot {
    align-self: flex-start;
    background: #f3f5f8;
    border-bottom-left-radius: 6px;
}
.assistant-form {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}
.assistant-form textarea {
    margin: 0;
    min-height: 52px;
    resize: none;
    flex: 1;
}
.assistant-form .btn { flex: 0 0 auto; min-height: 52px; }
.assistant-mic {
    min-width: 92px;
    font-size: 16px;
}
.assistant-mic.is-on { background: #fdecea; color: var(--err); }
.assistant-hints h2 { margin-bottom: 12px; }
.assistant-example {
    display: block;
    width: 100%;
    text-align: left;
    margin-bottom: 8px;
    padding: 10px 12px;
    border: 0;
    border-radius: 14px;
    background: #f3f5f8;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.assistant-example:hover { background: var(--green-soft); }
