:root {
  color-scheme: dark;
  --ink: #eef5ff;
  --muted: #8fa1ba;
  --soft: #b8c6d9;
  --bg: #050b14;
  --panel: #0b1524;
  --panel-2: #101d2e;
  --line: rgba(255,255,255,.09);
  --blue: #2c75ff;
  --blue-2: #6ea3ff;
  --green: #25d18a;
  --amber: #f4b942;
  --red: #ff6b6b;
  --purple: #a782ff;
  --shadow: 0 18px 55px rgba(0,0,0,.34);
  --radius: 20px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: radial-gradient(circle at 85% 0%, rgba(44,117,255,.16), transparent 33%), var(--bg); color: var(--ink); }
body { min-height: 100dvh; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }

.app-shell { width: min(100%, 980px); min-height: 100dvh; margin: 0 auto; position: relative; padding-bottom: 92px; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: calc(14px + env(safe-area-inset-top)) 18px 14px; background: linear-gradient(180deg, rgba(5,11,20,.98), rgba(5,11,20,.88)); backdrop-filter: blur(18px); border-bottom: 1px solid var(--line); }
.brand-lockup { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-icon { width: 42px; height: 42px; border-radius: 13px; box-shadow: 0 8px 22px rgba(44,117,255,.24); }
.eyebrow { margin: 0 0 2px; color: var(--blue-2); letter-spacing: .14em; font-weight: 800; font-size: 10px; }
h1 { margin: 0; font-size: 21px; letter-spacing: -.03em; }
.avatar-button { width: 42px; height: 42px; border-radius: 50%; border: 1px solid rgba(110,163,255,.4); background: linear-gradient(145deg, #17325c, #0a1525); display: grid; place-items: center; font-weight: 800; cursor: pointer; }

.main-content { padding: 18px; display: grid; gap: 18px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-heading h2 { margin: 0 0 5px; font-size: clamp(25px, 5vw, 34px); letter-spacing: -.045em; }
.page-heading p { margin: 0; color: var(--muted); line-height: 1.45; }

.hero { padding: 22px; border-radius: 26px; overflow: hidden; position: relative; background: linear-gradient(145deg, rgba(44,117,255,.24), rgba(11,21,36,.92) 65%); border: 1px solid rgba(110,163,255,.22); box-shadow: var(--shadow); }
.hero::after { content: ""; position: absolute; width: 210px; height: 210px; right: -90px; top: -105px; border-radius: 50%; background: rgba(44,117,255,.2); filter: blur(2px); }
.hero-top { position: relative; z-index: 1; display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; }
.hero h2 { margin: 0; font-size: clamp(28px, 6vw, 42px); max-width: 640px; letter-spacing: -.05em; }
.hero p { margin: 10px 0 0; color: #c9d8ed; max-width: 640px; line-height: 1.55; }
.live-pill { flex: none; padding: 7px 10px; border-radius: 999px; background: rgba(37,209,138,.13); color: #78e8b8; border: 1px solid rgba(37,209,138,.3); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.live-pill.sim { background: rgba(244,185,66,.12); color: #ffd47a; border-color: rgba(244,185,66,.28); }
.hero-actions { position: relative; z-index: 1; margin-top: 20px; display: flex; gap: 10px; flex-wrap: wrap; }

.button { appearance: none; border: 0; border-radius: 13px; padding: 12px 15px; font-weight: 800; cursor: pointer; transition: transform .15s ease, opacity .15s ease, background .15s ease; }
.button:active { transform: scale(.98); }
.button.primary { background: var(--blue); color: white; box-shadow: 0 10px 22px rgba(44,117,255,.25); }
.button.secondary { background: rgba(255,255,255,.07); border: 1px solid var(--line); }
.button.ghost { background: transparent; color: var(--blue-2); padding-inline: 8px; }
.button.danger { background: rgba(255,107,107,.13); color: #ff9999; border: 1px solid rgba(255,107,107,.25); }
.button.small { padding: 8px 10px; font-size: 12px; border-radius: 10px; }
.button:disabled { opacity: .45; cursor: not-allowed; }

.stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
.stat-card { background: linear-gradient(150deg, rgba(16,29,46,.97), rgba(9,18,31,.97)); border: 1px solid var(--line); border-radius: 18px; padding: 16px; min-height: 116px; }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 700; }
.stat-value { margin-top: 7px; font-size: 28px; font-weight: 900; letter-spacing: -.04em; }
.stat-foot { margin-top: 7px; color: var(--soft); font-size: 12px; }

.section-card { background: rgba(11,21,36,.9); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: 0 10px 36px rgba(0,0,0,.18); }
.section-header { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 16px 16px 10px; }
.section-header h3 { margin: 0; font-size: 17px; letter-spacing: -.02em; }
.section-header p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.list { display: grid; }
.list-row { display: grid; grid-template-columns: auto minmax(0,1fr) auto; gap: 12px; align-items: center; padding: 14px 16px; border-top: 1px solid var(--line); cursor: pointer; }
.list-row:hover { background: rgba(255,255,255,.025); }
.row-icon { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: rgba(44,117,255,.12); color: var(--blue-2); font-weight: 900; }
.row-title { margin: 0 0 3px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-subtitle { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.row-meta { text-align: right; color: var(--soft); font-size: 12px; }

.chip { display: inline-flex; align-items: center; gap: 5px; padding: 5px 8px; border-radius: 999px; background: rgba(255,255,255,.07); color: var(--soft); border: 1px solid var(--line); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .045em; }
.chip.green { color: #76e9b5; background: rgba(37,209,138,.1); border-color: rgba(37,209,138,.24); }
.chip.amber { color: #ffd47a; background: rgba(244,185,66,.1); border-color: rgba(244,185,66,.24); }
.chip.red { color: #ff9999; background: rgba(255,107,107,.1); border-color: rgba(255,107,107,.24); }
.chip.blue { color: #9bc0ff; background: rgba(44,117,255,.12); border-color: rgba(44,117,255,.25); }

.toolbar { display: flex; gap: 10px; align-items: center; }
.search { flex: 1; position: relative; }
.search input, .field input, .field select, .field textarea, .command-box textarea { width: 100%; border: 1px solid var(--line); background: rgba(255,255,255,.045); color: var(--ink); border-radius: 13px; padding: 12px 13px; outline: none; }
.search input:focus, .field input:focus, .field select:focus, .field textarea:focus, .command-box textarea:focus { border-color: rgba(110,163,255,.6); box-shadow: 0 0 0 3px rgba(44,117,255,.1); }

.card-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.entity-card { border: 1px solid var(--line); background: linear-gradient(150deg, rgba(16,29,46,.98), rgba(8,16,28,.98)); border-radius: 18px; padding: 16px; cursor: pointer; }
.entity-card:hover { border-color: rgba(110,163,255,.35); }
.entity-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.entity-card h3 { margin: 0 0 5px; font-size: 18px; }
.entity-card p { margin: 0; color: var(--muted); line-height: 1.5; font-size: 13px; }
.entity-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.next-action { margin-top: 14px; padding: 11px 12px; border-radius: 12px; background: rgba(244,185,66,.08); border: 1px solid rgba(244,185,66,.16); color: #ffe0a0; font-size: 12px; line-height: 1.45; }
.money { color: #78e8b8; font-weight: 900; }

.calendar-day { border-left: 2px solid var(--blue); margin-left: 9px; padding-left: 18px; }
.date-label { color: var(--blue-2); font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; margin: 4px 0 11px; }
.event-card { position: relative; margin-bottom: 12px; padding: 14px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line); }
.event-card::before { content: ""; position: absolute; left: -25px; top: 18px; width: 10px; height: 10px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 5px var(--bg); }
.event-time { font-weight: 900; color: var(--blue-2); font-size: 12px; }
.event-title { margin: 5px 0; font-weight: 800; }
.event-detail { color: var(--muted); font-size: 12px; }

.command-box { border: 1px solid rgba(110,163,255,.25); border-radius: 22px; padding: 16px; background: linear-gradient(145deg, rgba(44,117,255,.12), rgba(11,21,36,.95)); }
.command-box textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
.command-actions { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin-top: 11px; }
.command-hint { color: var(--muted); font-size: 11px; }
.quick-commands { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 5px; scrollbar-width: none; }
.quick-command { white-space: nowrap; border-radius: 999px; border: 1px solid var(--line); background: rgba(255,255,255,.04); color: var(--soft); padding: 9px 11px; cursor: pointer; font-size: 12px; }

.queue-card { border: 1px solid var(--line); background: var(--panel); border-radius: 18px; overflow: hidden; }
.queue-head { padding: 15px; display: flex; justify-content: space-between; gap: 15px; align-items: flex-start; }
.queue-head h3 { margin: 0 0 5px; font-size: 16px; }
.queue-head p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.queue-items { border-top: 1px solid var(--line); }
.queue-item { padding: 13px 15px; border-top: 1px solid var(--line); }
.queue-item:first-child { border-top: 0; }
.queue-item-top { display: flex; justify-content: space-between; gap: 12px; }
.queue-item h4 { margin: 0 0 3px; }
.queue-item p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.queue-outcome { margin-top: 10px; padding: 10px; border-radius: 11px; background: rgba(37,209,138,.07); color: #a8f1d0; font-size: 12px; line-height: 1.45; }

.empty-state { padding: 34px 20px; text-align: center; color: var(--muted); }
.empty-state strong { display: block; color: var(--soft); margin-bottom: 6px; }

.bottom-nav { position: fixed; z-index: 30; bottom: 0; left: 50%; transform: translateX(-50%); width: min(100%, 980px); display: grid; grid-template-columns: repeat(5, 1fr); padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); background: rgba(5,11,20,.96); backdrop-filter: blur(18px); border-top: 1px solid var(--line); }
.nav-item { border: 0; background: transparent; display: grid; place-items: center; gap: 3px; color: #73849c; padding: 5px; cursor: pointer; }
.nav-item span { font-size: 22px; line-height: 1; }
.nav-item small { font-size: 10px; font-weight: 800; }
.nav-item.active { color: var(--blue-2); }
.ai-nav span { width: 34px; height: 34px; border-radius: 13px; display: grid; place-items: center; background: var(--blue); color: white; box-shadow: 0 7px 20px rgba(44,117,255,.36); margin-top: -14px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.7); backdrop-filter: blur(8px); display: grid; align-items: end; }
.modal { width: min(100%, 720px); margin: 0 auto; max-height: 90dvh; overflow-y: auto; background: #091321; border: 1px solid var(--line); border-radius: 26px 26px 0 0; box-shadow: var(--shadow); }
.modal-header { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; padding: 18px; background: rgba(9,19,33,.96); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0 0 5px; font-size: 23px; }
.modal-header p { margin: 0; color: var(--muted); font-size: 12px; }
.icon-button { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: rgba(255,255,255,.05); cursor: pointer; }
.modal-body { padding: 18px; display: grid; gap: 17px; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 13px; }
.field { display: grid; gap: 6px; }
.field label { color: var(--soft); font-weight: 800; font-size: 12px; }
.field textarea { min-height: 100px; resize: vertical; }
.detail-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.detail-cell { background: rgba(255,255,255,.035); border: 1px solid var(--line); border-radius: 13px; padding: 11px; }
.detail-label { color: var(--muted); font-size: 10px; text-transform: uppercase; font-weight: 800; letter-spacing: .06em; }
.detail-value { margin-top: 5px; font-weight: 800; font-size: 13px; overflow-wrap: anywhere; }
.note { padding: 12px; border-radius: 13px; border: 1px solid var(--line); background: rgba(255,255,255,.03); }
.note p { margin: 0; line-height: 1.5; }
.note small { display: block; color: var(--muted); margin-top: 7px; }
.role-list { display: grid; gap: 9px; }
.role-option { width: 100%; border: 1px solid var(--line); border-radius: 15px; background: rgba(255,255,255,.04); text-align: left; padding: 13px; cursor: pointer; }
.role-option.active { border-color: rgba(110,163,255,.6); background: rgba(44,117,255,.1); }
.role-option strong { display: block; }
.role-option small { display: block; color: var(--muted); margin-top: 4px; }

.toast-root { position: fixed; z-index: 200; top: calc(74px + env(safe-area-inset-top)); right: 14px; display: grid; gap: 8px; }
.toast { max-width: min(360px, calc(100vw - 28px)); padding: 12px 14px; border-radius: 13px; background: #13233a; border: 1px solid rgba(110,163,255,.25); box-shadow: var(--shadow); animation: slideIn .2s ease; font-size: 13px; }
@keyframes slideIn { from { opacity: 0; transform: translateY(-8px); } }

.loading { min-height: 60dvh; display: grid; place-items: center; color: var(--muted); }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(255,255,255,.1); border-top-color: var(--blue); animation: spin .8s linear infinite; margin: 0 auto 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 700px) {
  .main-content { padding: 24px 28px; }
  .stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid.two { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .modal-backdrop { align-items: center; padding: 24px; }
  .modal { border-radius: 26px; max-height: 86dvh; }
}

/* AI queue controls (Milestone 1) */
.queue-controls { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 15px 15px; }
.item-controls { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.queue-item.excluded { opacity: .5; }

/* Authentication (Milestone 2) */
.login-wrap { min-height: 70dvh; display: grid; place-items: center; padding: 24px 4px; }
.login-card { width: min(420px, 100%); background: var(--surface, #101f34); border: 1px solid rgba(255,255,255,.08); border-radius: 22px; padding: 26px 22px; box-shadow: var(--shadow); }
.login-card h2 { margin: 0 0 4px; }
.login-sub { color: var(--muted); margin: 0 0 20px; font-size: 14px; }
.login-form { display: grid; gap: 14px; }
.login-demo { margin-top: 22px; border-top: 1px solid rgba(255,255,255,.08); padding-top: 16px; }
.login-demo > p { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; margin: 0 0 10px; }
.login-demo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
