:root {
  --side: #0f1b2d; --side-2: #16263d; --side-text: #c9d3e1; --side-muted: #7f8ea5;
  --gold: #c8a24a; --gold-2: #e0bf6b; --gold-soft: rgba(200,162,74,.14);
  --bg: #f4f5f7; --card: #fff; --line: #e3e6eb; --text: #121826; --muted: #5d6676;
  --red: #c0392b; --green: #1e8e5a; --blue: #2459c4; --amber: #b7791f;
  --radius: 12px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --font: 'Inter', 'Hind', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: 15px; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }

/* ── login ── */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1200px 600px at 20% -10%, #1f3556 0%, transparent 60%), var(--side); }
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 16px; padding: 28px 24px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 22px; }
.login-brand img { width: 46px; height: 46px; }
.login-brand b { display: block; font-size: 19px; letter-spacing: .3px; }
.login-brand span { color: var(--muted); font-size: 13px; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 6px; }
.login-note { font-size: 12.5px; color: var(--muted); margin-top: 14px; text-align: center; }

/* ── layout ── */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 30; }
.brand { display: flex; gap: 10px; align-items: center; padding: 18px 18px 14px; color: #fff; }
.brand img { width: 36px; height: 36px; }
.brand b { display: block; font-size: 15.5px; letter-spacing: .4px; }
.brand span { font-size: 11.5px; color: var(--side-muted); }
.nav { padding: 6px 10px 12px; flex: 1; }
.nav-group { font-size: 10.5px; text-transform: uppercase; letter-spacing: 1.1px; color: var(--side-muted); padding: 16px 10px 6px; font-weight: 600; }
.nav a { display: flex; gap: 11px; align-items: center; padding: 9px 10px; border-radius: 9px; color: var(--side-text); font-weight: 500; font-size: 14.5px; margin: 1px 0; }
.nav a:hover { background: var(--side-2); text-decoration: none; color: #fff; }
.nav a.on { background: var(--gold-soft); color: var(--gold-2); }
.nav a.on svg { color: var(--gold); }
.nav svg { width: 18px; height: 18px; flex: none; color: var(--side-muted); }
.nav .pill { margin-left: auto; background: var(--gold); color: #1a1405; font-size: 11px; font-weight: 700; border-radius: 99px; padding: 1px 7px; }
.side-user { border-top: 1px solid rgba(255,255,255,.08); padding: 12px 14px; display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--gold); color: #1a1405; display: grid; place-items: center; font-weight: 700; flex: none; }
.side-user .who { min-width: 0; flex: 1; }
.side-user .who b { display: block; color: #fff; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user .who span { font-size: 11.5px; color: var(--side-muted); text-transform: capitalize; }
.icon-btn { background: none; border: 0; color: var(--side-muted); cursor: pointer; padding: 6px; border-radius: 8px; display: grid; place-items: center; }
.icon-btn:hover { background: var(--side-2); color: #fff; }
.icon-btn svg { width: 18px; height: 18px; }

.scrim { display: none; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.page { padding: 26px 30px 60px; max-width: 1240px; width: 100%; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 23px; margin: 0; letter-spacing: -.2px; }
.page-head .sub { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ── controls ── */
.btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 8px 14px; font-weight: 600; font-size: 14px; cursor: pointer; color: var(--text); white-space: nowrap; }
.btn:hover { border-color: #c9ced6; text-decoration: none; }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--side); border-color: var(--side); color: #fff; }
.btn.primary:hover { background: #1b2d47; }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #1a1405; }
.btn.gold:hover { background: var(--gold-2); }
.btn.danger { color: var(--red); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: 13px; font-weight: 600; color: #344054; margin-bottom: 5px; }
label.f > small { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
.in, select.in, textarea.in { width: 100%; border: 1px solid #d0d5dd; border-radius: 9px; padding: 9px 11px; background: #fff; font-size: 15px; }
textarea.in { resize: vertical; min-height: 90px; line-height: 1.6; }
.in:focus { outline: 2px solid rgba(200,162,74,.45); border-color: var(--gold); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }
.search { max-width: 340px; }
.hint { color: var(--muted); font-size: 13px; }
.err { color: var(--red); font-size: 13.5px; margin: 6px 0; }

/* ── cards / lists ── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 16px; }
.card h2 { font-size: 16px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 26px; letter-spacing: -.5px; }
.stat span { color: var(--muted); font-size: 13px; }
.two { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; align-items: start; }
.list { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid #eef0f3; color: inherit; }
.row:last-child { border-bottom: 0; }
a.row:hover { background: #fafbfc; text-decoration: none; }
.row .grow { flex: 1; min-width: 0; }
.row .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .s { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.date-chip { flex: none; width: 52px; text-align: center; border-radius: 9px; background: #f2f4f7; padding: 5px 0; line-height: 1.15; }
.date-chip b { display: block; font-size: 17px; }
.date-chip span { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.date-chip.today { background: var(--gold-soft); color: #7a5b13; }
.badge { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: #eef1f5; color: #475467; white-space: nowrap; }
.badge.green { background: #e3f4ea; color: var(--green); }
.badge.amber { background: #fdf1dc; color: var(--amber); }
.badge.red { background: #fbe4e1; color: var(--red); }
.badge.blue { background: #e6eefc; color: var(--blue); }
.empty { color: var(--muted); padding: 22px 6px; text-align: center; font-size: 14px; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); font-weight: 600; }
.tbl td { padding: 11px 10px; border-bottom: 1px solid #eef0f3; vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: #fafbfc; }
.tbl-wrap { overflow-x: auto; }

/* ── tabs ── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 12px; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; font-size: 14px; }
.tabs button.on { color: var(--text); border-color: var(--gold); }
.tabs button .n { font-size: 11.5px; background: #eef1f5; border-radius: 99px; padding: 1px 6px; margin-left: 4px; }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 8px 14px; font-size: 14.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; white-space: pre-wrap; }
.facts { white-space: pre-wrap; line-height: 1.7; font-family: 'Hind', var(--font); }

/* ── drop zone ── */
.drop { border: 2px dashed #d0d5dd; border-radius: 12px; padding: 22px; text-align: center; color: var(--muted); cursor: pointer; }
.drop.over { border-color: var(--gold); background: var(--gold-soft); }
.chk { display: flex; align-items: flex-start; gap: 9px; padding: 7px 4px; cursor: pointer; font-size: 14px; }
.chk input { margin-top: 3px; }

/* ── draft editor ── */
.editor { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.editor textarea { min-height: 70vh; font-family: 'Hind', var(--font); font-size: 15.5px; line-height: 1.75; }
.paper-wrap { background: #e9e9ec; border-radius: 12px; padding: 14px; max-height: 78vh; overflow: auto; position: sticky; top: 16px; }
.paper { background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.1); font-family: 'Tiro Devanagari Hindi', serif; font-size: 14.5px; line-height: 1.75; color: #111; }
.paper .lh-top { display: flex; justify-content: space-between; align-items: center; background: #111; color: #fff; padding: 10px 18px; font-family: Inter, sans-serif; }
.paper .lh-name { font-size: 19px; font-weight: 700; }
.paper .lh-tag { font-size: 11.5px; opacity: .85; }
.paper .lh-adv { text-align: right; font-size: 10px; font-weight: 700; line-height: 1.45; }
.paper .doc { padding: 18px 26px 22px; }
.paper .doc h2 { text-align: center; font-size: 17px; margin: 4px 0 2px; }
.paper .doc h3 { text-align: center; font-size: 15px; text-decoration: underline; margin: 12px 0 6px; }
.paper .doc p { margin: 0 0 9px; text-align: justify; }
.paper .doc p.right { text-align: right; }
.paper .lh-bottom { border-top: 3px solid #111; margin: 0 16px; padding: 6px 0 10px; text-align: center; font-size: 9.5px; font-family: Inter, sans-serif; line-height: 1.5; }
.save-state { font-size: 12.5px; color: var(--muted); }
.writing { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 60px 16px; text-align: center; color: var(--muted); }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid #e3e6eb; border-top-color: var(--gold); animation: spin 0.9s linear infinite; }
.spinner.sm { width: 16px; height: 16px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── advisor chat ── */
.chat { display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 92%; border-radius: 14px; padding: 12px 15px; line-height: 1.7; font-family: 'Hind', var(--font); font-size: 15px; }
.msg.user { align-self: flex-end; background: var(--side); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg.assistant { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.failed { border-color: #f1c0b9; background: #fff6f5; color: var(--red); }
.msg .meta { font-family: var(--font); font-size: 11.5px; color: var(--muted); margin-top: 6px; }
.msg.user .meta { color: #a9b6ca; }
.md h2 { font-size: 16px; margin: 14px 0 6px; color: #0f1b2d; border-bottom: 1px solid #eef0f3; padding-bottom: 4px; }
.md h2:first-child { margin-top: 0; }
.md h3 { font-size: 15px; margin: 10px 0 4px; }
.md p { margin: 0 0 8px; }
.md ul, .md ol { margin: 0 0 8px; padding-left: 22px; }
.md li { margin: 3px 0; }
.ask-box { position: sticky; bottom: 0; background: var(--bg); padding-top: 12px; }
.ask-box .card { padding: 12px; }
.ask-box textarea { min-height: 70px; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.quick button { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 5px 11px; font-size: 13px; cursor: pointer; }
.quick button:hover { border-color: var(--gold); }
.notice { background: #fff8e8; border: 1px solid #f1dfb4; color: #6b5214; padding: 10px 14px; border-radius: 10px; font-size: 13.5px; margin-bottom: 14px; }

/* ── modal ── */
.modal-bg { position: fixed; inset: 0; background: rgba(10,16,28,.5); display: grid; place-items: center; padding: 16px; z-index: 100; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow: auto; padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal h3 { margin: 0 0 14px; font-size: 18px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

#toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(20px); background: #101828; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 200; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--red); }

/* ── phone / tablet ── */
@media (max-width: 1100px) {
  .editor { grid-template-columns: 1fr; }
  .paper-wrap { position: static; max-height: none; }
  .two { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 270px; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.35); }
  .shell.menu-open .side { transform: none; }
  .shell.menu-open .scrim { display: block; position: fixed; inset: 0; background: rgba(10,16,28,.45); z-index: 25; }
  .topbar { display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 20; background: var(--side); color: #fff; padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top)); }
  .topbar b { font-size: 15px; letter-spacing: .3px; }
  .topbar .icon-btn { color: #fff; }
  .topbar .icon-btn svg { width: 22px; height: 22px; }
  .page { padding: 16px 16px 60px; }
  .page-head h1 { font-size: 20px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dt { margin-top: 8px; }
  .search { max-width: none; width: 100%; }
  .msg { max-width: 100%; }
  .hide-sm { display: none !important; }
  .tbl.stack thead { display: none; }
  .tbl.stack tr { display: block; border-bottom: 1px solid #eef0f3; padding: 8px 0; }
  .tbl.stack td { display: block; border: 0; padding: 2px 6px; }
}
