@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=IBM+Plex+Sans:wght@400;500;600&display=swap");

:root {
  --bg: #f5f2ea;
  --bg-accent: #e7f0ff;
  --text: #0f172a;
  --muted: #6b7280;
  --card: #ffffff;
  --stroke: #e4e1da;
  --accent: #0b3b2e;
  --accent-2: #ff7a3d;
  --danger: #c2410c;
  --ok: #15803d;
  --warn: #b45309;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  background:
    radial-gradient(circle at 10% 10%, #e6f7ff, transparent 40%),
    radial-gradient(circle at 90% 0%, #ffe8d6, transparent 35%),
    var(--bg);
  color: var(--text);
}

code {
  font-family: "IBM Plex Sans", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 6px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  background: #0b3b2e;
  border-bottom: 1px solid var(--stroke);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #f8fafc;
}

.nav a {
  margin-left: 16px;
  text-decoration: none;
  color: #f8fafc;
  font-weight: 500;
}

.nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav a {
  margin-left: 0;
}

.nav a:hover {
  color: #ffd6c2;
}

.nav-dropdown {
  position: relative;
}

.nav-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 190px;
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.25);
  padding: 12px 8px 8px;
  display: none;
  z-index: 50;
}

.nav-dropdown:hover .nav-dropdown-menu {
  display: block;
}

.nav-dropdown:focus-within .nav-dropdown-menu {
  display: block;
}

.nav-dropdown-menu a {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
}

.nav-dropdown-menu a:hover {
  background: rgba(255, 255, 255, 0.1);
}

.container {
  padding: 28px;
  max-width: 1200px;
  margin: 0 auto;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 18px;
}

.card {
  background: var(--card);
  padding: 18px;
  margin-bottom: 18px;
  border: 1px solid var(--stroke);
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
}

.card-accent {
  border: 1px solid rgba(255, 122, 61, 0.35);
  background: linear-gradient(135deg, #fff3ec, #ffffff);
}

.card-title {
  font-weight: 600;
  margin-bottom: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  align-items: end;
}

label {
  display: flex;
  flex-direction: column;
  font-size: 13px;
  color: var(--muted);
}

input {
  margin-top: 6px;
  padding: 9px 12px;
  border: 1px solid var(--stroke);
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
}

button {
  padding: 9px 14px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
}

button:hover {
  opacity: 0.9;
}

button.ghost {
  background: transparent;
  color: var(--accent);
}

a.ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--accent);
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  background: transparent;
}

a.ghost:hover {
  opacity: 0.9;
}

button.danger {
  border-color: var(--danger);
  background: var(--danger);
}

.checkbox {
  flex-direction: row;
  gap: 8px;
  align-items: center;
}

.checkbox input {
  margin: 0;
}

.row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.link:hover {
  color: var(--accent-2);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--card);
  border-radius: 12px;
  overflow: visible;
}

.table-wrap {
  overflow-x: auto;
  border-radius: 12px;
  position: relative;
}

.table-tools {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.table-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: 8px;
  flex-wrap: wrap;
  gap: 12px;
}

.pagination-info {
  color: var(--muted);
  font-size: 14px;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

thead {
  background: #eef2f7;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #eef2f7;
}

tbody tr:nth-child(even) {
  background: #fafafa;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--stroke);
  text-align: left;
  font-size: 14px;
  vertical-align: top;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

.actions {
  white-space: nowrap;
}

.actions form {
  margin: 0 8px 0 0;
  display: inline-block;
  vertical-align: middle;
}

.actions .icon-btn {
  margin-right: 8px;
  vertical-align: middle;
}

.actions form:last-child,
.actions .icon-btn:last-child {
  margin-right: 0;
}

.sticky-col {
  position: sticky;
  right: 0;
  background: var(--card);
  box-shadow: -6px 0 12px rgba(15, 23, 42, 0.05);
  min-width: 140px;
  z-index: 4;
  border-left: 1px solid var(--stroke);
}

.actions-col {
  background: var(--card);
}

.metric-cell.metric-warn {
  background: #fffbeb;
}

.metric-cell.metric-alert {
  background: #fff1f2;
}

.sortable {
  cursor: pointer;
}

.center {
  text-align: center;
}

.clamp-2 {
  max-width: 260px;
  white-space: normal;
  word-break: break-word;
}

.col-host {
  min-width: 260px;
}

.col-network {
  min-width: 190px;
}

.nowrap {
  white-space: nowrap;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tab-btn {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: #fff;
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}

.tab-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.icon-btn {
  border: 1px solid var(--stroke);
  background: #fff;
  color: var(--text);
  padding: 6px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  display: block;
}

.icon-btn.danger {
  border-color: var(--danger);
  color: var(--danger);
  background: #fff;
}

.status-pill.offline {
  background: #fee2e2;
  color: #991b1b;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 40;
}

.modal[aria-hidden="false"] {
  display: flex;
}

.modal-card {
  background: var(--card);
  border-radius: 16px;
  padding: 18px;
  max-width: 700px;
  width: 100%;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.2);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.pill.ok {
  background: #dcfce7;
  color: var(--ok);
}

.pill.warn {
  background: #fef3c7;
  color: var(--warn);
}

.pill-healthy { background: #dcfce7; color: #166534; }
.pill-suspect { background: #fef3c7; color: #b45309; }
.pill-degraded { background: #fee2e2; color: #991b1b; }
.pill-maintenance { background: #e0e7ff; color: #3730a3; }
.pill-unknown { background: #f1f5f9; color: #64748b; }

td code {
  display: inline-block;
  max-width: 100%;
  white-space: normal;
  word-break: break-word;
}

@media (max-width: 900px) {
  .table-wrap {
    border: 1px solid var(--stroke);
  }
  th, td {
    font-size: 13px;
  }
  .actions { white-space: nowrap; }
}

.server-grid {
  display: grid;
  gap: 18px;
}

.server-card {
  background: var(--card);
  border-radius: 18px;
  border: 1px solid var(--stroke);
  padding: 18px;
  box-shadow: 0 16px 35px rgba(15, 23, 42, 0.08);
}

.server-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.server-title {
  font-size: 20px;
  font-weight: 700;
  display: flex;
  gap: 10px;
  align-items: center;
}

.server-id {
  font-size: 12px;
  background: #f1f5f9;
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--muted);
}

.server-meta {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pill {
  background: #f1f5f9;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  color: #334155;
}

.pill-active {
  background: #3b82f6;
  color: #fff;
}

.status-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.status-pill {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #fee2e2;
  color: #991b1b;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.status-pill.online {
  background: #dcfce7;
  color: var(--ok);
}

.status-pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.table-compact {
  table-layout: auto;
  min-width: 1500px;
  width: 1500px;
}

.table-compact.table-fit {
  width: 100%;
  min-width: 0;
  table-layout: auto;
}

.table-compact.table-fit th,
.table-compact.table-fit td {
  max-width: none;
  white-space: nowrap;
}

.table-compact.table-fit td:first-child,
.table-compact.table-fit th:first-child {
  white-space: normal;
}

.table-compact.table-fluid {
  table-layout: fixed;
  width: 100%;
  min-width: 0;
}

.table-compact.table-tight th,
.table-compact.table-tight td {
  padding: 6px 8px;
}

.table-compact th,
.table-compact td {
  max-width: 260px;
}

.table-compact th.sticky-col,
.table-compact td.sticky-col {
  right: 0;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric {
  background: #f8fafc;
  border-radius: 14px;
  padding: 12px;
  border: 1px solid #e5e7eb;
}

.metric-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.metric-value {
  font-size: 18px;
  font-weight: 700;
  margin-top: 6px;
}

.metric-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.bar {
  height: 6px;
  background: #e5e7eb;
  border-radius: 999px;
  margin-top: 8px;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.tooltip {
  position: relative;
}

.tooltip::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  background: #111827;
  color: #f9fafb;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease-in-out;
  z-index: 10;
}

.tooltip::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: calc(100% + 2px);
  transform: translateX(-50%);
  border-width: 6px 6px 0 6px;
  border-style: solid;
  border-color: #111827 transparent transparent transparent;
  opacity: 0;
  transition: opacity 0.15s ease-in-out;
  z-index: 10;
}

.tooltip:hover::after,
.tooltip:hover::before {
  opacity: 1;
}

/* ── Dashboard ── */
.dash { max-width: 1400px; margin: 0 auto; }
.dash-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.dash-header h1 { margin: 0; font-size: 24px; font-weight: 700; }
.dash-period { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.btn-period {
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--stroke);
  background: #fff; color: var(--text); font-weight: 600; cursor: pointer; font-size: 13px;
}
.btn-period.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.period-sep { color: var(--muted); font-size: 14px; margin: 0 2px; }
.period-dash { color: var(--muted); font-size: 13px; }
.date-input {
  padding: 6px 10px; border-radius: 8px; border: 1px solid var(--stroke);
  font-size: 13px; width: 130px; background: #fff; color: var(--text);
  font-family: inherit;
}

.kpi-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px; margin-bottom: 22px;
}
.kpi-card {
  background: var(--card); border: 1px solid var(--stroke); border-radius: 16px;
  padding: 16px 18px; text-align: center;
  box-shadow: 0 8px 20px rgba(15,23,42,.05);
}
.kpi-card.kpi-accent {
  border-color: rgba(99,102,241,.3);
  background: linear-gradient(135deg, #eef2ff, #fff);
}
.kpi-card.kpi-warn {
  border-color: rgba(245,158,11,.3);
  background: linear-gradient(135deg, #fffbeb, #fff);
}
.kpi-card.kpi-profit {
  border-color: rgba(16,185,129,.35);
  background: linear-gradient(135deg, #ecfdf5, #fff);
}
.kpi-card.kpi-profit .kpi-val { color: #065f46; }
.kpi-val { font-size: 26px; font-weight: 700; color: var(--accent); }
.kpi-label { font-size: 11px; color: var(--muted); margin-top: 4px; text-transform: uppercase; letter-spacing: .06em; }
.kpi-sub { font-size: 11px; color: var(--muted); margin-top: 3px; }

.dash-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 18px;
}
.dash-card {
  background: var(--card); border: 1px solid var(--stroke); border-radius: 16px;
  padding: 18px; box-shadow: 0 8px 20px rgba(15,23,42,.05);
}
.dash-card h3 { margin: 0 0 12px; font-size: 15px; font-weight: 600; }
.dash-card--wide { grid-column: 1 / -1; }

.ref-table-wrap { overflow-x: auto; }
.ref-table { width: 100%; font-size: 13px; }
.ref-table th { background: #eef2f7; font-weight: 600; text-align: left; padding: 8px 10px; white-space: nowrap; }
.ref-table td { padding: 7px 10px; border-bottom: 1px solid var(--stroke); }
.ref-table tbody tr:nth-child(even) { background: #fafafa; }
.ref-table .debt-cell { color: var(--warn); font-weight: 600; }

@media (max-width: 900px) {
  .dash-grid { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .date-input { width: 110px; }
}
