@import url('https://fonts.googleapis.com/css2?family=Geist:wght@300;400;500;600;700&family=Geist+Mono:wght@400;500&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #ffffff;
  --bg-subtle:   #f9f9f9;
  --bg-hover:    #f4f4f4;
  --border:      #e5e5e5;
  --border-mid:  #d1d1d1;
  --text:        #111111;
  --text-mid:    #555555;
  --text-soft:   #888888;
  --accent:      #111111;
  --accent-soft: #f0f0f0;
  --green:       #16a34a;
  --green-bg:    #f0fdf4;
  --red:         #dc2626;
  --red-bg:      #fef2f2;
  --orange:      #d97706;
  --orange-bg:   #fffbeb;
  --yellow:      #ca8a04;
  --yellow-bg:   #fefce8;
  --blue:        #2563eb;
  --blue-bg:     #eff6ff;
  --radius:      8px;
  --radius-lg:   12px;
  --shadow:      0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:   0 4px 12px rgba(0,0,0,.08);
  --font:        'Geist', system-ui, sans-serif;
  --font-mono:   'Geist Mono', monospace;
  --sidebar-w:   220px;
}

html { font-size: 14px; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.5; min-height: 100vh; }

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: var(--font); }
input, select, textarea { font-family: var(--font); }

/* ── LAYOUT ── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  background: var(--bg);
  z-index: 100;
}

.sidebar-logo {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo .logo-mark {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -.3px;
}
.logo-icon {
  width: 28px; height: 28px;
  background: var(--text);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-nav { padding: 8px; flex: 1; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius);
  font-size: 13.5px;
  color: var(--text-mid);
  transition: background .12s, color .12s;
}
.sidebar-nav a:hover  { background: var(--bg-hover); color: var(--text); }
.sidebar-nav a.active { background: var(--accent-soft); color: var(--text); font-weight: 500; }
.sidebar-nav .nav-icon { width: 16px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-footer a:hover { color: var(--text); }

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
}

.topbar {
  height: 52px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title { font-size: 15px; font-weight: 600; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.page { padding: 24px; max-width: 1200px; }

/* ── CARDS ── */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.card + .card { margin-top: 16px; }
.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 14px;
}

/* ── STATS GRID ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.stat-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.stat-card .stat-label { font-size: 12px; color: var(--text-soft); margin-bottom: 4px; }
.stat-card .stat-value { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.5px; }
.stat-card .stat-sub   { font-size: 11px; color: var(--text-soft); margin-top: 2px; }

/* ── PROGRESS BARS ── */
.stat-bar-wrap { margin-bottom: 12px; }
.stat-bar-wrap:last-child { margin-bottom: 0; }
.stat-bar-header { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text-mid); margin-bottom: 5px; }
.stat-bar { height: 5px; background: var(--bg-hover); border-radius: 99px; overflow: hidden; }
.stat-bar-fill { height: 100%; border-radius: 99px; transition: width .4s ease; }
.bar-blue   { background: var(--blue); }
.bar-orange { background: var(--orange); }
.bar-red    { background: var(--red); }

/* ── BADGES ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 500;
}
.badge-green  { background: var(--green-bg);  color: var(--green); }
.badge-red    { background: var(--red-bg);    color: var(--red); }
.badge-orange { background: var(--orange-bg); color: var(--orange); }
.badge-yellow { background: var(--yellow-bg); color: var(--yellow); }
.badge-gray   { background: var(--bg-hover);  color: var(--text-soft); }
.badge-blue   { background: var(--blue-bg);   color: var(--blue); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: background .12s, border-color .12s, opacity .12s;
  white-space: nowrap;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary  { background: var(--text); color: #fff; }
.btn-primary:hover { background: #333; }
.btn-outline  { background: transparent; border-color: var(--border-mid); color: var(--text); }
.btn-outline:hover { background: var(--bg-hover); }
.btn-danger   { background: var(--red-bg); border-color: transparent; color: var(--red); }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ── TABLE ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-subtle);
}
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-subtle); }
.td-mono { font-family: var(--font-mono); font-size: 12px; color: var(--text-mid); }

/* ── FORMS ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 5px; }
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  font-size: 13.5px;
  background: var(--bg);
  color: var(--text);
  transition: border-color .12s, box-shadow .12s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(0,0,0,.06);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 11.5px; color: var(--text-soft); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── ALERTS ── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.alert-error   { background: var(--red-bg);   color: var(--red);   border-color: #fecaca; }
.alert-success { background: var(--green-bg); color: var(--green); border-color: #bbf7d0; }
.alert-info    { background: var(--blue-bg);  color: var(--blue);  border-color: #bfdbfe; }

/* ── DIVIDERS & HELPERS ── */
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.mt-4 { margin-top: 4px; }  .mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-4 { margin-bottom: 4px; } .mb-16 { margin-bottom: 16px; }
.flex { display: flex; } .items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.text-soft { color: var(--text-soft); }
.text-sm { font-size: 12.5px; }
.font-mono { font-family: var(--font-mono); font-size: 12px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── MODAL ── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 480px;
  max-width: calc(100vw - 32px);
  box-shadow: var(--shadow-md);
}
.modal-title { font-size: 16px; font-weight: 600; margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ── LOGIN PAGE ── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-subtle);
}
.login-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 380px;
  box-shadow: var(--shadow-md);
}
.login-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}
.login-logo .logo-icon { width: 36px; height: 36px; font-size: 16px; border-radius: 8px; }
.login-logo span { font-size: 18px; font-weight: 700; letter-spacing: -.4px; }

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-soft);
}
.empty-state .empty-icon { font-size: 32px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ── SITE DETAIL ── */
.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.info-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.info-row:last-child { border-bottom: none; }
.info-key { color: var(--text-mid); }
.info-val { font-weight: 500; text-align: right; max-width: 60%; word-break: break-all; }

/* ── CHART ── */
.chart-container { position: relative; height: 180px; }

/* ── TOPBAR SEARCH ── */
.search-input {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  width: 220px;
  background: var(--bg-subtle);
}
.search-input:focus { outline: none; border-color: var(--text); background: var(--bg); }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
  .detail-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
