:root {
  --navy: #1f3a5f; --navy-700: #16304f; --navy-100: #e6edf5;
  --teal: #0f8b8d; --teal-100: #e0f3f3;
  --amber: #c77d0a; --amber-100: #fdf1dc;
  --red: #b42318; --red-100: #fde8e6;
  --green: #1a7f37; --green-100: #e3f5e8;
  --ink: #1c2430; --ink-2: #4b5563; --ink-3: #6b7280; --line: #e5e7eb; --line-2: #d1d5db;
  --bg: #f4f6f9; --card: #ffffff;
  --radius: 10px; --radius-sm: 6px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, Consolas, "SF Mono", Menlo, monospace;
  --sidebar-w: 240px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 14px; line-height: 1.45; }
a { color: var(--navy); text-decoration: none; } a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 10px; font-weight: 650; }
h3 { font-size: 14px; margin: 0 0 8px; font-weight: 650; color: var(--ink-2); }
p { margin: 0 0 8px; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
code { font-family: var(--mono); font-size: 12.5px; background: var(--navy-100); padding: 1px 5px; border-radius: 4px; }

#app { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--navy); color: #fff; display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; z-index: 30; transition: transform .2s; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; }
.brand-mark { width: 34px; height: 34px; border-radius: 8px; background: #fff; color: var(--navy); display: grid; place-items: center; font-weight: 800; font-size: 18px; }
.brand-name { font-weight: 700; font-size: 15px; } .brand-sub { font-size: 12px; opacity: .7; }
.nav { padding: 6px 10px; flex: 1; overflow-y: auto; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: rgba(255,255,255,.85); font-weight: 500; font-size: 13.5px; }
.nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.nav a.active { background: rgba(255,255,255,.16); color: #fff; }
.nav .nav-sep { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; opacity: .55; padding: 12px 12px 4px; }
.nav .ico { width: 20px; text-align: center; opacity: .9; }
.nav .pill { margin-left: auto; background: var(--amber); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 10px; }
.sidebar-foot { padding: 10px; border-top: 1px solid rgba(255,255,255,.12); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; }
.user-chip .avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--teal); display: grid; place-items: center; font-weight: 700; flex-shrink: 0; }
.user-chip .who { flex: 1; min-width: 0; } .user-chip .who b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .user-chip .who span { font-size: 11.5px; opacity: .75; }
.user-chip button { background: transparent; border: 1px solid rgba(255,255,255,.3); color: #fff; border-radius: 6px; padding: 4px 8px; cursor: pointer; font-size: 12px; }
.timer-widget { background: rgba(255,255,255,.1); border-radius: 8px; padding: 10px; margin-bottom: 8px; font-size: 12.5px; }
.timer-widget .t-time { font-family: var(--mono); font-size: 20px; font-weight: 600; }
.timer-widget .t-client { opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timer-widget .t-actions { display: flex; gap: 6px; margin-top: 6px; }
.timer-widget button { background: #fff; color: var(--navy); border: 0; border-radius: 6px; padding: 4px 10px; font-weight: 600; cursor: pointer; font-size: 12px; }
.timer-widget.running .t-time::before { content: "●"; color: #6ee7b7; margin-right: 6px; animation: blink 1.2s infinite; font-size: 12px; vertical-align: middle; }
@keyframes blink { 50% { opacity: .25; } }

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(244,246,249,.92); backdrop-filter: blur(6px); display: flex; align-items: center; gap: 12px; padding: 10px 24px; border-bottom: 1px solid var(--line); }
.search { flex: 1; max-width: 520px; } .search input { width: 100%; padding: 8px 12px; border: 1px solid var(--line-2); border-radius: 8px; background: #fff; }
.topbar-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.icon-btn { background: transparent; border: 0; cursor: pointer; font-size: 18px; padding: 6px; border-radius: 8px; position: relative; color: var(--ink); }
.icon-btn:hover { background: var(--navy-100); text-decoration: none; }
.menu-btn { display: none; }
.badge-count { position: absolute; top: 0; right: 0; background: var(--red); color: #fff; font-size: 10px; font-weight: 700; min-width: 16px; height: 16px; border-radius: 8px; display: grid; place-items: center; padding: 0 4px; }
.view { padding: 22px 24px 60px; max-width: 1400px; width: 100%; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .sub { color: var(--ink-3); margin-top: 2px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line-2); background: #fff; cursor: pointer; font-weight: 550; font-size: 13.5px; line-height: 1.2; }
.btn:hover { background: var(--navy-100); text-decoration: none; }
.btn.primary { background: var(--navy); color: #fff; border-color: var(--navy); } .btn.primary:hover { background: var(--navy-700); }
.btn.teal { background: var(--teal); color: #fff; border-color: var(--teal); }
.btn.danger { color: var(--red); border-color: #f3b4ae; } .btn.danger:hover { background: var(--red-100); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.card.flush { padding: 0; overflow: hidden; }
.card .card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card.flush .card-head { padding: 14px 18px 0; }
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat .label { color: var(--ink-3); font-size: 12.5px; }
.stat .value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.stat .value small { font-size: 13px; color: var(--ink-3); font-weight: 500; margin-left: 4px; }
.stat .hint { font-size: 12px; color: var(--ink-3); }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th, .tbl td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); font-weight: 600; background: #fafbfc; white-space: nowrap; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: #f8fafc; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .muted { color: var(--ink-3); }
.tbl-wrap { overflow-x: auto; }
.tbl tr.clickable { cursor: pointer; }
.tbl tfoot td { font-weight: 650; background: #fafbfc; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11.5px; font-weight: 600; background: var(--navy-100); color: var(--navy); white-space: nowrap; }
.badge.green { background: var(--green-100); color: var(--green); } .badge.amber { background: var(--amber-100); color: var(--amber); }
.badge.red { background: var(--red-100); color: var(--red); } .badge.teal { background: var(--teal-100); color: var(--teal); } .badge.gray { background: #eef0f3; color: var(--ink-3); }

.form { display: grid; gap: 12px; }
.form.cols-2 { grid-template-columns: 1fr 1fr; } .form .span-2 { grid-column: span 2; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field input, .field select, .field textarea { padding: 8px 10px; border: 1px solid var(--line-2); border-radius: 8px; background: #fff; width: 100%; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid rgba(31,58,95,.25); border-color: var(--navy); }
.field .help { font-size: 12px; color: var(--ink-3); }
.field.inline { flex-direction: row; align-items: center; gap: 8px; } .field.inline input { width: auto; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 14px; }
.filters .field { min-width: 150px; } .filters .field input, .filters .field select { padding: 6px 9px; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(17,24,39,.45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 12px; width: min(680px, 100%); max-height: 92vh; overflow: auto; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.wide { width: min(1000px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 18px 20px; } .modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
.toast-root { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); font-size: 13px; max-width: 360px; animation: slidein .2s; }
.toast.error { background: var(--red); } .toast.success { background: var(--green); }
@keyframes slidein { from { transform: translateY(8px); opacity: 0; } }

.empty { color: var(--ink-3); padding: 24px; text-align: center; }
.notice { border-left: 4px solid var(--amber); background: var(--amber-100); padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; }
.notice.info { border-color: var(--teal); background: var(--teal-100); } .notice.danger { border-color: var(--red); background: var(--red-100); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 8px 14px; border-bottom: 2px solid transparent; color: var(--ink-2); font-weight: 550; white-space: nowrap; }
.tabs a.active { color: var(--navy); border-color: var(--navy); } .tabs a:hover { text-decoration: none; }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 6px 12px; font-size: 13.5px; } .kv dt { color: var(--ink-3); } .kv dd { margin: 0; }
.progress { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; } .progress > span { display: block; height: 100%; background: var(--teal); }
.list { list-style: none; margin: 0; padding: 0; } .list li { padding: 9px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: center; } .list li:last-child { border: 0; }
.timeline { list-style: none; padding: 0 0 0 18px; margin: 0; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 14px 14px; } .timeline li::before { content: ""; position: absolute; left: -24px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--teal); border: 2px solid #fff; }
.timeline li.future::before { background: var(--amber); } .timeline li.past::before { background: var(--ink-3); }
.timeline .when { font-size: 12px; color: var(--ink-3); }

/* timesheet grid */
.ts-grid { width: 100%; border-collapse: collapse; font-size: 13px; }
.ts-grid th, .ts-grid td { border-bottom: 1px solid var(--line); padding: 6px 6px; }
.ts-grid th { font-size: 12px; color: var(--ink-3); text-align: center; font-weight: 600; } .ts-grid th:first-child { text-align: left; }
.ts-grid th.today { color: var(--teal); }
.ts-grid td.row-label { min-width: 240px; } .ts-grid td.row-label .sub { font-size: 12px; color: var(--ink-3); }
.ts-grid td.cell { text-align: center; width: 76px; }
.ts-grid td.cell input { width: 64px; text-align: center; padding: 6px 4px; border: 1px solid var(--line-2); border-radius: 6px; font-variant-numeric: tabular-nums; }
.ts-grid td.cell input:disabled { background: #f3f4f6; border-color: transparent; color: var(--ink-2); }
.ts-grid td.cell.locked input { background: var(--green-100); color: var(--green); font-weight: 600; }
.ts-grid td.cell.submitted input { background: var(--amber-100); color: var(--amber); }
.ts-grid td.cell.rejected input { border-color: var(--red); }
.ts-grid td.cell.dirty input { border-color: var(--teal); box-shadow: inset 0 0 0 1px var(--teal); }
.ts-grid td.total, .ts-grid tfoot td { font-weight: 650; text-align: center; font-variant-numeric: tabular-nums; }
.ts-grid td.cell small { display: block; font-size: 10px; color: var(--ink-3); }
.week-nav { display: flex; align-items: center; gap: 8px; }
.week-nav b { min-width: 230px; text-align: center; }

/* org chart */
.org { overflow-x: auto; padding: 10px 0; }
.org ul { list-style: none; padding-left: 26px; margin: 0; border-left: 2px dashed var(--line-2); }
.org > ul { border: 0; padding-left: 0; }
.org li { margin: 6px 0; }
.org .node { display: inline-flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; box-shadow: var(--shadow); }
.org .node .avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.org .node b { display: block; font-size: 13px; } .org .node span { font-size: 12px; color: var(--ink-3); }
.org .node .cnt { margin-left: 6px; }

/* people cards */
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.person { display: flex; gap: 12px; align-items: center; padding: 12px 14px; }
.person .avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--navy-100); color: var(--navy); display: grid; place-items: center; font-weight: 700; flex-shrink: 0; }
.person b { display: block; } .person .meta { font-size: 12.5px; color: var(--ink-3); }

.login-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, var(--navy) 0%, #0f8b8d 100%); padding: 20px; }
.login { background: #fff; border-radius: 14px; padding: 32px; width: min(420px, 100%); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.login .brand { padding: 0 0 18px; color: var(--ink); } .login .brand-mark { background: var(--navy); color: #fff; }
.bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--line); } .bar span { display: block; height: 100%; }
.bar .a { background: var(--teal); } .bar .b { background: var(--amber); } .bar .c { background: var(--navy); }
.mini-cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; font-size: 12px; text-align: center; }
.mini-cal .d { padding: 6px 2px; border-radius: 6px; background: #f8fafc; } .mini-cal .d.off { background: var(--amber-100); color: var(--amber); font-weight: 600; } .mini-cal .d.hol { background: var(--teal-100); }
.diff-add { color: var(--green); } .diff-rem { color: var(--red); } .diff-chg { color: var(--amber); }
pre.json { font-family: var(--mono); font-size: 12px; background: #f8fafc; border: 1px solid var(--line); padding: 10px; border-radius: 6px; overflow: auto; max-height: 300px; margin: 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.right { text-align: right; } .muted { color: var(--ink-3); } .small { font-size: 12.5px; } .mt { margin-top: 14px; } .mb { margin-bottom: 14px; }
.flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; } .between { justify-content: space-between; }
.counter { font-size: 32px; font-weight: 750; letter-spacing: -.02em; transition: color .2s; } .counter.neg { color: var(--red); }

@media (max-width: 1100px) { .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); } .sidebar.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.4); }
  .main { margin-left: 0; } .menu-btn { display: inline-flex; }
  .view { padding: 14px; } .topbar { padding: 8px 12px; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .form.cols-2 { grid-template-columns: 1fr; } .form .span-2 { grid-column: auto; }
  .kv { grid-template-columns: 1fr; } .week-nav b { min-width: 0; }
  .ts-grid td.row-label { min-width: 160px; }
}
@media print { .sidebar, .topbar, .actions, .filters { display: none !important; } .main { margin: 0; } .card { box-shadow: none; } }
#app.auth .main { margin-left: 0; } #app.auth .view { padding: 0; max-width: none; }
