:root {
  --ink: #111827;
  --muted: #667085;
  --line: #e4e7ec;
  --panel: #ffffff;
  --canvas: #f7f8fa;
  --navy: #101828;
  --blue: #175cd3;
  --green: #067647;
  --green-soft: #ecfdf3;
  --amber: #b54708;
  --amber-soft: #fffaeb;
  --red: #b42318;
  --red-soft: #fef3f2;
  --radius: 6px;
}

* { box-sizing: border-box; }
html { background: var(--canvas); color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body { margin: 0; min-width: 320px; }
button, input { font: inherit; }
button { cursor: pointer; }

.topbar {
  align-items: center;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 250px 1fr auto;
  height: 64px;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { align-items: center; display: flex; gap: 10px; }
.brand-logo { height: 28px; object-fit: contain; object-position: left center; width: 92px; }
.brand-mark { align-items: center; background: var(--navy); border-radius: 4px; color: white; display: flex; font-weight: 800; height: 32px; justify-content: center; width: 32px; }
.brand strong, .brand span { display: block; line-height: 1.15; }
.brand strong { font-size: 14px; }
.brand span { color: var(--muted); font-size: 11px; margin-top: 3px; }
.primary-nav { align-self: stretch; display: flex; gap: 6px; }
.nav-item { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); font-size: 13px; padding: 0 14px; }
.nav-item:hover { color: var(--ink); }
.nav-item.active { border-bottom-color: var(--ink); color: var(--ink); font-weight: 650; }
.top-actions { align-items: center; display: flex; gap: 10px; }
.top-actions form { margin: 0; }
.sync-label { color: var(--muted); font-size: 11px; min-width: 82px; text-align: right; }
.icon-button { align-items: center; background: white; border: 1px solid #d0d5dd; border-radius: 5px; color: #344054; display: inline-flex; font-size: 18px; height: 34px; justify-content: center; width: 34px; }
.icon-button:hover { background: #f9fafb; }
.icon-button.loading { animation: spin .9s linear infinite; }
.sign-out { background: none; border: 0; color: var(--muted); font-size: 12px; padding: 8px; }
.sign-out:hover { color: var(--red); }

.page-shell { margin: 0 auto; max-width: 1500px; padding: 30px 28px 64px; }
.page-heading { align-items: end; display: flex; justify-content: space-between; margin-bottom: 22px; }
.live-state { align-items: center; color: var(--green); display: flex; font-size: 11px; font-weight: 650; gap: 7px; margin-bottom: 7px; text-transform: uppercase; }
.live-state span:first-child { background: #12b76a; border-radius: 50%; height: 7px; width: 7px; }
.live-state.offline { color: var(--red); }
.live-state.offline span:first-child { background: #f04438; }
.page-heading h1 { font-size: 25px; letter-spacing: 0; margin: 0; }
.page-heading p { color: var(--muted); font-size: 13px; margin: 5px 0 0; }
.filters { background: white; border: 1px solid #d0d5dd; border-radius: var(--radius); display: flex; gap: 2px; padding: 3px; }
.filter { background: transparent; border: 0; border-radius: 4px; color: var(--muted); font-size: 12px; padding: 7px 12px; }
.filter.active { background: var(--navy); color: white; }

.summary-grid { background: white; border: 1px solid var(--line); border-radius: var(--radius); display: grid; grid-template-columns: repeat(5, 1fr); margin-bottom: 24px; overflow: hidden; }
.summary-item { border-right: 1px solid var(--line); min-height: 112px; padding: 20px; }
.summary-item:last-child { border-right: 0; }
.summary-item .label { color: var(--muted); font-size: 11px; font-weight: 650; text-transform: uppercase; }
.summary-value { font-size: 28px; font-weight: 700; line-height: 1; margin-top: 14px; }
.summary-detail { color: var(--muted); font-size: 11px; margin-top: 9px; }

.section-block { margin-top: 28px; scroll-margin-top: 88px; }
.section-heading { align-items: end; display: flex; justify-content: space-between; margin-bottom: 11px; }
.section-heading h2 { font-size: 16px; margin: 2px 0 0; }
.section-kicker { color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.count-label { color: var(--muted); font-size: 11px; }
.search-field { align-items: center; display: flex; gap: 8px; }
.search-field span { color: var(--muted); font-size: 11px; }
.search-field input { background: white; border: 1px solid #d0d5dd; border-radius: 5px; font-size: 12px; height: 34px; outline: none; padding: 0 10px; width: 180px; }
.search-field input:focus { border-color: #98a2b3; box-shadow: 0 0 0 3px rgba(152,162,179,.13); }

.issues-list { display: grid; gap: 8px; }
.issue-row { align-items: center; background: var(--red-soft); border: 1px solid #fecdca; border-radius: var(--radius); display: grid; grid-template-columns: 10px 170px 1fr auto; gap: 12px; min-height: 45px; padding: 9px 13px; }
.issue-row .dot { background: #f04438; border-radius: 50%; height: 7px; width: 7px; }
.issue-row strong { font-size: 12px; }
.issue-row p { color: #912018; font-size: 12px; margin: 0; }
.empty-state { background: white; border: 1px dashed #d0d5dd; border-radius: var(--radius); color: var(--muted); font-size: 12px; padding: 24px; text-align: center; }

.server-grid { display: grid; gap: 12px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.server-card { background: white; border: 1px solid var(--line); border-radius: var(--radius); padding: 17px; text-align: left; transition: border-color .15s, box-shadow .15s; }
.server-card:hover { border-color: #98a2b3; box-shadow: 0 2px 8px rgba(16,24,40,.06); }
.server-card-header { align-items: start; display: flex; justify-content: space-between; }
.server-card h3 { font-size: 14px; margin: 0; }
.server-meta { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; margin: 5px 0 0; }
.status { align-items: center; display: inline-flex; font-size: 10px; font-weight: 650; gap: 5px; text-transform: uppercase; }
.status::before { background: currentColor; border-radius: 50%; content: ""; height: 6px; width: 6px; }
.status.healthy { color: var(--green); }
.status.warning { color: var(--amber); }
.status.critical { color: var(--red); }
.metric-list { display: grid; gap: 12px; margin-top: 18px; }
.metric-label { align-items: center; color: var(--muted); display: flex; font-size: 10px; justify-content: space-between; margin-bottom: 5px; }
.metric-label strong { color: var(--ink); font-weight: 600; }
.bar { background: #f2f4f7; border-radius: 2px; height: 4px; overflow: hidden; }
.bar > span { background: #12b76a; display: block; height: 100%; }
.bar > span.warning { background: #f79009; }
.bar > span.critical { background: #f04438; }
.card-footer { align-items: center; border-top: 1px solid var(--line); color: var(--muted); display: flex; font-size: 10px; justify-content: space-between; margin-top: 16px; padding-top: 12px; }
.environment { background: #f2f4f7; border-radius: 3px; color: #475467; font-size: 9px; font-weight: 700; padding: 4px 6px; text-transform: uppercase; }

.table-frame { background: white; border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table { border-collapse: collapse; min-width: 760px; width: 100%; }
th { background: #f9fafb; color: var(--muted); font-size: 10px; font-weight: 700; padding: 10px 14px; text-transform: uppercase; }
td { border-top: 1px solid #f0f1f3; color: #344054; font-size: 12px; padding: 11px 14px; }
tbody tr:hover td { background: #fcfcfd; }
td strong { color: var(--ink); font-weight: 600; }
.result { border-radius: 3px; display: inline-flex; font-size: 10px; font-weight: 700; padding: 4px 7px; text-transform: uppercase; }
.result.ok { background: var(--green-soft); color: var(--green); }
.result.bad { background: var(--red-soft); color: var(--red); }

.server-dialog { border: 0; border-radius: 8px; box-shadow: 0 24px 48px rgba(16,24,40,.22); max-height: 88vh; max-width: 900px; padding: 0; width: calc(100% - 32px); }
.server-dialog::backdrop { background: rgba(16,24,40,.55); }
.dialog-header { align-items: center; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; padding: 20px 24px; }
.dialog-header h2 { font-size: 19px; margin: 3px 0 0; }
#dialog-content { padding: 22px 24px 28px; }
.detail-stats { display: grid; gap: 10px; grid-template-columns: repeat(4, 1fr); }
.detail-stat { background: var(--canvas); border-radius: 5px; padding: 13px; }
.detail-stat span { color: var(--muted); display: block; font-size: 9px; text-transform: uppercase; }
.detail-stat strong { display: block; font-size: 15px; margin-top: 6px; }
.chart-wrap { border: 1px solid var(--line); border-radius: 5px; margin-top: 18px; padding: 14px; }
.chart-header { align-items: center; display: flex; justify-content: space-between; }
.chart-header strong { font-size: 12px; }
.chart-legend { color: var(--muted); font-size: 10px; }
.history-chart { height: 210px; margin-top: 8px; width: 100%; }
.history-chart .grid { stroke: #eaecf0; stroke-width: 1; }
.history-chart .cpu { fill: none; stroke: #175cd3; stroke-width: 2; }
.history-chart .memory { fill: none; stroke: #12b76a; stroke-width: 2; }

.toast { background: var(--navy); border-radius: 5px; bottom: 22px; color: white; font-size: 12px; opacity: 0; padding: 11px 14px; pointer-events: none; position: fixed; right: 22px; transform: translateY(8px); transition: .2s; }
.toast.visible { opacity: 1; transform: translateY(0); }
@keyframes spin { to { transform: rotate(360deg); } }

.login-page { background: #f2f4f7; min-height: 100vh; }
.login-shell { background: white; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 30px rgba(16,24,40,.08); display: grid; grid-template-columns: 1fr 1fr; margin: 10vh auto; max-width: 820px; min-height: 500px; overflow: hidden; width: calc(100% - 32px); }
.login-brand { background: var(--navy); color: white; display: flex; flex-direction: column; justify-content: center; padding: 56px; }
.login-logo { height: auto; margin-bottom: 42px; width: 146px; }
.eyebrow { color: #98a2b3; font-size: 10px; font-weight: 700; letter-spacing: .08em; margin: 0 0 7px; text-transform: uppercase; }
.login-brand h1 { font-size: 31px; margin: 0; }
.login-copy { color: #98a2b3; font-size: 13px; margin-top: 9px; }
.login-status { align-items: center; color: #d0d5dd; display: flex; font-size: 10px; gap: 7px; margin-top: 80px; }
.login-status span { background: #32d583; border-radius: 50%; height: 7px; width: 7px; }
.login-panel { display: flex; flex-direction: column; justify-content: center; padding: 54px; }
.login-panel h2 { font-size: 24px; margin: 0 0 28px; }
.login-error { background: var(--red-soft); border: 1px solid #fecdca; border-radius: 5px; color: var(--red); font-size: 11px; margin-bottom: 15px; padding: 10px; }
.login-form { display: grid; gap: 16px; }
.login-form label { color: #344054; font-size: 11px; font-weight: 600; }
.login-form input { border: 1px solid #d0d5dd; border-radius: 5px; display: block; height: 42px; margin-top: 7px; outline: none; padding: 0 12px; width: 100%; }
.login-form input:focus { border-color: #667085; box-shadow: 0 0 0 3px rgba(102,112,133,.12); }
.login-form button { background: var(--navy); border: 0; border-radius: 5px; color: white; font-size: 12px; font-weight: 650; height: 42px; margin-top: 5px; }
.login-form button:hover { background: #1d2939; }

@media (max-width: 1000px) {
  .topbar { grid-template-columns: 190px 1fr auto; padding: 0 18px; }
  .server-grid { grid-template-columns: repeat(2, 1fr); }
  .summary-grid { grid-template-columns: repeat(3, 1fr); }
  .summary-item:nth-child(3) { border-right: 0; }
  .summary-item:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
}

@media (max-width: 720px) {
  .topbar { display: flex; height: 56px; justify-content: space-between; padding: 0 12px; }
  .brand span, .sync-label, .sign-out { display: none; }
  .primary-nav { background: white; border-top: 1px solid var(--line); bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr); height: 52px; left: 0; position: fixed; right: 0; z-index: 30; }
  .nav-item { border-bottom: 0; border-top: 2px solid transparent; font-size: 10px; padding: 0 4px; }
  .nav-item.active { border-bottom: 0; border-top-color: var(--ink); }
  .page-shell { padding: 22px 14px 82px; }
  .page-heading { align-items: stretch; flex-direction: column; gap: 16px; }
  .filters { width: 100%; }
  .filter { flex: 1; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .summary-item, .summary-item:nth-child(3) { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); }
  .summary-item:nth-child(even) { border-right: 0; }
  .summary-item:last-child { border-bottom: 0; }
  .server-grid { grid-template-columns: 1fr; }
  .section-heading { align-items: start; }
  .search-field span { display: none; }
  .search-field input { width: 130px; }
  .issue-row { grid-template-columns: 10px 1fr auto; }
  .issue-row p { grid-column: 2 / -1; }
  .detail-stats { grid-template-columns: repeat(2, 1fr); }
  .login-shell { display: block; margin: 0; min-height: 100vh; width: 100%; }
  .login-brand { min-height: 230px; padding: 34px; }
  .login-logo { margin-bottom: 24px; }
  .login-status { margin-top: 25px; }
  .login-panel { padding: 34px; }
}
