:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --ink: #1c2533;
  --ink-2: #5b6678;
  --ink-3: #8a94a6;
  --line: #e3e7ee;
  --line-2: #eef1f5;
  --nav: #16243a;
  --nav-2: #22344f;
  --accent: #2563eb;
  --danger: #dc2626;
  --ok: #16a34a;
  --acs: #2563eb;
  --hra: #eab308;
  --bbs: #db2777;
  --billing: #ec4899;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
body { overflow: hidden; }
#root { height: 100%; }
.boot { display: grid; place-items: center; height: 100%; color: var(--ink-3); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3, h4 { margin: 0; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }

/* ── buttons & inputs ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff;
  padding: 7px 12px; border-radius: 8px; cursor: pointer; font-weight: 500; white-space: nowrap;
}
.btn:hover { background: #f7f9fc; border-color: #cfd6e1; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #1d4fd7; }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.small { padding: 4px 9px; font-size: 13px; border-radius: 7px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: rgba(0,0,0,.05); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { border: none; background: none; cursor: pointer; padding: 3px 5px; border-radius: 6px; color: var(--ink-2); }
.icon-btn:hover { background: var(--line-2); color: var(--ink); }

input[type=text], input[type=password], input[type=email], input[type=tel], input[type=number],
input[type=date], input[type=time], input[type=search], select, textarea {
  border: 1px solid #d5dbe5; border-radius: 8px; padding: 7px 10px; background: #fff; width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(37, 99, 235, .25); border-color: var(--accent); }
textarea { min-height: 80px; resize: vertical; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-2); font-weight: 600; }
label.field > span { text-transform: uppercase; letter-spacing: .03em; font-size: 11px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 14px; }
.span2 { grid-column: span 2; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.grow { flex: 1; }
.ta-right { text-align: right; }
.nowrap { white-space: nowrap; }

/* toggle switch */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-weight: 500; }
.switch input { display: none; }
.switch .track { width: 36px; height: 20px; border-radius: 20px; background: #cfd6e1; position: relative; transition: .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; background: #fff; top: 2px; left: 2px; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + .track { background: var(--ok); }
.switch input:checked + .track::after { left: 18px; }

/* ── login ── */
.auth-wrap { display: grid; place-items: center; height: 100%; background: linear-gradient(160deg, #16243a, #2b4a74); }
.auth-card { background: #fff; padding: 32px; border-radius: 14px; width: 380px; max-width: 92vw; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.auth-card h1 { margin-bottom: 4px; }
.auth-card .stack { margin-top: 18px; }
.code-input { font-size: 26px !important; letter-spacing: 10px; text-align: center; font-weight: 600; }
.error-text { color: var(--danger); font-size: 13px; min-height: 18px; }

/* ── shell ── */
.shell { display: flex; height: 100%; }
.sidebar { width: 210px; flex: none; background: var(--nav); color: #cdd6e4; display: flex; flex-direction: column; padding: 14px 10px; }
.brand { color: #fff; font-weight: 700; font-size: 16px; padding: 6px 10px 18px; display: flex; gap: 9px; align-items: center; }
.brand .logo { width: 26px; height: 26px; border-radius: 7px; background: #2b4a74; display: grid; place-items: center; font-size: 13px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: #cdd6e4; text-decoration: none; font-weight: 500; margin-bottom: 2px; }
.nav-item:hover { background: var(--nav-2); color: #fff; }
.nav-item.active { background: #2f4a70; color: #fff; }
.nav-item .dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.nav-item .ico { width: 18px; text-align: center; flex: none; opacity: .9; }
.nav-sep { height: 1px; background: #2a3c58; margin: 10px 6px; }
.sidebar .me { margin-top: auto; padding: 10px; border-top: 1px solid #2a3c58; font-size: 13px; }
.sidebar .me b { color: #fff; display: block; }
.sidebar .me .role { color: #8fa1bd; font-size: 12px; }
.sidebar .me .btn { margin-top: 8px; width: 100%; justify-content: center; background: transparent; color: #cdd6e4; border-color: #3a506f; }
.clock-pill { margin: 8px 6px 0; padding: 8px 10px; border-radius: 8px; background: #123a2a; color: #7ee2a8; font-size: 12px; font-weight: 600; display: none; }
.clock-pill.on { display: block; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.tabstrip { display: flex; gap: 4px; padding: 8px 12px 0; background: #e9edf3; border-bottom: 1px solid var(--line); overflow-x: auto; flex: none; min-height: 8px; }
.tabstrip:empty { display: none; }
.ctab { display: flex; align-items: center; gap: 6px; padding: 7px 8px 7px 12px; border-radius: 8px 8px 0 0; background: #dde3ec; color: var(--ink-2); cursor: pointer; white-space: nowrap; max-width: 220px; border: 1px solid transparent; border-bottom: none; }
.ctab span { overflow: hidden; text-overflow: ellipsis; }
.ctab.active { background: var(--bg); color: var(--ink); font-weight: 600; border-color: var(--line); }
.ctab .x { border: none; background: none; cursor: pointer; color: var(--ink-3); border-radius: 4px; padding: 0 4px; font-size: 15px; line-height: 1; }
.ctab .x:hover { background: rgba(0,0,0,.08); color: var(--ink); }
.view { flex: 1; overflow: auto; padding: 22px 26px; min-height: 0; }
.view.split-host { padding: 0; overflow: hidden; display: flex; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 16px 18px; }
.card + .card { margin-top: 14px; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 700; margin: 16px 0 8px; }

/* ── client split view ── */
.split { display: flex; flex: 1; min-height: 0; }
.pane { overflow-y: auto; min-height: 0; padding: 20px; }
.pane.left { width: 380px; flex: none; border-right: 1px solid var(--line); background: #fff; }
.pane.right { flex: 1; }
.client-name { font-size: 22px; font-weight: 700; line-height: 1.2; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 10px; margin-top: 14px; align-items: baseline; }
.kv .k { color: var(--ink-3); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; font-weight: 600; }
.kv .v { word-break: break-word; }
.notes { white-space: pre-wrap; background: #fbfbf4; border: 1px solid #efedd9; border-radius: 8px; padding: 10px; min-height: 40px; }
.balance-badge { display: inline-block; padding: 4px 10px; border-radius: 20px; font-weight: 700; font-size: 13px; background: #e8f6ee; color: #146c37; }
.balance-badge.owes { background: #fdecec; color: #b42318; }

.link-row { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; background: #fafbfd; }
.link-row a { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; font-weight: 500; }
.link-row .path { color: var(--ink-3); font-size: 11px; display: block; overflow: hidden; text-overflow: ellipsis; }
.links-editor .le-row { display: grid; grid-template-columns: 1fr 2fr auto; gap: 6px; margin-bottom: 6px; }

.add-svc { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.add-svc .btn { color: #fff; border: none; }

/* ── service cards ── */
.svc { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; overflow: hidden; }
.svc.flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 4px rgba(37,99,235,.5); } 100% { box-shadow: var(--shadow); } }
.svc-status-bar { height: 7px; display: flex; }
.svc-status-bar > div { flex: 1; }
.svc-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; flex-wrap: wrap; }
.svc-head .type { font-weight: 800; letter-spacing: .04em; font-size: 15px; }
.svc-head .sub { opacity: .9; font-weight: 500; }
.svc-head .spacer { flex: 1; }
.svc-body { padding: 14px; border-top: 1px solid var(--line-2); }
.svc-foot { display: flex; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line-2); background: #fafbfd; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; color: #fff; white-space: nowrap; }
.pill.light { background: rgba(255,255,255,.9) !important; color: var(--ink); }
.pill .pdot { width: 8px; height: 8px; border-radius: 50%; }
.urgent { background: #dc2626; color: #fff; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 800; letter-spacing: .05em; }
.urgent-toggle { cursor: pointer; border: 1px dashed rgba(0,0,0,.25); background: rgba(255,255,255,.6); padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; color: #555; }
.urgent-toggle.on { background: #dc2626; color: #fff; border: 1px solid #dc2626; }
.svc-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px 18px; }
.cred { display: flex; align-items: center; gap: 4px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.cred .val { background: #f2f4f8; padding: 3px 7px; border-radius: 6px; min-width: 40px; }
.fieldv .k { color: var(--ink-3); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; margin-bottom: 3px; }
.money-row { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; padding: 10px 12px; background: #f7f9fc; border-radius: 8px; margin-top: 14px; }
.money-row .m { display: flex; flex-direction: column; }
.money-row .m b { font-size: 16px; }
.money-row .m span { font-size: 11px; color: var(--ink-3); text-transform: uppercase; font-weight: 700; letter-spacing: .04em; }
.owes { color: #b42318; }
.paid-up { color: #146c37; }

.program { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 12px; overflow: hidden; }
.program-head { display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: #fdf8e6; }
.program-head h4 { flex: 1; font-size: 14px; }
.program-body { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.checklist { display: flex; flex-direction: column; gap: 4px; }
.check { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 6px; cursor: pointer; }
.check:hover { background: #f4f6f9; }
.check input { width: 17px; height: 17px; accent-color: var(--ok); }
.check.done span { color: var(--ink-3); text-decoration: line-through; }
.progress { height: 6px; background: #edf0f5; border-radius: 6px; overflow: hidden; }
.progress > div { height: 100%; background: var(--ok); }
.appt-grid { display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; align-items: center; }

.months { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.month { padding: 12px 4px; border-radius: 8px; border: none; cursor: pointer; font-weight: 700; background: #e5e8ee; color: #6b7280; }
.month.on { background: #22c55e; color: #fff; }
.month:disabled { cursor: default; }

table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); padding: 8px 10px; border-bottom: 1px solid var(--line); background: #fafbfd; position: sticky; top: 0; white-space: nowrap; }
table.t th.sortable { cursor: pointer; user-select: none; }
table.t th.sortable:hover { color: var(--ink); }
table.t td { padding: 9px 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: #f5f8ff; }
table.t.compact td { padding: 6px 8px; }
.empty { padding: 40px; text-align: center; color: var(--ink-3); }

.svc-dots { display: flex; gap: 4px; flex-wrap: wrap; }
.svc-dot { font-size: 10px; font-weight: 800; padding: 2px 6px; border-radius: 5px; color: #fff; letter-spacing: .03em; }

/* ── search ── */
.search-hero { max-width: 720px; margin: 8vh auto 0; text-align: center; }
.search-hero h1 { font-size: 28px; margin-bottom: 22px; color: var(--ink); font-weight: 700; }
.oval { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid #dfe3ea; border-radius: 999px; padding: 6px 8px 6px 22px; box-shadow: 0 2px 10px rgba(16,24,40,.08); }
.oval:focus-within { box-shadow: 0 4px 18px rgba(37,99,235,.18); border-color: #b9cbf5; }
.oval input { border: none !important; outline: none !important; font-size: 18px; padding: 10px 0; background: transparent; }
.oval .mag { font-size: 18px; color: var(--ink-3); }
.results { max-width: 720px; margin: 22px auto; text-align: left; }
.result { display: flex; gap: 14px; align-items: center; padding: 14px 16px; background: #fff; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; cursor: pointer; }
.result:hover { border-color: #b9cbf5; background: #fafcff; }
.result .nm { font-weight: 700; font-size: 15px; }
.match { font-size: 11px; background: #eef3ff; color: #2952c8; padding: 2px 8px; border-radius: 20px; font-weight: 600; }

/* ── filters ── */
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.filters input[type=search] { width: 240px; }
.filters select { width: auto; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 5px 11px; cursor: pointer; font-size: 12px; font-weight: 600; display: inline-flex; gap: 6px; align-items: center; }
.chip .pdot { width: 8px; height: 8px; border-radius: 50%; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip .count { opacity: .7; font-weight: 500; }

/* ── modal ── */
.modal-back { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { background: #fff; border-radius: 14px; width: 560px; max-width: 100%; max-height: calc(100vh - 40px); display: flex; flex-direction: column; box-shadow: 0 25px 60px rgba(0,0,0,.3); }
.modal.wide { width: 820px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }

#toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: #1c2533; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: 380px; }
.toast.err { background: #b42318; }

/* ── timesheet ── */
.clock-card { display: flex; align-items: center; gap: 18px; padding: 18px; }
.clock-big { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.total-big { font-size: 22px; font-weight: 700; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button { border: none; background: none; padding: 10px 14px; cursor: pointer; font-weight: 600; color: var(--ink-2); border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }
.batch { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 8px; background: #fafbfd; }
.tag { font-size: 11px; padding: 2px 7px; border-radius: 5px; background: #eef1f5; color: var(--ink-2); font-weight: 600; }
.tag.blue { background: #e8efff; color: #2952c8; }

.list-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 14px; align-items: start; }
.list-grid > .card { margin-top: 0; }
.list-editor .li { display: grid; grid-template-columns: auto 1fr auto auto auto; gap: 6px; align-items: center; margin-bottom: 6px; }
.list-editor input[type=color] { width: 34px; height: 32px; border: 1px solid #d5dbe5; border-radius: 6px; padding: 2px; background: #fff; }
.perm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; }
.perm-grid label { display: flex; gap: 8px; align-items: center; padding: 4px 0; }

@media (max-width: 900px) {
  .sidebar { width: 64px; }
  .sidebar .label, .brand .label, .sidebar .me { display: none; }
  .pane.left { width: 300px; }
}
