:root {
  --navy: #16304d; --deep: #0f2238; --darkest: #0a1828; --red: #8e2a2a; --red-2: #a33a36; --red-soft: #f6e7e5;
  --ink: #142030; --ink-2: #3d4652; --muted: #6b7480; --line: #e3e7ec; --line-2: #eef1f4;
  --bg: #f5f6f8; --card: #ffffff; --blue-soft: #e8eef5; --green: #2f7d4f; --green-soft: #e5f2ea;
  --amber: #a26a00; --amber-soft: #fbf1dc; --radius: 14px; --shadow: 0 1px 2px rgba(16,32,48,.06), 0 4px 16px -6px rgba(16,32,48,.08);
  --side: 236px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 Inter, system-ui, -apple-system, sans-serif; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--navy); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font: 600 26px/1.15 "Source Serif 4", Georgia, serif; color: var(--deep); }
h2 { font: 600 18px/1.25 "Source Serif 4", Georgia, serif; color: var(--deep); }
h3 { font-size: 13px; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: .06em; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.hide { display: none !important; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(80% 60% at 10% 0%, rgba(58,95,138,.45), transparent 70%), radial-gradient(60% 50% at 100% 100%, rgba(142,42,42,.35), transparent 70%), linear-gradient(160deg, var(--deep), var(--darkest)); }
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: 18px; padding: 32px; box-shadow: 0 30px 60px -20px rgba(0,0,0,.5); }
.login-card .brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.login-card .brand img { width: 44px; height: 44px; }
.login-card .brand b { display: block; font: 600 17px "Source Serif 4", Georgia, serif; color: var(--deep); }
.login-card .brand span { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--red); font-weight: 600; }
.login-card p { color: var(--ink-2); margin: 6px 0 20px; }
.code-input { font-size: 28px !important; letter-spacing: 10px; text-align: center; font-weight: 600; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side { background: linear-gradient(180deg, var(--deep), var(--darkest)); color: #fff; padding: 18px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.side .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; text-decoration: none; color: #fff; }
.side .brand img { width: 34px; height: 34px; }
.side .brand b { font: 600 14.5px/1.2 "Source Serif 4", Georgia, serif; display: block; }
.side .brand span { font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase; color: #e8a39b; font-weight: 600; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 10px; color: #c9d4e1; text-decoration: none; font-weight: 500; }
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.on { background: rgba(255,255,255,.1); color: #fff; box-shadow: inset 3px 0 0 #c4504a; }
.nav .sep { height: 1px; background: rgba(255,255,255,.08); margin: 10px 6px; }
.side .me { margin-top: auto; padding: 12px 10px 4px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12.5px; color: #b9c6d5; }
.side .me b { color: #fff; display: block; font-size: 13px; }
.side .me button { background: none; border: 0; color: #e8a39b; padding: 0; cursor: pointer; font-size: 12px; margin-top: 4px; }
.main { min-width: 0; padding: 26px 32px 60px; }
.topbar { display: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.crumb { font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.crumb a { color: var(--muted); text-decoration: none; }
.crumb a:hover { color: var(--navy); }

/* ---------- building blocks ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; min-width: 0; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.stack > * + * { margin-top: 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .l { font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi .v { font: 600 24px/1.2 Inter, sans-serif; color: var(--deep); margin-top: 4px; letter-spacing: -.01em; }
.kpi .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi.accent { background: linear-gradient(150deg, var(--navy), var(--deep)); border-color: transparent; }
.kpi.accent .l, .kpi.accent .s { color: #b9c6d5; } .kpi.accent .v { color: #fff; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--ink); font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; font-size: 13.5px; }
.btn:hover { border-color: #c9d0d9; background: #fafbfc; }
.btn.primary { background: var(--red-2); border-color: var(--red-2); color: #fff; }
.btn.primary:hover { background: #b8423c; }
.btn.navy { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--line-2); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn.danger { color: var(--red); }
.btn svg { width: 16px; height: 16px; }
.btn[disabled] { opacity: .5; cursor: default; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.red { background: var(--red-soft); color: var(--red); }
.pill.amber { background: var(--amber-soft); color: var(--amber); }
.pill.blue { background: var(--blue-soft); color: var(--navy); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 9px 12px; color: var(--muted); text-decoration: none; font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); }
.tabs a.on { color: var(--deep); border-bottom-color: var(--red-2); }

table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.t td { padding: 10px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.t tr:last-child td { border-bottom: 0; }
.t tr.click { cursor: pointer; }
.t tr.click:hover td { background: #fafbfc; }
.t td.num, .t th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }

.bar { height: 8px; border-radius: 99px; background: var(--line-2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--navy); }
.bar.red > i { background: var(--red-2); }
.bar.green > i { background: var(--green); }

.list-row { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .title { font-weight: 600; }
.date-chip { flex: none; width: 46px; text-align: center; border: 1px solid var(--line); border-radius: 10px; padding: 4px 0; line-height: 1.1; }
.date-chip b { display: block; font-size: 16px; color: var(--deep); }
.date-chip span { font-size: 10px; text-transform: uppercase; color: var(--red); font-weight: 700; letter-spacing: .05em; }

.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }
.empty .btn { margin-top: 12px; }

.insight { border-radius: 12px; padding: 14px 16px; border: 1px solid var(--line); background: #fff; border-left: 4px solid var(--navy); }
.insight.good { border-left-color: var(--green); }
.insight.warn { border-left-color: var(--red-2); }
.insight b { display: block; color: var(--deep); margin-bottom: 3px; }
.insight p { margin: 0; color: var(--ink-2); font-size: 13px; }

.client-card { display: block; text-decoration: none; color: inherit; }
.client-card:hover { border-color: #c9d0d9; }
.avatar { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px; flex: none; }
.person { display: flex; gap: 12px; align-items: flex-start; }
.person .grow { min-width: 0; flex: 1; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.prose { white-space: pre-wrap; color: var(--ink-2); }
.chart-box { position: relative; height: 240px; }
.chart-box.tall { height: 300px; }

/* ---------- calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; }
.cal .dow { padding: 8px; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; background: #fafbfc; border-bottom: 1px solid var(--line); }
.cal .cell { min-height: 104px; border-right: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); padding: 6px; cursor: pointer; min-width: 0; }
.cal .cell:nth-child(7n) { border-right: 0; }
.cal .cell:hover { background: #fafbfc; }
.cal .cell.out { background: #fbfbfc; color: #b3bac4; }
.cal .cell.today .n { background: var(--red-2); color: #fff; }
.cal .n { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; font-size: 12px; font-weight: 600; }
.cal .ev { display: block; margin-top: 3px; padding: 2px 6px; border-radius: 6px; font-size: 11.5px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal .ev.planned { opacity: .55; }
.cal .ev.worked::before { content: "✓ "; }

/* ---------- forms & modal ---------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--muted); }
input[type=text], input[type=email], input[type=number], input[type=date], input[type=url], input[type=tel], input[type=search], select, textarea {
  width: 100%; height: 38px; padding: 0 11px; border: 1px solid #d5dbe2; border-radius: 10px; background: #fff; outline: none; }
textarea { height: auto; min-height: 90px; padding: 9px 11px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(22,48,77,.12); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.modal-back { position: fixed; inset: 0; background: rgba(10,24,40,.5); display: grid; place-items: center; padding: 16px; z-index: 50; animation: fade .15s; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 620px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 30px 70px -20px rgba(0,0,0,.45); }
.modal.wide { max-width: 920px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); gap: 10px; }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.x { background: none; border: 0; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); padding: 4px 8px; border-radius: 8px; }
.x:hover { background: var(--line-2); }
.error { color: var(--red); font-size: 13px; margin-top: 10px; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--deep); color: #fff; padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: 13.5px; opacity: 0; pointer-events: none; transition: .25s; z-index: 60; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
@keyframes fade { from { opacity: 0; } }

.drop { border: 2px dashed #cbd3dc; border-radius: 14px; padding: 26px; text-align: center; color: var(--muted); background: #fafbfc; }
.drop b { color: var(--ink); }
.progress-line { height: 6px; border-radius: 99px; background: var(--line-2); overflow: hidden; margin-top: 12px; }
.progress-line i { display: block; height: 100%; background: var(--red-2); width: 0; transition: width .2s; }
.map-table select { height: 32px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters input[type=search] { max-width: 260px; }
.filters select { width: auto; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 600; cursor: pointer; color: var(--ink-2); }
.chip.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.roadmap .card { border-style: dashed; box-shadow: none; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g-main { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .shell.menu .side { transform: none; box-shadow: 0 0 0 100vmax rgba(10,24,40,.45); }
  .topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; background: var(--deep); color: #fff; position: sticky; top: 0; z-index: 30; }
  .topbar img { width: 28px; height: 28px; }
  .topbar button { background: none; border: 0; color: #fff; padding: 6px; cursor: pointer; }
  .main { padding: 18px 16px 48px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .cal .cell { min-height: 64px; padding: 4px; }
  .cal .ev { font-size: 0; height: 6px; padding: 0; margin-top: 2px; }
  .kv { grid-template-columns: 1fr; gap: 0 0; } .kv dd { margin-bottom: 8px; }
}
