:root {
    --brand: #0b4f8a; --brand-dark: #083b68; --bg: #f3f5f8; --card: #fff; --text: #1f2933;
    --muted: #6b7785; --line: #e3e8ee; --danger: #c0392b; --warn: #c46a00; --ok: #1e7e4a; --radius: 8px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 { font-size: 15px; margin: 0 0 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
h3 { font-size: 14px; margin: 0 0 6px; }
code { background: #eef1f4; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.inline { display: inline; }
.pad { padding: 16px 20px; }

.brand { color: #fff; font-weight: 700; font-size: 17px; display: inline-flex; align-items: center; gap: 8px; }
.brand:hover { text-decoration: none; }
.brand .muted { color: rgba(255,255,255,.7); font-weight: 400; }
.brand-mark { background: #fff; color: var(--brand); border-radius: 6px; padding: 2px 6px; font-size: 13px; letter-spacing: .5px; }
.brand-lg { color: var(--brand); font-size: 22px; }
.brand-lg .brand-mark { background: var(--brand); color: #fff; }
.linklike { background: none; border: 0; font: inherit; cursor: pointer; }

/* ---------- App shell: left sidebar + content ---------- */
:root { --sidebar-w: 236px; --side-bg: #0b3d6b; --side-hover: rgba(255,255,255,.08); --side-active: rgba(255,255,255,.16); }
.shell { display: flex; min-height: 100vh; }
.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: var(--side-bg); color: #fff;
    display: flex; flex-direction: column; z-index: 40; overflow-y: auto;
}
.sidebar .brand { padding: 18px 18px 14px; border-bottom: 1px solid rgba(255,255,255,.1); }
.side-nav { flex: 1; padding: 10px 10px 16px; }
.nav-group { margin-top: 14px; }
.nav-group-title {
    font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase;
    color: rgba(255,255,255,.55); padding: 0 10px 6px;
}
.side-link {
    display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 6px;
    color: rgba(255,255,255,.88); font-weight: 500; font-size: 14.5px; margin-bottom: 2px;
}
.side-link svg { width: 18px; height: 18px; flex: 0 0 18px; opacity: .85; }
.side-link:hover { background: var(--side-hover); color: #fff; text-decoration: none; }
.side-link.active { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 #fff; }
.side-link.active svg { opacity: 1; }
.sidebar-user { border-top: 1px solid rgba(255,255,255,.1); padding: 12px 10px 14px; }
.sidebar-user .who { padding: 0 10px 8px; font-size: 13.5px; line-height: 1.35; }
.sidebar-user .who .muted { color: rgba(255,255,255,.6); font-size: 12px; display: block; overflow: hidden; text-overflow: ellipsis; }
.role-chip { font-size: 11px; background: rgba(255,255,255,.18); padding: 1px 7px; border-radius: 999px; margin-left: 4px; }
.sidebar-user form { margin: 0; }
.sidebar-user button.side-link { width: 100%; background: none; border: 0; font: inherit; cursor: pointer; text-align: left; }

.main-col { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }
.content { width: 100%; max-width: 1180px; padding: 26px 28px 24px; }
.footer { padding: 0 28px 24px; font-size: 12px; }

.mobile-bar { display: none; }
.sidebar-backdrop { display: none; }
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: 0 0 30px rgba(0,0,0,.25); }
    .menu-open .sidebar { transform: none; }
    .menu-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(15,23,32,.4); z-index: 30; }
    .main-col { margin-left: 0; }
    .mobile-bar {
        display: flex; align-items: center; gap: 12px; background: var(--side-bg); color: #fff;
        padding: 10px 16px; position: sticky; top: 0; z-index: 20;
    }
    .menu-toggle { background: none; border: 1px solid rgba(255,255,255,.4); color: #fff; font-size: 18px; border-radius: 6px; padding: 3px 10px; cursor: pointer; }
    .content { padding: 18px 16px; }
    .footer { padding: 0 16px 20px; }
}

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; }
.card.flush { padding: 0; overflow: hidden; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 { margin-bottom: 18px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 760px) { .grid-2, .row-2 { grid-template-columns: 1fr; } }

label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 12px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=search], textarea {
    display: block; width: 100%; margin-top: 4px; padding: 9px 10px; font: inherit; font-weight: 400;
    border: 1px solid #cfd6de; border-radius: 6px; background: #fff; color: var(--text);
}
input:focus, textarea:focus { outline: 2px solid rgba(11,79,138,.25); border-color: var(--brand); }
textarea { resize: vertical; }
.hint { display: block; font-weight: 400; color: var(--muted); font-size: 12px; margin-top: 4px; }
.hint.found { color: var(--ok); }
.req { color: var(--danger); }
.has-error input, .has-error textarea { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 12.5px; font-weight: 500; margin: 4px 0 8px; }
.from-block { line-height: 1.6; margin-bottom: 8px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 6px; border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none !important; white-space: nowrap; }
.btn-sm { padding: 6px 12px; font-size: 13.5px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--brand); color: #fff; }
.topbar .btn-primary { background: #fff; color: var(--brand); }
.btn-primary:hover { background: var(--brand-dark); }
.topbar .btn-primary:hover { background: #e9f0f7; }
.btn-secondary { background: #fff; color: var(--text); border-color: #cfd6de; }
.btn-secondary:hover { background: #f6f8fa; }
.btn-success { background: var(--ok); color: #fff; }
.btn-ghost-danger { background: #fff; color: var(--danger); border-color: #f0c9c4; }
.icon-btn { background: none; border: 0; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; padding: 4px 8px; border-radius: 4px; }
.icon-btn:hover { background: #fbeaea; color: var(--danger); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; justify-content: flex-end; border-top: 1px solid var(--line); }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); background: #f8fafb; }
.table th.num, .table td.num { text-align: right; }
.table tfoot td { border-bottom: 0; padding-top: 6px; padding-bottom: 6px; }
.table tr.grand td { font-weight: 700; font-size: 16px; border-top: 2px solid var(--brand); }
.table-scroll { overflow-x: auto; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #f6f9fc; }

.items-table { min-width: 640px; }
.items-table td { padding: 6px 8px; }
.items-table input { margin-top: 0; }
.col-qty { width: 90px; } .col-price { width: 150px; } .col-amt { width: 130px; } .col-x { width: 40px; }
#add-row { margin-top: 10px; }
.totals-wrap { display: flex; gap: 24px; margin-top: 20px; flex-wrap: wrap; }
.notes-col { flex: 1 1 300px; }
.totals { flex: 0 0 320px; border-collapse: collapse; align-self: flex-start; }
.totals th { text-align: left; font-weight: 500; padding: 6px 0; color: var(--muted); }
.totals td { padding: 6px 0; }
.totals .grand th, .totals .grand td { font-size: 18px; font-weight: 700; color: var(--text); border-top: 2px solid var(--brand); padding-top: 10px; }
.small-input { width: 120px !important; display: inline-block !important; margin: 0 !important; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eef1f4; color: var(--muted); vertical-align: middle; }
.badge-draft { background: #eef1f4; color: #52606d; }
.badge-queued, .badge-q-pending, .badge-q-sending, .badge-q-retry { background: #fff4de; color: var(--warn); }
.badge-sent, .badge-q-sent { background: #e3eefa; color: var(--brand); }
.badge-overdue, .badge-q-failed { background: #fbeaea; color: var(--danger); }
.badge-paid { background: #e3f4ea; color: var(--ok); }
.badge-cancelled { background: #eef1f4; color: #9aa5b1; text-decoration: line-through; }

.alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; border: 1px solid; }
.alert-success { background: #e9f6ee; border-color: #bfe3cc; color: #145c35; }
.alert-error { background: #fbeaea; border-color: #f0c9c4; color: #8c2a20; }
.alert-warning { background: #fff4de; border-color: #f2d7a6; color: #7a4600; }

.filters { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.filters input[type=search] { max-width: 280px; margin: 0; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab { padding: 6px 12px; border-radius: 6px; color: var(--muted); font-weight: 500; font-size: 14px; }
.tab.active { background: #fff; color: var(--brand); border: 1px solid var(--line); }
.tab:hover { text-decoration: none; background: #fff; }
.empty { padding: 40px; text-align: center; }

.dl { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; margin: 0; }
.dl dt { color: var(--muted); } .dl dd { margin: 0; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }

.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.login-card { width: 100%; max-width: 380px; }

/* Settings, users, account */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.settings-grid .wide { grid-column: 1 / -1; }
@media (max-width: 760px) { .settings-grid { grid-template-columns: 1fr; } }
input.short { max-width: 160px; }
label.check, label.radio { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; cursor: pointer; }
label.check input, label.radio input { margin-top: 4px; }
fieldset { border: 0; padding: 0; margin: 0 0 12px; }
legend { font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.card.narrow { max-width: 620px; }
.test-mail { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-top: 16px; }
.test-mail label { flex: 1 1 260px; margin: 0; }
.smtp-log { background: #0f1720; color: #d6e2ee; padding: 12px; border-radius: 6px; font-size: 12px; max-height: 320px; overflow: auto; white-space: pre-wrap; }
.text-danger { color: var(--danger); }
tr.inactive td { color: #9aa5b1; }
.role-list { list-style: none; padding: 0; margin: 0; }
.role-list li { padding: 6px 0; }
.badge-role-admin { background: #ede7fb; color: #5b3cc4; }
.badge-role-staff { background: #e3eefa; color: var(--brand); }
.badge-role-viewer { background: #eef1f4; color: #52606d; }

/* ---------- Sidebar badge ---------- */
.nav-badge { margin-left: auto; background: #f5a524; color: #1f2933; font-size: 11.5px; font-weight: 700; border-radius: 999px; padding: 1px 7px; min-width: 20px; text-align: center; }

/* ---------- Timesheets ---------- */
.badge-ts-draft { background: #eef1f4; color: #52606d; }
.badge-ts-submitted { background: #e3eefa; color: var(--brand); }
.badge-ts-changes_requested { background: #fff4de; color: var(--warn); }
.badge-ts-approved { background: #e3f4ea; color: var(--ok); }
.badge-role-hr { background: #fde8f1; color: #a3195b; }
.badge-role-employee { background: #e8f6f6; color: #0f6b6b; }
.btn-warning { background: var(--warn); color: #fff; }
.btn-warning:hover { background: #a55900; }
.alert-info { background: #eaf2fb; border-color: #c4dbf2; color: #0b3d6b; }

.this-week { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.week-title { font-size: 20px; font-weight: 700; }
.this-week-stat { display: flex; align-items: center; gap: 14px; }
.big-hours { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ts-total-box { text-align: right; }
.week-nav { display: flex; gap: 6px; flex-wrap: wrap; }
.ts-toolbar { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.ts-help { margin: 8px 0 14px; }
.review-callout div { margin-top: 4px; }

.ts-grid { min-width: 980px; }
.ts-grid th, .ts-grid td { padding: 6px 6px; }
.ts-grid th.col-day { width: 64px; line-height: 1.2; }
.ts-grid th.col-day span { display: block; font-weight: 400; text-transform: none; letter-spacing: 0; font-size: 11px; }
.ts-grid th.today { color: var(--brand); box-shadow: inset 0 -2px 0 var(--brand); }
.ts-grid .weekend { background: #fafbfc; }
.ts-grid .col-project { width: 190px; } .ts-grid .col-cat { width: 120px; } .ts-grid .col-total { width: 64px; }
.ts-grid input, .ts-grid select { margin: 0; padding: 7px 8px; }
.ts-grid select { width: 100%; font: inherit; border: 1px solid #cfd6de; border-radius: 6px; background: #fff; }
.ts-grid input.hrs { text-align: right; padding: 7px 6px; }
.ts-grid input.invalid { border-color: var(--danger); background: #fdf1f0; }
.ts-grid .day-total.over { color: var(--danger); }
.ts-grid tfoot td { font-weight: 700; }
.ts-readonly td { padding: 9px 8px; }
.sticky-total { margin-right: auto; }
.cat { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: #eef1f4; white-space: nowrap; }
.cat-overtime { background: #fff4de; color: var(--warn); }
.cat-pto, .cat-holiday { background: #e3f4ea; color: var(--ok); }
.cat-sick { background: #fbeaea; color: var(--danger); }
.cat-summary { padding: 10px 14px; margin: 0; display: flex; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--line); }
.timeline .comment { background: #f6f8fa; border-left: 3px solid var(--line); padding: 6px 10px; margin: 6px 0 2px; white-space: normal; }
.ts-tabs { margin-bottom: 12px; }
.tab .count { background: #f5a524; color: #1f2933; border-radius: 999px; font-size: 11px; padding: 0 6px; margin-left: 2px; }
.filter-bar { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; padding: 14px 16px; }
.filter-bar label { margin: 0; }
.filter-bar select, .filter-bar input { display: block; margin-top: 4px; padding: 7px 8px; font: inherit; border: 1px solid #cfd6de; border-radius: 6px; background: #fff; }
.review-actions .card { margin-bottom: 0; }
details.reopen summary { cursor: pointer; font-weight: 600; color: var(--warn); }
details.reopen form { margin-top: 12px; }

/* ---------- User approvals ---------- */
.badge-role-office_manager { background: #fff1e0; color: #9a5300; }
.pending-card { border-color: #f2d7a6; background: #fffaf1; }
.pending-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 0; border-top: 1px solid #f2e3c4; }
.pending-row:first-of-type { border-top: 0; }
.pending-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.reject-form { display: inline-flex; gap: 6px; }
.reject-form input { margin: 0; padding: 6px 8px; width: 200px; }
.count-pill { background: #f5a524; color: #1f2933; border-radius: 999px; font-size: 12px; padding: 0 8px; margin-left: 4px; }
.narrow-alert { max-width: 620px; }
.link-btn { color: var(--brand); padding: 0; }
.link-btn:hover { text-decoration: underline; }
.nowrap { white-space: nowrap; }
.badge { white-space: nowrap; }
.role-cell .badge { margin: 1px 0; }
.sidebar-user .role-chip { display: inline-block; margin-top: 2px; }

/* ---------- Apps & health ---------- */
.nav-badge-danger { background: #e5484d; color: #fff; }
.stat-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
@media (max-width: 700px) { .stat-tiles { grid-template-columns: repeat(2, 1fr); } }
.stat-tiles.five { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 900px) { .stat-tiles.five { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 700px) { .stat-tiles.five { grid-template-columns: repeat(2, 1fr); } }
.stat-tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; color: var(--text); }
a.stat-tile:hover { text-decoration: none; border-color: #c9d3dd; }
.stat-tile.active { box-shadow: inset 0 0 0 2px var(--brand); }
.stat-n { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-l { color: var(--muted); font-size: 13px; }
.stat-up .stat-n { color: var(--ok); } .stat-degraded .stat-n { color: var(--warn); } .stat-down .stat-n { color: var(--danger); }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 2px 10px 2px 8px; border-radius: 999px; white-space: nowrap; background: #eef1f4; color: #52606d; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill-up { background: #e3f4ea; color: var(--ok); }
.pill-degraded { background: #fff4de; color: var(--warn); }
.pill-down { background: #fbeaea; color: var(--danger); }
.pill-down .dot { animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .pill-down .dot { animation: none; } }
.bars { display: inline-flex; gap: 2px; align-items: flex-end; height: 22px; }
.bar { width: 5px; height: 100%; border-radius: 2px; background: #e3e8ee; }
.bar-up { background: #3fae6c; } .bar-degraded { background: #f0a43a; } .bar-down { background: #e5484d; } .bar-none { background: #edf0f3; }
.apps-table td { vertical-align: top; }
.apps-table .msg { max-width: 260px; margin-top: 4px; }
.apps-table tbody tr:nth-child(even) td { background: #f1f4f8; }
.apps-table tbody tr.clickable:hover td { background: #e3edf7; }
.apps-table .order-col { width: 1%; white-space: nowrap; cursor: default; }
.order-btn { border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 6px; width: 28px; height: 26px; padding: 0; font-size: 11px; line-height: 1; cursor: pointer; }
.order-btn:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.order-btn:disabled { opacity: .3; cursor: default; }
.order-col form + form { margin-left: 4px; }
.tag { display: inline-block; font-size: 11.5px; background: #eef1f4; color: #52606d; border-radius: 4px; padding: 0 6px; margin-left: 6px; vertical-align: 1px; }
.text-warn { color: var(--warn); font-weight: 600; }
.small-check { display: inline-flex; gap: 6px; align-items: center; margin: 0; font-weight: 500; }
.lead { font-size: 15.5px; margin: -6px 0 16px; color: #3e4c59; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
