:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-soft: #f8f9fa;
  --text: #17191c;
  --muted: #6d737c;
  --line: #e2e5e9;
  --green: #177c55;
  --green-soft: #e7f4ee;
  --blue: #2968b0;
  --blue-soft: #eaf2fb;
  --amber: #9a6500;
  --amber-soft: #fff3d8;
  --coral: #b44a38;
  --coral-soft: #fbece8;
  --shadow: 0 10px 30px rgba(18, 24, 31, 0.06);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); letter-spacing: 0; }
button, select, input { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 236px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 24px 16px; background: #1d2025; color: #fff; display: flex; flex-direction: column; }
.brand { display: flex; gap: 12px; align-items: center; padding: 0 8px 28px; }
.brand-mark { width: 38px; height: 38px; border-radius: 8px; display: grid; place-items: center; color: #17221d; background: #82d9ac; }
.brand-mark svg { width: 20px; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 14px; }
.brand small { margin-top: 3px; color: #9ba2ac; font-size: 11px; text-transform: uppercase; }
nav { display: grid; gap: 5px; }
.nav-item { height: 42px; padding: 0 12px; display: flex; align-items: center; gap: 11px; color: #aeb4bc; text-decoration: none; border-radius: 6px; font-size: 14px; }
.nav-item svg { width: 18px; }
.nav-item:hover, .nav-item.active { background: #2a2e34; color: #fff; }
.sidebar-foot { margin-top: auto; padding: 12px; display: flex; align-items: center; gap: 9px; color: #9ba2ac; font-size: 12px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #59c993; box-shadow: 0 0 0 4px rgba(89, 201, 147, 0.12); }

main { width: min(1240px, 100%); margin: 0 auto; padding: 38px 42px 64px; }
.topbar, .section-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.topbar { min-height: 86px; margin-bottom: 28px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: 29px; line-height: 1.15; }
h2 { margin-bottom: 0; font-size: 20px; }
h3 { margin-bottom: 5px; font-size: 15px; }
.eyebrow { margin-bottom: 7px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: 0.12em; }
.muted { margin-bottom: 0; color: var(--muted); font-size: 13px; }

.icon-button { flex: none; width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--text); }
.icon-button:hover { background: var(--surface-soft); }
.icon-button svg { width: 18px; }
.icon-button.loading svg { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.status-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.status-card { min-width: 0; min-height: 166px; padding: 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.status-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.icon-box { width: 34px; height: 34px; border-radius: 7px; display: grid; place-items: center; }
.icon-box svg { width: 17px; }
.icon-box.blue { background: var(--blue-soft); color: var(--blue); }
.icon-box.green { background: var(--green-soft); color: var(--green); }
.icon-box.amber { background: var(--amber-soft); color: var(--amber); }
.icon-box.coral { background: var(--coral-soft); color: var(--coral); }
.badge { display: inline-flex; align-items: center; min-height: 22px; padding: 0 8px; border-radius: 999px; font-size: 10px; font-weight: 700; }
.badge.neutral { background: #eef0f2; color: #656b73; }
.badge.success { background: var(--green-soft); color: var(--green); }
.badge.warning { background: var(--amber-soft); color: var(--amber); }
.badge.danger { background: var(--coral-soft); color: var(--coral); }
.status-card .label { margin-bottom: 5px; color: var(--muted); font-size: 11px; }
.status-card strong { display: block; margin-bottom: 5px; font-size: 17px; line-height: 1.25; }
.status-card small { display: block; min-height: 32px; color: var(--muted); font-size: 11px; line-height: 1.45; }

.section { scroll-margin-top: 18px; margin-top: 22px; padding: 28px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.section-heading { margin-bottom: 22px; }
.primary-button, .secondary-button { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 14px; border-radius: 6px; font-size: 12px; font-weight: 650; }
.primary-button { border: 1px solid #20242a; background: #20242a; color: #fff; }
.primary-button:hover { background: #343940; }
.secondary-button { border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.secondary-button:hover { background: var(--surface-soft); }
.primary-button:disabled, .secondary-button:disabled { cursor: wait; opacity: 0.55; }
.primary-button svg, .secondary-button svg { width: 16px; }

.operation-list { border-top: 1px solid var(--line); }
.operation-row { min-height: 116px; display: grid; grid-template-columns: 38px minmax(260px, 1fr) auto 124px 156px; align-items: center; gap: 18px; padding: 20px 0; border-bottom: 1px solid var(--line); }
.operation-icon { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 7px; color: var(--muted); }
.operation-icon svg { width: 17px; }
.operation-copy p { margin-bottom: 7px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.operation-copy small { color: #8a9098; font-size: 10px; }
code { padding: 2px 5px; border-radius: 4px; background: #f0f2f4; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em; }
.switch-control, .interval-control { display: grid; gap: 7px; color: var(--muted); font-size: 10px; }
.switch-control { grid-template-columns: auto 38px; align-items: center; gap: 10px; }
.switch-control input { position: absolute; opacity: 0; pointer-events: none; }
.switch { width: 38px; height: 22px; position: relative; border-radius: 999px; background: #ccd1d7; transition: background 0.2s ease; }
.switch::after { content: ""; width: 16px; height: 16px; position: absolute; top: 3px; left: 3px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.2); transition: transform 0.2s ease; }
.switch-control input:checked + .switch { background: var(--green); }
.switch-control input:checked + .switch::after { transform: translateX(16px); }
.interval-control select { width: 124px; height: 36px; padding: 0 28px 0 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--text); font-size: 11px; }
.notice { margin-top: 18px; padding: 14px 16px; display: flex; gap: 12px; border-radius: 7px; }
.notice.warning { background: var(--amber-soft); color: #674600; }
.notice svg { flex: none; width: 17px; margin-top: 1px; }
.notice strong { display: block; margin-bottom: 3px; font-size: 12px; }
.notice p { margin-bottom: 0; font-size: 11px; line-height: 1.5; }

.storage-strip { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); margin-bottom: 22px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.storage-metric { min-width: 0; padding: 18px 16px; border-right: 1px solid var(--line); }
.storage-metric:last-child { border-right: 0; }
.storage-metric span, .storage-metric small { display: block; color: var(--muted); font-size: 10px; line-height: 1.4; }
.storage-metric strong { display: block; margin: 7px 0 5px; font-size: 20px; line-height: 1.2; }
.storage-metric small { min-height: 28px; }

.health-strip { display: grid; grid-template-columns: repeat(5, 1fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.metric { min-width: 0; padding: 20px 18px; text-align: left; border: 0; border-right: 1px solid var(--line); background: transparent; color: var(--text); }
.metric:last-child { border-right: 0; }
.metric:hover { background: var(--surface-soft); }
.metric span, .metric small { display: block; color: var(--muted); font-size: 10px; }
.metric strong { display: block; margin: 7px 0 5px; font-size: 24px; }
.metric small { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.health-meta { padding-top: 13px; display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 10px; }

.table-wrap { overflow-x: auto; border-top: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: 11px; }
th { padding: 12px 10px; color: var(--muted); font-size: 9px; font-weight: 700; text-align: left; text-transform: uppercase; }
td { height: 52px; padding: 8px 10px; border-top: 1px solid var(--line); }
.table-action { font-weight: 650; }
.table-button { width: 30px; height: 30px; display: grid; place-items: center; border: 0; border-radius: 5px; background: transparent; color: var(--muted); }
.table-button:hover { background: var(--surface-soft); color: var(--text); }
.table-button svg { width: 15px; }
.empty-state { height: 86px; color: var(--muted); text-align: center; }

dialog { width: min(720px, calc(100vw - 32px)); max-height: min(720px, calc(100vh - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 24px 80px rgba(0,0,0,.2); }
dialog::backdrop { background: rgba(20, 24, 29, 0.45); }
.dialog-head { padding: 20px 22px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.dialog-body { max-height: 580px; padding: 20px 22px; overflow: auto; }
.detail-list { display: grid; gap: 8px; }
.detail-item { padding: 11px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-soft); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; line-height: 1.45; overflow-wrap: anywhere; }
.log-output { margin: 0; padding: 16px; border-radius: 6px; background: #1d2025; color: #dce1e7; font: 11px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.toast { position: fixed; right: 24px; bottom: 24px; max-width: 380px; padding: 12px 15px; border-radius: 7px; background: #20242a; color: #fff; box-shadow: 0 10px 30px rgba(0,0,0,.22); font-size: 12px; opacity: 0; transform: translateY(12px); pointer-events: none; transition: 0.2s ease; }
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { background: #8f3528; }

@media (max-width: 1050px) {
  .app-shell { grid-template-columns: 76px minmax(0, 1fr); }
  .sidebar { padding-inline: 12px; }
  .brand { justify-content: center; padding-inline: 0; }
  .brand > span:last-child, .nav-item span, .sidebar-foot span:last-child { display: none; }
  .nav-item { justify-content: center; padding: 0; }
  .operation-row { grid-template-columns: 38px minmax(210px, 1fr) auto 124px; }
  .operation-row .secondary-button { grid-column: 2 / -1; justify-self: end; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; z-index: 20; top: auto; bottom: 0; width: 100%; height: 64px; padding: 8px 12px; flex-direction: row; align-items: center; }
  .brand, .sidebar-foot { display: none; }
  nav { width: 100%; display: grid; grid-template-columns: repeat(4, 1fr); }
  .nav-item { height: 48px; }
  main { padding: 24px 16px 90px; }
  .topbar { min-height: 68px; }
  .status-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section { padding: 20px 16px; }
  .section-heading { align-items: flex-start; }
  .section-heading .primary-button span, .section-heading .secondary-button span { display: none; }
  .operation-row { grid-template-columns: 36px minmax(0, 1fr); gap: 12px; }
  .operation-row .switch-control, .operation-row .interval-control, .operation-row .secondary-button { grid-column: 2; justify-self: stretch; }
  .operation-row .secondary-button { width: 100%; }
  .switch-control { grid-template-columns: 1fr 38px; }
  .interval-control select { width: 100%; }
  .health-strip { grid-template-columns: repeat(2, 1fr); }
  .storage-strip { grid-template-columns: repeat(2, 1fr); }
  .storage-metric { border-bottom: 1px solid var(--line); }
  .storage-metric:nth-child(2n) { border-right: 0; }
  .storage-metric:last-child { grid-column: 1 / -1; border-bottom: 0; }
  .metric { border-bottom: 1px solid var(--line); }
  .metric:nth-child(2n) { border-right: 0; }
  .metric:last-child { border-bottom: 0; }
}

@media (max-width: 430px) {
  .status-grid { grid-template-columns: 1fr; }
  .status-card { min-height: 148px; }
  h1 { font-size: 25px; }
}
