:root {
  color-scheme: light;
  --ink: #18211f;
  --muted: #62706c;
  --line: #dce3e0;
  --surface: #ffffff;
  --canvas: #f4f7f5;
  --nav: #14231f;
  --nav-muted: #a9b8b2;
  --primary: #147d64;
  --primary-dark: #0d624e;
  --blue: #2468a2;
  --amber: #9a6400;
  --red: #b43838;
  --shadow: 0 12px 30px rgba(26, 45, 39, .09);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body { margin: 0; color: var(--ink); background: var(--canvas); font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; letter-spacing: 0; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }

.login-screen { position: fixed; inset: 0; z-index: 20; display: none; place-items: center; padding: 24px; background: rgba(10, 23, 19, .86); }
.login-screen.visible { display: grid; }
.login-panel { width: min(100%, 420px); padding: 30px; border-radius: 8px; background: var(--surface); box-shadow: 0 24px 70px rgba(0, 0, 0, .28); }
.login-brand { color: var(--primary-dark); font-size: 13px; font-weight: 750; }
.login-panel h1 { margin: 8px 0 0; font-size: 24px; line-height: 1.25; }
.login-panel > p { margin: 10px 0 18px; color: var(--muted); }
.login-button { width: 100%; margin-top: 20px; }
.login-panel .form-status { margin-bottom: 0; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 226px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 24px 16px; color: #fff; background: var(--nav); }
.brand { padding: 0 10px 28px; }
.brand strong { display: block; font-size: 19px; line-height: 1.25; }
.brand span { display: block; margin-top: 6px; color: var(--nav-muted); font-size: 12px; }
.nav { display: grid; gap: 6px; }
.nav button { min-height: 46px; padding: 0 14px; border: 0; border-radius: 6px; color: var(--nav-muted); background: transparent; text-align: left; transition: background .18s ease, color .18s ease; }
.nav button:hover, .nav button:focus-visible { color: #fff; background: rgba(255,255,255,.08); outline: none; }
.nav button.active { color: #fff; background: var(--primary); font-weight: 650; }
.sidebar-foot { position: absolute; right: 26px; bottom: 22px; left: 26px; color: var(--nav-muted); font-size: 11px; }

.main { min-width: 0; padding: 24px 28px 48px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 0; font-size: 24px; line-height: 1.2; }
.topbar p { margin: 7px 0 0; color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: 8px; }
.status { display: inline-flex; align-items: center; min-height: 34px; padding: 0 12px; border: 1px solid #b8d7cc; border-radius: 999px; color: var(--primary-dark); background: #eaf5f1; font-size: 12px; font-weight: 650; white-space: nowrap; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(120px, 1fr)); gap: 1px; margin-top: 20px; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--line); box-shadow: var(--shadow); }
.metric { min-height: 88px; padding: 16px 18px; background: var(--surface); }
.metric span { display: block; color: var(--muted); font-size: 12px; }
.metric strong { display: block; margin-top: 7px; font-size: 24px; line-height: 1; }

.view { display: none; padding-top: 24px; }
.view.active { display: block; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 12px; }
.section-head h2 { margin: 0; font-size: 18px; }
.section-head p { margin: 4px 0 0; color: var(--muted); }
.work-grid { display: grid; grid-template-columns: minmax(280px, 350px) minmax(0, 1fr); gap: 18px; align-items: start; }
.form-panel, .table-panel { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.form-panel { padding: 18px; }
.form-panel h3 { margin: 0 0 14px; font-size: 16px; }
.field { display: block; margin-top: 13px; color: #36433f; font-size: 12px; font-weight: 650; }
.field input, .field select, .field textarea { width: 100%; margin-top: 6px; border: 1px solid #cbd5d1; border-radius: 6px; color: var(--ink); background: #fff; outline: none; }
.field input, .field select { height: 44px; padding: 0 11px; }
.field textarea { min-height: 108px; padding: 10px 11px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(20,125,100,.14); }
.check { display: flex; align-items: center; gap: 9px; margin-top: 14px; color: #36433f; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.button, button.button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 15px; border: 1px solid transparent; border-radius: 6px; color: #fff; background: var(--primary); font-weight: 650; text-decoration: none; transition: background .18s ease, border-color .18s ease; }
.button:hover { background: var(--primary-dark); }
.button.secondary { color: var(--ink); border-color: #cbd5d1; background: #fff; }
.button.secondary:hover { border-color: #91a39d; background: #f5f8f7; }
.button.compact { min-height: 34px; padding: 0 11px; font-size: 12px; }
.button.danger { color: var(--red); border-color: #e2b9b9; background: #fff; }
.button:disabled { cursor: wait; opacity: .55; }
.form-status { min-height: 21px; margin: 12px 0 0; color: var(--muted); font-size: 12px; }
.form-status.error { color: var(--red); }
.form-status.success { color: var(--primary-dark); }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); background: #f7f9f8; font-size: 11px; font-weight: 700; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td strong { font-weight: 700; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; }
.sub { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.badge { display: inline-flex; min-height: 24px; align-items: center; padding: 0 8px; border-radius: 999px; color: var(--blue); background: #eaf1f7; font-size: 11px; font-weight: 700; }
.badge.ok { color: var(--primary-dark); background: #e7f4ef; }
.badge.warning { color: var(--amber); background: #fff4d9; }
.badge.critical { color: var(--red); background: #faeaea; }
.badge.unknown { color: #596762; background: #edf1ef; }
.analysis { max-width: 430px; }
.analysis details { margin-top: 6px; color: var(--muted); }
.analysis summary { cursor: pointer; color: var(--blue); }
.analysis ul { margin: 8px 0 0; padding-left: 18px; }
.empty { padding: 32px 18px; color: var(--muted); text-align: center; }

@media (max-width: 920px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 16px; }
  .brand { padding-bottom: 14px; }
  .nav { grid-template-columns: repeat(3, 1fr); }
  .nav button { text-align: center; }
  .sidebar-foot { display: none; }
  .main { padding: 20px 16px 40px; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .work-grid { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  input, select, textarea { font-size: 16px; }
  .topbar { align-items: stretch; flex-direction: column; }
  .top-actions { justify-content: space-between; }
  .login-screen { padding: 14px; }
  .login-panel { padding: 24px 20px; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric { min-height: 78px; padding: 14px; }
  .metric strong { font-size: 21px; }
  .section-head { align-items: flex-start; flex-direction: column; }
  th, td { padding: 11px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
