/* ── Variables ──────────────────────────────────────────────────────────────── */
:root {
  --bg:       #0f1117;
  --surface:  #1a1d27;
  --surface2: #242736;
  --border:   #2d3148;
  --text:     #e2e8f0;
  --muted:    #64748b;
  --cyan:     #22d3ee;
  --yellow:   #fbbf24;
  --green:    #22c55e;
  --red:      #ef4444;
  --amber:    #f59e0b;
  --purple:   #a78bfa;

  --nav-h:    48px;
  --radius:   6px;
  --font:     system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono:     ui-monospace, "JetBrains Mono", "Fira Code", monospace;
}

/* ── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  min-height: 100vh;
}
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
input, select, textarea, button { font: inherit; }

/* ── Nav ────────────────────────────────────────────────────────────────────── */
.topnav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-h);
  background: #0a0c12;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 16px;
}
.topnav-brand {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  padding: 0 12px 0 0;
  margin-right: 8px;
  border-right: 1px solid var(--border);
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: -0.01em;
}
.topnav-teams {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}
.topnav-teams::-webkit-scrollbar { display: none; }
.topnav-team {
  color: var(--muted);
  padding: 6px 10px;
  border-radius: var(--radius);
  font-size: 13px;
  white-space: nowrap;
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}
.topnav-team:hover { color: var(--text); background: var(--surface2); text-decoration: none; }
.topnav-team.active { color: var(--cyan); background: rgba(34,211,238,0.08); }
.topnav-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  padding-left: 12px;
}
.topnav-link {
  color: var(--muted);
  font-size: 13px;
  padding: 4px 8px;
  border-radius: var(--radius);
  text-decoration: none;
  transition: color 0.15s;
}
.topnav-link:hover { color: var(--text); text-decoration: none; }
.topnav-user {
  color: var(--muted);
  font-size: 12px;
}
.topnav-logout { display: inline; }

/* ── Main layout ────────────────────────────────────────────────────────────── */
.main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* ── Login ──────────────────────────────────────────────────────────────────── */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-wrap { width: 100%; max-width: 380px; padding: 20px; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
}
.login-logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--cyan);
  text-align: center;
  margin-bottom: 24px;
  letter-spacing: -0.02em;
}
.login-form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 500; }

/* ── Page header ────────────────────────────────────────────────────────────── */
.page-header {
  position: sticky;
  top: var(--nav-h);
  z-index: 90;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  padding-top: 4px;
  margin-bottom: 12px;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}
.page-header-left { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.page-header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.page-title { font-size: 22px; font-weight: 700; line-height: 1.2; }

/* ── Cards ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.card.mb { margin-bottom: 12px; }
.card-title { font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.card-inset {
  background: var(--surface2);
  border-radius: var(--radius);
  padding: 12px;
  margin-top: 8px;
}

/* ── Section cards (collapsible) ────────────────────────────────────────────── */
.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
}
.section-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  user-select: none;
  list-style: none;
  border-radius: var(--radius);
}
.section-card-title::-webkit-details-marker { display: none; }
details[open] > .section-card-title {
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
}
.section-card-title::before {
  content: "▶";
  font-size: 10px;
  color: var(--muted);
  transition: transform 0.15s;
}
details[open] > .section-card-title::before { transform: rotate(90deg); }
.section-card-body { padding: 16px; }

/* ── Section ────────────────────────────────────────────────────────────────── */
.section { margin-bottom: 24px; }
.section-title { font-size: 15px; font-weight: 600; margin-bottom: 12px; }
.section-header-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.subsection-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 16px 0 8px;
}
.subsection-title:first-child { margin-top: 0; }

/* ── Org team grid ──────────────────────────────────────────────────────────── */
.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.team-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s;
}
.team-card:hover { border-color: var(--cyan); text-decoration: none; }
.team-card-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.team-card-name { font-weight: 600; }
.team-card-sprint { font-size: 14px; }
.team-card-focus { font-size: 14px; line-height: 1.4; }
.team-card-synced { font-size: 11px; margin-top: 4px; }

/* ── Tables ─────────────────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th {
  text-align: left;
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}
.table td {
  padding: 7px 8px;
  border-bottom: 1px solid rgba(45,49,72,0.5);
  vertical-align: top;
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: rgba(255,255,255,0.02); }
.table.table-sm td, .table.table-sm th { padding: 4px 8px; }
.table .num { text-align: right; }
.row-actions { text-align: right; white-space: nowrap; }
.table-link { color: var(--text); }
.table-link:hover { color: var(--cyan); }

/* ── Badges ─────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.02em;
}
.badge.badge-sm { padding: 0 5px; font-size: 10px; }
.badge-red    { background: rgba(239,68,68,0.15);   color: #fca5a5; }
.badge-amber  { background: rgba(245,158,11,0.15);  color: #fcd34d; }
.badge-green  { background: rgba(34,197,94,0.15);   color: #86efac; }
.badge-cyan   { background: rgba(34,211,238,0.12);  color: var(--cyan); }
.badge-muted  { background: rgba(100,116,139,0.15); color: var(--muted); }
.badge-purple { background: rgba(167,139,250,0.15); color: var(--purple); }

/* ── Status ─────────────────────────────────────────────────────────────────── */
.status-icon { font-weight: 700; margin-right: 4px; }
.status-green  { color: var(--green); }
.status-amber  { color: var(--amber); }
.status-red    { color: var(--red); }
.status-muted  { color: var(--muted); }

/* ── Severity ───────────────────────────────────────────────────────────────── */
.severity-high   { color: var(--red); }
.severity-medium { color: var(--amber); }
.severity-low    { color: var(--muted); }

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.btn:hover { opacity: 0.85; text-decoration: none; }
.btn-primary { background: var(--cyan); color: #0a0c12; border-color: var(--cyan); }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}
.btn-ghost:hover { color: var(--text); }
.btn-danger { color: var(--red) !important; border-color: rgba(239,68,68,0.3) !important; }
.btn-danger:hover { background: rgba(239,68,68,0.1); }
.btn-full { width: 100%; justify-content: center; }
.btn-sm { padding: 3px 9px; font-size: 12px; }
.btn-icon {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  font-size: 12px;
  opacity: 0.5;
  transition: opacity 0.15s;
}
.btn-icon:hover { opacity: 1; }

/* ── Inputs ─────────────────────────────────────────────────────────────────── */
.input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 6px 10px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s;
}
.input:focus { border-color: var(--cyan); }
.input-sm {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 4px 8px;
  font-size: 12px;
  outline: none;
}
.input-sm:focus { border-color: var(--cyan); }
.input-grow { flex: 1; min-width: 0; }
.textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 8px 10px;
  font-size: 15px;
  outline: none;
  resize: vertical;
  width: 100%;
  transition: border-color 0.15s;
}
.textarea:focus { border-color: var(--cyan); }

/* ── Forms ──────────────────────────────────────────────────────────────────── */
.inline-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stack-form { display: flex; flex-direction: column; gap: 8px; }
.form-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ── Flash messages ─────────────────────────────────────────────────────────── */
.flash {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 15px;
  margin-bottom: 12px;
}
.flash-error   { background: rgba(239,68,68,0.15);  color: #fca5a5; border: 1px solid rgba(239,68,68,0.3); }
.flash-success { background: rgba(34,197,94,0.12);  color: #86efac; border: 1px solid rgba(34,197,94,0.3); }
.flash-info    { background: rgba(34,211,238,0.10); color: var(--cyan); border: 1px solid rgba(34,211,238,0.3); }

/* ── Sprint bar ─────────────────────────────────────────────────────────────── */
.sprint-bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0;
}
.sprint-bar-label { color: var(--muted); font-size: 14px; white-space: nowrap; }
.sprint-bar { font-family: var(--mono); font-size: 16px; letter-spacing: 2px; }
.sprint-block-filled { color: var(--cyan); }
.sprint-block-empty  { color: var(--border); }
.sprint-day-bar { font-family: var(--mono); font-size: 15px; letter-spacing: 1px; color: var(--border); }
.sprint-day-today  { color: var(--yellow); }
.sprint-day-past   { color: var(--cyan); }
.sprint-day-future { color: var(--border); }
.sprint-pips { font-family: var(--mono); font-size: 14px; letter-spacing: 2px; }
.sprint-pip-past    { color: var(--muted); }
.sprint-pip-current { color: var(--yellow); font-weight: 700; }
.sprint-pip-future  { color: var(--muted); }
.sprint-plan-row { margin-bottom: 8px; }
.sprint-plan-link { font-weight: 500; color: var(--cyan); }
.sprint-goal-list {
  margin-top: 10px;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}

/* ── Goals ──────────────────────────────────────────────────────────────────── */
.goal-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.goal-item { display: flex; align-items: baseline; gap: 8px; font-size: 15px; }
.goal-text { flex: 1; }
.alignment-summary { font-size: 13px; color: var(--muted); margin-bottom: 12px; line-height: 1.6; }

/* ── Forecast banner ────────────────────────────────────────────────────────── */
.forecast-banner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 12px;
}
.forecast-on_track { background: rgba(34,197,94,0.12); color: #86efac; }
.forecast-at_risk  { background: rgba(245,158,11,0.12); color: #fcd34d; }
.forecast-off_track { background: rgba(239,68,68,0.12); color: #fca5a5; }

/* ── Concerns ───────────────────────────────────────────────────────────────── */
.concerns-list { display: flex; flex-direction: column; gap: 4px; }
.concern-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.concern-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 15px;
  list-style: none;
}
.concern-summary::-webkit-details-marker { display: none; }
.concern-severity {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.concern-body {
  padding: 8px 12px 12px;
  font-size: 15px;
  color: var(--muted);
  line-height: 1.6;
  border-top: 1px solid var(--border);
}
.concern-severity-high   { border-left: 3px solid var(--red); }
.concern-severity-medium { border-left: 3px solid var(--amber); }
.concern-severity-low    { border-left: 3px solid var(--border); }

/* ── Workload bar ───────────────────────────────────────────────────────────── */
.workload-bar-col { width: 120px; }
.workload-bar-wrap { background: var(--surface2); border-radius: 3px; height: 8px; overflow: hidden; }
.workload-bar { height: 100%; background: var(--cyan); border-radius: 3px; min-width: 2px; transition: width 0.3s; }

/* ── Velocity chart ─────────────────────────────────────────────────────────── */
.velocity-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 100px;
  margin-bottom: 16px;
  padding: 0 4px;
}
.velocity-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
}
.velocity-bar-wrap {
  width: 100%;
  flex: 1;
  display: flex;
  align-items: flex-end;
  background: var(--surface2);
  border-radius: 3px 3px 0 0;
}
.velocity-bar {
  width: 100%;
  background: var(--cyan);
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  transition: height 0.3s;
}
.velocity-label { font-size: 10px; text-align: center; line-height: 1.2; }

/* ── Metrics ────────────────────────────────────────────────────────────────── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.metric-panel {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
}
.metric-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.metric-value { font-size: 24px; font-weight: 700; }

/* ── Marketing ──────────────────────────────────────────────────────────────── */
.campaign-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
}
.campaign-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.campaign-title { font-weight: 600; }
.campaign-tasks { list-style: none; display: flex; flex-direction: column; gap: 4px; padding-left: 8px; }
.campaign-task { display: flex; align-items: baseline; gap: 6px; font-size: 15px; }

/* ── Calendar grid ──────────────────────────────────────────────────────────── */
.cal-months { display: flex; gap: 24px; flex-wrap: wrap; margin-bottom: 16px; }
.cal-month { flex: 1; min-width: 200px; }
.cal-month-label { font-size: 13px; font-weight: 600; color: var(--cyan); margin-bottom: 8px; }
.cal-grid { width: 100%; border-collapse: collapse; font-size: 12px; }
.cal-grid th { text-align: center; padding: 2px 4px; color: var(--muted); font-size: 11px; }
.cal-day { text-align: center; padding: 3px 2px; position: relative; border-radius: 3px; }
.cal-day-empty { }
.cal-today .cal-daynum { color: var(--yellow); font-weight: 700; }
.cal-has-event .cal-daynum { color: var(--cyan); }
.cal-today.cal-has-event .cal-daynum { color: var(--yellow); font-weight: 700; }
.cal-dot {
  display: inline-block;
  width: 4px; height: 4px;
  background: var(--cyan);
  border-radius: 50%;
  vertical-align: super;
  font-size: 0;
}
.cal-nav { display: flex; gap: 4px; }
.cal-nav-inline { margin-left: auto; display: flex; gap: 4px; }
.cal-events { margin-top: 12px; display: flex; flex-direction: column; gap: 4px; }
.cal-undated { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.cal-event-row { display: flex; align-items: baseline; gap: 8px; font-size: 15px; flex-wrap: wrap; }
.cal-event-date { flex-shrink: 0; width: 56px; }
.cal-event-team { flex-shrink: 0; width: 100px; overflow: hidden; text-overflow: ellipsis; }

/* ── Annotations ────────────────────────────────────────────────────────────── */
.ann-section { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.ann-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(45,49,72,0.4);
  font-size: 15px;
}
.ann-item:last-of-type { border-bottom: none; }
.ann-content { flex: 1; line-height: 1.5; }
.ann-add-btn { margin-top: 8px; }
.ann-form { display: flex; flex-direction: column; gap: 8px; }
.ann-textarea { min-height: 56px; }
.ann-form-actions { display: flex; gap: 6px; }
.ann-form-wrap { padding: 10px 0; }

/* ── Warning banner ─────────────────────────────────────────────────────────── */
.warning-banner {
  background: rgba(245,158,11,0.10);
  border: 1px solid rgba(245,158,11,0.25);
  border-radius: var(--radius);
  color: var(--amber);
  padding: 8px 12px;
  font-size: 13px;
  margin: 8px 0;
}

/* ── Sync status ────────────────────────────────────────────────────────────── */
.sync-status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 4px 10px; border-radius: var(--radius); }
.sync-status-running { background: rgba(34,211,238,0.10); color: var(--cyan); }
.sync-status-done    { background: rgba(34,197,94,0.12);  color: #86efac; }
.sync-status-error   { background: rgba(239,68,68,0.12);  color: #fca5a5; }
@keyframes spin { to { transform: rotate(360deg); } }
.sync-spinner { display: inline-block; animation: spin 1s linear infinite; }

/* ── Config nav ─────────────────────────────────────────────────────────────── */
.config-nav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}
.config-nav-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s;
}
.config-nav-card:hover { border-color: var(--cyan); text-decoration: none; }
.config-nav-title { font-weight: 600; margin-bottom: 4px; }
.config-nav-desc { font-size: 13px; line-height: 1.4; }

/* ── Source/config tags ─────────────────────────────────────────────────────── */
.config-tag { display: flex; align-items: center; gap: 4px; margin-bottom: 3px; }

/* ── Admin grid ─────────────────────────────────────────────────────────────── */
.admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }

/* ── Action dropdown ────────────────────────────────────────────────────────── */
.action-dropdown { position: relative; display: inline-block; }
.action-dropdown summary { list-style: none; cursor: pointer; }
.action-dropdown summary::-webkit-details-marker { display: none; }
.dropdown-content {
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 50;
  min-width: 220px;
  margin-top: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

/* ── Filter bar ─────────────────────────────────────────────────────────────── */
.filter-bar { padding: 8px 0; }

/* ── Misc helpers ───────────────────────────────────────────────────────────── */
.muted    { color: var(--muted); }
.small    { font-size: 13px; }
.mono     { font-family: var(--mono); }
.hidden   { display: none !important; }
.mb       { margin-bottom: 12px; }
.mt-sm    { margin-top: 8px; }
.divider  { border: none; border-top: 1px solid var(--border); margin: 8px 0; }
.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 32px;
  font-size: 13px;
}
.summary-actions {
  display: flex;
  gap: 4px;
  margin-left: auto;
}
.add-member-wrap { margin-top: 8px; }
.add-member-wrap > summary { display: inline-flex; }
