/* ─── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Revolut-inspired palette */
  --bg:        #0C0C14;
  --bg2:       #111119;
  --card:      #16162A;
  --card2:     #1D1D30;
  --border:    rgba(255,255,255,0.07);
  --border2:   rgba(255,255,255,0.13);
  --text:      #FFFFFF;
  --text2:     rgba(255,255,255,0.65);
  --muted:     rgba(255,255,255,0.32);
  --purple:    #7C6FF7;
  --purple2:   #A78BFA;
  --grad:      linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);
  --grad2:     linear-gradient(135deg, #7C6FF7 0%, #A78BFA 100%);
  --green:     #00D563;
  --green-bg:  rgba(0,213,99,0.13);
  --red:       #FF4545;
  --red-bg:    rgba(255,69,69,0.13);
  --amber:     #FFB020;
  --amber-bg:  rgba(255,176,32,0.13);
  --r:         16px;
  --r-sm:      12px;
  --nav-h:     64px;
  --topbar-h:  56px;
  --safe-b:    env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%; width: 100%;
  font-family: -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

/* ─── Screen layout ──────────────────────────────────────────────────────── */
.screen {
  display: none;
  position: fixed;
  inset: 0 0 calc(var(--nav-h) + var(--safe-b)) 0;
  flex-direction: column;
}
.screen.active { display: flex; }

/* ─── Topbar ─────────────────────────────────────────────────────────────── */
.topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: var(--topbar-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}
.topbar-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}
.topbar-sub   { font-size: 12px; color: var(--muted); margin-top: 1px; }
.chat-online  { color: var(--green); }

.icon-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  color: var(--text2);
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; cursor: pointer; flex-shrink: 0;
  transition: background .15s;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn:active { background: rgba(255,255,255,0.12); }
.refresh-icon { display: inline-block; }
.spinning .refresh-icon { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Hero stats row ─────────────────────────────────────────────────────── */
.hero-row {
  flex-shrink: 0;
  display: flex;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}
.hero-card {
  flex: 1;
  padding: 18px 8px 22px;
  text-align: center;
  position: relative;
}
.hero-card + .hero-card::before {
  content: "";
  position: absolute;
  left: 0; top: 22%; bottom: 22%;
  width: 1px;
  background: var(--border2);
}
.hero-val {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -2px;
  line-height: 1;
  color: var(--text);
  margin-bottom: 5px;
  transition: color .3s, text-shadow .3s;
}
.hero-val.lit-red   { color: var(--red);    text-shadow: 0 0 24px rgba(255,69,69,0.45); }
.hero-val.lit-amber { color: var(--amber);  text-shadow: 0 0 24px rgba(255,176,32,0.45); }
.hero-val.lit-blue  { color: var(--purple2); text-shadow: 0 0 24px rgba(167,139,250,0.45); }
.hero-lbl {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.7px;
}
.hero-bar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
}
.hbar-red   { background: radial-gradient(ellipse at center, var(--red) 0%, transparent 70%); }
.hbar-amber { background: radial-gradient(ellipse at center, var(--amber) 0%, transparent 70%); }
.hbar-blue  { background: radial-gradient(ellipse at center, var(--purple) 0%, transparent 70%); }

/* ─── Scroll area ────────────────────────────────────────────────────────── */
.scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 0;
  background: var(--bg);
  -webkit-overflow-scrolling: touch;
}
.scroll-pad { height: 24px; }

/* ─── Bottom nav ─────────────────────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--bg2);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
}
.nav-btn {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
  background: none; border: none;
  cursor: pointer; color: var(--muted);
  padding: 6px 0; position: relative;
  transition: color .15s;
  -webkit-tap-highlight-color: transparent;
}
.nav-btn.active { color: var(--text); }
.nav-btn.active::before {
  content: "";
  position: absolute;
  top: 0; left: 50%; transform: translateX(-50%);
  width: 28px; height: 2px;
  background: var(--grad);
  border-radius: 0 0 3px 3px;
  box-shadow: 0 0 10px rgba(99,102,241,0.6);
}
.nav-icon  { font-size: 22px; line-height: 1; }
.nav-label { font-size: 10px; font-weight: 600; letter-spacing: 0.3px; }

/* ─── Sections ───────────────────────────────────────────────────────────── */
.section { margin-bottom: 22px; }
.sec-header {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 10px; padding: 0 2px;
}
.sec-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.9px;
}

/* ─── Badges ─────────────────────────────────────────────────────────────── */
.badge {
  font-size: 11px; font-weight: 700;
  padding: 2px 7px; border-radius: 20px;
  background: rgba(255,255,255,0.07); color: var(--muted);
  min-width: 22px; text-align: center;
}
.badge-red   { background: var(--red-bg);   color: var(--red); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-blue  { background: rgba(124,111,247,0.15); color: var(--purple2); }

/* ─── Card stack ─────────────────────────────────────────────────────────── */
.card-stack { display: flex; flex-direction: column; gap: 8px; }

/* ─── Skeleton ───────────────────────────────────────────────────────────── */
.skel-card {
  background: linear-gradient(90deg, var(--card) 25%, var(--card2) 50%, var(--card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--r);
  height: 80px; width: 100%;
}
.kpi-skel { height: 90px; border-radius: var(--r-sm); }
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ─── Task / Comm cards ──────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--r);
  padding: 13px 14px 13px 18px;
  border: 1px solid var(--border);
  position: relative; overflow: hidden;
  transition: background .12s;
}
.card:active { background: var(--card2); }
.card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--card-accent, transparent);
  border-radius: 3px 0 0 3px;
}
.card.risk-red    { --card-accent: var(--red); }
.card.risk-yellow { --card-accent: var(--amber); }
.card.risk-green  { --card-accent: var(--green); }
.card.risk-gray   { --card-accent: rgba(255,255,255,0.2); }

.card-id {
  font-size: 10px; font-weight: 700;
  color: var(--muted);
  margin-bottom: 4px;
  text-transform: uppercase; letter-spacing: 0.9px;
}
.card-title {
  font-size: 14px; font-weight: 600;
  line-height: 1.35; margin-bottom: 8px;
  color: var(--text);
}
.card-meta { display: flex; flex-wrap: wrap; gap: 5px; }

/* ─── Tags ───────────────────────────────────────────────────────────────── */
.tag {
  font-size: 11px; padding: 3px 8px; border-radius: 6px;
  background: rgba(255,255,255,0.06); color: var(--text2);
  white-space: nowrap; font-weight: 500;
}
.tag.red    { background: var(--red-bg);   color: var(--red); }
.tag.yellow { background: var(--amber-bg); color: var(--amber); }
.tag.green  { background: var(--green-bg); color: var(--green); }
.tag.blue   { background: rgba(124,111,247,0.15); color: var(--purple2); }

.card-blocker {
  margin-top: 8px; font-size: 12px;
  color: var(--amber); background: var(--amber-bg);
  border-radius: 8px; padding: 6px 10px; font-weight: 500;
}

/* ─── Comm cards ─────────────────────────────────────────────────────────── */
.comm-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.comm-from   { font-size: 14px; font-weight: 700; color: var(--text); }
.comm-wait   { font-size: 11px; padding: 3px 8px; border-radius: 6px; white-space: nowrap; flex-shrink: 0; font-weight: 700; }
.comm-wait.high   { background: var(--red-bg);   color: var(--red); }
.comm-wait.medium { background: var(--amber-bg); color: var(--amber); }
.comm-subject  { font-size: 12px; color: var(--muted); margin-bottom: 5px; font-weight: 500; }
.comm-message  { font-size: 13px; line-height: 1.45; color: var(--text2); }
.comm-blocking { margin-top: 6px; font-size: 11px; color: var(--red); font-weight: 700; }

/* ─── PL card ────────────────────────────────────────────────────────────── */
.pl-card {
  background: var(--card);
  border-radius: var(--r);
  border: 1px solid var(--border);
  overflow: hidden;
}
.pl-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px;
  background: linear-gradient(135deg, rgba(99,102,241,0.18) 0%, rgba(139,92,246,0.10) 100%);
  border-bottom: 1px solid var(--border);
}
.pl-health {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 8px;
  font-size: 12px; font-weight: 700;
}
.pl-health.red    { background: var(--red-bg);   color: var(--red); }
.pl-health.yellow { background: var(--amber-bg); color: var(--amber); }
.pl-health.green  { background: var(--green-bg); color: var(--green); }
.pl-period { font-size: 12px; color: var(--muted); font-weight: 500; }

.pl-body { padding: 2px 0; }
.pl-row {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 11px 16px;
}
.pl-row + .pl-row { border-top: 1px solid var(--border); }
.pl-label  { font-size: 13px; color: var(--text2); font-weight: 500; }
.pl-values { display: flex; align-items: center; gap: 10px; }
.pl-plan   { font-size: 11px; color: var(--muted); }
.pl-fact   { font-size: 15px; font-weight: 700; color: var(--text); }
.pl-dev    { font-size: 11px; padding: 2px 7px; border-radius: 5px; font-weight: 700; }
.pl-dev.pos { background: var(--green-bg); color: var(--green); }
.pl-dev.neg { background: var(--red-bg);   color: var(--red); }

.pl-devs {
  padding: 10px 16px;
  background: rgba(255,176,32,0.06);
  border-top: 1px solid var(--border);
}
.pl-devs-title {
  font-size: 10px; color: var(--amber); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.7px; margin-bottom: 6px;
}
.pl-dev-item {
  font-size: 12px; color: var(--text2);
  padding-left: 12px; position: relative;
  margin-bottom: 3px; line-height: 1.4;
}
.pl-dev-item::before { content: "—"; position: absolute; left: 0; color: var(--amber); font-size: 10px; top: 1px; }

/* ─── KPI grid ───────────────────────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kpi-card {
  background: var(--card);
  border-radius: var(--r-sm);
  padding: 14px 14px 14px;
  border: 1px solid var(--border);
  position: relative; overflow: hidden;
}
.kpi-card::after {
  content: "";
  position: absolute;
  bottom: 0; left: 0; right: 0; height: 2px;
}
.kpi-card.kpi-pos::after { background: linear-gradient(90deg, var(--green), transparent 70%); }
.kpi-card.kpi-neg::after { background: linear-gradient(90deg, var(--red),   transparent 70%); }

.kpi-label {
  font-size: 10px; color: var(--muted);
  margin-bottom: 8px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.7px;
}
.kpi-fact  { font-size: 24px; font-weight: 800; letter-spacing: -0.5px; color: var(--text); line-height: 1; }
.kpi-plan  { font-size: 11px; color: var(--muted); margin-top: 4px; }
.kpi-dev   { font-size: 12px; margin-top: 6px; font-weight: 700; display: flex; align-items: center; gap: 3px; }
.kpi-dev.pos { color: var(--green); }
.kpi-dev.neg { color: var(--red); }

/* ─── Epic cards ─────────────────────────────────────────────────────────── */
.epic-card {
  background: var(--card);
  border-radius: var(--r);
  padding: 14px 14px 12px 18px;
  border: 1px solid var(--border);
  position: relative; overflow: hidden;
  transition: background .12s;
}
.epic-card:active { background: var(--card2); }
.epic-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0; width: 3px;
  border-radius: 3px 0 0 3px;
}
.epic-card.risk-red::before    { background: var(--red);   box-shadow: 0 0 10px rgba(255,69,69,0.5); }
.epic-card.risk-yellow::before { background: var(--amber); box-shadow: 0 0 10px rgba(255,176,32,0.5); }
.epic-card.risk-green::before  { background: var(--green); box-shadow: 0 0 10px rgba(0,213,99,0.5); }

.epic-top {
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 8px;
  margin-bottom: 10px;
}
.epic-title { font-size: 14px; font-weight: 700; line-height: 1.3; color: var(--text); }
.risk-badge {
  font-size: 10px; font-weight: 700;
  padding: 3px 8px; border-radius: 5px;
  flex-shrink: 0; white-space: nowrap;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.risk-green  { background: var(--green-bg); color: var(--green); }
.risk-yellow { background: var(--amber-bg); color: var(--amber); }
.risk-red    { background: var(--red-bg);   color: var(--red); }

.progress-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px;
}
.progress-bar {
  flex: 1; height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 4px; overflow: hidden;
}
.progress-fill { height: 100%; border-radius: 4px; transition: width .6s ease; }
.fill-green  { background: linear-gradient(90deg, #00D563, #00B84C); }
.fill-yellow { background: linear-gradient(90deg, #FFB020, #F59E0B); }
.fill-red    { background: linear-gradient(90deg, #FF4545, #DC2626); }
.progress-pct { font-size: 12px; font-weight: 700; color: var(--text2); min-width: 30px; text-align: right; }

.epic-meta {
  display: flex; flex-wrap: wrap; gap: 6px;
  font-size: 11px; color: var(--muted); font-weight: 500;
  margin-bottom: 2px;
}
.epic-risks { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.epic-risk-item { font-size: 12px; color: var(--amber); padding-left: 12px; position: relative; margin-bottom: 2px; line-height: 1.4; }
.epic-risk-item::before { content: "—"; position: absolute; left: 0; font-size: 10px; top: 1px; }

/* ─── Empty state ────────────────────────────────────────────────────────── */
.empty {
  text-align: center; padding: 20px 14px;
  color: var(--muted); font-size: 13px;
  background: var(--card); border-radius: var(--r);
  border: 1px solid var(--border);
}

/* ─── Chat ───────────────────────────────────────────────────────────────── */
.quick-chips {
  flex-shrink: 0;
  display: flex; gap: 8px;
  overflow-x: auto;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  scrollbar-width: none;
}
.quick-chips::-webkit-scrollbar { display: none; }

.qchip {
  flex-shrink: 0;
  padding: 7px 12px; border-radius: 8px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  color: var(--text2);
  font-size: 12px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
  -webkit-tap-highlight-color: transparent;
}
.qchip:active { background: rgba(124,111,247,0.2); border-color: var(--purple); color: var(--purple2); }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
  background: var(--bg);
  -webkit-overflow-scrolling: touch;
}

.chat-bubble { max-width: 88%; border-radius: 18px; font-size: 14px; line-height: 1.5; word-break: break-word; white-space: pre-wrap; }

.chat-bubble.user {
  align-self: flex-end;
  background: var(--grad);
  color: #fff;
  padding: 10px 14px;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 20px rgba(99,102,241,0.4);
}
.chat-bubble.agent {
  align-self: flex-start;
  background: var(--card);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  padding: 0;
}
.bubble-content { padding: 10px 14px; color: var(--text2); }
.bubble-hint    { font-size: 12px; color: var(--muted); margin-top: 6px; }
.chat-bubble.thinking { opacity: .55; }

.chat-bar {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: var(--bg2);
  border-top: 1px solid var(--border);
}
.chat-input {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px; color: var(--text);
  outline: none; transition: border-color .2s, box-shadow .2s;
}
.chat-input:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(124,111,247,0.15);
}
.chat-input::placeholder { color: var(--muted); }

.send-btn {
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--grad); color: #fff;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 16px rgba(99,102,241,0.4);
  -webkit-tap-highlight-color: transparent;
  transition: opacity .12s;
}
.send-btn:disabled { opacity: .35; cursor: not-allowed; box-shadow: none; }
.send-btn:active   { opacity: .75; }

/* ─── Topbar actions group ───────────────────────────────────────────────── */
.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* ─── Theme toggle btn ───────────────────────────────────────────────────── */
.theme-btn { font-size: 15px; }

/* ─── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ══════════════════════════════════════════════════════════════════════════ */
/* ─── LIGHT THEME ────────────────────────────────────────────────────────── */
/* ══════════════════════════════════════════════════════════════════════════ */
body.light {
  --bg:        #EEF2F8;
  --bg2:       #FFFFFF;
  --card:      #FFFFFF;
  --card2:     #F4F7FC;
  --border:    rgba(15,26,36,0.09);
  --border2:   rgba(15,26,36,0.16);
  --text:      #0F1A24;
  --text2:     rgba(15,26,36,0.65);
  --muted:     rgba(15,26,36,0.40);
  --purple:    #5A52E8;
  --purple2:   #6366F1;
  --green:     #15803D;
  --green-bg:  rgba(21,128,61,0.11);
  --red:       #DC2626;
  --red-bg:    rgba(220,38,38,0.10);
  --amber:     #B45309;
  --amber-bg:  rgba(180,83,9,0.10);
}

/* Remove glow in light mode */
body.light .hero-val.lit-red,
body.light .hero-val.lit-amber,
body.light .hero-val.lit-blue   { text-shadow: none; }

/* Light skeleton */
body.light .skel-card {
  background: linear-gradient(90deg, #E6EDF6 25%, #F0F5FB 50%, #E6EDF6 75%);
  background-size: 200% 100%;
}

/* Remove glow on epic accent bars */
body.light .epic-card.risk-red::before,
body.light .epic-card.risk-yellow::before,
body.light .epic-card.risk-green::before { box-shadow: none; }

/* PL header tint (softer in light) */
body.light .pl-header {
  background: linear-gradient(135deg, rgba(99,102,241,0.07) 0%, rgba(139,92,246,0.04) 100%);
}

/* Card & KPI shadows in light */
body.light .card,
body.light .kpi-card,
body.light .epic-card,
body.light .pl-card {
  box-shadow: 0 1px 4px rgba(15,26,36,0.06), 0 4px 16px rgba(15,26,36,0.04);
}

/* Chat bubble text in light */
body.light .bubble-content { color: var(--text2); }
body.light .chat-messages   { background: var(--bg); }

/* Nav active glow — softer in light */
body.light .nav-btn.active::before { box-shadow: 0 0 6px rgba(90,82,232,0.25); }

/* Send button shadow — softer in light */
body.light .send-btn { box-shadow: 0 2px 10px rgba(90,82,232,0.3); }
body.light .chat-bubble.user { box-shadow: 0 2px 10px rgba(90,82,232,0.25); }

/* Hero bars — use solid color in light (radial gradient invisible on light bg) */
body.light .hbar-red   { background: var(--red); opacity: 0.5; }
body.light .hbar-amber { background: var(--amber); opacity: 0.5; }
body.light .hbar-blue  { background: var(--purple); opacity: 0.5; }
