:root {
  --bg: #eef1f0;
  --panel: #ffffff;
  --ink: #1b2420;
  --muted: #66756c;
  --line: #d7ddd9;
  --brand: #1a5c3a;
  --brand-soft: #e6f3eb;
  --danger: #9b2c2c;
  --danger-soft: #f8e8e8;
  --warn: #8a5a00;
  --warn-soft: #fff3d6;
  --font: "Segoe UI", "Avenir Next", "Trebuchet MS", sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(900px 400px at 0% 0%, #d9ebe1, transparent 60%),
    var(--bg);
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.tiny { font-size: 0.85rem; }
.brand { margin: 0; color: var(--brand); font-weight: 800; letter-spacing: -0.02em; }

a { color: var(--brand); }

.gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.gate-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px;
  box-shadow: 0 12px 40px rgba(20, 40, 30, 0.06);
}

.gate-card h1 {
  margin: 6px 0 8px;
  font-size: 1.8rem;
  letter-spacing: -0.03em;
}

.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100dvh;
}

.sidebar {
  background: #143528;
  color: #e8f2ec;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.side-brand {
  display: grid;
  gap: 2px;
  padding: 8px 10px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
}
.side-brand strong { font-size: 1.1rem; }
.side-brand span { color: #9fc4af; font-size: 0.85rem; }

.side-nav { display: grid; gap: 6px; }
.nav-item {
  border: 0;
  background: transparent;
  color: #cfe3d7;
  text-align: left;
  padding: 12px 12px;
  border-radius: 10px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}
.nav-item:hover { background: rgba(255,255,255,0.06); }
.nav-item.active { background: rgba(255,255,255,0.12); color: #fff; }

.side-foot { margin-top: auto; display: grid; gap: 10px; }
.who { font-size: 0.85rem; color: #9fc4af; padding: 0 8px; word-break: break-all; }

.main { padding: 28px 32px 48px; overflow: auto; }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}
.page-head h1 {
  margin: 0 0 4px;
  font-size: 1.7rem;
  letter-spacing: -0.03em;
}
.page-head p { margin: 0; }

.stats { display: flex; gap: 10px; flex-wrap: wrap; }
.stat-pill {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.9rem;
  font-weight: 700;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 16px;
}
.panel.narrow { max-width: 420px; }
.panel h2 { margin: 0 0 12px; font-size: 1.05rem; }

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}
.field span { font-size: 0.85rem; color: var(--muted); font-weight: 650; }
.field input, .field textarea, .field select {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  background: #fff;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 8px;
}

.btn {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.btn.primary { background: var(--brand); color: #fff; }
.btn.ghost {
  background: transparent;
  color: inherit;
  border: 1px solid rgba(255,255,255,0.2);
}
.btn.block { width: 100%; }
.btn.sm { padding: 7px 10px; font-size: 0.85rem; }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.ok { background: var(--brand-soft); color: var(--brand); }

.table-wrap { overflow: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
th, td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
th { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.78rem;
  font-weight: 750;
}
.badge.trial { background: var(--warn-soft); color: var(--warn); }
.badge.active { background: var(--brand-soft); color: var(--brand); }
.badge.inactive { background: var(--danger-soft); color: var(--danger); }
.badge.pending { background: #e8eef8; color: #2a4a7a; }
.badge.lock { background: #fde8e8; color: #9b2c2c; margin-left: 4px; }
.badge.warn-soon { background: #fff3d6; color: #8a5a00; margin-left: 4px; }
.tiny { font-size: 0.8rem; margin-top: 2px; }

.split {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  align-items: start;
}

.cat-list { padding: 10px; }
.cat-item {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
  padding: 12px;
  border-radius: 12px;
  font: inherit;
  cursor: pointer;
  margin-bottom: 4px;
}
.cat-item:hover { background: #f4f7f5; }
.cat-item.active { background: var(--brand-soft); border-color: #b7d8c5; }
.cat-item strong { display: block; }
.cat-item span { color: var(--muted); font-size: 0.85rem; }

.unit-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 16px; }
.unit-chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 8px 12px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.unit-chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }

.items-table input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  font: inherit;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #143528;
  color: #fff;
  padding: 12px 16px;
  border-radius: 999px;
  font-weight: 700;
  z-index: 50;
}

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .side-nav { display: flex; flex-wrap: wrap; }
  .side-foot { margin-top: 0; width: 100%; }
  .split, .form-grid { grid-template-columns: 1fr; }
}
