:root {
  --bg: #f6f3ec;
  --bg-grad: radial-gradient(1200px 600px at 80% -10%, #efe9db 0%, #f6f3ec 55%);
  --card: #ffffff;
  --ink: #23241f;
  --muted: #7c7a6f;
  --line: #e7e2d6;
  --olive: #3f5333;
  --olive-2: #50693f;
  --gold: #b3892f;
  --gold-soft: #f4ead2;
  --green: #2f7d4f;
  --green-soft: #e3f1e7;
  --amber: #b07a1a;
  --amber-soft: #f7ecd2;
  --grey: #8a877c;
  --grey-soft: #eeebe2;
  --red: #b23a3a;
  --shadow: 0 1px 2px rgba(35,36,31,.04), 0 8px 24px rgba(35,36,31,.06);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-grad), var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
}

/* Brand */
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px; height: 38px; display: grid; place-items: center;
  background: linear-gradient(150deg, var(--olive) 0%, var(--olive-2) 100%);
  border-radius: 10px; font-size: 20px; box-shadow: var(--shadow);
}
.brand-name { font-weight: 700; letter-spacing: -.01em; }
.brand-sub { font-size: 12px; color: var(--muted); }
.brand-logo { height: 84px; width: auto; display: block; }
.brand-divider { width: 1px; height: 40px; background: var(--line); display: inline-block; }
.topbar .brand-sub { font-size: 12px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--gold); }
.brand-login { justify-content: center; margin-bottom: 10px; }
.brand-login .brand-logo { height: 84px; }
.brand-sub-login { text-align: center; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--gold); margin-bottom: 2px; }

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 28px; background: rgba(255,255,255,.7);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }

/* Layout */
.wrap { max-width: 1080px; margin: 0 auto; padding: 28px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 18px; }
h1 { font-size: 22px; margin: 0 0 2px; letter-spacing: -.02em; }
.muted { color: var(--muted); margin: 0; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.stat .n { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.stat .l { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.stat.accent .n { color: var(--green); }
.stat.amber .n { color: var(--amber); }

/* Toolbar */
.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 6px 14px; border-radius: 999px; font-size: 13px; cursor: pointer; font-weight: 500;
}
.chip.active { background: var(--olive); color: #fff; border-color: var(--olive); }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch .track { width: 36px; height: 20px; background: var(--grey-soft); border-radius: 999px; position: relative; transition: .15s; border: 1px solid var(--line); }
.switch .track::after { content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%; background: #fff; top: 1px; left: 1px; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: .15s; }
.switch input:checked + .track { background: var(--green); border-color: var(--green); }
.switch input:checked + .track::after { left: 17px; }

/* List + cards */
.list { display: flex; flex-direction: column; gap: 14px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px; display: grid;
  grid-template-columns: 4px 1fr auto; gap: 0 18px; position: relative; overflow: hidden;
}
.card .accent-bar { grid-row: 1 / 99; width: 4px; border-radius: 4px; background: var(--grey); }
.card.is-active .accent-bar { background: var(--green); }
.card.is-pending .accent-bar { background: var(--amber); }

.card-main { min-width: 0; }
.tagrow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.tag {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  padding: 3px 9px; border-radius: 6px; background: var(--grey-soft); color: var(--grey);
}
.tag.cat { background: var(--gold-soft); color: var(--gold); }
.tag.chan { background: #e8eef6; color: #3a5a82; }
.badge { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; display: inline-flex; align-items: center; gap: 5px; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.active { background: var(--green-soft); color: var(--green); }
.badge.disabled { background: var(--grey-soft); color: var(--grey); }
.badge.pending { background: var(--amber-soft); color: var(--amber); }

.card h3 { margin: 2px 0 6px; font-size: 16px; letter-spacing: -.01em; }
.summary { color: #56544b; margin: 0 0 12px; font-size: 13px; max-width: 70ch; }

.meta { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-bottom: 12px; }
.meta .item { font-size: 12.5px; }
.meta .k { color: var(--muted); margin-right: 6px; }
.meta .v { font-weight: 500; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: #f3f0e7; padding: 1px 6px; border-radius: 5px; }

.recips { display: flex; flex-wrap: wrap; gap: 6px; }
.recip { display: inline-flex; align-items: center; gap: 6px; background: #f5f2ea; border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px 3px 4px; font-size: 12px; }
.recip .av { width: 18px; height: 18px; border-radius: 50%; background: var(--olive); color: #fff; display: grid; place-items: center; font-size: 9px; font-weight: 700; }
.recip .num { color: var(--muted); }

.card-actions { display: flex; flex-direction: column; gap: 8px; align-items: stretch; min-width: 120px; }

/* Buttons */
.btn { font-family: inherit; font-size: 13px; font-weight: 600; border-radius: 9px; padding: 8px 14px; cursor: pointer; border: 1px solid transparent; transition: .12s; white-space: nowrap; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--olive); color: #fff; }
.btn-primary:hover { background: var(--olive-2); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { background: #fff; }
.btn-run { background: var(--gold-soft); color: var(--gold); border-color: #ecdcb8; }
.btn-run:hover { background: #efe1c2; }

/* Pills */
.pill { font-size: 12px; font-weight: 600; padding: 5px 12px; border-radius: 999px; display: inline-flex; align-items: center; gap: 6px; }
.pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill-ok { background: var(--green-soft); color: var(--green); }
.pill-bad { background: #f7e2e2; color: var(--red); }
.pill-muted { background: var(--grey-soft); color: var(--grey); }

.empty { text-align: center; color: var(--muted); padding: 48px; background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); }

/* Toasts */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 9999; }
.toast {
  min-width: 240px; max-width: 360px; padding: 12px 16px; border-radius: 11px;
  background: #2a2b25; color: #fff; box-shadow: 0 8px 28px rgba(0,0,0,.22);
  font-size: 13px; font-weight: 500; opacity: 0; transform: translateY(12px); transition: .25s;
  border-left: 4px solid var(--gold);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { border-left-color: #57c97f; }
.toast.error { border-left-color: #e06464; }

/* Confirm modal */
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { filter: brightness(.93); }
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center;
  background: rgba(43, 43, 37, .42); backdrop-filter: blur(3px);
  opacity: 0; transition: opacity .18s; padding: 20px;
}
.modal-overlay.show { opacity: 1; }
.modal {
  width: 420px; max-width: 100%; background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: 0 24px 70px rgba(0,0,0,.28); padding: 24px 24px 20px;
  transform: translateY(10px) scale(.98); transition: transform .18s;
}
.modal-overlay.show .modal { transform: translateY(0) scale(1); }
.modal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.modal-icon {
  width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
  font-size: 17px; flex: none;
}
.modal-icon.gold { background: var(--gold-soft); color: var(--gold); }
.modal-icon.danger { background: #f7e2e2; color: var(--red); }
.modal-head h2 { font-size: 17px; font-weight: 700; letter-spacing: -.01em; margin: 0; }
.modal-body { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 0 0 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* Login */
.login-body { min-height: 100vh; display: grid; place-items: center; }
.login-card { width: 360px; max-width: 92vw; background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 30px 28px; }
.login-card h1 { font-size: 20px; margin: 20px 0 4px; }
.login-card .brand { margin-bottom: 4px; }
.login-card label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 18px 0 6px; }
.login-card input { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; font-family: inherit; }
.login-card input:focus { outline: none; border-color: var(--olive); }
.login-card button { width: 100%; margin-top: 18px; background: var(--olive); color: #fff; border: none; padding: 11px; border-radius: 10px; font-weight: 600; font-size: 14px; cursor: pointer; }
.login-card button:hover { background: var(--olive-2); }
.alert { background: #f7e2e2; color: var(--red); border-radius: 9px; padding: 9px 12px; font-size: 13px; margin-top: 14px; }
.login-foot { margin-top: 22px; text-align: center; font-size: 11px; }

@media (max-width: 720px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .card { grid-template-columns: 4px 1fr; }
  .card-actions { flex-direction: row; margin-top: 12px; grid-column: 2; }
  .wrap, .topbar { padding-left: 16px; padding-right: 16px; }
}
