/* BEF Analytics dashboard — design language inspired by causehouse.co:
   warm cream paper, forest-green ink, sage/lime/brick accents,
   Fraunces serif display + Inter body, hard offset shadows, pill buttons. */

@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=Inter:wght@400;500;600;700&display=swap");

:root {
  --bg: #f7f0e6;
  --bg-alt: #f3ebdd;
  --surface: #fffcf4;
  --ink: #1f2a1f;
  --ink-70: rgba(29, 43, 31, 0.7);
  --ink-45: rgba(29, 43, 31, 0.45);
  --ink-25: rgba(29, 43, 31, 0.25);
  --ink-12: rgba(29, 43, 31, 0.12);
  --ink-06: rgba(29, 43, 31, 0.06);
  --text: #1f2a1f;
  --text-dim: #4f5d51;
  --text-faint: #6b7a6d;
  --sage: #b9d9c4;
  --sage-soft: rgba(185, 217, 196, 0.4);
  --lime: #bfea4b;
  --lime-soft: rgba(191, 234, 75, 0.28);
  --brick: #c53a20;
  --brick-soft: rgba(197, 58, 32, 0.1);
  --blue: #1e5bff;
  --amber: #b45309;
  --green-deep: #2e6b3f;
  /* Aliases kept for older markup */
  --accent: #1f2a1f;
  --accent-soft: var(--sage-soft);
  --green: #2e6b3f;
  --green-soft: var(--sage-soft);
  --yellow: #b45309;
  --red: #c53a20;
  --red-soft: var(--brick-soft);
  --panel: var(--surface);
  --panel-alt: var(--bg-alt);
  --border: var(--ink-25);
  --border-strong: var(--ink);
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 3px 3px 0 0 var(--ink);
  --shadow-sm: 2px 2px 0 0 var(--ink);
  --shadow-lg: 6px 6px 0 0 var(--ink);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display: "Fraunces", "Georgia", serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { scrollbar-color: var(--ink-45) transparent; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, .display {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
}

a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--ink-45); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--ink); }

svg.icon { width: 17px; height: 17px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }

/* ---------- Top bar ---------- */

header.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 1.5px solid var(--ink);
  background: rgba(247, 240, 230, 0.92);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 50;
  flex-wrap: wrap;
  gap: 10px;
}

header.topbar .brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 21px;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 10px;
}

header.topbar .brand a { text-decoration: none; }

header.topbar .brand::before {
  content: "";
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--lime);
  border: 1.5px solid var(--ink);
  box-shadow: 2px 2px 0 0 var(--ink);
}

nav.tabs { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }

nav.tabs a {
  padding: 7px 15px;
  border-radius: 999px;
  border: 1.5px solid transparent;
  color: var(--ink-70);
  font-size: 14px;
  font-weight: 500;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

nav.tabs a:hover { background: var(--ink-06); color: var(--ink); }
nav.tabs a.active {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--ink);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}
nav.tabs a.logout { color: var(--brick); }

/* ---------- Layout ---------- */

main { max-width: 1240px; margin: 0 auto; padding: 32px 28px 56px; }

.card {
  background: var(--surface);
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card.flat { box-shadow: none; border-color: var(--ink-25); }

.card h3 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.grid { display: grid; gap: 16px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); }

.section-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
  margin: 40px 0 14px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.section-title .num {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-faint);
  letter-spacing: 0.08em;
}

.two-col { display: grid; grid-template-columns: 320px 1fr; gap: 18px; }

/* ---------- Stat tiles ---------- */

.stat-card {
  background: var(--surface);
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.stat-card:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 0 var(--ink); }

.stat-card .label {
  order: 1;
  color: var(--text-dim);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 6px;
}

.stat-card .value {
  order: 2;
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat-card .sub { order: 3; color: var(--text-faint); font-size: 12.5px; margin-top: 5px; }

/* ---------- Badges & chips ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1.5px solid var(--ink);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; flex: none; background: currentColor; }

.badge.online { background: var(--lime); color: var(--ink); }
.badge.online::before { animation: pulse 2s ease-in-out infinite; }
.badge.offline { background: var(--bg-alt); color: var(--brick); border-color: var(--brick); }
.badge.live { background: var(--brick); color: #fff; border-color: var(--ink); }
.badge.live::before { background: #fff; animation: pulse 1.6s ease-in-out infinite; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--ink-25);
  background: var(--bg-alt);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  white-space: nowrap;
}

.chip.sage { background: var(--sage-soft); border-color: var(--green-deep); color: var(--green-deep); }
.chip.lime { background: var(--lime-soft); border-color: var(--ink); color: var(--ink); }
.chip.brick { background: var(--brick-soft); border-color: var(--brick); color: var(--brick); }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

@media (prefers-reduced-motion: reduce) {
  .badge::before { animation: none !important; }
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

/* ---------- Tables ---------- */

table { width: 100%; border-collapse: collapse; }

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

th {
  color: var(--text-faint);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding-bottom: 8px;
  border-bottom: 1.5px solid var(--ink);
  white-space: nowrap;
}

th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
th .arrow { font-size: 10px; }

td { font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.12s ease; }
tbody tr:hover { background: var(--ink-06); }
tbody tr.clickable { cursor: pointer; }

/* ---------- Buttons & forms ---------- */

button, .btn {
  background: var(--surface);
  color: var(--ink);
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  padding: 8px 18px;
  min-height: 40px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.15s ease;
}

button:hover, .btn:hover { background: var(--bg-alt); transform: translate(-1px, -1px); box-shadow: 3px 3px 0 0 var(--ink); text-decoration: none; }
button:active, .btn:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 0 var(--ink); }
button:focus-visible, .btn:focus-visible, a:focus-visible { outline: 2.5px solid var(--blue); outline-offset: 2px; }

button.primary, .btn.primary { background: var(--ink); color: var(--bg); }
button.primary:hover, .btn.primary:hover { background: #2c3b2d; }

button.accent, .btn.accent { background: var(--lime); color: var(--ink); }
button.accent:hover, .btn.accent:hover { background: #cdf267; }

button.danger, .btn.danger { background: var(--surface); color: var(--brick); border-color: var(--brick); box-shadow: 2px 2px 0 0 var(--brick); }
button.danger:hover, .btn.danger:hover { background: var(--brick-soft); box-shadow: 3px 3px 0 0 var(--brick); }
button.danger:active, .btn.danger:active { box-shadow: 1px 1px 0 0 var(--brick); }

button.ghost, .btn.ghost { box-shadow: none; border-color: var(--ink-25); font-weight: 500; }
button.ghost:hover, .btn.ghost:hover { transform: none; box-shadow: none; border-color: var(--ink); }

button:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; box-shadow: var(--shadow-sm) !important; }

input, select, textarea {
  background: var(--surface);
  color: var(--ink);
  border: 1.5px solid var(--ink-45);
  border-radius: var(--radius-sm);
  padding: 9px 13px;
  min-height: 40px;
  font-size: 14px;
  font-family: var(--font);
  width: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input::placeholder, textarea::placeholder { color: var(--text-faint); }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 2px 2px 0 0 var(--ink);
}

input[type="checkbox"] { accent-color: var(--ink); }

label { display: block; margin-bottom: 6px; color: var(--text-dim); font-size: 13px; font-weight: 600; }

.form-row { margin-bottom: 14px; }

.search-wrap { position: relative; }
.search-wrap svg.icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-faint); pointer-events: none; }
.search-wrap input { padding-left: 38px; }

/* ---------- Meter (disk usage) ---------- */

.meter {
  height: 12px;
  border-radius: 999px;
  background: var(--bg-alt);
  border: 1.5px solid var(--ink);
  overflow: hidden;
}

.meter > .fill {
  height: 100%;
  background: var(--sage);
  border-right: 1.5px solid var(--ink);
  transition: width 0.4s ease;
  min-width: 2px;
}

.meter > .fill.warn { background: #f2c94c; }
.meter > .fill.crit { background: var(--brick); }

.meter-legend {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--text-dim);
  margin-top: 8px;
  font-variant-numeric: tabular-nums;
}

/* ---------- Toast / modal ---------- */

.toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  padding: 12px 20px;
  border-radius: 999px;
  border: 1.5px solid var(--ink);
  font-weight: 600;
  font-size: 14px;
  z-index: 300;
  box-shadow: var(--shadow);
  animation: toast-in 0.2s ease-out;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.toast svg.icon { width: 16px; height: 16px; flex-shrink: 0; }

@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.toast.success { background: var(--lime); color: var(--ink); }
.toast.error { background: var(--brick); color: #fff; }

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(29, 43, 31, 0.5);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  padding: 20px;
}

.modal {
  background: var(--surface);
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  padding: 26px;
  max-width: 560px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal h3 { font-family: var(--font-display); font-size: 20px; margin-top: 0; text-transform: none; letter-spacing: 0; color: var(--ink); }

.hidden { display: none !important; }

/* ---------- Skeleton loading ---------- */

.skeleton {
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--ink-06) 25%, var(--ink-12) 50%, var(--ink-06) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease infinite;
  color: transparent !important;
  user-select: none;
}

@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- Misc ---------- */

.empty-state {
  text-align: center;
  padding: 36px 20px;
  color: var(--text-faint);
  font-size: 14px;
}

.empty-state .big { font-family: var(--font-display); font-size: 18px; color: var(--text-dim); margin-bottom: 4px; }
.empty-state > svg.icon { width: 28px; height: 28px; opacity: 0.55; margin-bottom: 8px; }

.breadcrumbs { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; color: var(--text-faint); }
.breadcrumbs a { font-weight: 600; }

.divider { border: none; border-top: 1.5px solid var(--ink-12); margin: 18px 0; }

::selection { background: var(--lime); color: var(--ink); }

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  main { padding: 18px 16px 44px; }
  header.topbar { padding: 10px 16px; }
  .section-title { margin-top: 30px; }
}
