/* ==========================================================
   Green Life Admin — design tokens
   Same brand family as the storefront (forest/gold/cream)
   but tuned for data density: tighter type scale, neutral
   surface for tables, color reserved for status + accents.
   ========================================================== */

:root {
  --forest: #0D5B2A;
  --forest-dark: #0A4620;
  --emerald: #2E7D32;
  --leaf: #6BAF45;
  --gold: #C89B3C;
  --cream: #FAF8F2;
  --paper: #FFFFFF;
  --ink: #16301F;
  --line: #E7E2D6;
  --muted: #6B7368;
  --sidebar-w: 268px;
  --topbar-h: 68px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: 'Manrope', -apple-system, sans-serif;
  background: #F3F1EA;
  color: var(--ink);
  font-size: 14px;
}
.font-display { font-family: 'Fraunces', serif; }

a { color: inherit; text-decoration: none; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #D8D2C2; border-radius: 8px; }

/* ---------- Layout shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--forest);
  color: #EAF3EC;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  transition: transform .3s ease;
  z-index: 40;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand .mark {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,.1); border: 1px solid var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Fraunces', serif; font-size: 15px; color: #fff;
}
.sidebar-brand .name { font-family: 'Fraunces', serif; font-size: 16px; letter-spacing: .04em; }
.sidebar-brand .sub { font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: var(--gold); }

.nav-section {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .14em;
  color: rgba(234,243,236,.45); padding: 18px 20px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 20px; margin: 1px 10px; border-radius: 10px;
  font-size: 13.5px; font-weight: 500; color: rgba(234,243,236,.82);
  transition: background .18s ease, color .18s ease;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .85; }
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.12); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }

.sidebar-foot {
  margin-top: auto; padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.08);
  font-size: 11px; color: rgba(234,243,236,.45);
}

.main {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
}

.topbar {
  height: var(--topbar-h);
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 30;
}
.topbar h1 { font-family: 'Fraunces', serif; font-size: 20px; margin: 0; color: var(--forest); }
.topbar .crumb { font-size: 12px; color: var(--muted); margin-top: 1px; }

.search-box {
  display: flex; align-items: center; gap: 8px;
  background: #F3F1EA; border: 1px solid var(--line);
  border-radius: 999px; padding: 8px 14px; width: 280px;
  font-size: 13px; color: var(--muted);
}
.search-box input { border: none; background: transparent; outline: none; width: 100%; font-size: 13px; }

.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--forest); color: #fff; display: flex; align-items: center; justify-content: center;
  font-family: 'Fraunces', serif; font-size: 13px;
}

.page { padding: 26px 28px 60px; }

/* ---------- Cards / KPIs ---------- */
.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: 16px;
  min-width: 0; /* fixes a common CSS Grid overflow bug: grid items default to
                   min-width:auto (as wide as their content needs), so a wide
                   table inside a .card pushes the whole page wider instead of
                   scrolling internally. min-width:0 lets it shrink to its
                   track and hand off scrolling to .table-wrap as intended. */
}
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 16px; }
.kpi {
  background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px;
}
.kpi .label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.kpi .value { font-family: 'Fraunces', serif; font-size: 28px; color: var(--forest); margin-top: 6px; }
.kpi .delta { font-size: 12px; margin-top: 6px; font-weight: 600; }
.kpi .delta.up { color: var(--emerald); }
.kpi .delta.down { color: #C0392B; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; border-radius: 10px; font-size: 13.5px; font-weight: 600;
  border: 1px solid transparent; cursor: pointer; transition: all .2s ease;
}
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--forest); color: #fff; }
.btn-primary:hover { background: var(--forest-dark); }
.btn-gold { background: var(--gold); color: #fff; }
.btn-gold:hover { filter: brightness(1.06); }
.btn-outline { background: #fff; color: var(--forest); border-color: var(--line); }
.btn-outline:hover { border-color: var(--forest); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: #F3F1EA; color: var(--ink); }
.btn-danger-outline { background: #fff; color: #C0392B; border-color: #F2D4CD; }
.btn-danger-outline:hover { background: #FBEAE6; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted); border: 1px solid var(--line); background: #fff; cursor: pointer;
}
.icon-btn:hover { color: var(--forest); border-color: var(--forest); }
.icon-btn svg { width: 14px; height: 14px; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table.dt { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.dt thead th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.dt tbody td { padding: 13px 16px; border-bottom: 1px solid #F0EDE3; vertical-align: middle; }
table.dt tbody tr:hover { background: #FBFAF6; }
table.dt tbody tr:last-child td { border-bottom: none; }

.badge {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: .02em; box-shadow: inset 0 0 0 1px;
}

.thumb { width: 40px; height: 40px; border-radius: 9px; object-fit: cover; background: #F3F1EA; }

/* ---------- Forms ---------- */
.field-label { font-size: 12.5px; font-weight: 600; color: var(--ink); margin-bottom: 6px; display: block; }
.field-hint { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
input[type=text], input[type=number], input[type=email], input[type=password],
input[type=date], input[type=datetime-local], input[type=url], input[type=tel],
select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  font-size: 13.5px; font-family: 'Manrope', sans-serif; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--leaf); outline-offset: 1px; border-color: transparent; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.form-row { margin-bottom: 18px; }
.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: #D8D2C2; border-radius: 999px; transition: .2s; cursor: pointer; }
.switch .slider::before { content: ''; position: absolute; height: 16px; width: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--emerald); }
.switch input:checked + .slider::before { transform: translateX(18px); }

.tab-bar { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.tab-btn { padding: 10px 4px; margin-right: 22px; font-size: 13.5px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; }
.tab-btn.active { color: var(--forest); border-color: var(--gold); }

.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state svg { width: 40px; height: 40px; margin: 0 auto 14px; opacity: .5; }

.pagination { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; font-size: 12.5px; color: var(--muted); }
.page-btn { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); display: inline-flex; align-items: center; justify-content: center; background: #fff; cursor: pointer; }
.page-btn.active { background: var(--forest); color: #fff; border-color: var(--forest); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; }
.filters select, .filters input { width: auto; min-width: 140px; }

.section-title { font-family: 'Fraunces', serif; font-size: 17px; color: var(--forest); margin: 0 0 4px; }
.section-sub { font-size: 12.5px; color: var(--muted); margin: 0 0 16px; }

@media (max-width: 1024px) {
  .sidebar { position: fixed; left: 0; transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .form-grid { grid-template-columns: 1fr; }
}