:root {
  --bg: #0f1410;
  --bg-elev: #171e18;
  --bg-soft: #1e2720;
  --ink: #e8eee6;
  --muted: #8a9688;
  --line: #2a342c;
  --accent: #c4a35a;
  --accent-2: #6f9e7a;
  --danger: #d07060;
  --warn: #d4a24c;
  --radius: 10px;
  --font: "DM Sans", system-ui, sans-serif;
  --display: "Instrument Serif", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

/* Themed scrollbars — match forest / gold palette */
html {
  scrollbar-width: thin;
  scrollbar-color: #5a6e58 transparent;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 999px;
}
*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #4a5c48 0%, #3a4a3a 100%);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
  min-height: 40px;
}
*::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--accent) 0%, #8a6b2e 100%);
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:active {
  background: linear-gradient(180deg, #d4b56a 0%, var(--accent) 100%);
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-corner {
  background: transparent;
}

.rail,
.side,
.chat {
  scrollbar-width: thin;
  scrollbar-color: #5a6e58 var(--bg-elev);
}
.rail::-webkit-scrollbar-track,
.side::-webkit-scrollbar-track,
.chat::-webkit-scrollbar-track {
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  margin: 6px 0;
}
.rail::-webkit-scrollbar-thumb,
.side::-webkit-scrollbar-thumb,
.chat::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #556655 0%, #3d4d40 55%, #2e3a30 100%);
  border: 2px solid var(--bg-elev);
  background-clip: padding-box;
}
.rail::-webkit-scrollbar-thumb:hover,
.side::-webkit-scrollbar-thumb:hover,
.chat::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--accent) 0%, #9a7a3a 100%);
  border: 2px solid var(--bg-elev);
  background-clip: padding-box;
}

body {
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 10% -10%, #243028 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #2a2418 0%, transparent 50%),
    var(--bg);
  color: var(--ink);
}

.app {
  display: grid;
  grid-template-columns: 280px 1fr 320px;
  min-height: 100vh;
  gap: 0;
}

.rail, .side {
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  border-right: 1px solid var(--line);
  padding: 1.25rem;
  overflow-y: auto;
  max-height: 100vh;
}
.side { border-right: none; border-left: 1px solid var(--line); }

.brand { display: flex; gap: .75rem; align-items: center; margin-bottom: 1.5rem; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--accent), #8a6b2e);
  color: #14120c; font-weight: 700; letter-spacing: .02em;
}
.brand-name { font-weight: 600; }
.brand-sub { color: var(--muted); font-size: .78rem; }

.panel { margin-bottom: 1.4rem; }
.panel h2, .side h2 {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); font-weight: 600; margin: 0 0 .6rem;
}

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
.stat {
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 8px; padding: .55rem .65rem;
}
.stat b { display: block; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.stat span { font-size: .7rem; color: var(--muted); }
.stat.hot b { color: var(--danger); }
.stat.warn b { color: var(--warn); }

.biz-list { list-style: none; padding: 0; margin: 0 0 .6rem; }
.biz-list li {
  padding: .45rem .5rem; border-radius: 6px; font-size: .9rem;
  border: 1px solid transparent;
}
.biz-list li:hover { background: var(--bg-soft); border-color: var(--line); }
.biz-list .slug { display: block; color: var(--muted); font-size: .72rem; }

.approvals .item {
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 8px; padding: .65rem; margin-bottom: .5rem; font-size: .85rem;
}
.approvals .actions { display: flex; gap: .4rem; margin-top: .5rem; }
.approvals button { font-size: .75rem; }

.google-panel {
  display: flex;
  flex-direction: column;
  gap: .55rem;
}
.btn-connect {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  width: 100%;
  box-sizing: border-box;
  text-align: center;
  text-decoration: none !important;
  padding: .7rem .9rem;
  border-radius: 10px;
  border: 1px solid transparent;
  background: linear-gradient(145deg, #d4b56a, var(--accent) 55%, #8a6b2e);
  color: #14120c !important;
  font-weight: 700;
  font-size: .88rem;
  letter-spacing: .01em;
  box-shadow: 0 1px 0 rgba(255,255,255,.2) inset, 0 4px 12px rgba(0,0,0,.25);
  transition: filter .15s ease, transform .15s ease;
}
.btn-connect:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}
.btn-connect:active {
  transform: translateY(0);
  filter: brightness(.96);
}
.pull-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .4rem;
}
.pull-btn {
  width: 100%;
  border-radius: 10px !important;
  padding: .5rem .4rem !important;
  font-size: .75rem !important;
  white-space: nowrap;
}
.google-status {
  font-size: .75rem;
  line-height: 1.35;
}

.links { display: flex; flex-direction: column; gap: .4rem; }
.links a { color: var(--accent); text-decoration: none; font-size: .85rem; }

.main {
  display: flex; flex-direction: column;
  padding: 1.5rem 1.75rem 1rem;
  min-height: 100vh; max-height: 100vh;
}
.top h1 {
  font-family: var(--display);
  font-weight: 400; font-size: clamp(1.8rem, 3vw, 2.4rem);
  margin: 0 0 .35rem; letter-spacing: -.01em;
}
.lede { color: var(--muted); margin: 0 0 1rem; max-width: 42rem; }
.quick { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.quick button, .ghost, .composer button, .approvals button, .modal-actions button {
  font-family: inherit; cursor: pointer; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg-soft); color: var(--ink);
  padding: .4rem .75rem; font-size: .8rem;
}
.quick button:hover, .ghost:hover { border-color: var(--accent); color: var(--accent); }
#send, #modal-save {
  background: var(--accent); color: #14120c; border-color: transparent; font-weight: 600;
  border-radius: 10px; padding: .7rem 1.1rem;
}

.chat {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: .85rem;
  padding-right: .25rem; margin-bottom: .75rem;
}
.bubble {
  max-width: 92%; padding: .85rem 1rem; border-radius: 14px;
  line-height: 1.45; white-space: pre-wrap; font-size: .95rem;
}
.bubble.user {
  align-self: flex-end;
  background: #243328; border: 1px solid #314337;
}
.bubble.assistant {
  align-self: flex-start;
  background: var(--bg-elev); border: 1px solid var(--line);
}
.bubble .tools {
  margin-top: .55rem; font-size: .72rem; color: var(--muted);
  border-top: 1px solid var(--line); padding-top: .45rem;
}

.composer {
  display: grid; grid-template-columns: 1fr auto; gap: .6rem; align-items: end;
}
.composer textarea, .modal-card input, .modal-card textarea {
  width: 100%; font-family: inherit; font-size: .95rem;
  background: var(--bg-elev); color: var(--ink);
  border: 1px solid var(--line); border-radius: 12px;
  padding: .75rem .9rem; resize: vertical;
}
.status { font-size: .8rem; min-height: 1.2em; margin-top: .35rem; }
.muted { color: var(--muted); }

.task-board .card {
  border: 1px solid var(--line); background: var(--bg-soft);
  border-radius: var(--radius); padding: .7rem .75rem; margin-bottom: .55rem;
}
.task-board .title { font-size: .88rem; font-weight: 550; margin-bottom: .25rem; }
.task-board .meta { font-size: .72rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: .35rem; }
.pill {
  display: inline-block; padding: .1rem .4rem; border-radius: 4px;
  background: #2a322b; border: 1px solid var(--line);
}
.pill.p0 { color: var(--danger); border-color: #5a3030; }
.pill.p1 { color: var(--warn); }

.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  display: grid; place-items: center; z-index: 20;
}
.modal.hidden { display: none; }
.modal-card {
  width: min(420px, 92vw); background: var(--bg-elev);
  border: 1px solid var(--line); border-radius: 14px; padding: 1.2rem;
}
.modal-card label { display: block; font-size: .8rem; color: var(--muted); margin: .6rem 0 .25rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }

@media (max-width: 1100px) {
  .app { grid-template-columns: 1fr; }
  .rail, .side { max-height: none; border: none; border-bottom: 1px solid var(--line); }
  .main { max-height: none; min-height: 70vh; }
}
