:root {
  --bg0: #1a1714;
  --bg1: #241f1a;
  --bg2: #2e2822;
  --line: rgba(232, 220, 200, 0.12);
  --ink: #f3ebe0;
  --muted: #a89884;
  --accent: #e8a54b;
  --accent-ink: #1a1208;
  --ok: #6fbf8a;
  --danger: #d17a6a;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --font: "Source Sans 3", "Segoe UI", sans-serif;
  --display: "Fraunces", Georgia, serif;
  --radius: 14px;
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(232, 165, 75, 0.14), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(90, 140, 160, 0.12), transparent 50%),
    linear-gradient(165deg, var(--bg0), #12100e 60%, #1c1814);
}

body { min-height: 100vh; }

.grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 0;
}

.top, main, .drawer, .dlg, .toast, .scrim { position: relative; z-index: 1; }

.top {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  background: rgba(26, 23, 20, 0.72);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand { display: flex; align-items: center; gap: 0.7rem; min-width: 9rem; }
.brand__mark {
  width: 2.4rem; height: 2.4rem;
  display: grid; place-items: center;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--accent), #c47a2a);
  color: var(--accent-ink);
  font-weight: 700;
  font-family: var(--display);
  letter-spacing: -0.03em;
}
.brand__name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.brand__sub { font-size: 0.72rem; color: var(--muted); letter-spacing: 0.12em; text-transform: uppercase; }

.tabs { display: flex; gap: 0.35rem; flex: 1; }
.tab {
  appearance: none; border: 0; cursor: pointer;
  background: transparent; color: var(--muted);
  font: inherit; font-weight: 600; padding: 0.45rem 0.85rem;
  border-radius: 999px;
  transition: color .2s, background .2s;
}
.tab.is-on { color: var(--ink); background: var(--bg2); }
.top__actions { display: flex; gap: 0.5rem; }

.btn {
  appearance: none; border: 0; cursor: pointer;
  font: inherit; font-weight: 600;
  padding: 0.55rem 0.95rem;
  border-radius: 10px;
  background: linear-gradient(180deg, #f0b45a, var(--accent));
  color: var(--accent-ink);
  box-shadow: 0 1px 0 rgba(255,255,255,0.2) inset;
  transition: transform .15s ease, filter .15s;
}
.btn:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn--ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: none;
}
.btn--sm { padding: 0.35rem 0.65rem; font-size: 0.85rem; }

main { padding: 1rem 1rem 2rem; }

.view { display: none; animation: rise .35s ease both; }
.view.is-on { display: block; }
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.board {
  display: flex;
  gap: 0.85rem;
  overflow-x: auto;
  padding-bottom: 1rem;
  scroll-snap-type: x proximity;
  min-height: calc(100vh - 7rem);
}

.col {
  flex: 0 0 272px;
  scroll-snap-align: start;
  background: rgba(36, 31, 26, 0.85);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 7rem);
}
.col__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 0.85rem 0.55rem;
  border-bottom: 1px solid var(--line);
}
.col__title {
  display: flex; align-items: center; gap: 0.45rem;
  font-weight: 600; font-size: 0.92rem;
}
.dot {
  width: 0.55rem; height: 0.55rem; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}
.col__count {
  font-size: 0.75rem; color: var(--muted);
  background: var(--bg0); padding: 0.15rem 0.45rem; border-radius: 999px;
}
.col__body {
  padding: 0.55rem;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 0.5rem;
  flex: 1;
}

.card {
  text-align: left;
  width: 100%;
  appearance: none; border: 1px solid transparent;
  background: var(--bg2);
  color: inherit;
  border-radius: 12px;
  padding: 0.7rem 0.75rem;
  cursor: grab;
  transition: border-color .15s, transform .15s, box-shadow .15s;
  font: inherit;
}
.card:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.card:active { cursor: grabbing; }
.card.is-drag { opacity: 0.45; }
.card__title {
  font-family: var(--display);
  font-size: 0.98rem;
  font-weight: 550;
  margin: 0 0 0.35rem;
  line-height: 1.25;
}
.card__meta { font-size: 0.8rem; color: var(--muted); }
.card__row { display: flex; justify-content: space-between; gap: 0.5rem; margin-top: 0.45rem; align-items: center; }
.card__amt { font-weight: 700; font-size: 0.85rem; color: var(--accent); }

.col.is-over { outline: 2px dashed color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: -4px; }

.sites-head h1 {
  font-family: var(--display);
  font-size: 1.6rem;
  margin: 0.2rem 0 0.25rem;
}
.sites-head p { margin: 0 0 1rem; color: var(--muted); }
.sites-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.85rem;
}
.site {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  background: rgba(36, 31, 26, 0.9);
}
.site__domain {
  font-family: var(--display);
  font-size: 1.15rem;
  margin: 0 0 0.35rem;
}
.site__status {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: var(--bg0);
  color: var(--muted);
}
.site__status[data-s="live"] { color: var(--ok); }
.site__status[data-s="restoring"] { color: var(--accent); }
.site__status[data-s="stub"] { color: var(--muted); }
.site p { margin: 0.55rem 0 0; font-size: 0.85rem; color: var(--muted); }

.dlg {
  border: 0; padding: 0; background: transparent;
  max-width: 420px; width: calc(100% - 2rem);
}
.dlg::backdrop { background: rgba(8, 6, 4, 0.72); backdrop-filter: blur(4px); }
.dlg__card {
  background: var(--bg1);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.25rem;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 0.7rem;
}
.dlg__card h2 {
  font-family: var(--display);
  margin: 0;
  font-size: 1.35rem;
}
.muted { color: var(--muted); font-size: 0.9rem; margin: 0; }
.dlg__row { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 0.35rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }

label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.82rem; color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--ink);
  background: var(--bg0);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
}
textarea { resize: vertical; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(420px, 100%);
  background: var(--bg1);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem 2rem;
  overflow-y: auto;
  z-index: 20;
  animation: slide .28s ease both;
  display: flex; flex-direction: column; gap: 0.75rem;
}
@keyframes slide {
  from { transform: translateX(24px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.drawer[hidden], .scrim[hidden] { display: none !important; }
.scrim {
  position: fixed; inset: 0;
  background: rgba(8,6,4,0.45);
  z-index: 15;
}
.drawer__head { display: flex; align-items: center; gap: 0.55rem; }
.drawer__head h2 {
  flex: 1; margin: 0;
  font-family: var(--display);
  font-size: 1.25rem;
  line-height: 1.2;
}
.icon-btn {
  appearance: none; border: 1px solid var(--line);
  background: var(--bg0); color: var(--ink);
  width: 2rem; height: 2rem; border-radius: 8px;
  font-size: 1.25rem; cursor: pointer; line-height: 1;
}
.pill {
  font-size: 0.8rem; font-weight: 700;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  padding: 0.25rem 0.55rem; border-radius: 999px;
}
.drawer__meta { font-size: 0.88rem; color: var(--muted); line-height: 1.45; }
.ai-row { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.note-form { display: flex; flex-direction: column; gap: 0.4rem; }
.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.55rem; }
.feed li {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  background: var(--bg0);
  font-size: 0.88rem;
}
.feed__t {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); margin-bottom: 0.25rem;
}
.feed__body { white-space: pre-wrap; }

.toast {
  position: fixed; bottom: 1.25rem; left: 50%;
  transform: translateX(-50%);
  background: var(--bg2);
  border: 1px solid var(--line);
  padding: 0.65rem 1rem;
  border-radius: 999px;
  box-shadow: var(--shadow);
  z-index: 40;
  font-size: 0.9rem;
}

code { font-size: 0.85em; color: var(--accent); }

@media (max-width: 720px) {
  .top { flex-wrap: wrap; }
  .brand { min-width: auto; }
  .tabs { order: 3; width: 100%; }
  .grid-2 { grid-template-columns: 1fr; }
}
