:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --line: #dbe4ef;
    --text: #142033;
    --muted: #6a7a90;
    --blue: #155eef;
    --blue-soft: #edf4ff;
    --green: #087443;
    --green-soft: #e8f8f0;
    --red: #bd2525;
    --red-soft: #fff0f0;
    --amber: #9a6700;
    --amber-soft: #fff7dc;
    --shadow: 0 12px 30px rgba(20, 32, 51, .06);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    color: var(--text);
    background: var(--bg);
    font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
h1, h2, p { margin: 0; }
h1 { font-size: 27px; line-height: 1.15; }
h2 { font-size: 17px; }
.muted, .panel-head p, .topbar time, small { color: var(--muted); }
.eyebrow { color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: .14em; }

.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(440px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 30px; box-shadow: var(--shadow); }
.auth-card h1 { margin: 10px 0 8px; }
.auth-link { margin-top: 18px; color: var(--blue); }
.logo { width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: 8px; color: white; background: var(--blue); font-weight: 900; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 228px minmax(0, 1fr); }
.sidebar { display: flex; flex-direction: column; gap: 28px; min-height: 100vh; padding: 22px 18px; background: #10243d; color: #e8f0fa; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand strong, .brand small { display: block; }
.brand small { color: #9fb2c9; font-size: 12px; }
.sidebar .logo { background: #2b7fff; }
.nav { display: grid; gap: 6px; }
.nav a { padding: 10px 12px; border-radius: 6px; color: #b9c9db; }
.nav a:hover, .nav a.active { color: white; background: #1d3b60; }
.sidebar-foot { display: grid; gap: 6px; margin-top: auto; padding-top: 18px; border-top: 1px solid #29425f; }
.sidebar-foot strong { margin-bottom: 8px; }
.main { min-width: 0; padding: 30px; }
.topbar { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 24px; }
.topbar h1 { margin-top: 5px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin-bottom: 18px; }
.stat-card, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.stat-card { min-height: 122px; padding: 18px; }
.stat-card span { color: var(--muted); font-weight: 700; }
.stat-card strong { display: block; margin: 10px 0 2px; font-size: 30px; line-height: 1; }
.stat-card.green strong { color: var(--green); }
.stat-card.red strong { color: var(--red); }
.stat-card.amber strong { color: var(--amber); }
.stat-card small { display: block; }
.panel { padding: 18px; margin-bottom: 18px; }
.panel.narrow { max-width: 880px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 15px; margin-bottom: 16px; }
.panel-head p { margin-top: 3px; }
.panel-actions, .panel-actions form { display: flex; align-items: center; gap: 8px; }

.form-stack, .form-grid { display: grid; gap: 13px; }
.form-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: end; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
label { display: grid; gap: 6px; color: #33465e; font-weight: 700; }
input, select { width: 100%; min-height: 39px; padding: 8px 10px; color: var(--text); background: white; border: 1px solid var(--line); border-radius: 6px; outline: 0; }
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(21, 94, 239, .12); }
.check { display: flex; grid-template-columns: auto 1fr; align-items: center; gap: 8px; font-weight: 600; }
.check input { width: 16px; min-height: 16px; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.form-grid .form-actions { min-height: 39px; align-items: center; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 36px; border: 1px solid transparent; border-radius: 6px; padding: 7px 12px; cursor: pointer; white-space: nowrap; }
.button.primary { color: white; background: var(--blue); }
.button.secondary { color: #0f4dbf; background: var(--blue-soft); border-color: #c9dcff; }
.button.ghost { color: #b9c9db; background: transparent; border-color: #48617e; }
.button.ghost.full { color: #dbe8f5; margin-top: 8px; }
.button.danger { color: var(--red); background: var(--red-soft); border-color: #ffcaca; }
.button:hover { filter: brightness(.97); }

.alert { margin-bottom: 16px; padding: 10px 12px; border: 1px solid; border-radius: 6px; }
.alert.success { color: var(--green); background: var(--green-soft); border-color: #b6e7ce; }
.alert.error { color: var(--red); background: var(--red-soft); border-color: #ffcaca; }
.empty { display: grid; gap: 6px; place-items: center; min-height: 130px; padding: 20px; color: var(--muted); border: 1px dashed var(--line); border-radius: 6px; text-align: center; }
.empty strong { color: var(--text); }

.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 720px; border-collapse: collapse; }
th, td { padding: 11px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); background: var(--surface-soft); font-size: 12px; }
td strong, td small { display: block; }
td small { margin-top: 2px; }
.resolved-ip { max-width: 240px; overflow-wrap: anywhere; }
.status { display: inline-flex; align-items: center; justify-content: center; min-width: 52px; padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 800; }
.status.up { color: var(--green); background: var(--green-soft); }
.status.down { color: var(--red); background: var(--red-soft); }
.status.unknown { color: var(--amber); background: var(--amber-soft); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.actions form { display: inline; }
.error-text { color: var(--red); max-width: 300px; overflow-wrap: anywhere; }

@media (max-width: 980px) {
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-grid, .form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { min-height: auto; }
    .nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .sidebar-foot { margin-top: 0; }
    .main { padding: 20px 14px; }
    .topbar, .panel-head { align-items: flex-start; flex-direction: column; }
    .stat-grid, .form-grid, .form-grid.two { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: auto; }
    .form-actions { align-items: stretch; flex-direction: column; width: 100%; }
}
