:root {
  --bg: #070a14;
  --bg-2: #0b1020;
  --panel: rgba(15, 21, 38, .82);
  --panel-solid: #0f1526;
  --panel-2: #131b30;
  --line: rgba(148, 163, 184, .16);
  --line-strong: rgba(148, 163, 184, .28);
  --text: #eef2ff;
  --muted: #94a3b8;
  --muted-2: #64748b;
  --accent: #ff8a00;
  --accent-2: #ffb340;
  --accent-soft: rgba(255, 138, 0, .14);
  --green: #22c55e;
  --green-soft: rgba(34, 197, 94, .13);
  --red: #ef4444;
  --red-soft: rgba(239, 68, 68, .13);
  --blue: #38bdf8;
  --blue-soft: rgba(56, 189, 248, .12);
  --violet: #a78bfa;
  --yellow: #facc15;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 24px 70px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(255, 138, 0, .10), transparent 55%),
    radial-gradient(900px 500px at -10% 20%, rgba(56, 189, 248, .08), transparent 50%),
    var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
::selection { background: rgba(255, 138, 0, .35); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, .25); border-radius: 20px; }
::-webkit-scrollbar-track { background: transparent; }

/* boot + login */
.boot-screen { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 18px; background: var(--bg); z-index: 100; }
.boot-mark { width: 68px; height: 68px; border-radius: 20px; display: grid; place-items: center; font-size: 30px; font-weight: 800; background: linear-gradient(145deg, var(--accent), #ff5e00); color: #1a0d00; box-shadow: 0 20px 50px rgba(255, 122, 0, .35); animation: breathe 1.8s ease-in-out infinite; }
.boot-text { color: var(--muted); font-size: 13px; letter-spacing: .4px; }
@keyframes breathe { 50% { transform: translateY(-4px); box-shadow: 0 28px 60px rgba(255, 122, 0, .45); } }

.login-root { position: fixed; inset: 0; display: grid; place-items: center; padding: 22px; z-index: 20; }
.login-card { width: min(100%, 420px); padding: 34px; border: 1px solid var(--line); border-radius: 24px; background: linear-gradient(160deg, rgba(21, 29, 50, .96), rgba(10, 15, 29, .96)); box-shadow: var(--shadow); }
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; }
.login-brand .mark { width: 48px; height: 48px; border-radius: 15px; display: grid; place-items: center; background: linear-gradient(145deg, var(--accent), #ff5e00); color: #1a0d00; font-weight: 800; font-size: 22px; }
.login-brand h1 { margin: 0; font-size: 19px; letter-spacing: -.3px; }
.login-brand p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.login-card h2 { margin: 0 0 6px; font-size: 24px; letter-spacing: -.5px; }
.login-card > p.sub { margin: 0 0 22px; color: var(--muted); }
.login-note { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted-2); font-size: 12px; text-align: center; }

/* shell */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 248px; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: rgba(9, 13, 25, .92); backdrop-filter: blur(18px); z-index: 12; }
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 20px 18px 18px; }
.sidebar-brand .mark { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: linear-gradient(145deg, var(--accent), #ff5e00); color: #1a0d00; font-weight: 800; }
.sidebar-brand strong { display: block; font-size: 14px; letter-spacing: -.2px; }
.sidebar-brand span { display: block; color: var(--muted-2); font-size: 11px; }
.sidebar-scroll { flex: 1; overflow-y: auto; padding: 4px 12px 16px; }
.nav-group { margin: 14px 0 4px; padding: 0 10px; color: var(--muted-2); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.3px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 9px 10px; margin: 2px 0; border-radius: 10px; color: var(--muted); font-weight: 500; transition: .15s; }
.nav-link:hover { color: var(--text); background: rgba(148, 163, 184, .08); text-decoration: none; }
.nav-link.active { color: var(--text); background: linear-gradient(90deg, rgba(255, 138, 0, .17), rgba(255, 138, 0, .04)); box-shadow: inset 2px 0 0 var(--accent); }
.nav-link svg { width: 17px; height: 17px; flex: 0 0 auto; opacity: .82; }
.nav-link .count { margin-left: auto; min-width: 19px; height: 19px; padding: 0 6px; border-radius: 20px; background: var(--accent); color: #1a0d00; font-size: 10px; font-weight: 800; display: grid; place-items: center; }
.sidebar-foot { padding: 14px; border-top: 1px solid var(--line); }
.side-user { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; }
.side-user:hover { background: rgba(148, 163, 184, .07); text-decoration: none; }
.side-user .avatar { width: 34px; height: 34px; }
.side-user .meta { min-width: 0; }
.side-user .meta strong { display: block; font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user .meta span { display: block; font-size: 11px; color: var(--muted-2); }

.main { flex: 1; min-width: 0; margin-left: 248px; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 14px; padding: 13px 26px; border-bottom: 1px solid var(--line); background: rgba(7, 10, 20, .82); backdrop-filter: blur(16px); }
.topbar .search { position: relative; flex: 1; max-width: 460px; }
.topbar .search input { width: 100%; padding: 9px 13px 9px 36px; border: 1px solid var(--line); border-radius: 10px; background: rgba(148, 163, 184, .06); outline: none; }
.topbar .search input:focus { border-color: rgba(255, 138, 0, .55); background: rgba(255, 138, 0, .04); }
.topbar .search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted-2); }
.search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-solid); box-shadow: var(--shadow); overflow: hidden; z-index: 30; }
.search-results a { display: flex; gap: 10px; align-items: center; padding: 10px 13px; color: var(--text); border-bottom: 1px solid var(--line); }
.search-results a:last-child { border-bottom: 0; }
.search-results a:hover { background: rgba(148, 163, 184, .07); text-decoration: none; }
.search-results small { display: block; color: var(--muted-2); font-size: 11px; }
.topbar-spacer { flex: 1; }
.icon-btn { position: relative; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 10px; background: rgba(148, 163, 184, .05); display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.icon-btn:hover { color: var(--text); border-color: var(--line-strong); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn .dot { position: absolute; top: 8px; right: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px rgba(255, 138, 0, .18); }
.mobile-menu { display: none; }

.view { flex: 1; width: 100%; max-width: 1500px; margin: 0 auto; padding: 26px; outline: none; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 24px; letter-spacing: -.6px; }
.page-head p { margin: 5px 0 0; color: var(--muted); }
.page-head .actions { margin-left: auto; display: flex; gap: 9px; flex-wrap: wrap; }
.eyebrow { margin: 0 0 5px; color: var(--accent-2); font-size: 10px; font-weight: 800; letter-spacing: 1.6px; text-transform: uppercase; }

/* layout */
.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)); }
.grid.side { grid-template-columns: 300px minmax(0, 1fr); }
.grid.side-right { grid-template-columns: minmax(0, 1fr) 320px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.mt { margin-top: 16px; }
.mt-sm { margin-top: 8px; }
.mb { margin-bottom: 16px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; }
.sep { height: 1px; background: var(--line); margin: 16px 0; }

/* cards */
.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: 0 12px 40px rgba(0, 0, 0, .18); overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 15px 17px; border-bottom: 1px solid var(--line); }
.card-head h2, .card-head h3 { margin: 0; font-size: 14px; letter-spacing: -.1px; }
.card-head .sub { color: var(--muted-2); font-size: 11px; }
.card-head .actions { margin-left: auto; display: flex; gap: 7px; align-items: center; }
.card-body { padding: 17px; }
.card-body.tight { padding: 10px; }
.card-foot { padding: 12px 17px; border-top: 1px solid var(--line); background: rgba(0, 0, 0, .12); }

.stat { position: relative; padding: 17px; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(160deg, rgba(22, 30, 52, .78), rgba(12, 18, 33, .7)); overflow: hidden; }
.stat::after { content: ""; position: absolute; inset: auto -20px -40px auto; width: 110px; height: 110px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 138, 0, .13), transparent 70%); }
.stat .label { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .9px; }
.stat .value { margin: 7px 0 2px; font-size: 27px; font-weight: 800; letter-spacing: -.8px; }
.stat .hint { color: var(--muted-2); font-size: 11px; }
.stat.green .value { color: var(--green); }
.stat.red .value { color: var(--red); }
.stat.blue .value { color: var(--blue); }
.stat.orange .value { color: var(--accent-2); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 14px; border: 1px solid var(--line-strong); border-radius: 9px; background: rgba(148, 163, 184, .07); color: var(--text); font-weight: 600; font-size: 13px; cursor: pointer; transition: .15s; white-space: nowrap; }
.btn:hover { border-color: rgba(255, 138, 0, .4); background: rgba(255, 138, 0, .08); text-decoration: none; }
.btn svg { width: 15px; height: 15px; }
.btn.primary { border-color: transparent; background: linear-gradient(135deg, var(--accent), #ff6a00); color: #1a0d00; box-shadow: 0 8px 24px rgba(255, 122, 0, .22); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: #fecaca; border-color: rgba(239, 68, 68, .4); background: var(--red-soft); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: rgba(148, 163, 184, .08); }
.btn.sm { padding: 6px 10px; font-size: 12px; border-radius: 7px; }
.btn.xs { padding: 4px 8px; font-size: 11px; border-radius: 6px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.link-btn { border: 0; background: none; color: var(--accent-2); cursor: pointer; padding: 0; font-weight: 600; }
.link-btn:hover { text-decoration: underline; }

/* forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field label { color: var(--muted); font-size: 12px; font-weight: 600; }
.field .hint { color: var(--muted-2); font-size: 11px; }
input, select, textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: rgba(6, 10, 20, .55); outline: none; transition: border-color .15s; }
input:focus, select:focus, textarea:focus { border-color: rgba(255, 138, 0, .55); }
textarea { min-height: 100px; resize: vertical; line-height: 1.55; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; gap: 8px; align-items: flex-start; padding: 8px 0; color: var(--muted); font-size: 12px; }
.check input { margin-top: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border: 1px solid var(--line); border-radius: 30px; background: rgba(148, 163, 184, .06); color: var(--muted); font-size: 11px; font-weight: 600; cursor: pointer; user-select: none; }
.chip.on { border-color: rgba(255, 138, 0, .45); background: var(--accent-soft); color: var(--accent-2); }
.chip input { display: none; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 9px 12px; text-align: left; color: var(--muted-2); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(148, 163, 184, .035); }
td .sub { color: var(--muted-2); font-size: 11px; }
.table-link { color: var(--text); font-weight: 600; }
.table-link:hover { color: var(--accent-2); text-decoration: none; }

/* badges + avatars */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 30px; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; border: 1px solid transparent; white-space: nowrap; }
.badge.gray { background: rgba(148, 163, 184, .1); color: var(--muted); border-color: var(--line); }
.badge.green { background: var(--green-soft); color: #86efac; border-color: rgba(34, 197, 94, .25); }
.badge.red { background: var(--red-soft); color: #fca5a5; border-color: rgba(239, 68, 68, .25); }
.badge.orange { background: var(--accent-soft); color: var(--accent-2); border-color: rgba(255, 138, 0, .28); }
.badge.blue { background: var(--blue-soft); color: #7dd3fc; border-color: rgba(56, 189, 248, .25); }
.badge.violet { background: rgba(167, 139, 250, .13); color: #c4b5fd; border-color: rgba(167, 139, 250, .25); }
.badge.yellow { background: rgba(250, 204, 21, .12); color: #fde68a; border-color: rgba(250, 204, 21, .22); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; flex: 0 0 auto; background: linear-gradient(145deg, #2a3552, #1a2138); border: 1px solid var(--line-strong); font-size: 11px; font-weight: 800; color: var(--muted); overflow: hidden; object-fit: cover; }
.avatar.lg { width: 64px; height: 64px; font-size: 22px; }
.avatar.md { width: 42px; height: 42px; font-size: 15px; }
.user-cell { display: flex; align-items: center; gap: 9px; min-width: 0; }
.user-cell .meta { min-width: 0; }
.user-cell .meta strong { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-cell .meta span { display: block; color: var(--muted-2); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.role-tag { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; }
.role-dot { width: 7px; height: 7px; border-radius: 50%; }

/* lists */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; gap: 11px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item .body { min-width: 0; flex: 1; }
.list-item .body strong { display: block; font-size: 13px; }
.list-item .body p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.list-item .body .meta { margin-top: 4px; color: var(--muted-2); font-size: 11px; }
.empty { padding: 30px 16px; text-align: center; color: var(--muted-2); font-size: 12px; }
.empty strong { display: block; color: var(--muted); font-size: 13px; margin-bottom: 4px; }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tab { padding: 9px 13px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent-2); border-bottom-color: var(--accent); }

/* progress */
.progress { height: 7px; border-radius: 20px; background: rgba(148, 163, 184, .14); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 20px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.progress.green > span { background: linear-gradient(90deg, #16a34a, #4ade80); }

/* charts */
.chart { display: flex; align-items: flex-end; gap: 3px; height: 130px; padding-top: 10px; }
.chart .bar { flex: 1; min-width: 2px; border-radius: 4px 4px 0 0; background: linear-gradient(180deg, rgba(255, 138, 0, .85), rgba(255, 138, 0, .15)); position: relative; }
.chart .bar:hover { filter: brightness(1.2); }
.chart-labels { display: flex; justify-content: space-between; color: var(--muted-2); font-size: 10px; margin-top: 5px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11px; color: var(--muted); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }

/* chat */
.chat-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; height: calc(100vh - 170px); min-height: 460px; background: var(--panel); }
.chat-side { border-right: 1px solid var(--line); overflow-y: auto; background: rgba(8, 12, 23, .5); }
.chat-side-head { padding: 13px 14px; border-bottom: 1px solid var(--line); font-size: 11px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--muted-2); }
.chat-item { display: flex; gap: 9px; align-items: center; width: 100%; padding: 10px 13px; border: 0; background: none; color: var(--muted); text-align: left; cursor: pointer; border-bottom: 1px solid rgba(148, 163, 184, .05); }
.chat-item:hover { background: rgba(148, 163, 184, .06); color: var(--text); }
.chat-item.active { background: rgba(255, 138, 0, .1); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.chat-item .name { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item .dot-badge { min-width: 17px; height: 17px; border-radius: 20px; background: var(--accent); color: #1a0d00; font-size: 9px; font-weight: 800; display: grid; place-items: center; padding: 0 4px; }
.chat-main { display: flex; flex-direction: column; min-width: 0; }
.chat-head { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.chat-head h2 { margin: 0; font-size: 14px; }
.chat-head p { margin: 1px 0 0; color: var(--muted-2); font-size: 11px; }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.msg { display: flex; gap: 9px; align-items: flex-start; }
.msg.own { flex-direction: row-reverse; }
.msg .bubble { max-width: min(72%, 620px); padding: 9px 12px; border: 1px solid var(--line); border-radius: 12px 12px 12px 3px; background: rgba(148, 163, 184, .06); }
.msg.own .bubble { border-radius: 12px 12px 3px 12px; background: rgba(255, 138, 0, .11); border-color: rgba(255, 138, 0, .22); }
.msg .bubble .who { font-size: 11px; font-weight: 700; color: var(--accent-2); margin-bottom: 2px; }
.msg .bubble p { margin: 0; white-space: pre-wrap; word-break: break-word; }
.msg .bubble .time { margin-top: 3px; color: var(--muted-2); font-size: 10px; }
.chat-compose { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.chat-compose textarea { min-height: 40px; max-height: 120px; padding: 9px 11px; }
.chat-compose .btn { align-self: flex-end; }

/* chips/filters */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters input, .filters select { width: auto; min-width: 130px; padding: 7px 10px; font-size: 12px; }
.filters .grow-input { flex: 1; min-width: 180px; }

/* timeline */
.timeline { position: relative; padding-left: 18px; }
.timeline::before { content: ""; position: absolute; left: 4px; top: 6px; bottom: 6px; width: 1px; background: var(--line); }
.timeline-item { position: relative; padding: 0 0 16px 8px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before { content: ""; position: absolute; left: -18px; top: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px rgba(255, 138, 0, .13); }
.timeline-item strong { font-size: 13px; }
.timeline-item p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.timeline-item small { color: var(--muted-2); font-size: 11px; }

/* modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(2, 5, 12, .72); backdrop-filter: blur(5px); display: grid; place-items: center; padding: 20px; z-index: 50; animation: fade .15s ease; }
.modal { width: min(100%, 620px); max-height: 90vh; display: flex; flex-direction: column; border: 1px solid var(--line-strong); border-radius: 18px; background: var(--panel-solid); box-shadow: var(--shadow); animation: pop .16s ease; }
.modal.wide { width: min(100%, 920px); }
.modal.narrow { width: min(100%, 440px); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 17px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 16px; letter-spacing: -.3px; }
.modal-head .sub { margin: 2px 0 0; color: var(--muted-2); font-size: 11px; }
.modal-head .x { margin-left: auto; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.99); opacity: 0; } }

/* toast */
.toast-root { position: fixed; right: 18px; bottom: 18px; z-index: 80; display: flex; flex-direction: column; gap: 8px; max-width: 380px; }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: 12px; background: #111a2e; box-shadow: var(--shadow); animation: slide .18s ease; font-size: 13px; }
.toast.success { border-color: rgba(34, 197, 94, .4); }
.toast.error { border-color: rgba(239, 68, 68, .45); }
.toast .bar { width: 3px; align-self: stretch; border-radius: 4px; background: var(--accent); }
.toast.success .bar { background: var(--green); }
.toast.error .bar { background: var(--red); }
@keyframes slide { from { transform: translateY(10px); opacity: 0; } }

/* misc */
.notice { padding: 12px 14px; border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 9px; background: rgba(255, 138, 0, .05); color: var(--muted); font-size: 12px; }
.notice.red { border-left-color: var(--red); background: var(--red-soft); }
.notice.green { border-left-color: var(--green); background: var(--green-soft); }
.notice.blue { border-left-color: var(--blue); background: var(--blue-soft); }
.prose { color: #cbd5e1; font-size: 14px; line-height: 1.72; }
.prose h2 { color: var(--text); font-size: 17px; margin: 24px 0 8px; letter-spacing: -.3px; }
.prose h3 { color: var(--text); font-size: 15px; margin: 20px 0 6px; }
.prose p { margin: 0 0 12px; }
.prose ul, .prose ol { margin: 0 0 14px; padding-left: 22px; }
.prose li { margin: 4px 0; }
.prose code { padding: 2px 5px; border-radius: 5px; background: rgba(148, 163, 184, .12); color: var(--accent-2); font-size: 12px; }
.prose blockquote { margin: 14px 0; padding: 10px 14px; border-left: 3px solid var(--accent); background: rgba(255, 138, 0, .06); color: var(--muted); border-radius: 0 8px 8px 0; }
.prose strong { color: var(--text); }
.kv { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 8px 12px; font-size: 12px; }
.kv dt { color: var(--muted-2); }
.kv dd { margin: 0; color: var(--text); }
.perm-group { margin-bottom: 14px; }
.perm-group h4 { margin: 0 0 7px; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted-2); }
.perm-item { display: flex; gap: 8px; align-items: flex-start; padding: 5px 0; font-size: 12px; color: var(--muted); }
.perm-item code { color: var(--muted-2); font-size: 10px; }
.profile-hero { display: flex; align-items: center; gap: 18px; padding: 22px; }
.profile-hero .info h1 { margin: 0; font-size: 22px; letter-spacing: -.5px; }
.profile-hero .info p { margin: 3px 0 0; color: var(--muted); }
.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.quick { padding: 13px; border: 1px solid var(--line); border-radius: 12px; background: rgba(148, 163, 184, .04); color: var(--text); font-weight: 600; font-size: 12px; }
.quick:hover { border-color: rgba(255, 138, 0, .35); background: var(--accent-soft); text-decoration: none; }
.quick span { display: block; color: var(--muted-2); font-weight: 400; font-size: 10px; margin-top: 3px; }
.score { display: inline-flex; flex-direction: column; align-items: center; min-width: 42px; padding: 4px 6px; border-radius: 8px; border: 1px solid var(--line); background: rgba(148, 163, 184, .05); font-weight: 800; }
.vote { display: inline-flex; flex-direction: column; gap: 2px; }
.vote button { width: 28px; height: 24px; border: 1px solid var(--line); border-radius: 6px; background: rgba(148, 163, 184, .05); color: var(--muted); cursor: pointer; }
.vote button.on { color: var(--accent-2); border-color: rgba(255, 138, 0, .4); background: var(--accent-soft); }
.answer-option { display: flex; gap: 9px; align-items: flex-start; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; margin-bottom: 7px; cursor: pointer; font-size: 13px; }
.answer-option:hover { border-color: var(--line-strong); }
.answer-option.on { border-color: rgba(255, 138, 0, .45); background: var(--accent-soft); }
.answer-option input { margin-top: 2px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.calendar-day { min-height: 96px; padding: 7px; border: 1px solid var(--line); border-radius: 9px; background: rgba(148, 163, 184, .03); }
.calendar-day.out { opacity: .35; }
.calendar-day .d { color: var(--muted-2); font-size: 10px; font-weight: 700; margin-bottom: 5px; }
.calendar-event { display: block; margin-bottom: 3px; padding: 3px 5px; border-radius: 5px; background: var(--accent-soft); color: var(--accent-2); font-size: 10px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calendar-head { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin-bottom: 6px; color: var(--muted-2); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; text-align: center; }
.drop-zone { border: 1px dashed var(--line-strong); border-radius: 12px; padding: 20px; text-align: center; color: var(--muted-2); cursor: pointer; }
.drop-zone:hover { border-color: var(--accent); color: var(--muted); }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0 14px; }
.admin-section { margin-bottom: 22px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11px; }

@media (max-width: 1100px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.side, .grid.side-right { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chat-layout { grid-template-columns: 200px minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 60px rgba(0, 0, 0, .6); }
  .main { margin-left: 0; }
  .mobile-menu { display: grid; }
  .view { padding: 18px 14px; }
  .topbar { padding: 11px 14px; }
  .topbar .search { max-width: none; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .page-head .actions { margin-left: 0; width: 100%; }
  .calendar-day { min-height: 66px; }
  .calendar-event { font-size: 9px; }
  .msg .bubble { max-width: 86%; }
  .profile-hero { flex-direction: column; align-items: flex-start; }
}
