/* ==========================================================================
   Praman Dashboard — Light Sepia & Saffron Design System
   ========================================================================== */

:root {
  --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-indic: 'Noto Sans Devanagari', 'Outfit', sans-serif;

  /* Light Sepia & Parchment Palette */
  --bg-primary: #faf6ee;
  --bg-parchment: #f4ece0;
  --bg-card: #ffffff;
  --bg-card-hover: #fdfbf7;
  --bg-input: #fbf8f2;
  --border-subtle: #e5dac9;
  --border-card: #dfd2be;
  --border-focus: #ea580c;

  /* Typography Colors (Deep Warm Ink) */
  --text-main: #271f18;
  --text-muted: #645648;
  --text-dim: #948372;

  /* Saffron (केसरी / भगवा) & Harmonic Accents */
  --accent-saffron: #ea580c;
  --accent-saffron-hover: #c2410c;
  --accent-saffron-light: rgba(234, 88, 12, 0.08);
  --accent-saffron-border: rgba(234, 88, 12, 0.28);
  --accent-saffron-glow: rgba(234, 88, 12, 0.22);

  --accent-gold: #d97706;
  --accent-emerald: #15803d;
  --accent-emerald-light: rgba(21, 128, 61, 0.08);
  --accent-rose: #be123c;
  --accent-sepia: #78350f;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 3px rgba(60, 40, 20, 0.06);
  --shadow-card: 0 4px 20px -2px rgba(90, 60, 30, 0.07), 0 2px 6px -1px rgba(90, 60, 30, 0.04);
  --shadow-modal: 0 20px 40px -10px rgba(50, 30, 10, 0.25);
  --shadow-saffron: 0 4px 14px var(--accent-saffron-glow);

  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

body.light-sepia-theme {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  background-image:
    radial-gradient(at 15% 15%, rgba(234, 88, 12, 0.04) 0px, transparent 45%),
    radial-gradient(at 85% 85%, rgba(217, 119, 6, 0.04) 0px, transparent 45%);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */
.app-header {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0.85rem 2rem;
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #f97316, #ea580c);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-indic);
  font-size: 1.6rem;
  font-weight: 700;
  color: #ffffff;
  box-shadow: var(--shadow-saffron);
}

.brand-title-row {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.brand-title {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.brand-native {
  font-family: var(--font-indic);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent-saffron);
}

.version-badge {
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--bg-parchment);
  border: 1px solid var(--border-subtle);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  color: var(--text-muted);
}

.brand-tagline {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.control-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-parchment);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 0.35rem 0.9rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.styled-select {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}

.styled-select option {
  background: #ffffff;
  color: var(--text-main);
}

/* ==========================================================================
   Main Content Layout
   ========================================================================== */
.main-content {
  max-width: 1400px;
  width: 100%;
  margin: 1.5rem auto 3rem;
  padding: 0 1.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-card);
}

/* ==========================================================================
   Research Input Form
   ========================================================================== */
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.card-title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-main);
}

.card-subtitle {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.preset-pills {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.preset-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dim);
}

.preset-btn {
  background: var(--bg-parchment);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.3rem 0.85rem;
  cursor: pointer;
  transition: var(--transition);
}

.preset-btn:hover {
  background: var(--accent-saffron-light);
  color: var(--accent-saffron);
  border-color: var(--accent-saffron);
  transform: translateY(-1px);
}

.textarea-wrapper {
  margin-bottom: 1rem;
}

.seeds-textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.98rem;
  resize: vertical;
  min-height: 85px;
  outline: none;
  transition: var(--transition);
}

.seeds-textarea:focus {
  background: #ffffff;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.15);
}

.options-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.budget-limit-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.number-input {
  width: 100px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 0.4rem 0.65rem;
  font-family: inherit;
  font-size: 0.88rem;
  outline: none;
}

.number-input:focus {
  border-color: var(--border-focus);
}

/* ==========================================================================
   Buttons (Functional & Saffron Highlighted)
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: inherit;
  font-weight: 600;
  border-radius: var(--radius-md);
  padding: 0.65rem 1.4rem;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  outline: none;
  user-select: none;
}

.btn-primary {
  background: linear-gradient(135deg, #f97316, #ea580c);
  color: #ffffff;
  box-shadow: var(--shadow-saffron);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #ea580c, #c2410c);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(234, 88, 12, 0.35);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-saffron {
  background: #ea580c;
  color: #ffffff;
}

.btn-saffron:hover {
  background: #c2410c;
  color: #ffffff;
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-parchment);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
  background: #eae0d0;
  color: #000000;
}

.btn-outline {
  background: #ffffff;
  border: 1px solid var(--border-card);
  color: var(--text-muted);
}

.btn-outline:hover {
  background: var(--bg-parchment);
  color: var(--text-main);
  border-color: var(--accent-saffron);
}

.btn-sm {
  padding: 0.4rem 0.9rem;
  font-size: 0.84rem;
  border-radius: var(--radius-sm);
}

.btn-spinner {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   Provenance Banners
   ========================================================================== */
.banner-section {
  display: flex;
  justify-content: center;
}

.banner-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 1.35rem;
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}

.banner-fixture {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}

.banner-recorded {
  background: #ecfeff;
  border: 1px solid #a5f3fc;
  color: #0e7490;
}

.banner-live {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
}

/* ==========================================================================
   KPI Ribbon (Sepia/Parchment)
   ========================================================================== */
.kpi-ribbon {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.kpi-card {
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
}

.kpi-label {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 0.35rem;
}

.kpi-value {
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.kpi-subtext {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.highlight-green { color: var(--accent-emerald); }
.highlight-saffron { color: var(--accent-saffron); }
.highlight-sepia { color: var(--text-main); }

/* ==========================================================================
   Tabs & Action Toolbar
   ========================================================================== */
.tab-bar-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1.5px solid var(--border-subtle);
  padding-bottom: 0.65rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.tab-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.94rem;
  font-weight: 600;
  padding: 0.6rem 1.15rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
}

.tab-btn:hover {
  color: var(--text-main);
  background: var(--bg-parchment);
}

.tab-btn.active {
  color: var(--accent-saffron);
  background: #ffffff;
  border-color: var(--border-card);
  box-shadow: var(--shadow-sm);
}

.tab-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ==========================================================================
   Data Table (High Readability Sepia)
   ========================================================================== */
.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.search-input {
  max-width: 320px;
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  padding: 0.45rem 0.85rem;
  font-family: inherit;
  font-size: 0.88rem;
  outline: none;
}

.search-input:focus {
  border-color: var(--border-focus);
}

.table-count-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-dim);
}

.table-scroll {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.92rem;
}

.data-table th {
  background: var(--bg-parchment);
  padding: 0.85rem 1rem;
  font-weight: 700;
  color: var(--text-muted);
  text-align: left;
  border-bottom: 1.5px solid var(--border-subtle);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.data-table th:hover {
  color: var(--text-main);
}

.sort-icon {
  font-size: 0.75rem;
  opacity: 0.5;
}

.data-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid #f0e6d8;
  vertical-align: middle;
}

.data-table tr:hover td {
  background: var(--bg-card-hover);
}

.seed-cell {
  font-weight: 600;
  color: var(--text-main);
}

.seed-cell code {
  font-size: 0.95rem;
  color: var(--text-main);
}

.demand-score-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-weight: 800;
  font-size: 0.95rem;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.demand-score-pill:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.demand-high { background: #dcfce7; color: #15803d; }
.demand-med { background: #fef3c7; color: #b45309; }
.demand-low { background: #f3f4f6; color: #6b7280; }

.partial-flag {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent-gold);
  margin-left: 0.25rem;
}

.badge {
  display: inline-block;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  text-transform: capitalize;
}

/* Evidence Bands */
.badge-evidence-strong { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.badge-evidence-moderate { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }
.badge-evidence-weak { background: #f5f5f4; color: #78716c; border: 1px solid #e7e5e4; }
.badge-evidence-insufficient { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

.badge-intent {
  background: var(--bg-parchment);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
}

.badge-intent:hover {
  border-color: var(--accent-saffron);
  color: var(--accent-saffron);
}

.badge-unmeasured { background: #fef2f2; color: #991b1b; }

.tree-trigger-btn {
  background: var(--bg-parchment);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  cursor: pointer;
  transition: var(--transition);
}

.tree-trigger-btn:hover {
  background: var(--accent-saffron-light);
  border-color: var(--accent-saffron);
  color: var(--accent-saffron);
}

/* Candidate View Toggles */
.candidate-view-toggle {
  display: flex;
  background: var(--bg-parchment);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 0.2rem;
}

.btn-toggle {
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition);
}

.btn-toggle.active {
  background: #ffffff;
  color: var(--accent-saffron);
  box-shadow: var(--shadow-sm);
}

/* Candidates Grid */
.candidates-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
  margin-top: 1.25rem;
  max-height: 580px;
  overflow-y: auto;
  padding-right: 0.5rem;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-saffron) var(--bg-parchment);
}

.candidates-container::-webkit-scrollbar {
  width: 8px;
}

.candidates-container::-webkit-scrollbar-track {
  background: var(--bg-parchment);
  border-radius: 4px;
}

.candidates-container::-webkit-scrollbar-thumb {
  background: #d6cbbe;
  border-radius: 4px;
}

.candidates-container::-webkit-scrollbar-thumb:hover {
  background: var(--accent-saffron);
}

.candidate-card {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  transition: var(--transition);
}

.candidate-card:hover {
  background: #ffffff;
  border-color: var(--accent-saffron-border);
  box-shadow: var(--shadow-sm);
}

.candidate-query-text {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.measure-candidate-btn {
  background: var(--accent-saffron-light);
  border: 1px solid var(--accent-saffron-border);
  border-radius: var(--radius-sm);
  color: var(--accent-saffron);
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 0.25rem 0.55rem;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
}

.measure-candidate-btn:hover {
  background: var(--accent-saffron);
  color: #ffffff;
  transform: translateY(-1px);
}

/* Score Breakdown Modal Styles */
.score-breakdown-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.score-breakdown-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.score-breakdown-table th, .score-breakdown-table td {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
}

.score-breakdown-table th {
  background: var(--bg-parchment);
  font-weight: 700;
  color: var(--text-muted);
}

.score-total-row {
  font-weight: 800;
  background: var(--accent-saffron-light);
  color: var(--accent-saffron);
}

/* ==========================================================================
   Tree Canvas & Hierarchical Branch View
   ========================================================================== */
.tree-canvas-card {
  overflow: hidden;
}

.tree-canvas-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.tree-search-input {
  width: 220px;
}

.tree-select {
  padding: 0.4rem 0.75rem;
  font-size: 0.84rem;
  background: #ffffff;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  color: var(--text-main);
}

/* Scrollable Tree Canvas Viewport */
.tree-canvas-viewport {
  background: #faf7f2;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-top: 1.25rem;
  max-height: 580px;
  min-height: 380px;
  overflow-y: auto;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-saffron) #eee6d8;
  position: relative;
}

.tree-canvas-viewport::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.tree-canvas-viewport::-webkit-scrollbar-track {
  background: #eee6d8;
  border-radius: 6px;
}

.tree-canvas-viewport::-webkit-scrollbar-thumb {
  background: #cfbeab;
  border-radius: 6px;
  border: 2px solid #eee6d8;
}

.tree-canvas-viewport::-webkit-scrollbar-thumb:hover {
  background: var(--accent-saffron);
}

.tree-canvas-content {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  min-width: 650px;
}

.tree-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  color: var(--text-dim);
  text-align: center;
}

.tree-empty-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}

/* Tree Seed Block */
.tree-seed-block {
  background: #ffffff;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.tree-seed-block:hover {
  box-shadow: var(--shadow-card);
  border-color: var(--accent-saffron-border);
}

.tree-seed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0.85rem;
  margin-bottom: 1rem;
}

.tree-seed-name {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.tree-seed-badges {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Branch Hierarchy */
.tree-branches {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-left: 1.25rem;
  border-left: 2px dashed #e2d9cd;
  margin-left: 0.5rem;
}

.tree-branch-section {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.tree-branch-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  padding: 0.25rem 0;
}

.tree-branch-title:hover {
  color: var(--accent-saffron);
}

.tree-candidate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.65rem;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 0.5rem;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-saffron) var(--bg-parchment);
}

.tree-candidate-grid::-webkit-scrollbar {
  width: 6px;
}

.tree-candidate-grid::-webkit-scrollbar-thumb {
  background: #d6cbbe;
  border-radius: 3px;
}

/* Modal Tree View */
.tree-seed-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.tree-section-header {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 1rem 0 0.5rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tree-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-left: 1rem;
  border-left: 2px dashed var(--border-subtle);
  max-height: 380px;
  overflow-y: auto;
  padding-right: 0.5rem;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-saffron) var(--bg-parchment);
}

.tree-list::-webkit-scrollbar {
  width: 6px;
}

.tree-list::-webkit-scrollbar-thumb {
  background: #d6cbbe;
  border-radius: 3px;
}

.tree-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.85rem;
}

/* ==========================================================================
   Intent Diagnostic & Evidence Modal
   ========================================================================== */
.intent-diagnostic-box {
  background: var(--bg-parchment);
  border: 1px solid var(--border-subtle);
  border-left: 4px solid var(--accent-saffron);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.intent-status-badge {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.intent-diagnostic-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.intent-evidence-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.intent-evidence-scroll-container {
  max-height: 380px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 0.65rem;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-saffron) var(--bg-parchment);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.intent-evidence-scroll-container::-webkit-scrollbar {
  width: 8px;
}

.intent-evidence-scroll-container::-webkit-scrollbar-track {
  background: var(--bg-parchment);
  border-radius: 4px;
}

.intent-evidence-scroll-container::-webkit-scrollbar-thumb {
  background: #d6cbbe;
  border-radius: 4px;
}

.intent-evidence-scroll-container::-webkit-scrollbar-thumb:hover {
  background: var(--accent-saffron);
}

.intent-group-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.intent-candidate-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.85rem;
  gap: 0.5rem;
}

.serp-edit-btn {
  background: #ffffff;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  cursor: pointer;
  transition: var(--transition);
  margin-left: 0.4rem;
}

.serp-edit-btn:hover {
  background: var(--accent-saffron-light);
  color: var(--accent-saffron);
  border-color: var(--accent-saffron);
}

/* ==========================================================================
   Content Planner & Calendar
   ========================================================================== */
.planner-actions-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.25rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.planner-info-text {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.planner-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr));
  gap: 1.5rem;
}

.calendar-list, .link-graph-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: 1rem;
}

.calendar-item {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem 1.15rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  transition: var(--transition);
}

.calendar-item:hover {
  background: #ffffff;
  border-color: var(--accent-saffron-border);
  box-shadow: var(--shadow-sm);
}

.calendar-order-badge {
  font-size: 1rem;
  font-weight: 800;
  color: var(--accent-saffron);
  background: var(--accent-saffron-light);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.55rem;
}

.calendar-item-body {
  flex: 1;
}

.calendar-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  color: var(--text-main);
}

.calendar-meta {
  display: flex;
  gap: 0.85rem;
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.calendar-shape {
  font-size: 0.84rem;
  color: var(--accent-sepia);
  font-weight: 500;
}

.link-item {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.9rem 1.15rem;
}

.link-flow {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.35rem;
  color: var(--text-main);
}

.link-arrow {
  color: var(--accent-saffron);
}

.link-anchor-row {
  font-size: 0.86rem;
  color: var(--text-muted);
}

.link-anchor {
  color: var(--accent-saffron);
  font-weight: 700;
}

/* ==========================================================================
   Candidates Tag Cloud
   ========================================================================== */
.candidates-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1rem;
}

.candidate-tag {
  background: var(--bg-parchment);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 0.35rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-main);
  cursor: pointer;
  transition: var(--transition);
}

.candidate-tag:hover {
  background: var(--accent-saffron-light);
  border-color: var(--accent-saffron);
  color: var(--accent-saffron);
  transform: translateY(-1px);
}

/* ==========================================================================
   Methodology & Math Section
   ========================================================================== */
.methodology-content {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.math-box {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
  font-family: monospace;
  font-size: 0.95rem;
  color: var(--accent-sepia);
  font-weight: 700;
  overflow-x: auto;
}

.methodology-list {
  padding-left: 1.5rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* ==========================================================================
   Modals (SERP & Report Preview)
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(30, 20, 10, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-card {
  background: #ffffff;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  max-width: 540px;
  width: 100%;
  max-height: 88vh;
  box-shadow: var(--shadow-modal);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modalFadeIn 0.2s ease-out;
}

.modal-large {
  max-width: 860px;
  width: 90vw;
}

@keyframes modalFadeIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--text-dim);
  cursor: pointer;
  line-height: 1;
}

.modal-close-btn:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: calc(88vh - 85px);
  scrollbar-width: thin;
  scrollbar-color: var(--accent-saffron) var(--bg-parchment);
}

.modal-body::-webkit-scrollbar {
  width: 8px;
}

.modal-body::-webkit-scrollbar-track {
  background: var(--bg-parchment);
}

.modal-body::-webkit-scrollbar-thumb {
  background: #d6cbbe;
  border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
  background: var(--accent-saffron);
}

.modal-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.serp-form-group {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
}

.serp-label {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-main);
}

.tristate-toggle {
  display: flex;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.tristate-btn {
  flex: 1;
  background: transparent;
  border: none;
  padding: 0.35rem 0.75rem;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.tristate-btn.active[data-val="yes"] {
  background: #dcfce7;
  color: #15803d;
}

.tristate-btn.active[data-val="no"] {
  background: #fee2e2;
  color: #b91c1c;
}

.tristate-btn.active[data-val="unrecorded"] {
  background: var(--bg-parchment);
  color: var(--text-dim);
}

.serp-preview-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border-subtle);
  font-size: 0.88rem;
  font-weight: 600;
}

.modal-footer {
  padding: 1rem 1.5rem;
  background: var(--bg-input);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.report-preview-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.report-preview-textarea {
  width: 100%;
  height: 450px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
  font-family: monospace;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text-main);
  resize: none;
  outline: none;
}

/* ==========================================================================
   Toast Notifications
   ========================================================================== */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: #ffffff;
  color: var(--text-main);
  border: 1px solid var(--border-card);
  border-left: 4px solid var(--accent-saffron);
  border-radius: var(--radius-md);
  padding: 0.75rem 1.25rem;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow-modal);
  animation: toastSlideIn 0.25s ease-out;
}

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ==========================================================================
   User Flow Steps (Manual)
   ========================================================================== */
.user-flow-steps {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: 1rem;
}

.user-flow-step {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.15rem;
  transition: var(--transition);
}

.user-flow-step:hover {
  background: #ffffff;
  border-color: var(--accent-saffron-border);
  box-shadow: var(--shadow-sm);
}

.step-num {
  width: 28px;
  height: 28px;
  background: var(--accent-saffron);
  color: #ffffff;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  flex-shrink: 0;
  margin-top: 0.15rem;
}

.step-content strong {
  display: block;
  font-size: 0.95rem;
  color: var(--text-main);
  margin-bottom: 0.2rem;
}

.step-content p {
  margin: 0;
  font-size: 0.86rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.app-footer {
  border-top: 1px solid var(--border-subtle);
  padding: 1.5rem 2rem;
  font-size: 0.82rem;
  color: var(--text-dim);
  background: #ffffff;
}

.footer-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.table-swipe-hint {
  display: none;
  font-size: 0.74rem;
  color: var(--accent-saffron);
  font-weight: 600;
  background: var(--accent-saffron-light);
  border: 1px solid var(--accent-saffron-border);
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
}

/* ==========================================================================
   Header Tutorial Guide Pill & Modal Elements
   ========================================================================== */
.guide-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--accent-saffron-light);
  border: 1.5px solid var(--accent-saffron-border);
  color: var(--accent-saffron);
  border-radius: var(--radius-full);
  padding: 0.4rem 0.95rem;
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 1px 4px rgba(234, 88, 12, 0.08);
  white-space: nowrap;
}

.guide-pill-btn:hover {
  background: var(--accent-saffron);
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: var(--shadow-saffron);
}

.guide-icon {
  font-size: 1rem;
}

.guide-modal-title-row {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.guide-badge {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-saffron);
}

.guide-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
}

.guide-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.guide-section-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-main);
}

.guide-lead {
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.guide-step-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.85rem;
  margin-top: 0.5rem;
}

.guide-step-card {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  position: relative;
}

.guide-step-num {
  width: 26px;
  height: 26px;
  background: var(--accent-saffron);
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 800;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.35rem;
}

.guide-step-card h5 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.guide-step-card p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.guide-bands-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
}

.guide-band-card {
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  border: 1px solid var(--border-subtle);
}

.guide-band-card.band-strong { background: #f0fdf4; border-color: #bbf7d0; }
.guide-band-card.band-moderate { background: #fffbeb; border-color: #fde68a; }
.guide-band-card.band-weak { background: #f5f5f4; border-color: #e7e5e4; }
.guide-band-card.band-insufficient { background: #fef2f2; border-color: #fecaca; }

.guide-band-badge {
  font-size: 0.84rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.guide-band-card p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.guide-safety-box {
  background: var(--bg-parchment);
  border: 1px solid var(--border-subtle);
  border-left: 4px solid var(--accent-emerald);
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
}

.guide-preset-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ==========================================================================
   Mobile & Responsive Adaptations (Mobile First Polish)
   ========================================================================== */

/* Tablet & Smaller Laptops (<= 1024px) */
@media (max-width: 1024px) {
  .app-header {
    padding: 0.85rem 1.25rem;
  }
  
  .main-content {
    padding: 0 1rem;
    margin: 1.25rem auto 2.5rem;
  }

  .planner-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .kpi-ribbon {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Standard Mobile Devices (<= 768px) */
@media (max-width: 768px) {
  /* Header & Navigation */
  .app-header {
    padding: 0.75rem 0.85rem;
  }

  .header-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .brand-group {
    justify-content: flex-start;
  }

  .brand-title {
    font-size: 1.25rem;
  }

  .brand-native {
    font-size: 1.05rem;
  }

  .brand-tagline {
    font-size: 0.76rem;
    line-height: 1.3;
  }

  .header-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    width: 100%;
  }

  .guide-pill-btn {
    grid-column: span 2;
    justify-content: center;
    width: 100%;
    min-height: 42px;
    font-size: 0.88rem;
  }

  .control-pill {
    padding: 0.4rem 0.65rem;
    font-size: 0.78rem;
    justify-content: space-between;
    min-height: 40px;
  }

  .styled-select {
    font-size: 0.8rem;
    max-width: 110px;
    text-overflow: ellipsis;
  }

  .guide-step-grid,
  .guide-bands-grid {
    grid-template-columns: 1fr;
  }

  /* Main Container & Cards */
  .main-content {
    padding: 0 0.65rem;
    margin: 0.85rem auto 2rem;
    gap: 1rem;
  }

  .card {
    padding: 1rem;
    border-radius: var(--radius-md);
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.65rem;
  }

  .card-title {
    font-size: 1.15rem;
  }

  .card-subtitle {
    font-size: 1.05rem;
  }

  /* Preset Pills Ribbon (Smooth Horizontal Touch Scroll) */
  .preset-pills {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.35rem;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .preset-pills::-webkit-scrollbar {
    display: none;
  }

  .preset-label {
    white-space: nowrap;
    font-size: 0.78rem;
  }

  .preset-btn {
    white-space: nowrap;
    padding: 0.45rem 0.8rem;
    font-size: 0.82rem;
    flex-shrink: 0;
    min-height: 38px;
  }

  /* Input Form & Action Row */
  .seeds-textarea {
    padding: 0.75rem 0.85rem;
    font-size: 0.92rem;
    min-height: 90px;
  }

  .options-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .checkbox-label {
    font-size: 0.84rem;
    min-height: 36px;
  }

  .budget-limit-group {
    justify-content: space-between;
    font-size: 0.84rem;
  }

  .budget-limit-group .number-input {
    width: 120px;
    padding: 0.45rem 0.65rem;
  }

  /* Full-width primary CTA button with high thumb touch target */
  #run-research-btn {
    width: 100%;
    padding: 0.85rem 1.25rem;
    font-size: 1rem;
    border-radius: var(--radius-md);
    min-height: 48px;
  }

  /* Provenance Banner */
  .banner-pill {
    padding: 0.45rem 0.85rem;
    font-size: 0.78rem;
    text-align: center;
  }

  /* KPI Ribbon (2x2 Mobile Grid) */
  .kpi-ribbon {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.65rem;
  }

  .kpi-card {
    padding: 0.85rem 1rem;
  }

  .kpi-label {
    font-size: 0.72rem;
  }

  .kpi-value {
    font-size: 1.55rem;
  }

  .kpi-subtext {
    font-size: 0.74rem;
  }

  /* Swipeable Tab Bar */
  .tab-bar-container {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .tab-bar {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.45rem;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .tab-bar::-webkit-scrollbar {
    display: none;
  }

  .tab-btn {
    white-space: nowrap;
    flex-shrink: 0;
    padding: 0.55rem 0.85rem;
    font-size: 0.84rem;
    min-height: 40px;
  }

  /* Action Buttons (2x2 Grid) */
  .tab-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    width: 100%;
  }

  .tab-actions .btn {
    width: 100%;
    justify-content: center;
    padding: 0.5rem 0.65rem;
    font-size: 0.78rem;
    min-height: 40px;
  }

  /* Table Toolbar */
  .table-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .search-input {
    max-width: 100%;
    width: 100%;
    font-size: 0.88rem;
  }

  .table-toolbar-right {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
  }

  .table-swipe-hint {
    display: inline-block;
  }

  /* Sticky First Column for Smooth Horizontal Swiping */
  .table-scroll {
    position: relative;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-sm);
  }

  .data-table th:first-child,
  .data-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: #ffffff;
    box-shadow: 2px 0 6px -2px rgba(60, 40, 20, 0.12);
  }

  .data-table th:first-child {
    background: var(--bg-parchment);
    z-index: 3;
  }

  /* Candidate Pool */
  .candidate-view-toggle {
    display: flex;
    width: 100%;
    margin-top: 0.5rem;
  }

  .candidate-view-toggle .btn-toggle {
    flex: 1;
    text-align: center;
    padding: 0.5rem 0.5rem;
    font-size: 0.78rem;
    min-height: 38px;
  }

  .candidates-container {
    grid-template-columns: 1fr;
    max-height: 480px;
  }

  /* Tree Canvas */
  .tree-canvas-controls {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 0.5rem;
  }

  .tree-search-input {
    width: 100%;
  }

  .tree-select {
    width: 100%;
    padding: 0.5rem 0.75rem;
  }

  .tree-canvas-controls .btn {
    flex: 1;
    min-height: 40px;
  }

  .tree-canvas-viewport {
    padding: 0.85rem;
    min-height: 280px;
    max-height: 440px;
    -webkit-overflow-scrolling: touch;
  }

  .tree-seed-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .tree-branches {
    padding-left: 0.75rem;
    margin-left: 0.25rem;
  }

  .tree-candidate-grid {
    grid-template-columns: 1fr;
  }

  /* Content Planner */
  .planner-actions-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }

  .planner-actions-bar .btn {
    width: 100%;
    min-height: 42px;
  }

  .calendar-item {
    padding: 0.85rem;
    gap: 0.75rem;
  }

  /* Modals */
  .modal-backdrop {
    padding: 0.5rem;
  }

  .modal-card {
    width: 96vw;
    max-width: 96vw;
    border-radius: var(--radius-md);
  }

  .modal-large {
    width: 96vw;
    max-width: 96vw;
  }

  .modal-header {
    padding: 1rem;
  }

  .modal-title {
    font-size: 1.05rem;
  }

  .modal-body {
    padding: 1rem;
    max-height: calc(88vh - 120px);
  }

  .modal-footer {
    padding: 0.75rem 1rem;
    flex-direction: column-reverse;
  }

  .modal-footer .btn {
    width: 100%;
    padding: 0.65rem 1rem;
    min-height: 42px;
  }

  .report-preview-actions {
    flex-direction: column;
    gap: 0.5rem;
  }

  .report-preview-actions .btn {
    width: 100%;
    min-height: 42px;
  }

  .report-preview-textarea {
    height: 300px;
    font-size: 0.8rem;
  }

  /* Toast Notification */
  .toast-container {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
  }

  .toast {
    width: 100%;
  }

  /* Footer */
  .app-footer {
    padding: 1.25rem 1rem;
  }

  .footer-inner {
    flex-direction: column;
    text-align: center;
    gap: 0.5rem;
  }
}

/* Extra Small Phones (<= 400px) */
@media (max-width: 400px) {
  .brand-title {
    font-size: 1.15rem;
  }

  .brand-native {
    font-size: 0.95rem;
  }

  .brand-tagline {
    display: none;
  }

  .kpi-value {
    font-size: 1.35rem;
  }

  .tab-actions {
    grid-template-columns: 1fr;
  }
}
