:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-muted: #eef1ef;
  --ink: #17201c;
  --muted: #66716b;
  --line: #d8dfdb;
  --accent: #0e766e;
  --accent-strong: #075b55;
  --warm: #c96b2c;
  --danger: #a53b3b;
  --sidebar: #1d2823;
  --sidebar-muted: #a9b6b0;
  --shadow: 0 12px 32px rgba(22, 34, 28, 0.12);
  font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); }
button, input, textarea, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 20px 14px; color: white; background: var(--sidebar); display: flex; flex-direction: column; }
.brand-block { display: flex; gap: 11px; align-items: center; padding: 4px 8px 22px; border-bottom: 1px solid rgba(255,255,255,.12); }
.brand-block strong, .brand-block span { display: block; }
.brand-block span { margin-top: 2px; color: var(--sidebar-muted); font-size: 12px; }
.brand-mark { display: grid !important; place-items: center; width: 38px; height: 38px; border-radius: 6px; background: var(--accent); color: white !important; font-weight: 750; font-size: 14px !important; }
nav { display: grid; gap: 3px; margin-top: 18px; }
.nav-item { width: 100%; min-height: 38px; padding: 0 12px; border: 0; border-radius: 5px; color: var(--sidebar-muted); background: transparent; text-align: left; }
.nav-item:hover, .nav-item.active { color: white; background: rgba(255,255,255,.09); }
.nav-item.active { box-shadow: inset 3px 0 0 var(--accent); }
.sidebar-footer { margin-top: auto; display: grid; gap: 8px; }

.workspace { min-width: 0; }
.topbar { min-height: 78px; padding: 16px clamp(18px, 3vw, 38px); border-bottom: 1px solid var(--line); background: rgba(255,255,255,.9); display: flex; align-items: center; gap: 16px; }
.topbar h1 { margin: 0; font-size: 20px; line-height: 1.25; }
.topbar p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.service-state { margin-left: auto; display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.service-state span { width: 8px; height: 8px; border-radius: 50%; background: #2aa66d; box-shadow: 0 0 0 3px rgba(42,166,109,.14); }
.menu-button { display: none; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); }
.content-region { padding: 24px clamp(18px, 3vw, 38px) 44px; }

.page-actions { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.page-actions h2 { margin: 0; font-size: 16px; }
.action-group { display: flex; flex-wrap: wrap; gap: 8px; }
.primary-command, .secondary-command, .quiet-command, .danger-command, .icon-command { min-height: 36px; border-radius: 5px; padding: 0 13px; border: 1px solid transparent; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.primary-command { color: white; background: var(--accent); }
.primary-command:hover { background: var(--accent-strong); }
.secondary-command { color: var(--ink); background: var(--surface); border-color: var(--line); }
.quiet-command { color: var(--muted); background: transparent; border-color: var(--line); }
.danger-command { color: var(--danger); background: #fff; border-color: #e7c7c7; }
.icon-command { width: 36px; padding: 0; color: var(--muted); background: transparent; font-size: 22px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); border: 1px solid var(--line); border-radius: 7px; overflow: hidden; background: var(--surface); }
.metric { min-height: 112px; padding: 20px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric strong { display: block; font-size: 28px; line-height: 1; }
.metric span { display: block; margin-top: 10px; color: var(--muted); font-size: 13px; }
.two-column { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(280px, .75fr); gap: 18px; margin-top: 18px; }
.panel { border-top: 3px solid var(--accent); background: var(--surface); box-shadow: 0 0 0 1px var(--line); }
.panel.warm { border-top-color: var(--warm); }
.panel-header { min-height: 52px; padding: 0 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-header h3 { margin: 0; font-size: 14px; }
.panel-body { padding: 16px; }

.data-list { border: 1px solid var(--line); background: var(--surface); }
.data-row { width: 100%; min-height: 58px; padding: 11px 14px; border: 0; border-bottom: 1px solid var(--line); background: transparent; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: center; text-align: left; }
.data-row:last-child { border-bottom: 0; }
.data-row:hover { background: #f8faf9; }
.data-row strong { display: block; overflow-wrap: anywhere; }
.data-row small, .muted { color: var(--muted); }
.data-row small { display: block; margin-top: 4px; }
.row-meta { color: var(--muted); font-size: 12px; text-align: right; }
.status-tag { display: inline-flex; align-items: center; min-height: 24px; padding: 0 8px; border-radius: 4px; color: var(--accent-strong); background: #dff0ed; font-size: 12px; }
.status-tag.warm { color: #874516; background: #f6e4d7; }
.status-tag.muted { color: #59615d; background: #e9ecea; }
.empty-state { padding: 38px 20px; border: 1px dashed #bfc9c3; color: var(--muted); background: rgba(255,255,255,.45); text-align: center; }

.stack-form { display: grid; gap: 12px; }
.stack-form label { font-size: 13px; font-weight: 650; }
input, textarea, select { width: 100%; border: 1px solid #bcc7c1; border-radius: 5px; color: var(--ink); background: #fff; }
input, select { min-height: 39px; padding: 0 10px; }
textarea { min-height: 170px; padding: 10px; resize: vertical; line-height: 1.55; }
input:focus, textarea:focus, select:focus { outline: 3px solid rgba(14,118,110,.14); border-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.checkbox-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; }
.checkbox-grid label { display: flex; align-items: center; gap: 8px; font-weight: 450; }
.checkbox-grid input { width: 16px; min-height: 16px; }
.form-error { margin: 0; color: var(--danger); font-size: 13px; }

.editor-dialog { width: min(840px, calc(100vw - 24px)); max-height: calc(100vh - 32px); padding: 0; border: 0; border-radius: 7px; box-shadow: var(--shadow); }
.editor-dialog::backdrop { background: rgba(11,20,16,.54); }
.dialog-header { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.dialog-header h2 { margin: 0; font-size: 17px; }
.dialog-header p { margin: 4px 0 0; font-size: 12px; }
.dialog-body { padding: 18px; overflow: auto; max-height: calc(100vh - 130px); }
.code-block { padding: 12px; border: 1px solid var(--line); border-radius: 5px; background: #17201c; color: #e9f1ed; overflow: auto; font: 12px/1.5 Consolas, "SFMono-Regular", monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.connection-list { display: grid; gap: 12px; }
.connection-item { padding: 14px 0; border-bottom: 1px solid var(--line); }
.connection-item:last-child { border-bottom: 0; }
.connection-item h3 { margin: 0 0 6px; font-size: 14px; }
.connection-item p { margin: 0; color: var(--muted); line-height: 1.55; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: #e8eeeb; }
.login-panel { width: min(400px, 100%); padding: 28px; border-top: 4px solid var(--accent); background: var(--surface); box-shadow: var(--shadow); }
.login-panel h1 { margin: 4px 0 8px; font-size: 24px; }
.login-panel > p { margin: 0 0 22px; }
.product-name { color: var(--accent) !important; font-size: 12px; font-weight: 750; text-transform: uppercase; }
.toast { position: fixed; right: 18px; bottom: 18px; max-width: min(420px, calc(100vw - 36px)); padding: 12px 15px; border-radius: 5px; color: white; background: #24322b; box-shadow: var(--shadow); }

@media (max-width: 900px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .two-column { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 20; width: min(280px, 86vw); transform: translateX(-102%); transition: transform .18s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .menu-button { display: inline-grid; place-items: center; }
  .topbar { align-items: flex-start; }
  .service-state { display: none; }
  .content-region { padding-top: 18px; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric { min-height: 96px; padding: 16px; }
  .metric strong { font-size: 23px; }
  .form-grid, .checkbox-grid { grid-template-columns: 1fr; }
  .page-actions { align-items: flex-start; flex-direction: column; }
}
