/* Equipotential. One stylesheet, no build step.
   Every colour is a custom property on :root so a dark variant is a swap, not a rewrite. */

:root {
  /* Surfaces */
  --bg:           #f4f2ee;
  --surface:      #ffffff;
  --surface-2:    #faf9f7;
  --sidebar:      #1d2a26;
  --sidebar-2:    #16211e;

  /* Ink */
  --ink:          #1b2320;
  --ink-2:        #5a6763;
  --ink-3:        #8a9490;
  --on-dark:      #e8ede9;
  --on-dark-2:    #93a39c;

  /* Brand: hunter green and saddle brass */
  --accent:       #2f6b52;
  --accent-soft:  #e4efe8;
  --brass:        #b6883f;

  /* Status */
  --ok:           #2f6b52;
  --ok-soft:      #e4efe8;
  --warn:         #9a6a13;
  --warn-soft:    #fbf0da;
  --crit:         #a33427;
  --crit-soft:    #fae6e3;

  --line:         #e3e0da;
  --line-2:       #eeece7;

  --radius:       12px;
  --radius-sm:    8px;
  --shadow:       0 1px 2px rgba(27,35,32,.05), 0 4px 16px rgba(27,35,32,.05);

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
small { font-size: 12px; }
code { font-family: var(--mono); font-size: 12px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; border: 1px solid var(--line-2); }
.muted { color: var(--ink-3); }

/* ---------------------------------------------------------------- shell */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  flex: 0 0 220px;
  background: var(--sidebar);
  color: var(--on-dark);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand { display: flex; align-items: center; gap: 10px; color: var(--on-dark); text-decoration: none; padding: 0 6px; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px; flex: 0 0 30px;
  display: grid; place-items: center;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  font-weight: 700; font-size: 12px; letter-spacing: .04em;
}
.brand-text { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }

.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  color: var(--on-dark-2);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-weight: 500;
}
.nav-item:hover { background: var(--sidebar-2); color: var(--on-dark); text-decoration: none; }
.nav-item.is-active { background: var(--accent); color: #fff; }
.nav-admin { margin-top: 10px; border-top: 1px solid rgba(255,255,255,.08); padding-top: 14px; color: var(--brass); }

.sidebar-foot { margin-top: auto; font-size: 11px; line-height: 1.5; color: var(--on-dark-2); opacity: .7; padding: 0 6px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 18px; }
.user-menu { display: flex; align-items: center; gap: 12px; }
.user-name { font-size: 13px; color: var(--ink-2); }

.content { padding: 24px 28px 48px; display: flex; flex-direction: column; gap: 20px; }

/* ---------------------------------------------------------------- cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.card-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); margin-bottom: 14px; }
.card-more { display: inline-block; margin-top: 12px; font-size: 13px; font-weight: 500; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); }
.stat-value { font-size: 30px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; }
.stat-unit { font-size: 13px; font-weight: 500; color: var(--ink-3); margin-left: 5px; letter-spacing: 0; }
.stat-note { font-size: 11px; color: var(--ink-3); }
.stat-alert .stat-value { color: var(--crit); }

.split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 20px; align-items: start; }

/* ---------------------------------------------------------------- table */
.table-wrap { overflow-x: auto; margin: 0 -20px -18px; padding: 0 20px 18px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-weight: 600; font-size: 11px; text-transform: uppercase;
  letter-spacing: .05em; color: var(--ink-3);
  padding: 0 10px 8px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td { padding: 10px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.horse-cell { display: flex; align-items: center; gap: 10px; color: inherit; }
.horse-cell:hover { text-decoration: none; }
.horse-cell strong { display: block; font-weight: 600; }
.horse-cell strong:hover { color: var(--accent); }
.horse-cell small { color: var(--ink-3); }

/* CSS-generated avatar: initials on a colour block driven by horses.avatar_hue. */
.avatar {
  width: 34px; height: 34px; flex: 0 0 34px;
  display: grid; place-items: center;
  border-radius: 9px;
  font-size: 12px; font-weight: 700; letter-spacing: .02em;
  background: hsl(var(--hue, 200) 38% 88%);
  color: hsl(var(--hue, 200) 44% 28%);
  border: 1px solid hsl(var(--hue, 200) 34% 80%);
}
.avatar-sm { width: 28px; height: 28px; flex: 0 0 28px; font-size: 10px; border-radius: 7px; }

/* ---------------------------------------------------------------- chips */
.chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px; font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
}
.chip-normal   { background: var(--ok-soft);   color: var(--ok); }
.chip-warning  { background: var(--warn-soft); color: var(--warn); }
.chip-critical { background: var(--crit-soft); color: var(--crit); }
.chip-admin    { background: #efe6d3; color: var(--brass); }
.delta-hot { color: var(--crit); font-weight: 600; }

/* ---------------------------------------------------------------- alerts */
.alert-feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.alert-feed li { display: flex; gap: 11px; padding: 12px 0; border-bottom: 1px solid var(--line-2); }
.alert-feed li:last-child { border-bottom: 0; padding-bottom: 0; }
.alert-feed p { margin: 0; }
.alert-head { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; }
.alert-msg { font-size: 13px; color: var(--ink-2); margin-top: 2px !important; }
.alert-time { font-size: 11px; color: var(--ink-3); margin-top: 3px !important; }

.empty { color: var(--ink-3); font-size: 13px; margin: 0; padding: 8px 0; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-block;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #26563f; }
.btn-ghost { background: transparent; color: var(--ink-2); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-block { width: 100%; padding: 11px; margin-top: 6px; }

/* ---------------------------------------------------------------- flash */
.flash { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; border: 1px solid; }
.flash-ok    { background: var(--ok-soft);   color: var(--ok);   border-color: #c8ddd1; }
.flash-error { background: var(--crit-soft); color: var(--crit); border-color: #ecc8c3; }

/* ---------------------------------------------------------------- login */
.login-body { display: grid; place-items: center; min-height: 100vh; background: var(--sidebar); padding: 24px; }
.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,.28);
}
.login-brand { display: flex; align-items: center; gap: 10px; }
.login-brand .brand-text { color: var(--ink); font-size: 17px; }
.login-sub { margin: 6px 0 22px; font-size: 13px; color: var(--ink-3); }
.login-card label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin: 14px 0 5px; }
.login-card input {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 14px; color: var(--ink);
  background: var(--surface-2);
}
.login-card input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); background: var(--surface); }
.login-demo { margin: 22px 0 0; padding-top: 16px; border-top: 1px solid var(--line-2); font-size: 12px; color: var(--ink-2); line-height: 1.7; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1000px) {
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .sidebar { width: auto; flex: none; flex-direction: row; align-items: center; gap: 14px; overflow-x: auto; padding: 12px 14px; }
  .sidebar nav { flex-direction: row; gap: 4px; }
  .nav-item { white-space: nowrap; padding: 6px 10px; font-size: 13px; }
  .nav-admin { margin-top: 0; border-top: 0; padding-top: 6px; }
  .sidebar-foot { display: none; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
}

/* ---------------------------------------------------------------- toolbar */
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap;
}
.search { display: flex; gap: 8px; flex: 1 1 280px; max-width: 460px; }
.search input {
  flex: 1; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 13px; background: var(--surface);
}
.search input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.range-tabs { display: flex; gap: 4px; flex-wrap: wrap; background: var(--surface); padding: 4px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.range-tab { padding: 6px 12px; border-radius: 6px; font-size: 13px; font-weight: 500; color: var(--ink-2); white-space: nowrap; }
.range-tab:hover { background: var(--surface-2); text-decoration: none; }
.range-tab.is-active { background: var(--accent); color: #fff; }

/* ---------------------------------------------------------------- picker */
.picker { display: flex; gap: 6px; flex-wrap: wrap; }
.picker-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
  font-size: 13px; font-weight: 500; color: var(--ink-2);
}
.picker-item:hover { border-color: var(--accent); text-decoration: none; }
.picker-item.is-active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

/* ---------------------------------------------------------------- charts */
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 20px; }
.chart-box { position: relative; height: 230px; }
.chart-note { margin: 10px 0 0; font-size: 11px; color: var(--ink-3); }

/* ---------------------------------------------------------------- profile */
.profile { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.profile-id { flex: 1; min-width: 220px; }
.profile-id h2 { font-size: 20px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.profile-id p { margin: 4px 0 0; font-size: 13px; }
.avatar-lg { width: 52px; height: 52px; flex: 0 0 52px; font-size: 17px; border-radius: 13px; }
.stat-note.is-hot { color: var(--crit); font-weight: 600; }

/* ---------------------------------------------------------------- horse grid */
.horse-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.horse-card { display: flex; gap: 14px; color: inherit; align-items: flex-start; }
.horse-card:hover { text-decoration: none; border-color: var(--accent); }
.horse-card-body { min-width: 0; flex: 1; }
.horse-card h3 { font-size: 15px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.horse-card p { margin: 4px 0 0; font-size: 12px; }
.horse-card-vitals { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px !important; font-size: 12px; color: var(--ink-2); }
.horse-card-vitals strong { font-size: 15px; color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- intensity chips */
.chip-low      { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.chip-moderate { background: var(--accent-soft); color: var(--accent); }
.chip-high     { background: #efe6d3; color: var(--brass); }

/* ---------------------------------------------------------------- admin */
.actions { display: flex; flex-direction: column; gap: 8px; }
.action { display: flex; align-items: center; gap: 12px; }
.action .btn { min-width: 190px; text-align: center; }
.action-note { font-size: 12px; color: var(--ink-3); }
.btn-danger { background: var(--crit-soft); color: var(--crit); border-color: #ecc8c3; }
.btn-danger:hover { background: var(--crit); color: #fff; }

.sim label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin: 12px 0 5px; }
.sim select {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-family: inherit; font-size: 13px; background: var(--surface); color: var(--ink);
}
.sim select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

@media (max-width: 620px) {
  .action { flex-direction: column; align-items: stretch; }
  .action .btn { min-width: 0; }
  .chart-grid { grid-template-columns: 1fr; }
}
