/* Barnaby dashboard. One accent (hay gold) on a forest-green base.
   Shape rule: cards 14px, inputs 10px, buttons and chips fully round. */
:root {
  --bg: #eef2ec;
  --surface: #ffffff;
  --surface-2: #f4f7f2;
  --ink: #16241b;
  --muted: #5b6b61;
  --line: #dbe3d8;
  --forest: #1d3d2b;
  --forest-ink: #e7efe8;
  --forest-muted: #9db5a4;
  --accent: #d99a1e;
  --accent-soft: #f8ebcf;
  --accent-ink: #2b1d02;
  --danger: #c2443b;
  --danger-soft: #f8dfdc;
  --ok: #2c8350;
  --ok-soft: #dcefe2;
  --shadow: 0 1px 2px rgba(29, 61, 43, 0.06), 0 8px 24px -12px rgba(29, 61, 43, 0.18);
  --r-card: 14px;
  --r-input: 10px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1510;
    --surface: #142019;
    --surface-2: #1a2920;
    --ink: #e5ece6;
    --muted: #96a89c;
    --line: #24362b;
    --forest: #0a120d;
    --forest-ink: #dfe9e1;
    --forest-muted: #7f998a;
    --accent: #e8ad3a;
    --accent-soft: #3a2d10;
    --accent-ink: #1e1401;
    --danger: #e0675e;
    --danger-soft: #3a1c19;
    --ok: #57b37c;
    --ok-soft: #173123;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 "Outfit", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
i.ph, i[class^="ph"] { font-size: 1.15em; vertical-align: -0.15em; }

/* ---------- Boot / login ---------- */
.boot { min-height: 100dvh; display: grid; place-items: center; }
.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.login {
  min-height: 100dvh; display: grid; grid-template-columns: 1.1fr 1fr;
}
.login-art {
  background: var(--forest); color: var(--forest-ink);
  padding: 56px; display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.login-art::after {
  content: ""; position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px;
  border-radius: 50%; background: radial-gradient(circle, rgba(232, 173, 58, 0.28), transparent 65%);
}
.login-art h1 { font-size: clamp(40px, 6vw, 72px); line-height: 1.02; letter-spacing: -0.03em; margin: 0; max-width: 9ch; }
.login-art p { color: var(--forest-muted); max-width: 40ch; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px; width: max-content;
  padding: 4px 12px; border-radius: 999px; font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase;
  background: rgba(255, 255, 255, 0.08); color: var(--forest-ink);
}
.login-panel { display: grid; place-items: center; padding: 32px 16px; }
.login-card { width: min(380px, 100%); }
.login-card h2 { font-size: 28px; letter-spacing: -0.02em; margin: 0 0 6px; }
.login-card p { color: var(--muted); margin: 0 0 24px; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100dvh; }
.side {
  background: var(--forest); color: var(--forest-ink);
  padding: 22px 14px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100dvh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 20px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-size: 20px; overflow: hidden;
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.brand b { display: block; font-size: 17px; letter-spacing: -0.01em; }
.brand small { color: var(--forest-muted); font-size: 12px; }
.nav-btn {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 10px 12px; border: 0; border-radius: 999px; background: transparent;
  color: var(--forest-muted); cursor: pointer; text-align: left;
  transition: background 0.3s var(--ease), color 0.3s var(--ease);
}
.nav-btn:hover { color: var(--forest-ink); background: rgba(255, 255, 255, 0.05); }
.nav-btn[aria-current="page"] { background: rgba(232, 173, 58, 0.16); color: var(--accent); }
.nav-btn .count {
  margin-left: auto; font-size: 12px; min-width: 22px; text-align: center;
  padding: 1px 7px; border-radius: 999px; background: var(--accent); color: var(--accent-ink);
}
.side-foot { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 10px 0; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.side-foot img { width: 30px; height: 30px; border-radius: 50%; }
.side-foot span { flex: 1; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn {
  border: 0; background: transparent; color: inherit; cursor: pointer;
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  transition: background 0.3s var(--ease);
}
.icon-btn:hover { background: rgba(127, 127, 127, 0.15); }

main { padding: 36px clamp(16px, 3vw, 40px) 80px; width: 100%; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.page-head h1 { font-size: clamp(28px, 4vw, 38px); letter-spacing: -0.03em; line-height: 1.05; margin: 0; }
.page-head p { margin: 6px 0 0; color: var(--muted); max-width: 60ch; }

/* ---------- Cards and grids ---------- */
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.span-2 { grid-column: span 2; }
.card {
  background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow);
  padding: 22px; min-width: 0;
  animation: rise 0.6s var(--ease) both;
}
.card h2 { font-size: 17px; letter-spacing: -0.01em; margin: 0 0 4px; display: flex; align-items: center; gap: 8px; }
.card > .hint { color: var(--muted); margin: 0 0 18px; font-size: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.card-head .hint { margin: 0; color: var(--muted); font-size: 14px; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.grid > .card:nth-child(2) { animation-delay: 0.05s; }
.grid > .card:nth-child(3) { animation-delay: 0.1s; }
.grid > .card:nth-child(4) { animation-delay: 0.15s; }
.grid > .card:nth-child(5) { animation-delay: 0.2s; }

.stat { display: flex; flex-direction: column; gap: 2px; }
.stat i { color: var(--accent); font-size: 22px; margin-bottom: 8px; }
.stat b { font-size: 30px; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 14px; }

/* ---------- Forms ---------- */
.fields { display: grid; gap: 16px; }
.fields-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 13px; font-weight: 500; color: var(--muted); }
.field .help { font-size: 12.5px; color: var(--muted); }
input[type="text"], input[type="number"], input[type="url"], input[type="datetime-local"], select, textarea {
  width: 100%; padding: 10px 12px; border-radius: var(--r-input);
  border: 1px solid var(--line); background: var(--surface-2);
  transition: border-color 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
textarea { min-height: 96px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.toggle { display: flex; align-items: center; gap: 12px; cursor: pointer; user-select: none; }
.toggle input { appearance: none; width: 40px; height: 24px; border-radius: 999px; background: var(--line); position: relative; cursor: pointer; flex: none; transition: background 0.3s var(--ease); margin: 0; }
.toggle input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform 0.3s var(--ease); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); }
.toggle input:checked { background: var(--ok); }
.toggle input:checked::after { transform: translateX(16px); }
.toggle input:focus-visible { box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
.toggle span b { display: block; font-weight: 500; }
.toggle span small { color: var(--muted); font-size: 13px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line); font-size: 13.5px; max-width: 100%;
}
.chip .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.chip button { border: 0; background: transparent; cursor: pointer; padding: 0; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.chip button:hover { background: var(--line); color: var(--ink); }

.row-editor { display: grid; gap: 8px; }
.row-editor .row { display: grid; grid-template-columns: 64px 1fr auto; gap: 8px; align-items: center; }
.row-editor .row.with-role { grid-template-columns: 64px 1fr 1fr auto; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-weight: 500; white-space: nowrap;
  transition: transform 0.2s var(--ease), background 0.3s var(--ease), border-color 0.3s var(--ease), opacity 0.2s;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { border-color: var(--accent); filter: brightness(1.05); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); background: var(--danger-soft); }
.btn-sm { padding: 6px 12px; font-size: 13.5px; }
.btn-discord { background: #5865f2; border-color: #5865f2; color: #fff; width: 100%; padding: 13px 18px; }
.btn-discord:hover { border-color: #5865f2; filter: brightness(1.08); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 20px; }
.actions .spacer { flex: 1; }

/* ---------- Lists / tables ---------- */
.list { display: flex; flex-direction: column; }
.item { display: flex; gap: 14px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); min-width: 0; }
.item:first-child { border-top: 0; padding-top: 0; }
.item .grow { flex: 1; min-width: 0; }
.item .title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.item .meta { color: var(--muted); font-size: 13.5px; overflow-wrap: anywhere; }
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 500; background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--accent-soft); color: var(--accent); }
.badge.bad { background: var(--danger-soft); color: var(--danger); }
.when-col { width: 120px; flex: none; color: var(--muted); font-size: 13.5px; }

.check { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
.check:first-child { border-top: 0; }
.check i { font-size: 20px; margin-top: 1px; }
.check .done { color: var(--ok); }
.check .todo { color: var(--muted); }
.check small { display: block; color: var(--muted); }

.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.empty i { font-size: 30px; display: block; margin-bottom: 8px; color: var(--line); }
.error-box { padding: 14px 16px; border-radius: var(--r-input); background: var(--danger-soft); color: var(--danger); }
.notice { padding: 12px 14px; border-radius: var(--r-input); background: var(--accent-soft); color: var(--ink); font-size: 14px; display: flex; gap: 10px; align-items: flex-start; }
.notice i { color: var(--accent); }

.skeleton { border-radius: var(--r-card); background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.4s ease infinite; height: 120px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.preview {
  padding: 14px 16px; border-radius: var(--r-input); background: var(--surface-2);
  border-left: 4px solid var(--accent); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px;
}

/* ---------- Toasts / modal ---------- */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 30; }
.toast {
  padding: 12px 16px; border-radius: 999px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow);
  display: flex; gap: 10px; align-items: center; animation: rise 0.4s var(--ease) both; max-width: min(420px, calc(100vw - 32px));
}
.toast.bad { background: var(--danger); color: #fff; }
dialog {
  border: 0; border-radius: var(--r-card); padding: 0; width: min(760px, calc(100vw - 32px));
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(10, 20, 14, 0.55); }
#modal-body { padding: 24px; }
.transcript { max-height: 60vh; overflow: auto; background: var(--surface-2); border-radius: var(--r-input); padding: 14px; font: 13px/1.6 ui-monospace, "Cascadia Mono", monospace; white-space: pre-wrap; overflow-wrap: anywhere; }

.chat { height: min(52vh, 520px); overflow: auto; background: var(--surface-2); border-radius: var(--r-input); padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.msg { display: flex; gap: 10px; align-items: flex-start; max-width: 85%; }
.msg > img { width: 32px; height: 32px; border-radius: 50%; flex: none; }
.msg .bubble { background: var(--surface); border-radius: var(--r-card); padding: 8px 12px; min-width: 0; overflow-wrap: anywhere; white-space: pre-wrap; box-shadow: var(--shadow); }
.msg.me { align-self: flex-end; flex-direction: row-reverse; }
.msg.me .bubble { background: var(--accent-soft); }
.msg .who { font-size: 12.5px; font-weight: 600; display: flex; gap: 8px; align-items: baseline; }
.msg .who span { font-weight: 400; color: var(--muted); }
.msg .embed { border-left: 3px solid var(--accent); padding-left: 8px; margin-top: 4px; color: var(--muted); font-size: 13.5px; }
.msg .shot { max-width: 240px; max-height: 180px; border-radius: var(--r-input); margin-top: 6px; display: block; }

.head-tools { display: flex; gap: 4px; align-items: center; }
.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; right: 0; top: 40px; min-width: 190px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-input); box-shadow: var(--shadow); padding: 6px; z-index: 5; }
.menu-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 9px 10px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; text-align: left; }
.menu-item:hover { background: var(--surface-2); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-soft); }
.inbox-bar { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 16px; }
.inbox-search { width: min(320px, 100%); }
.segs { display: inline-flex; padding: 4px; gap: 4px; border-radius: 999px; background: var(--surface-2); }
.seg { border: 0; background: transparent; padding: 7px 16px; border-radius: 999px; cursor: pointer; color: var(--muted); font-weight: 500; transition: background 0.3s var(--ease), color 0.3s var(--ease); }
.seg[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.chip-btn { border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px; padding: 4px 12px; font-size: 13.5px; cursor: pointer; transition: background 0.25s var(--ease), border-color 0.25s var(--ease); }
.chip-btn:hover { border-color: var(--muted); }
.chip-btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); font-weight: 500; }

.mobile-bar { display: none; }

/* ---------- Small screens ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; overflow-x: auto; padding: 10px 12px; gap: 4px; }
  .brand, .side-foot { display: none; }
  .nav-btn { width: auto; flex: none; padding: 8px 14px; }
  .nav-btn .count { display: none; }
  .mobile-bar { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 0; }
  main { padding: 20px 16px 64px; }
  .grid-2, .fields-2 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .login { grid-template-columns: 1fr; }
  .login-art { padding: 32px 16px; min-height: 280px; }
  .when-col { display: none; }
  .item { flex-wrap: wrap; gap: 8px 10px; }
  .item .grow { flex: 1 1 100%; order: -1; }
  .row-editor .row.with-role { grid-template-columns: 56px 1fr auto; }
  .row-editor .row.with-role select { grid-column: 1 / -1; grid-row: 2; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
