:root {
  color-scheme: light;
  --ink: #17191f;
  --ink-soft: #353943;
  --muted: #737985;
  --muted-strong: #545a66;
  --line: #e5e7eb;
  --line-strong: #d5d8de;
  --surface: #ffffff;
  --surface-soft: #f7f8fa;
  --canvas: #f3f4f6;
  --accent: #2563eb;
  --accent-deep: #1d4ed8;
  --accent-soft: #eef4ff;
  --success: #16a36a;
  --success-soft: #eaf8f1;
  --amber: #a15c07;
  --amber-soft: #fff6e7;
  --red: #b33f49;
  --red-soft: #fff0f1;
  --blue: #2563eb;
  --blue-soft: #edf4ff;
  --sidebar: #ffffff;
  --sidebar-hover: #f5f6f8;
  --sidebar-active: #edf3ff;
  --sidebar-ink: #17191f;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .03), 0 8px 24px rgba(15, 23, 42, .035);
  --shadow-lg: 0 22px 60px rgba(15, 23, 42, .16);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; background: var(--canvas); }
body { margin: 0; color: var(--ink); background: var(--canvas); font-size: 14px; letter-spacing: 0; }
button, input, textarea, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid rgba(37, 99, 235, .18); outline-offset: 2px; }
svg.lucide { width: 18px; height: 18px; stroke-width: 1.9; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 232px minmax(560px, 1fr) 354px; }
.sidebar { background: var(--sidebar); color: var(--sidebar-ink); padding: 20px 12px 14px; display: flex; flex-direction: column; min-height: 100vh; border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 10px 30px; }
.brand-mark, .assistant-avatar, .login-mark { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 8px; background: #17191f; color: #ffffff; font-weight: 850; box-shadow: none; }
.brand strong, .brand span, .assistant-head strong, .assistant-head span { display: block; }
.brand strong { font-size: 16px; line-height: 1.2; }
.brand span { margin-top: 4px; color: var(--muted); font-size: 12px; }
.nav { display: grid; gap: 4px; }
.nav-label { padding: 0 12px 7px; color: #9aa0aa; font-size: 10px; font-weight: 760; text-transform: uppercase; }
.nav-label-secondary { margin-top: 16px; }
.nav button { position: relative; border: 0; background: transparent; color: #5f6570; text-align: left; padding: 10px 11px; border-radius: 7px; display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; align-items: center; gap: 10px; min-height: 44px; font-weight: 650; }
.nav button:hover { background: var(--sidebar-hover); color: var(--ink); }
.nav button.active { background: var(--sidebar-active); color: #1d4ed8; box-shadow: none; }
.nav button > span { overflow: hidden; text-overflow: ellipsis; }
.nav button svg { color: #969ca6; }
.nav button.active svg { color: #2563eb; }
.nav button:hover svg { color: #5f6570; }
.nav button b { min-width: 21px; min-height: 21px; padding: 3px 6px; border-radius: 11px; background: var(--amber-soft); color: var(--amber); font-size: 11px; line-height: 15px; text-align: center; }
.nav button b:empty { display: none; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding: 15px 8px 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 11px; }
.account-summary { display: flex; align-items: center; gap: 8px; min-width: 0; }
.account-summary span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-dot, .status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px rgba(22,163,106,.12); }

.workspace { min-width: 0; }
.topbar { min-height: 86px; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); padding: 16px 26px; display: flex; align-items: center; gap: 14px; justify-content: space-between; position: sticky; top: 0; z-index: 5; backdrop-filter: blur(16px); }
.topbar p { margin: 0 0 3px; color: var(--blue); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.topbar h1 { margin: 0; font-size: 25px; line-height: 1.16; }
.top-actions { display: flex; align-items: center; gap: 11px; color: var(--muted); font-size: 11px; }
.icon-command { width: 38px; height: 38px; flex: 0 0 38px; border: 1px solid var(--line); border-radius: 7px; color: var(--ink-soft); background: #fff; display: inline-grid; place-items: center; padding: 0; }
.icon-command:hover { background: var(--surface-soft); border-color: var(--line-strong); }
.icon-command-dark { color: #69707c; background: #fff; border-color: var(--line); }
.icon-command-dark:hover { background: var(--sidebar-hover); border-color: var(--line-strong); }
.content { padding: 24px 26px 44px; max-width: 1460px; margin: 0 auto; }

.assistant-panel { background: #ffffff; border-left: 1px solid var(--line); display: flex; flex-direction: column; height: 100vh; position: sticky; top: 0; }
.assistant-head { min-height: 86px; padding: 16px 18px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 11px; align-items: center; background: #fff; }
.assistant-head strong { font-size: 14px; }
.assistant-head span { color: var(--muted); font-size: 10px; margin-top: 4px; }
.assistant-head .status-dot { width: 6px; height: 6px; margin-right: 6px; vertical-align: 1px; }
.assistant-conversation { flex: 1; overflow: auto; padding: 18px; display: flex; flex-direction: column; gap: 12px; background: #fafafa; }
.assistant-message { max-width: 94%; align-self: flex-start; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 12px 13px; line-height: 1.52; white-space: pre-wrap; box-shadow: var(--shadow-sm); }
.assistant-message.user { align-self: flex-end; background: #20242c; border-color: #20242c; color: #fff; margin-left: 28px; }
.message-author { display: block; margin-bottom: 4px; color: var(--blue); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.ask-form { padding: 14px; border-top: 1px solid var(--line); background: #fff; }
.quick-prompts { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 9px; scrollbar-width: none; }
.quick-prompts::-webkit-scrollbar { display: none; }
.quick-prompts button { flex: 0 0 auto; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-soft); color: var(--muted-strong); padding: 6px 8px; font-size: 10px; font-weight: 650; }
.quick-prompts button:hover { border-color: #b9cdf8; color: var(--accent-deep); background: var(--accent-soft); }
.composer { position: relative; }
.ask-form textarea { width: 100%; resize: none; min-height: 88px; max-height: 180px; padding: 11px 48px 11px 12px; border: 1px solid var(--line-strong); border-radius: 8px; color: var(--ink); background: #fff; line-height: 1.45; }
.ask-form textarea:focus { border-color: var(--accent); }
.send-command { position: absolute; right: 8px; bottom: 9px; width: 32px; height: 32px; border: 0; border-radius: 7px; display: grid; place-items: center; padding: 0; background: var(--accent); color: #fff; }
.send-command:hover { background: var(--accent-deep); }
.ask-form button:disabled, button:disabled { opacity: .5; cursor: default; }

.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(116px, 1fr)); gap: 10px; margin-bottom: 24px; }
.metric { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 15px; min-height: 105px; box-shadow: var(--shadow-sm); overflow: hidden; }
.metric::after { display: none; }
.metric-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); }
.metric-head span { font-size: 11px; line-height: 1.25; }
.metric-head svg { width: 16px; height: 16px; color: #9aa0aa; }
.metric strong { display: block; font-size: 29px; line-height: 1; margin-top: 18px; }
.metric.attention strong { color: var(--amber); }
.section { margin-top: 24px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 10px; margin-bottom: 11px; }
.section-heading h2 { margin: 0; font-size: 17px; }
.section-heading p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.split-grid { display: grid; grid-template-columns: minmax(0, 1.14fr) minmax(280px, .86fr); gap: 18px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; box-shadow: var(--shadow-sm); }
.empty { padding: 42px 22px; text-align: center; color: var(--muted); }
.empty-icon { width: 36px; height: 36px; margin: 0 auto 10px; border-radius: 8px; display: grid; place-items: center; color: var(--accent); background: var(--accent-soft); }
.empty-icon svg { width: 17px; height: 17px; }
.empty strong { color: var(--ink-soft); }
.empty p { margin: 6px 0 0; line-height: 1.45; }
.list-row { width: 100%; border: 0; border-bottom: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 13px 14px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; text-align: left; align-items: center; }
.list-row:last-child { border-bottom: 0; }
button.list-row:hover { background: var(--surface-soft); }
.list-row-main { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 11px; align-items: start; }
.row-icon { width: 32px; height: 32px; border-radius: 7px; display: grid; place-items: center; color: #5f6570; background: #f0f1f3; }
.row-icon.blue { color: var(--blue); background: var(--blue-soft); }
.row-icon.amber { color: var(--amber); background: var(--amber-soft); }
.row-icon.red { color: var(--red); background: var(--red-soft); }
.row-icon svg { width: 16px; height: 16px; }
.list-row strong, .list-row span { overflow-wrap: anywhere; }
.list-row strong { display: block; font-size: 13px; line-height: 1.28; }
.list-row .sub { color: var(--muted); font-size: 11px; margin-top: 4px; line-height: 1.42; }
.list-row time { color: var(--muted); font-size: 10px; white-space: nowrap; align-self: center; }
.tag { display: inline-flex; align-items: center; width: fit-content; padding: 3px 7px; border-radius: 4px; color: var(--blue); background: var(--blue-soft); font-size: 10px; font-weight: 750; }
.tag.green { color: var(--success); background: var(--success-soft); }
.tag.amber { color: var(--amber); background: var(--amber-soft); }
.tag.red { color: var(--red); background: var(--red-soft); }
.row-copy .tag { margin-bottom: 5px; }

.toolbar { display: grid; grid-template-columns: minmax(180px, 1fr) auto auto; gap: 8px; margin-bottom: 13px; }
.toolbar input, .toolbar select { border: 1px solid var(--line-strong); border-radius: 7px; background: #fff; padding: 10px 11px; color: var(--ink); min-width: 0; }
.toolbar input[type="search"] { padding-left: 13px; }
.primary-button, .login-state button { border: 0; border-radius: 7px; background: var(--accent); color: #fff; font-weight: 750; padding: 10px 14px; }
.primary-button:hover, .login-state button:hover { background: var(--accent-deep); }
.detail-drawer { margin-top: 0; }
.detail-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px; border-bottom: 1px solid var(--line); background: var(--surface-soft); }
.detail-head .sub { color: var(--muted); font-size: 11px; margin-top: 3px; }
.message-list { padding: 14px; max-height: 60vh; overflow: auto; display: flex; flex-direction: column; gap: 8px; background: #fafafa; }
.message { max-width: 82%; border-radius: 8px; padding: 10px 11px; background: #eff1f4; line-height: 1.45; }
.message.outgoing { align-self: flex-end; background: var(--blue-soft); }
.message small { display: block; margin-top: 6px; color: var(--muted); font-size: 10px; }
.switch { position: relative; width: 42px; height: 24px; display: inline-block; flex: 0 0 42px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i { position: absolute; inset: 0; background: #c9cdd4; border-radius: 12px; transition: .2s; }
.switch i::after { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.14); }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(18px); }

.approval-card { padding: 16px; border-bottom: 1px solid var(--line); }
.approval-card:last-child { border-bottom: 0; }
.approval-card h3 { margin: 7px 0 8px; font-size: 14px; }
.approval-card p { margin: 5px 0; line-height: 1.48; }
.approval-actions { display: flex; gap: 8px; margin-top: 13px; }
.approval-actions button { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line-strong); border-radius: 7px; padding: 8px 12px; background: #fff; color: var(--ink-soft); font-weight: 700; }
.approval-actions button:hover { background: var(--surface-soft); }
.approval-actions button.send { background: var(--accent); color: #fff; border-color: var(--accent); }
.approval-actions button.send:hover { background: var(--accent-deep); }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 11px 13px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted-strong); font-size: 10px; font-weight: 800; background: var(--surface-soft); position: sticky; top: 0; text-transform: uppercase; }
td { font-size: 12px; }
tbody tr:hover { background: #f8f9fb; }
.bar { height: 7px; border-radius: 4px; background: #e7e9ed; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); }

.startup-state, .login-state { min-height: 100vh; place-content: center; padding: 24px; margin: auto; }
.startup-state { text-align: center; max-width: 470px; }
.startup-state .login-mark { margin: 0 auto 18px; width: 52px; height: 52px; font-size: 22px; }
.startup-state h1 { font-size: 28px; margin: 0 0 10px; }
.startup-state p { color: var(--muted); }
.login-state { max-width: none; background: #f1f2f5; }
.login-card { width: min(100%, 440px); margin: auto; padding: 30px; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-lg); }
.login-brand { display: flex; align-items: center; gap: 13px; margin-bottom: 20px; }
.login-brand .login-mark { width: 48px; height: 48px; font-size: 19px; }
.login-brand h1 { font-size: 25px; margin: 2px 0 0; }
.login-brand span { color: var(--accent); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.login-card > p { margin: 0; color: var(--muted); line-height: 1.55; }
.password-login-form { text-align: left; margin-top: 20px; }
.password-login-form label { display: grid; gap: 7px; margin-top: 12px; font-size: 12px; font-weight: 750; color: var(--muted-strong); }
.password-login-form input { width: 100%; border: 1px solid var(--line-strong); border-radius: 7px; background: #fff; color: var(--ink); padding: 11px 12px; }
.password-login-form input:focus { border-color: var(--accent); }
.password-login-form button { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 8px; }
.login-error { min-height: 20px; margin: 10px 0 0; color: var(--red); font-size: 12px; }
.login-divider { display: flex; align-items: center; gap: 12px; margin: 23px 0 14px; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.login-divider::before, .login-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.login-state a { color: var(--accent-deep); }
.login-state .secondary-button { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 15px; background: #fff; color: var(--ink-soft); border: 1px solid var(--line-strong); }
.login-state .secondary-button:hover { background: var(--surface-soft); }
.muted { color: var(--muted); }
.toast { position: fixed; right: 18px; bottom: 18px; max-width: 360px; padding: 11px 14px; border-radius: 7px; background: var(--ink); color: #fff; box-shadow: var(--shadow-lg); transform: translateY(90px); opacity: 0; transition: .2s; z-index: 20; }
.toast.show { transform: translateY(0); opacity: 1; }
.loading { min-height: 260px; display: grid; place-items: center; color: var(--muted); }
.loading::before { content: ""; width: 24px; height: 24px; margin-bottom: -90px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.mobile-only, .assistant-fab, .scrim { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1260px) {
  .app-shell { grid-template-columns: 218px minmax(500px, 1fr) 318px; }
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .mobile-only { display: inline-grid; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 258px; z-index: 15; transform: translateX(-100%); transition: .22s; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .assistant-panel { position: fixed; inset: 0 0 0 auto; width: min(94vw, 400px); z-index: 16; transform: translateX(100%); transition: .22s; box-shadow: var(--shadow-lg); }
  .assistant-panel.open { transform: translateX(0); }
  .assistant-fab { position: fixed; right: 18px; bottom: 18px; z-index: 10; width: 48px; height: 48px; border: 0; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; box-shadow: var(--shadow-lg); }
  .scrim { position: fixed; inset: 0; z-index: 14; background: rgba(17,24,39,.38); }
  .scrim.open { display: block; }
  .topbar { padding: 14px 18px; }
  .content { padding: 18px 16px 82px; }
}

@media (max-width: 660px) {
  .topbar { min-height: 76px; }
  .topbar h1 { font-size: 21px; }
  .top-actions span { display: none; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric { min-height: 94px; }
  .metric strong { font-size: 25px; margin-top: 15px; }
  .split-grid { grid-template-columns: 1fr; }
  .chat-layout { gap: 12px; }
  .toolbar { grid-template-columns: 1fr 1fr; }
  .toolbar input { grid-column: 1 / -1; }
  th:nth-child(n+4), td:nth-child(n+4) { display: none; }
  .list-row { padding: 11px; gap: 8px; }
  .list-row-main { grid-template-columns: 28px minmax(0, 1fr); gap: 9px; }
  .row-icon { width: 28px; height: 28px; }
  .approval-actions { flex-direction: column; }
  .approval-actions button { justify-content: center; }
  .login-state { padding: 14px; }
  .login-card { padding: 24px 20px; }
}

@media (max-width: 400px) {
  .metric-grid { grid-template-columns: 1fr; }
  .metric { min-height: 82px; }
  .metric strong { margin-top: 12px; }
  .section-heading { align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
