* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: #0f172a;
  background: #f8fafc;
  line-height: 1.5;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: #0f172a;
  color: #f8fafc;
}
.brand { font-weight: 600; letter-spacing: 0.02em; }
.userbar { display: flex; align-items: center; gap: 1rem; }
.user { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; opacity: 0.85; }
.logout-form { display: inline; margin: 0; }
button.link {
  background: none;
  border: none;
  color: #f8fafc;
  cursor: pointer;
  text-decoration: underline;
  font: inherit;
  padding: 0;
}

main { max-width: 960px; margin: 2rem auto; padding: 0 1.25rem; }
h1 { margin-top: 0; }
code {
  background: #e2e8f0;
  padding: 0 0.3rem;
  border-radius: 3px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.95em;
}
.bullets li { margin: 0.25rem 0; }

.login-box { max-width: 560px; }
#status { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: #475569; }
.dev-bypass {
  border: 2px solid #f59e0b;
  background: #fef3c7;
  padding: 1rem 1.25rem;
  border-radius: 6px;
}
.dev-bypass h1 { color: #92400e; margin-top: 0; }

button {
  font: inherit;
  padding: 0.4rem 0.9rem;
  border: 1px solid #cbd5e1;
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
}
button:hover { background: #f1f5f9; }

/* ---- Primary nav ---- */
.primary-nav {
  display: flex;
  gap: 0.25rem;
  padding: 0 1.25rem;
  background: #1e293b;
  border-bottom: 1px solid #334155;
  flex-wrap: wrap;
}
.primary-nav .tab {
  display: inline-block;
  padding: 0.6rem 1rem;
  color: #cbd5e1;
  text-decoration: none;
  border-bottom: 2px solid transparent;
  font-weight: 500;
}
.primary-nav .tab:hover { color: #f8fafc; background: #0f172a; }
.primary-nav .tab.active {
  color: #f8fafc;
  border-bottom-color: #38bdf8;
  background: #0f172a;
}

/* ---- Page headers ---- */
.page-header { margin-bottom: 1.5rem; }
.page-header h1 { margin: 0 0 0.25rem 0; }
.page-header .muted { margin: 0; color: #64748b; font-size: 0.95rem; }
.muted { color: #64748b; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.92em; }
.small { font-size: 0.85em; }
.timestamp { color: #94a3b8; font-size: 0.85rem; margin-top: 1rem; }

/* ---- Banners ---- */
.banner {
  padding: 0.75rem 1rem;
  border-radius: 4px;
  margin-bottom: 1rem;
  border-left: 4px solid;
}
.banner-info  { background: #eff6ff; border-color: #3b82f6; color: #1e3a8a; }
.banner-warn  { background: #fef3c7; border-color: #f59e0b; color: #92400e; }
.banner-error { background: #fee2e2; border-color: #ef4444; color: #991b1b; }

.empty-state {
  padding: 2rem;
  text-align: center;
  color: #94a3b8;
  font-style: italic;
}

/* ---- Status pills ---- */
.pill {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.pill-ok       { background: #d1fae5; color: #065f46; }
.pill-degraded { background: #fef3c7; color: #92400e; }
.pill-down     { background: #fee2e2; color: #991b1b; }
.pill-unknown  { background: #e2e8f0; color: #475569; }

.pill-state-active    { background: #d1fae5; color: #065f46; }
.pill-state-suspended { background: #fee2e2; color: #991b1b; }

/* ---- Service category sections ---- */
.category-section { margin-bottom: 1.5rem; }
.category-heading {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #475569;
  margin: 1.25rem 0 0.5rem 0;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid #e2e8f0;
}

/* ---- Card grid (services) ---- */
.aggregate-banner {
  display: inline-block;
  padding: 0.4rem 0.9rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.95rem;
  text-transform: none;
  letter-spacing: 0;
}
.aggregate-banner strong { text-transform: uppercase; letter-spacing: 0.05em; }
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 1rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.card.status-down { border-left: 3px solid #ef4444; }
.card.status-degraded { border-left: 3px solid #f59e0b; }
.card.status-ok { border-left: 3px solid #10b981; }
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}
.card-title { font-weight: 600; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.card-body { display: grid; grid-template-columns: max-content 1fr; gap: 0.2rem 0.75rem; margin: 0; }
.card-body dt { color: #64748b; font-size: 0.82rem; }
.card-body dd { margin: 0; font-size: 0.92rem; word-break: break-word; }
.card-detail { color: #475569; font-size: 0.88rem; }

/* ---- Zone Controllers cards ---- */
.zc-cards { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.zc-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 1rem 1.25rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.zc-card.status-down { border-left: 4px solid #ef4444; }
.zc-card.status-degraded { border-left: 4px solid #f59e0b; }
.zc-card.status-ok { border-left: 4px solid #10b981; }
.zc-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}
.zc-title { display: flex; align-items: baseline; gap: 0.75rem; }
.zc-name { font-size: 1.1rem; font-weight: 600; }
.zc-display-name { font-size: 0.95rem; }
.zc-status { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.zc-detail { margin: 0.5rem 0; }
.zc-activity {
  display: flex;
  gap: 1.5rem;
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  background: #f8fafc;
  border-radius: 4px;
}
.zc-metric { display: flex; flex-direction: column; align-items: flex-start; }
.zc-metric-value {
  font-size: 1.5rem;
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #0f172a;
}
.zc-metric-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
}
.zc-section-heading {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #475569;
  margin: 1rem 0 0.5rem 0;
}
.zc-systems-table th,
.zc-systems-table td { padding: 0.4rem 0.7rem; }

/* /clients — Zone controller cell (name + status pill side-by-side) */
.zc-cell { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

/* ---- Tables ---- */
.table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  overflow: hidden;
}
.table th, .table td {
  text-align: left;
  padding: 0.5rem 0.85rem;
  border-bottom: 1px solid #e2e8f0;
}
.table th {
  background: #f8fafc;
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #475569;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #f8fafc; }

/* ---- Settings form ---- */
.settings-form { max-width: 880px; }
.settings-section { margin-bottom: 2rem; }
.settings-field {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 0.9rem 1rem;
  margin-bottom: 0.75rem;
}
.settings-field.has-error { border-color: #ef4444; background: #fef2f2; }
.settings-field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.3rem;
}
.settings-label { font-weight: 600; color: #0f172a; }
.settings-label-text { margin-right: 0.5rem; }
.settings-key {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  background: #f1f5f9;
  padding: 0.05rem 0.4rem;
  border-radius: 3px;
  color: #475569;
  font-weight: 500;
}
.settings-help { color: #64748b; font-size: 0.85rem; margin: 0.25rem 0 0.5rem 0; }
.settings-error { color: #991b1b; font-size: 0.85rem; margin: 0.4rem 0 0 0; }
.settings-form input[type="text"],
.settings-form input[type="url"],
.settings-form select,
.settings-form textarea {
  width: 100%;
  font: inherit;
  padding: 0.4rem 0.55rem;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  background: #fff;
}
.settings-form textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em; }
.settings-form .settings-field.has-error input[type="text"],
.settings-form .settings-field.has-error input[type="url"],
.settings-form .settings-field.has-error textarea,
.settings-form .settings-field.has-error select {
  border-color: #ef4444;
}

.sensitive-field {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.sensitive-mask {
  padding: 0.4rem 0.55rem;
  border: 1px dashed #cbd5e1;
  border-radius: 4px;
  background: #f8fafc;
  color: #64748b;
  letter-spacing: 0.15em;
}
.sensitive-reveal, .sensitive-cancel {
  padding: 0.35rem 0.75rem;
}
.sensitive-input { flex: 1 1 100%; min-width: 16rem; }

.pill-source-settings { background: #ddd6fe; color: #5b21b6; }
.pill-source-env      { background: #cffafe; color: #155e75; }
.pill-source-default  { background: #e2e8f0; color: #475569; }

.settings-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1.5rem;
  padding: 1rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  position: sticky;
  bottom: 0;
}
button.primary {
  background: #0f172a;
  color: #f8fafc;
  border-color: #0f172a;
  padding: 0.5rem 1.25rem;
  font-weight: 600;
}
button.primary:hover { background: #1e293b; }

/* ---- Filter form ---- */
.filter-form {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
}
.filter-form label { font-weight: 500; color: #475569; }
.filter-form select {
  font: inherit;
  padding: 0.35rem 0.5rem;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  background: #fff;
}
