:root {
  color-scheme: light;
  --bg: #f4f6f7;
  --surface: #ffffff;
  --surface-2: #edf1f2;
  --ink: #182126;
  --muted: #66747b;
  --border: #d7dfe2;
  --accent: #087f72;
  --accent-hover: #06695f;
  --warning: #b66a08;
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --success-bg: #e8f6f2;
  --shadow: 0 8px 24px rgba(24, 33, 38, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--bg); color: var(--ink); }
button, input, select { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid rgba(8, 127, 114, 0.24); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #e9edef; }
.login-panel { width: min(400px, 100%); display: grid; gap: 12px; padding: 32px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); }
.login-panel h1 { margin: 0; font-size: 1.35rem; }
.login-panel p { margin: 4px 0 8px; }
.brand-mark { width: 48px; height: 48px; display: grid; place-items: center; background: var(--ink); color: white; border-radius: 6px; font-weight: 800; }
.brand-mark.small { width: 34px; height: 34px; font-size: 0.8rem; }
label { color: #344248; font-size: 0.84rem; font-weight: 650; }
input, select { width: 100%; min-height: 40px; padding: 8px 11px; color: var(--ink); background: var(--surface); border: 1px solid #bcc8cc; border-radius: 5px; }
input:hover, select:hover { border-color: #8fa0a6; }
.form-error { min-height: 20px; margin: 0; color: var(--danger); font-size: 0.86rem; }

.app-shell { min-height: 100vh; display: grid; grid-template: 58px 1fr / 210px 1fr; }
.topbar { position: sticky; top: 0; z-index: 20; grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; padding: 0 18px; background: #131b1f; color: white; border-bottom: 1px solid #2b373c; }
.brand-row, .topbar-actions, .toolbar, .inline-form, .url-row, .account-band, .section-heading, .panel-heading { display: flex; align-items: center; }
.brand-row { gap: 10px; }
.brand-row strong { margin-right: 6px; }
.topbar-actions { gap: 8px; }
.sidebar { position: sticky; top: 58px; height: calc(100vh - 58px); display: flex; flex-direction: column; gap: 4px; padding: 16px 10px; background: #202b30; border-right: 1px solid #2f3c41; }
.nav-item { height: 42px; display: flex; align-items: center; gap: 11px; padding: 0 12px; border: 0; border-radius: 5px; background: transparent; color: #bfc9cd; cursor: pointer; text-align: left; }
.nav-item:hover { background: #29373c; color: white; }
.nav-item.active { background: #e7f4f1; color: #075f57; font-weight: 700; }
.nav-item svg, button svg { width: 18px; height: 18px; flex: 0 0 auto; }
.workspace { min-width: 0; padding: 28px clamp(18px, 3vw, 42px) 48px; }
.view { display: none; max-width: 1240px; margin: 0 auto; }
.view.active { display: block; }
.section-heading { justify-content: space-between; gap: 16px; min-height: 54px; margin-bottom: 20px; }
.section-heading h1 { margin: 0; font-size: 1.5rem; line-height: 1.25; }
.section-heading p { margin: 4px 0 0; }

.button, .icon-button { border: 1px solid transparent; border-radius: 5px; cursor: pointer; transition: background-color 120ms ease, border-color 120ms ease; }
.button { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 14px; font-weight: 700; }
.button.full { width: 100%; }
.button.primary { background: var(--accent); color: white; }
.button.primary:hover { background: var(--accent-hover); }
.button.secondary { background: var(--surface); border-color: var(--border); color: var(--ink); }
.button.secondary:hover, .icon-button:hover { background: var(--surface-2); }
.button.danger, .icon-button.danger { background: var(--danger-bg); border-color: #f2c5c0; color: var(--danger); }
.button:disabled, .icon-button:disabled { opacity: 0.5; cursor: not-allowed; }
.icon-button { width: 38px; height: 38px; display: inline-grid; place-items: center; padding: 0; background: transparent; color: inherit; }

.status-badge { display: inline-flex; align-items: center; gap: 7px; min-height: 28px; padding: 4px 9px; border: 1px solid var(--border); border-radius: 999px; font-size: 0.78rem; font-weight: 750; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-badge.success { color: #087264; background: var(--success-bg); border-color: #a9dbd0; }
.status-badge.warning { color: var(--warning); background: #fff7e8; border-color: #ecd19e; }
.status-badge.danger { color: var(--danger); background: var(--danger-bg); border-color: #f2c5c0; }
.status-badge.neutral { color: #5d6a70; background: #eef2f3; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--border); background: var(--surface); border-radius: 7px; overflow: hidden; }
.metric { min-width: 0; min-height: 132px; display: flex; flex-direction: column; justify-content: center; padding: 20px; border-right: 1px solid var(--border); }
.metric:last-child { border-right: 0; }
.metric-label { margin-bottom: 12px; color: var(--muted); font-size: 0.8rem; font-weight: 700; text-transform: uppercase; }
.metric strong { overflow-wrap: anywhere; font-size: 1.35rem; }
.metric small { margin-top: 7px; color: var(--muted); }
.panel { margin-top: 20px; padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: 7px; }
.panel-heading { justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.panel-heading h2, .danger-zone h2 { margin: 0; font-size: 1rem; }
.detail-list { margin: 0; }
.detail-list > div { display: grid; grid-template-columns: 180px 1fr; gap: 16px; padding: 13px 0; border-top: 1px solid var(--border); }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; overflow-wrap: anywhere; }

.account-band { justify-content: space-between; gap: 18px; padding: 22px; background: #172126; color: white; border-radius: 7px; }
.account-band h2 { margin: 12px 0 5px; font-size: 1.2rem; overflow-wrap: anywhere; }
.account-band p { margin: 0; }
.account-band .account-scope { margin-top: 10px; color: #b9c7cb; font-size: 0.82rem; }
.account-table { min-width: 980px; }
.account-table td:first-child { min-width: 220px; }
.account-table td:first-child strong, .account-table td:first-child small { display: block; overflow-wrap: anywhere; }
.account-table td:first-child small { margin-top: 4px; color: var(--muted); }
.account-detail { margin-top: 20px; padding: 22px; background: var(--surface); border: 1px solid var(--border); border-radius: 7px; }
.detail-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding-bottom: 16px; }
.detail-title h2 { margin: 10px 0 4px; font-size: 1.2rem; overflow-wrap: anywhere; }
.detail-title p { margin: 0; }
.compact-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--border); }
.compact-details > div { grid-template-columns: 150px minmax(0, 1fr); }
.account-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.account-detail > .account-actions { padding-top: 16px; }
.panel.inset { margin-top: 18px; background: var(--surface-2); }
.terminal.account-log { height: 240px; }
.usage-panel .panel-heading { align-items: flex-start; }
.usage-panel .panel-heading p { margin: 4px 0 0; }
.usage-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.usage-window { min-width: 0; }
.usage-label { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.usage-label span { color: var(--accent); font-size: 1.05rem; font-weight: 750; }
.usage-track { height: 9px; margin: 10px 0 8px; overflow: hidden; background: #dbe3e5; border-radius: 4px; }
.usage-track span { display: block; width: 0; height: 100%; background: #168b7d; border-radius: inherit; transition: width 180ms ease; }
.usage-window small { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; overflow-wrap: anywhere; }
.compact-button { min-height: 34px; padding: 5px 10px; }
.inline-form { gap: 8px; margin: 7px 0 15px; }
.inline-form input { flex: 1; }
.url-row { min-height: 44px; justify-content: space-between; gap: 8px; margin: 7px 0 15px; padding: 6px 7px 6px 11px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; }
.url-row a { min-width: 0; color: var(--accent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.danger-zone { margin-top: 24px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 20px; background: var(--surface); border: 1px solid #edc0bb; border-left: 4px solid var(--danger); border-radius: 5px; }
.danger-zone p { margin: 5px 0 0; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 7px; }
table { width: 100%; border-collapse: collapse; min-width: 860px; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { background: var(--surface-2); color: #46545a; font-size: 0.78rem; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
td code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.empty-state { min-height: 180px; display: grid; place-items: center; align-content: center; gap: 10px; color: var(--muted); }
.empty-state svg { width: 28px; height: 28px; }

.toolbar { justify-content: flex-end; gap: 10px; }
.toolbar select { width: auto; min-width: 130px; }
.toggle { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.toggle input { width: 17px; min-height: 17px; }
.terminal { height: min(68vh, 680px); margin: 0; padding: 16px; overflow: auto; background: #101719; color: #c9d6d9; border: 1px solid #273438; border-radius: 6px; font: 12px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.terminal.compact { height: 190px; margin-top: 14px; }

dialog { width: min(430px, calc(100% - 32px)); padding: 0; border: 0; border-radius: 8px; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(12, 18, 21, 0.58); }
.dialog-panel { display: grid; gap: 13px; padding: 24px; }
.dialog-panel h2, .dialog-panel p { margin: 0; }
.dialog-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; }
.dialog-icon.danger { color: var(--danger); background: var(--danger-bg); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.toast { position: fixed; right: 18px; bottom: 18px; z-index: 50; max-width: min(420px, calc(100% - 36px)); padding: 11px 14px; background: #172126; color: white; border-radius: 5px; box-shadow: var(--shadow); }
.toast.error { background: #7d1f18; }

@media (max-width: 900px) {
  .app-shell { grid-template: 58px 48px 1fr / 1fr; }
  .sidebar { position: sticky; top: 58px; z-index: 15; height: 48px; flex-direction: row; justify-content: stretch; padding: 4px 8px; overflow-x: auto; border-right: 0; border-bottom: 1px solid #2f3c41; }
  .nav-item { min-width: 0; flex: 1; height: 39px; justify-content: center; padding: 0 10px; }
  .workspace { grid-row: 3; padding-top: 20px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
}

@media (max-width: 600px) {
  .topbar { padding: 0 10px; }
  .brand-row .muted, #header-status { display: none; }
  .nav-item span { display: none; }
  .workspace { padding-inline: 12px; }
  .section-heading, .account-band, .danger-zone { align-items: stretch; flex-direction: column; }
  .section-heading .button, .account-band .button, .danger-zone .button { width: 100%; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric { min-height: 108px; border-right: 0; border-bottom: 1px solid var(--border); }
  .metric:last-child { border-bottom: 0; }
  .inline-form { align-items: stretch; flex-direction: column; }
  .detail-list > div { grid-template-columns: 1fr; gap: 5px; }
  .compact-details { grid-template-columns: 1fr; }
  .usage-grid { grid-template-columns: 1fr; }
  .account-detail { padding: 16px; }
  .account-actions { align-items: stretch; flex-direction: column; }
  .account-actions .button { width: 100%; }
  .toolbar { width: 100%; flex-wrap: wrap; justify-content: flex-start; }
  .toolbar select { flex: 1; }
  .terminal { height: 58vh; }
}
