:root {
  color-scheme: dark;
  font-family: Inter, "SF Pro Display", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --bg: #0b0b0d;
  --surface: #141416;
  --surface-2: #1a1a1d;
  --surface-3: #202024;
  --line: #2b2b31;
  --line-soft: #222227;
  --text: #f2f2f5;
  --muted: #96969f;
  --purple: #7667ef;
  --purple-hover: #897bf7;
  --green: #55cf81;
  --red: #ef7777;
  --warning: #e7b75d;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 980px; min-height: 100vh; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 8px; color: #9d91ff; font-size: 11px; font-weight: 700; letter-spacing: .15em; }

.login-layout { min-height: 100vh; display: grid; place-items: center; padding: 48px; background: radial-gradient(circle at 50% 20%, #211d3a 0, #101014 36%, #09090b 72%); }
.login-card { width: 440px; padding: 42px; border: 1px solid var(--line); border-radius: 22px; background: rgba(20,20,23,.96); box-shadow: 0 30px 90px rgba(0,0,0,.5); }
.login-card h1 { margin: 4px 0 8px; font-size: 30px; }
.login-card > .muted { margin: 0 0 28px; line-height: 1.6; }
.brand-mark { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 24px; border-radius: 14px; background: linear-gradient(145deg, #8d7cff, #5f51d8); color: white; font-size: 25px; font-weight: 800; box-shadow: 0 10px 28px rgba(118,103,239,.28); }
.brand-mark.small { width: 34px; height: 34px; margin: 0; border-radius: 10px; font-size: 18px; }

.stack-form { display: grid; gap: 18px; }
label { display: grid; gap: 8px; color: #c6c6cd; font-size: 13px; font-weight: 600; }
input, select { width: 100%; min-height: 42px; padding: 0 13px; border: 1px solid var(--line); border-radius: 9px; outline: none; background: #0f0f11; color: var(--text); transition: border-color .16s, box-shadow .16s; }
input:focus, select:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(118,103,239,.14); }
button { min-height: 38px; padding: 0 16px; border: 1px solid transparent; border-radius: 9px; color: var(--text); background: transparent; font-weight: 650; }
button:disabled { cursor: not-allowed; opacity: .45; }
.primary { background: var(--purple); }
.primary:hover:not(:disabled) { background: var(--purple-hover); }
.secondary { border-color: var(--line); background: var(--surface-2); }
.secondary:hover:not(:disabled), .ghost:hover:not(:disabled) { background: var(--surface-3); }
.wide { width: 100%; min-height: 44px; margin-top: 4px; }
.danger-text { color: #f29a9a; }
.form-error { min-height: 20px; margin: 16px 0 0; color: #f29a9a; font-size: 13px; }

.app-shell { min-height: 100vh; }
.topbar { position: sticky; z-index: 5; top: 0; height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; border-bottom: 1px solid var(--line-soft); background: rgba(13,13,15,.95); backdrop-filter: blur(18px); }
.brand-row, .topbar-actions { display: flex; align-items: center; gap: 12px; }
.brand-row > div:last-child { display: grid; gap: 2px; }
.brand-row strong { font-size: 14px; }
.brand-row span, #current-user { color: var(--muted); font-size: 12px; }
.service-state { display: flex; align-items: center; gap: 7px; color: #b7b7bd; font-size: 12px; }
.service-state i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(85,207,129,.1); }
.topbar-actions .ghost { min-height: 32px; padding: 0 10px; font-size: 12px; }

.workspace { display: grid; grid-template-columns: 220px minmax(0,1fr); min-height: calc(100vh - 64px); }
.sidebar { position: sticky; top: 64px; height: calc(100vh - 64px); display: flex; flex-direction: column; padding: 28px 16px 20px; border-right: 1px solid var(--line-soft); background: #101012; }
.sidebar-label { margin: 0 10px 10px; color: #686870; font-size: 11px; font-weight: 700; letter-spacing: .08em; }
.nav-item { width: 100%; text-align: left; color: #bdbdc4; }
.nav-item.active { background: #25242a; color: white; }
.sidebar-footer { display: grid; gap: 5px; margin-top: auto; padding: 14px 10px 0; border-top: 1px solid var(--line-soft); color: #777780; font-size: 11px; }
.sidebar-footer small { color: #55555d; }

.content { width: min(1180px, calc(100vw - 260px)); margin: 0 auto; padding: 44px 32px 72px; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.page-heading h1 { margin: 0 0 8px; font-size: 28px; letter-spacing: -.02em; }
.page-heading p:last-child { margin: 0; font-size: 13px; }
.summary-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; margin-bottom: 20px; }
.summary-card { display: grid; gap: 7px; min-height: 122px; padding: 20px; border: 1px solid var(--line-soft); border-radius: 14px; background: var(--surface); }
.summary-card span { color: var(--muted); font-size: 12px; }
.summary-card strong { font-size: 30px; letter-spacing: -.03em; }
.summary-card small { color: #65656e; }

.panel { margin-top: 18px; border: 1px solid var(--line-soft); border-radius: 14px; background: var(--surface); overflow: hidden; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; min-height: 76px; padding: 18px 22px; border-bottom: 1px solid var(--line-soft); }
.panel-heading h2 { margin: 0 0 5px; font-size: 16px; }
.panel-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.create-grid { display: grid; grid-template-columns: 1fr 1.25fr 150px auto; align-items: end; gap: 14px; padding: 20px 22px 24px; }
.create-grid button { min-width: 112px; min-height: 42px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { height: 66px; padding: 0 18px; border-bottom: 1px solid var(--line-soft); text-align: left; font-size: 13px; }
th { height: 42px; color: #74747d; font-size: 11px; font-weight: 700; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255,255,255,.018); }
td select { width: 116px; min-height: 34px; }
.user-cell { display: grid; gap: 4px; }
.user-cell strong { font-size: 13px; }
.user-cell small { color: #65656e; font-family: ui-monospace, monospace; }
.badge { display: inline-flex; align-items: center; width: fit-content; min-height: 25px; padding: 0 9px; border-radius: 999px; background: rgba(85,207,129,.1); color: #7ddd9d; font-size: 11px; font-weight: 700; }
.badge.disabled { background: rgba(239,119,119,.1); color: #ef9999; }
.actions-heading { text-align: right; }
.row-actions { display: flex; justify-content: flex-end; gap: 6px; }
.row-actions button { min-height: 32px; padding: 0 10px; font-size: 11px; }
.empty { height: 100px; color: var(--muted); text-align: center; }

dialog { width: 460px; padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-2); color: var(--text); box-shadow: 0 30px 100px rgba(0,0,0,.65); }
dialog::backdrop { background: rgba(0,0,0,.7); backdrop-filter: blur(3px); }
.dialog-card { display: grid; gap: 17px; padding: 24px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.dialog-heading h2 { margin: 0 0 6px; font-size: 18px; }
.dialog-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.icon-button { width: 32px; min-height: 32px; padding: 0; color: var(--muted); font-size: 22px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 5px; }
.toast { position: fixed; z-index: 20; right: 24px; bottom: 24px; max-width: 420px; padding: 13px 16px; border: 1px solid var(--line); border-radius: 10px; background: #25252a; color: white; opacity: 0; transform: translateY(10px); pointer-events: none; transition: .2s; box-shadow: 0 15px 45px rgba(0,0,0,.4); font-size: 13px; }
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { border-color: rgba(239,119,119,.45); background: #352123; color: #ffb2b2; }

@media (max-width: 1120px) {
  .create-grid { grid-template-columns: 1fr 1fr; }
  .create-grid button { align-self: end; }
}

.ai-settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px 24px; padding: 24px; max-width: 920px; }
.ai-settings-grid small, .stack-form small { color: var(--muted); font-size: 12px; line-height: 1.5; font-weight: 400; }
.ai-settings-grid > label { align-content: start; }
.ai-settings-grid input:not([type=checkbox]) { height: 42px; min-height: 42px; }
.full-field { grid-column: 1 / -1; }
.check-field { display: flex; align-items: center; gap: 10px; min-height: 34px; }
.check-field input[type=checkbox] { width: 17px; min-height: 17px; height: 17px; accent-color: var(--accent, #8777f6); margin: 0; }
.ai-form-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ai-note { padding: 22px; }
.ai-note h2 { margin: 0; font-size: 16px; }
.ai-note p { color: var(--muted); font-size: 13px; line-height: 1.8; }
.panel > .stack-form { padding: 24px; max-width: 860px; }
.mcp-projects { border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px; }
.mcp-projects legend { color: var(--muted); font-size: 12px; padding: 0 6px; }
#mcp-projects-list { max-height: 220px; overflow-y: auto; }
.token-list { padding: 10px 22px; color: var(--muted); }
.token-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 0; border-bottom: 1px solid var(--line-soft); }
.token-row:last-child { border-bottom: 0; }
.token-row div { display: grid; gap: 6px; }.token-row strong { color: var(--text); }
@media (max-width: 760px) { .ai-settings-grid { grid-template-columns: 1fr; } .sidebar { width: 150px; } .content { padding: 20px; } }
