:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-2: #eef3f8;
  --ink: #14212f;
  --muted: #617287;
  --line: #d8e1ea;
  --teal: #147d80;
  --teal-2: #0f6467;
  --gold: #b7791f;
  --red: #c2413b;
  --green: #23845f;
  --blue: #2f6fab;
  --shadow: 0 18px 45px rgba(30, 45, 62, .13);
  --radius: 8px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
.boot { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.boot-panel { width: min(460px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); }
.boot-panel h1 { margin: 18px 0 8px; font-size: 26px; }
.boot-panel p { margin: 0; color: var(--muted); line-height: 1.6; }
.mark { width: 52px; height: 52px; display: grid; place-items: center; color: #fff; background: var(--teal); border-radius: var(--radius); font-weight: 800; }

.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 520px) 1fr; background: #10202c; color: #fff; }
.auth-panel { padding: 44px; display: flex; flex-direction: column; justify-content: center; }
.auth-visual { position: relative; overflow: hidden; background: linear-gradient(145deg, #173142, #0d1a24); border-left: 1px solid rgba(255,255,255,.12); }
.auth-visual svg { position: absolute; inset: 10% 8%; width: 84%; height: 80%; opacity: .9; }
.auth-card { background: #fff; color: var(--ink); border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow); }
.auth-card h1 { margin: 0 0 8px; font-size: 28px; }
.auth-card p { margin: 0 0 22px; color: var(--muted); line-height: 1.65; }
.auth-note { margin-top: 16px; color: #b6c4d2; line-height: 1.7; font-size: 14px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 260px 1fr; }
.sidebar { background: #10202c; color: #dbe7ef; padding: 22px 16px; display: flex; flex-direction: column; gap: 20px; }
.brand { display: flex; gap: 12px; align-items: center; padding: 0 6px 12px; }
.brand-title { font-size: 16px; font-weight: 800; color: #fff; }
.brand-sub { font-size: 12px; color: #9fb2c2; margin-top: 2px; }
.nav { display: grid; gap: 6px; }
.nav button { height: 42px; display: flex; align-items: center; gap: 10px; border: 0; border-radius: var(--radius); padding: 0 12px; color: #c8d6e0; background: transparent; text-align: left; }
.nav button:hover, .nav button.active { color: #fff; background: rgba(255,255,255,.1); }
.nav button.disabled { color: #718393; cursor: not-allowed; }
.sidebar-foot { margin-top: auto; padding: 12px; border: 1px solid rgba(255,255,255,.12); border-radius: var(--radius); color: #bfd0dc; font-size: 12px; line-height: 1.6; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { min-height: 72px; display: flex; gap: 16px; align-items: center; justify-content: space-between; padding: 14px 22px; background: rgba(255,255,255,.86); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 8; }
.selectors { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.content { padding: 22px; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-head h2 { margin: 0 0 6px; font-size: 26px; }
.section-head p { margin: 0; color: var(--muted); line-height: 1.6; }

.grid { display: grid; gap: 14px; }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: 0 8px 22px rgba(30,45,62,.06); }
.metric { min-height: 96px; }
.metric .label { color: var(--muted); font-size: 13px; }
.metric .value { margin-top: 10px; font-size: 30px; font-weight: 800; }
.metric .hint { margin-top: 5px; color: var(--muted); font-size: 12px; }

.account-layout { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; gap: 16px; align-items: start; margin-top: 16px; }
.account-form-card { position: sticky; top: 94px; }
.account-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.account-card { min-height: 246px; display: flex; flex-direction: column; gap: 14px; }
.account-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.account-title { min-width: 0; }
.account-title h3 { margin: 0 0 6px; font-size: 18px; line-height: 1.25; word-break: break-word; }
.account-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.account-note { min-height: 44px; color: #405366; line-height: 1.55; word-break: break-word; }
.account-card-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.account-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.capacity-box { width: 178px; flex: 0 0 auto; border: 1px solid var(--line); border-radius: var(--radius); padding: 9px; background: #f8fafc; }
.capacity-box.has-error { border-color: #edc6c3; background: #fff3f2; }
.capacity-main { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.capacity-label { color: var(--muted); font-size: 12px; line-height: 1; }
.capacity-value { margin-top: 5px; font-family: var(--mono); font-size: 18px; font-weight: 800; color: var(--ink); white-space: nowrap; }
.capacity-actions { display: flex; gap: 5px; }
.capacity-actions .btn.icon { width: 30px; min-height: 30px; }
.capacity-state { margin-top: 7px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.capacity-error { color: #7b2520; line-height: 1.5; font-size: 13px; word-break: break-word; }
.capacity-detail-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.capacity-detail-summary strong { display: block; margin-top: 4px; font-family: var(--mono); font-size: 24px; }
.capacity-table table { min-width: 640px; }
.capacity-ratio { font-family: var(--mono); font-size: 16px; font-weight: 800; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 16px 0; }
.table-wrap { overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; min-width: 980px; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: #516376; font-size: 12px; text-transform: uppercase; background: #f8fafc; position: sticky; top: 0; z-index: 1; }
td { font-size: 14px; }
tr:last-child td { border-bottom: 0; }
.mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--muted); }
.strong { font-weight: 750; }
.nowrap { white-space: nowrap; }
.tagline { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; border: 1px solid var(--line); border-radius: 999px; padding: 3px 8px; background: #f8fafc; color: #405366; font-size: 12px; }
.status { border-radius: 999px; padding: 4px 9px; font-size: 12px; font-weight: 750; }
.status.running { background: rgba(35,132,95,.12); color: var(--green); }
.status.stopped { background: rgba(194,65,59,.11); color: var(--red); }
.status.pending, .status.stopping { background: rgba(183,121,31,.14); color: var(--gold); }
.status.terminated { background: #e8edf3; color: #5f6f80; }

.btn { min-height: 36px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); border-radius: var(--radius); padding: 0 12px; background: #fff; color: var(--ink); text-decoration: none; }
.btn:hover { border-color: #b8c6d3; background: #f8fafc; }
.btn.primary { background: var(--teal); color: #fff; border-color: var(--teal); }
.btn.primary:hover { background: var(--teal-2); }
.btn.danger { color: #fff; background: var(--red); border-color: var(--red); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 30px; padding: 0 9px; font-size: 12px; }
.btn.icon { width: 36px; padding: 0; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.icon-svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }

.field { display: grid; gap: 7px; }
.field label { color: #405366; font-size: 13px; font-weight: 700; }
.field input, .field select, .field textarea { width: 100%; min-height: 38px; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; background: #fff; color: var(--ink); }
.field textarea { min-height: 86px; resize: vertical; }
.field small { color: var(--muted); line-height: 1.55; }
.option-detail { min-height: 34px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border: 1px solid #dfe7ef; background: #f7fafc; border-radius: var(--radius); color: #405366; font-size: 13px; }
.option-detail strong { color: var(--ink); font-weight: 800; }
.option-detail span { text-align: right; overflow-wrap: anywhere; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.checkline { display: flex; gap: 12px; flex-wrap: wrap; }
.checkline label { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: #405366; }

.notice { padding: 12px 14px; border: 1px solid #d7c49e; background: #fff8ea; color: #6d4b12; border-radius: var(--radius); line-height: 1.6; }
.errors { display: grid; gap: 8px; margin: 12px 0; }
.error-item { border: 1px solid #edc6c3; background: #fff3f2; color: #7b2520; border-radius: var(--radius); padding: 10px 12px; font-size: 13px; line-height: 1.5; }
.empty { padding: 34px; text-align: center; color: var(--muted); background: var(--panel); border: 1px dashed #bdc9d5; border-radius: var(--radius); }

.drawer-backdrop, .modal-backdrop { position: fixed; inset: 0; background: rgba(10,20,30,.36); z-index: 20; }
.drawer { position: fixed; top: 0; right: 0; z-index: 21; width: min(680px, 100%); height: 100vh; background: #fff; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.drawer-head, .modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.drawer-body { padding: 18px 20px; overflow: auto; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.detail-item { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; background: #fbfdff; }
.detail-item .k { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.detail-item .v { word-break: break-word; }
.modal { position: fixed; top: 5vh; left: 50%; transform: translateX(-50%); z-index: 22; width: min(760px, calc(100% - 26px)); max-height: 90vh; overflow: auto; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); }
.modal-body { padding: 18px 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--line); }

.toast-stack { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 10px; z-index: 40; width: min(420px, calc(100% - 36px)); }
.toast { padding: 12px 14px; border-radius: var(--radius); color: #fff; background: #24384a; box-shadow: var(--shadow); line-height: 1.5; }
.toast.error { background: var(--red); }
.toast.ok { background: var(--green); }

@media (max-width: 980px) {
  .auth-shell, .app-shell { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
  .sidebar { position: sticky; top: 0; z-index: 12; padding: 12px; }
  .brand { padding-bottom: 4px; }
  .nav { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .nav button { justify-content: center; padding: 0 8px; }
  .nav button span.label { display: none; }
  .sidebar-foot { display: none; }
  .topbar { position: static; align-items: flex-start; flex-direction: column; }
  .grid.cols-4, .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .account-layout { grid-template-columns: 1fr; }
  .account-form-card { position: static; }
}

@media (max-width: 640px) {
  .content, .auth-panel { padding: 16px; }
  .section-head { flex-direction: column; }
  .grid.cols-4, .grid.cols-3, .form-grid, .detail-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .selectors, .toolbar { width: 100%; }
  .selectors .field, .toolbar .field, .toolbar input, .toolbar select, .toolbar button { flex: 1 1 100%; }
  .nav { grid-template-columns: repeat(4, 1fr); }
  .auth-card { padding: 20px; }
  .account-card-grid { grid-template-columns: 1fr; }
  .account-card-top { flex-direction: column; }
  .capacity-box { width: 100%; }
  .account-card-foot { align-items: stretch; }
  .account-actions, .account-card-foot .btn.primary { width: 100%; }
  .account-actions .btn { flex: 1 1 0; }
}
