:root {
  --navy: #1c2d49; --navy-2: #14223a; --navy-3: #0f1a2e;
  --green: #0c8a4d; --green-2: #0a7341; --green-soft: #e6f4ec;
  --ink: #18212f; --mute: #5d6878; --faint: #8b94a3; --line: #e3e7ee; --line-2: #eef1f5;
  --bg: #f4f6f9; --card: #ffffff;
  --amber: #b7791f; --amber-soft: #fdf3e2; --red: #c0392b; --red-soft: #fbeceb; --blue: #2c5ea8; --blue-soft: #e9f0fb;
  --r: 14px; --r-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --font: "DM Sans", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 14.5px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--green-2); }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
.boot { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 14px; background: var(--navy-3); color: #c9d3e4; }
.boot img { background: #fff; border-radius: 14px; padding: 12px 16px; }

/* sign in */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.login-art { background: radial-gradient(120% 90% at 20% 10%, #2a4170 0%, var(--navy) 45%, var(--navy-3) 100%); color: #fff; padding: 48px 56px; display: flex; flex-direction: column; position: relative; overflow: hidden; }
.login-art::after { content: ""; position: absolute; right: -180px; bottom: -180px; width: 520px; height: 520px; border-radius: 50%; border: 70px solid rgba(12, 138, 77, .18); }
.login-logo { background: #fff; border-radius: 16px; padding: 14px 18px; width: 220px; }
.login-logo img { width: 100%; display: block; }
.login-art h1 { font-size: clamp(38px, 4.4vw, 60px); font-weight: 700; margin-top: auto; letter-spacing: -.03em; }
.login-art p { color: #c3cde0; max-width: 460px; font-size: 16px; }
.login-stats { display: flex; gap: 36px; margin-top: 34px; padding-top: 22px; border-top: 1px solid rgba(255,255,255,.14); position: relative; z-index: 1; }
.login-stats b { display: block; font-size: 17px; }
.login-stats span { color: #9fb0cb; font-size: 12.5px; }
.login-form { display: grid; place-items: center; padding: 40px 20px; background: #f7f8fb; }
.login-card { width: min(400px, 100%); }
.login-card h2 { font-size: 30px; margin-bottom: 6px; }
.login-card .sub { color: var(--mute); margin: 0 0 26px; }
.login-card .help { color: var(--faint); font-size: 12.5px; margin-top: 18px; }

/* app shell */
.shell { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }
.side { background: linear-gradient(180deg, var(--navy) 0%, var(--navy-3) 100%); color: #d6deeb; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.side-brand { padding: 18px 18px 10px; }
.side-brand .logo { background: #fff; border-radius: 12px; padding: 8px 12px; display: block; }
.side-brand .logo img { width: 100%; max-width: 190px; display: block; margin: 0 auto; }
.me { margin: 10px 14px 6px; padding: 12px 14px; border-radius: 12px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08); display: flex; gap: 10px; align-items: center; }
.me b { display: block; color: #fff; font-size: 13.5px; }
.me span { font-size: 12px; color: #a9b6cc; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #3fd18a; box-shadow: 0 0 0 3px rgba(63, 209, 138, .18); margin-left: auto; flex: none; }
.nav { flex: 1; overflow-y: auto; padding: 10px 10px 16px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent; }
.nav-h { font-size: 12px; color: #7f8ea8; padding: 10px 10px 6px; }
.nav button { width: 100%; display: flex; align-items: center; gap: 11px; padding: 9px 10px; border: 0; background: none; border-radius: 9px; color: #cdd6e4; cursor: pointer; text-align: left; font-size: 13.8px; }
.nav button:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav button.on { background: rgba(12, 138, 77, .22); color: #fff; box-shadow: inset 3px 0 0 #2fbf77; }
.nav button svg { width: 17px; height: 17px; flex: none; opacity: .9; }
.nav .chev { margin-left: auto; transition: transform .2s; width: 14px !important; height: 14px !important; }
.nav .grp.open > button .chev { transform: rotate(90deg); }
.nav .sub { display: none; padding: 2px 0 4px 28px; }
.nav .grp.open .sub { display: block; }
.nav .sub button { font-size: 13.2px; padding: 7px 10px; color: #aebbd0; }
.nav .badge { margin-left: auto; background: #2fbf77; color: #06291a; font-size: 11px; font-weight: 700; border-radius: 20px; padding: 1px 7px; }
.side-foot { padding: 12px 14px 16px; border-top: 1px solid rgba(255,255,255,.07); }
.side-foot button { width: 100%; justify-content: center; }
.main { min-width: 0; display: flex; flex-direction: column; }
.top { height: 62px; display: flex; align-items: center; gap: 14px; padding: 0 28px; background: rgba(255,255,255,.86); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top .crumb { font-size: 13px; color: var(--mute); }
.top .crumb b { color: var(--ink); font-weight: 600; }
.top .sp { flex: 1; }
.seg { display: flex; background: var(--line-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 8px; font-size: 13px; color: var(--mute); cursor: pointer; display: flex; gap: 6px; align-items: center; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.seg svg { width: 15px; height: 15px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--green); color: #fff; display: grid; place-items: center; font-size: 12.5px; font-weight: 700; flex: none; }
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.who .avatar, .conv .avatar, .me .avatar, .list .avatar { display: grid; color: #fff; font-size: 11px; font-weight: 700; }
.who .avatar:not(.sm) { font-size: 12.5px; }
.menu-btn { display: none; border: 0; background: none; cursor: pointer; padding: 6px; }
.page { padding: 28px; max-width: 1320px; width: 100%; }
.page-h { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-h h1 { font-size: 30px; font-weight: 700; letter-spacing: -.025em; }
.page-h p { margin: 6px 0 0; color: var(--mute); }
.page-h .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.date-line { color: var(--mute); font-size: 13px; margin-bottom: 4px; }

/* cards and grids */
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.card-h { padding: 16px 18px 12px; display: flex; align-items: flex-start; gap: 10px; }
.card-h h3 { font-size: 15.5px; font-weight: 600; }
.card-h p { margin: 3px 0 0; color: var(--mute); font-size: 12.8px; }
.card-h .r { margin-left: auto; }
.card-b { padding: 0 18px 18px; }
.card-f { padding: 12px 18px 16px; border-top: 1px solid var(--line-2); }
.stat { padding: 18px; }
.stat .k { color: var(--mute); font-size: 13px; }
.stat .v { font-size: 30px; font-weight: 700; margin: 8px 0 2px; letter-spacing: -.02em; }
.stat .s { color: var(--faint); font-size: 12.5px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line-2); }
.list li:last-child { border-bottom: 0; }
.list .t { font-weight: 600; font-size: 13.8px; }
.list .m { color: var(--mute); font-size: 12.5px; }
.list .r { margin-left: auto; text-align: right; }
.empty { text-align: center; padding: 28px 16px; color: var(--mute); }
.empty b { display: block; color: var(--ink); margin-bottom: 4px; }
.trio { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; padding: 8px 0 14px; border-bottom: 1px solid var(--line-2); margin-bottom: 12px; }
.trio b { display: block; font-size: 22px; }
.trio span { color: var(--mute); font-size: 12.5px; }

/* buttons, pills, forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 10px; padding: 8px 14px; cursor: pointer; font-weight: 500; font-size: 13.5px; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #cfd5df; background: #fafbfc; }
.btn.pri { background: var(--green); border-color: var(--green); color: #fff; }
.btn.pri:hover { background: var(--green-2); }
.btn.dark { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--mute); }
.btn.ghost:hover { background: var(--line-2); color: var(--ink); }
.btn.danger { color: var(--red); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.block { width: 100%; padding: 11px; }
.btn.side-out { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.12); color: #dbe3ef; }
.btn:disabled { opacity: .55; cursor: default; }
.btn svg { width: 15px; height: 15px; }
.pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 20px; padding: 2px 9px; font-size: 12px; font-weight: 600; background: var(--line-2); color: var(--mute); white-space: nowrap; }
.pill.green { background: var(--green-soft); color: var(--green-2); }
.pill.amber { background: var(--amber-soft); color: var(--amber); }
.pill.red { background: var(--red-soft); color: var(--red); }
.pill.blue { background: var(--blue-soft); color: var(--blue); }
.pill.navy { background: #e8ecf3; color: var(--navy); }
label.f { display: block; }
label.f > span { display: block; font-size: 12.8px; font-weight: 600; margin-bottom: 5px; color: #2c3646; }
label.f > small { display: block; color: var(--faint); font-size: 12px; margin-top: 4px; }
.in, select.in, textarea.in { width: 100%; border: 1px solid #d6dce5; background: #fff; border-radius: 10px; padding: 9px 12px; outline: none; transition: border-color .15s, box-shadow .15s; }
.in:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(12, 138, 77, .14); }
textarea.in { min-height: 96px; resize: vertical; }
.in.sm { padding: 5px 8px; font-size: 13px; border-radius: 8px; }
.form { display: grid; gap: 14px; }
.form .row { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form .row3 { display: grid; gap: 14px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form h4 { margin: 8px 0 0; font-size: 14px; padding-top: 14px; border-top: 1px solid var(--line-2); }
.pass-wrap { position: relative; }
.pass-wrap button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; cursor: pointer; color: var(--faint); padding: 4px; }
.err { background: var(--red-soft); color: var(--red); border-radius: 10px; padding: 9px 12px; font-size: 13px; }
.note { background: var(--amber-soft); color: #7a5312; border-radius: 10px; padding: 10px 14px; font-size: 13px; display: flex; gap: 10px; align-items: center; }
.note.green { background: var(--green-soft); color: var(--green-2); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .in { width: auto; }
.toolbar .search { min-width: 230px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button { border: 0; background: none; padding: 9px 12px; cursor: pointer; color: var(--mute); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tabs button.on { color: var(--ink); border-color: var(--green); }
.tabs .n { background: var(--line-2); border-radius: 10px; padding: 0 7px; font-size: 11.5px; margin-left: 4px; }

/* tables */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-weight: 600; color: var(--mute); font-size: 12.5px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafbfc; white-space: nowrap; }
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: #f8faf9; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tfoot td { font-weight: 700; border-top: 1px solid var(--line); background: #fafbfc; }
.who { display: flex; align-items: center; gap: 10px; }
.who b { display: block; font-weight: 600; }
.who span { color: var(--mute); font-size: 12.3px; }
.bar { height: 8px; background: var(--line-2); border-radius: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--green); border-radius: 6px; }

/* drawer and modal */
.veil { position: fixed; inset: 0; background: rgba(15, 26, 46, .42); z-index: 40; display: flex; justify-content: flex-end; animation: fade .15s ease; }
.veil.center { justify-content: center; align-items: center; padding: 16px; }
.drawer { width: min(560px, 100%); height: 100%; background: #fff; overflow-y: auto; animation: slide .2s ease; display: flex; flex-direction: column; }
.modal { width: min(520px, 100%); max-height: 92vh; overflow-y: auto; background: #fff; border-radius: 16px; animation: pop .16s ease; }
.drawer-h, .modal-h { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; position: sticky; top: 0; background: #fff; z-index: 1; }
.drawer-h h3, .modal-h h3 { font-size: 18px; }
.drawer-h .x, .modal-h .x { margin-left: auto; }
.drawer-b, .modal-b { padding: 20px 22px; }
.drawer-f, .modal-f { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; position: sticky; bottom: 0; background: #fff; margin-top: auto; }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
@keyframes pop { from { transform: scale(.97); opacity: 0; } }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--navy-3); color: #fff; padding: 10px 18px; border-radius: 12px; font-size: 13.5px; opacity: 0; pointer-events: none; transition: .2s; z-index: 60; }
#toast.on { opacity: 1; transform: translateX(-50%); }
#toast.bad { background: var(--red); }

/* chat */
.chat { display: grid; grid-template-columns: 290px 1fr; height: calc(100vh - 62px - 150px); min-height: 480px; overflow: hidden; }
.chat-list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.chat-list .head { padding: 14px; border-bottom: 1px solid var(--line-2); }
.chat-list .head h3 { font-size: 15px; margin-bottom: 10px; }
.chat-list .scroll { overflow-y: auto; flex: 1; padding: 8px; }
.chat-list .lbl { font-size: 12px; color: var(--faint); padding: 10px 8px 4px; }
.conv { width: 100%; display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 9px 8px; border-radius: 10px; cursor: pointer; text-align: left; }
.conv:hover { background: var(--line-2); }
.conv.on { background: var(--green-soft); }
.conv .hash { width: 28px; height: 28px; border-radius: 8px; background: var(--navy); color: #fff; display: grid; place-items: center; font-weight: 700; }
.conv b { display: block; font-size: 13.5px; font-weight: 600; }
.conv span { display: block; font-size: 12px; color: var(--mute); }
.conv .badge { margin-left: auto; background: var(--green); color: #fff; font-size: 11px; font-weight: 700; border-radius: 20px; padding: 1px 7px; }
.chat-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-main .head { padding: 12px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.chat-main .head b { display: block; }
.chat-main .head span { font-size: 12.3px; color: var(--mute); }
.msgs { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 2px; background: #fbfcfd; }
.msg { display: flex; gap: 10px; padding: 6px 0; }
.msg .body { min-width: 0; }
.msg .meta { font-size: 12px; color: var(--faint); }
.msg .meta b { color: var(--ink); font-size: 13.4px; margin-right: 6px; }
.msg .txt { white-space: pre-wrap; word-wrap: break-word; }
.msg.cont { padding-top: 0; }
.msg.cont .avatar { visibility: hidden; height: 0; }
.day-sep { text-align: center; font-size: 12px; color: var(--faint); margin: 12px 0 6px; }
.file-chip { display: inline-flex; align-items: center; gap: 10px; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 8px 12px; margin-top: 4px; text-decoration: none; color: var(--ink); max-width: 100%; }
.file-chip svg { width: 18px; height: 18px; color: var(--green); flex: none; }
.file-chip span { color: var(--mute); font-size: 12px; }
.file-img { display: block; max-width: 280px; max-height: 220px; border-radius: 10px; margin-top: 6px; border: 1px solid var(--line); }
.composer { border-top: 1px solid var(--line); padding: 12px 14px; }
.composer textarea { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; resize: none; min-height: 46px; max-height: 160px; outline: none; }
.composer textarea:focus { border-color: var(--green); }
.composer .bar2 { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.composer .hint { margin-left: auto; color: var(--faint); font-size: 12px; }
.pending-file { display: inline-flex; gap: 8px; align-items: center; background: var(--green-soft); color: var(--green-2); padding: 4px 10px; border-radius: 8px; font-size: 12.5px; }
.chat-foot { text-align: center; color: var(--faint); font-size: 12px; padding: 10px 0 0; }

/* misc */
.policy-body { white-space: pre-wrap; line-height: 1.65; }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 8px 14px; font-size: 13.5px; }
.kv dt { color: var(--mute); }
.kv dd { margin: 0; }
.kudo { padding: 16px 18px; display: flex; gap: 12px; }
.kudo .icon { width: 38px; height: 38px; border-radius: 10px; background: var(--amber-soft); color: var(--amber); display: grid; place-items: center; flex: none; }
.kudo .icon svg { width: 20px; height: 20px; }
.chart-row { display: grid; grid-template-columns: 150px 1fr 110px; gap: 12px; align-items: center; padding: 6px 0; font-size: 13px; }
.chart-row .num { text-align: right; font-variant-numeric: tabular-nums; }
.slip { font-size: 13.5px; }
.slip table { width: 100%; border-collapse: collapse; }
.slip td { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.slip td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.slip .net td { font-weight: 700; font-size: 15px; border-bottom: 0; border-top: 2px solid var(--navy); padding-top: 10px; }
.hide { display: none !important; }
.mt { margin-top: 16px; }
.muted { color: var(--mute); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 850px) {
  .login { grid-template-columns: 1fr; }
  .login-art { padding: 28px 22px; min-height: 280px; }
  .login-art h1 { margin-top: 40px; font-size: 36px; }
  .login-stats { gap: 20px; }
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 272px; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .shell.nav-open .side { transform: none; box-shadow: 0 0 0 100vmax rgba(15, 26, 46, .45); }
  .menu-btn { display: block; }
  .top { padding: 0 14px; }
  .seg { display: none; }
  .page { padding: 18px 16px; }
  .page-h h1 { font-size: 25px; }
  .g3, .g2 { grid-template-columns: 1fr; }
  .g4 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 14px; }
  .stat .v { font-size: 24px; }
  .menu-btn svg { width: 24px; height: 24px; display: block; }
  .form .row, .form .row3 { grid-template-columns: 1fr; }
  .chat { grid-template-columns: 1fr; height: calc(100dvh - 62px - 150px); min-height: 420px; }
  .page.chat-page .page-h p, .page.chat-page .page-h .pill, .composer .hint, .chat-foot { display: none; }
  .page.chat-page .page-h { margin-bottom: 12px; }
  .chat-list { display: none; }
  .chat.list-open .chat-list { display: flex; }
  .chat.list-open .chat-main { display: none; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
  .chart-row { grid-template-columns: 100px 1fr 90px; }
}
@media print {
  body { background: #fff; }
  .side, .top, .no-print, #toast { display: none !important; }
  .shell { display: block; }
  .page { padding: 0; }
  .card { box-shadow: none; border: 0; }
}
