:root {
  --navy: #1E2A6B;
  --navy-2: #27357f;
  --navy-3: #3a4796;
  --orange: #E8552D;
  --orange-soft: #fbe3da;
  --cream: #F7F2EA;
  --cream-2: #efe7da;
  --white: #ffffff;
  --ink: #141414;
  --gray: #6B6B6B;
  --line: #e6ddcf;
  --ok: #2E9E6B;
  --ok-soft: #dff2e9;
  --blue: #2F6BFF;
  --blue-soft: #e2eaff;
  --warn: #b7791f;
  --warn-soft: #fbefd6;
  --danger: #c0392b;
  --danger-soft: #f8e0dc;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(20, 20, 20, .04), 0 8px 24px rgba(30, 42, 107, .06);
  --serif: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --sidebar: 252px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--navy); text-decoration: none; }
a:hover { color: var(--orange); }
h1, h2, h3 { font-family: var(--serif); color: var(--navy); margin: 0; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 30px; line-height: 1.15; }
h2 { font-size: 20px; }
h3 { font-size: 16px; font-family: var(--sans); font-weight: 600; }
.muted { color: var(--gray); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* ---------- Wordmark ---------- */
.wordmark { font-family: var(--serif); font-weight: 800; letter-spacing: .04em; font-size: 22px; line-height: 1; }
.wordmark .w1 { color: var(--navy); }
.wordmark .w2 { color: var(--orange); }
.sidebar .wordmark .w1 { color: var(--white); }

/* ---------- Layout ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar);
  background: var(--navy); color: #d9ddf2; display: flex; flex-direction: column;
  padding: 26px 16px 18px; z-index: 40; overflow-y: auto;
}
.sidebar .brand { padding: 0 10px 24px; }
.sidebar .brand .tag { display: block; margin-top: 8px; font-size: 11px; letter-spacing: .14em; color: #9aa3d6; text-transform: uppercase; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav .group { margin: 16px 10px 6px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: #8790c7; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 12px;
  color: #dfe3f7; font-weight: 500;
}
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav a:hover { background: var(--navy-2); color: var(--white); }
.nav a.active { background: var(--white); color: var(--navy); }
.nav a.active svg { color: var(--orange); opacity: 1; }
.nav .count { margin-left: auto; background: var(--orange); color: var(--white); border-radius: 999px; font-size: 11px; padding: 1px 8px; font-weight: 600; }
.sidebar .foot { margin-top: auto; padding: 18px 10px 0; border-top: 1px solid var(--navy-3); }
.sidebar .foot .who { font-size: 12px; color: #aab2e3; margin-bottom: 10px; word-break: break-all; }
.sidebar .foot .brandfoot { font-size: 10px; letter-spacing: .2em; color: #7880bf; margin-top: 14px; }

.main { flex: 1; margin-left: var(--sidebar); min-width: 0; position: relative; }
.main::before, .main::after {
  content: ''; position: absolute; border-radius: 50%; filter: blur(2px); z-index: 0; pointer-events: none;
}
.main::before { width: 340px; height: 340px; right: -120px; top: -140px; background: radial-gradient(circle, rgba(232, 85, 45, .14), rgba(232, 85, 45, 0) 70%); }
.main::after { width: 420px; height: 420px; left: 30%; bottom: -260px; background: radial-gradient(circle, rgba(30, 42, 107, .08), rgba(30, 42, 107, 0) 70%); position: fixed; }
.content { position: relative; z-index: 1; padding: 30px 36px 60px; max-width: 1320px; }
.topbar { display: none; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head .eyebrow { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--orange); font-weight: 600; margin-bottom: 6px; }
.page-head p { margin: 6px 0 0; color: var(--gray); }
.crumbs { font-size: 13px; color: var(--gray); margin-bottom: 8px; }
.crumbs a { color: var(--gray); }

/* ---------- Cards / grid ---------- */
.card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; border: 1px solid rgba(230, 221, 207, .6); }
.card + .card { margin-top: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.grid { display: grid; gap: 18px; }
.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)); }
.span2 { grid-column: span 2; }
.stack > * + * { margin-top: 18px; }

.kpi { position: relative; overflow: hidden; }
.kpi .label { font-size: 12px; color: var(--gray); text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.kpi .value { font-family: var(--serif); font-size: 34px; color: var(--navy); margin-top: 6px; line-height: 1.1; }
.kpi .sub { font-size: 12px; color: var(--gray); margin-top: 4px; }
.kpi.accent { background: var(--navy); border-color: var(--navy); }
.kpi.accent .label, .kpi.accent .sub { color: #b9c0ea; }
.kpi.accent .value { color: var(--white); }
.kpi.alert .value { color: var(--orange); }
.kpi::after { content: ''; position: absolute; right: -30px; top: -30px; width: 90px; height: 90px; border-radius: 50%; background: var(--cream); opacity: .7; }
.kpi.accent::after { background: var(--orange); opacity: .25; }

.chart-box { position: relative; height: 260px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -22px; padding: 0 22px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--gray); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px; border-bottom: 1px solid #f1ebe1; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fcfaf6; }
.person { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.person .meta { min-width: 0; }
.person .meta strong { display: block; font-weight: 600; }
.person .meta span { font-size: 12px; color: var(--gray); }

.avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: var(--cream-2); color: var(--navy); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex: none; }
.avatar.lg { width: 72px; height: 72px; font-size: 22px; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--cream-2); color: var(--navy); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.orange { background: var(--orange-soft); color: var(--orange); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.navy { background: var(--navy); color: var(--white); }
.verified { display: inline-flex; width: 16px; height: 16px; border-radius: 50%; background: var(--blue); color: #fff; align-items: center; justify-content: center; font-size: 10px; vertical-align: middle; margin-left: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 3px 10px; border-radius: 999px; background: var(--cream); border: 1px solid var(--line); font-size: 12px; color: var(--navy); }

/* ---------- Buttons / forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 999px; border: 1px solid transparent; font: inherit; font-weight: 600; font-size: 13px; cursor: pointer; background: var(--navy); color: var(--white); text-decoration: none; line-height: 1.2; }
.btn:hover { background: var(--navy-2); color: var(--white); }
.btn.orange { background: var(--orange); }
.btn.orange:hover { background: #d54620; }
.btn.ok { background: var(--ok); }
.btn.ok:hover { background: #268558; }
.btn.ghost { background: transparent; color: var(--navy); border-color: var(--line); }
.btn.ghost:hover { background: var(--cream); color: var(--navy); }
.btn.danger { background: transparent; color: var(--danger); border-color: #efc9c3; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.sm { padding: 6px 12px; font-size: 12px; }
.btn.block { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
form.inline { display: inline; }

label { display: block; font-size: 12px; font-weight: 600; color: var(--navy); margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--white); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 10px 12px; outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--navy); box-shadow: 0 0 0 3px rgba(30, 42, 107, .1); }
.field { margin-bottom: 14px; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; font-size: 14px; color: var(--ink); margin-bottom: 12px; }
.check input { width: 18px; height: 18px; accent-color: var(--orange); }
.hint { font-size: 12px; color: var(--gray); margin-top: 4px; font-weight: 400; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 18px; }
.filters .field { margin: 0; min-width: 150px; }
.filters .grow { flex: 1; min-width: 200px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.tabs a { padding: 7px 14px; border-radius: 999px; background: var(--white); border: 1px solid var(--line); font-size: 13px; font-weight: 600; color: var(--navy); }
.tabs a.on { background: var(--navy); color: var(--white); border-color: var(--navy); }
.tabs a .n { opacity: .65; margin-left: 4px; font-weight: 500; }

/* ---------- Flash ---------- */
.flash { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; font-weight: 500; border: 1px solid; }
.flash.ok { background: var(--ok-soft); color: #1f6e4b; border-color: #bfe3d1; }
.flash.error { background: var(--danger-soft); color: #8e2a1f; border-color: #efc9c3; }

/* ---------- Profile cards ---------- */
.pcard { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.pcard .cover { height: 130px; background: var(--cream-2) center/cover no-repeat; position: relative; }
.pcard .cover .badge { position: absolute; top: 12px; left: 12px; }
.pcard .body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.pcard .head { display: flex; gap: 12px; align-items: center; margin-top: -40px; }
.pcard .head .avatar { width: 60px; height: 60px; border: 3px solid var(--white); font-size: 18px; }
.pcard .head .meta { padding-top: 26px; min-width: 0; }
.pcard .head strong { font-size: 15px; display: block; }
.pcard .head span { font-size: 12px; color: var(--gray); }
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.metric { background: var(--cream); border-radius: 12px; padding: 8px 10px; }
.metric b { display: block; font-family: var(--serif); font-size: 17px; color: var(--navy); }
.metric span { font-size: 11px; color: var(--gray); }
.pcard .foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; gap: 8px; }

.portfolio { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; }
.portfolio img { width: 100%; aspect-ratio: 4/5; object-fit: cover; border-radius: 12px; background: var(--cream-2); }

dl.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; margin: 0; }
dl.kv dt { color: var(--gray); font-size: 13px; }
dl.kv dd { margin: 0; font-weight: 500; word-break: break-word; }

/* ---------- Stage line ---------- */
.stages { display: flex; gap: 0; margin: 6px 0 4px; overflow-x: auto; padding-bottom: 4px; }
.stage { flex: 1; min-width: 92px; text-align: center; position: relative; font-size: 12px; color: var(--gray); font-weight: 600; }
.stage .dot { width: 30px; height: 30px; border-radius: 50%; background: var(--cream-2); color: var(--gray); display: flex; align-items: center; justify-content: center; margin: 0 auto 6px; position: relative; z-index: 1; font-size: 12px; }
.stage::before { content: ''; position: absolute; top: 15px; left: -50%; width: 100%; height: 3px; background: var(--cream-2); z-index: 0; }
.stage:first-child::before { display: none; }
.stage.done .dot { background: var(--navy); color: var(--white); }
.stage.done::before, .stage.current::before { background: var(--navy); }
.stage.current .dot { background: var(--orange); color: var(--white); box-shadow: 0 0 0 5px var(--orange-soft); }
.stage.current { color: var(--orange); }
.stage.done { color: var(--navy); }

/* ---------- Chat ---------- */
.chat { display: flex; flex-direction: column; gap: 10px; max-height: 620px; overflow-y: auto; padding: 4px; }
.bubble { max-width: 74%; padding: 10px 14px; border-radius: 18px; background: var(--cream); align-self: flex-start; }
.bubble.r { align-self: flex-end; background: var(--navy); color: var(--white); border-bottom-right-radius: 6px; }
.bubble.c { border-bottom-left-radius: 6px; }
.bubble .who { font-size: 11px; font-weight: 700; opacity: .7; margin-bottom: 2px; }
.bubble .when { font-size: 11px; opacity: .6; margin-top: 4px; }
.bubble a { color: inherit; text-decoration: underline; }
.readonly-note { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--gray); background: var(--cream); padding: 8px 12px; border-radius: 10px; margin-bottom: 14px; }

.empty { text-align: center; padding: 34px 10px; color: var(--gray); }
.empty .t { font-family: var(--serif); font-size: 18px; color: var(--navy); margin-bottom: 4px; }

.pager { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 16px; font-size: 13px; color: var(--gray); }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid #f1ebe1; }
.list-plain li:last-child { border-bottom: 0; }
.temp-pass { font-family: ui-monospace, Menlo, monospace; font-size: 16px; background: var(--navy); color: var(--white); padding: 10px 14px; border-radius: 12px; display: inline-block; letter-spacing: .04em; }
pre.json { white-space: pre-wrap; word-break: break-word; background: var(--cream); padding: 8px 10px; border-radius: 10px; margin: 0; font-size: 11px; max-width: 460px; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.login-art { background: var(--navy); color: var(--white); padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-art::before { content: ''; position: absolute; width: 520px; height: 520px; border-radius: 50%; background: var(--orange); opacity: .9; right: -220px; bottom: -200px; }
.login-art::after { content: ''; position: absolute; width: 240px; height: 240px; border-radius: 50%; background: var(--cream); opacity: .12; left: -60px; top: 34%; }
.login-art .wordmark { font-size: 30px; position: relative; z-index: 1; }
.login-art .wordmark .w1 { color: var(--white); }
.login-art .claim { position: relative; z-index: 1; font-family: var(--serif); font-size: 44px; line-height: 1.08; max-width: 460px; }
.login-art .claim em { color: var(--orange); font-style: italic; }
.login-art .foot { position: relative; z-index: 1; font-size: 11px; letter-spacing: .24em; color: #b9c0ea; }
.login-form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.login-form .card { width: 100%; max-width: 400px; padding: 34px; }
.login-form h1 { font-size: 28px; margin-bottom: 4px; }

/* ---------- Responsive ---------- */
#nav-toggle { display: none; }
.scrim { display: none; }
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; box-shadow: 0 0 40px rgba(0, 0, 0, .25); }
  #nav-toggle:checked ~ .shell .sidebar { transform: none; }
  #nav-toggle:checked ~ .shell .scrim { display: block; position: fixed; inset: 0; background: rgba(20, 20, 20, .35); z-index: 30; }
  .main { margin-left: 0; }
  .topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; background: var(--cream); position: sticky; top: 0; z-index: 20; border-bottom: 1px solid var(--line); }
  .topbar label { margin: 0; cursor: pointer; display: inline-flex; width: 40px; height: 40px; align-items: center; justify-content: center; border-radius: 12px; background: var(--white); border: 1px solid var(--line); }
  .topbar .wordmark { font-size: 18px; }
  .content { padding: 20px 16px 48px; }
  .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); }
  .span2 { grid-column: auto; }
  h1 { font-size: 24px; }
  dl.kv { grid-template-columns: 1fr; gap: 2px; }
  dl.kv dd { margin-bottom: 8px; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-art { padding: 28px; min-height: 220px; }
  .login-art .claim { font-size: 30px; margin: 24px 0; }
  .bubble { max-width: 90%; }
  .kpi .value { font-size: 28px; }
}
