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

  body {
    font-family: 'Inter', -apple-system, 'Segoe UI', system-ui, sans-serif;
    background: #f0f4f8;
    color: #18181b;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
  }

  /* ── Layout ── */
  .header {
    background: #29284B; box-shadow: 0 2px 16px rgba(41,40,75,0.4);
    position: sticky; top: 0; z-index: 100;
  }
  .header-inner { max-width: 780px; margin: 0 auto; padding: 18px 24px 0; }
  .header-logo {
    width: 42px; height: 42px; flex-shrink: 0; display: block;
  }
  .header-title {
    font-family: 'Inter', sans-serif; font-weight: 800; font-size: 20px; color: #fff;
    letter-spacing: -0.3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .header-sub { font-family: 'Inter', sans-serif; font-size: 11px; color: rgba(255,255,255,0.55); margin-top: 3px; letter-spacing: 0.4px; text-transform: uppercase; }
  #logout-btn { transition: background 0.15s, border-color 0.15s, color 0.15s; }
  #logout-btn:hover { background: #cc2f33 !important; border-color: #cc2f33 !important; color: #fff !important; }
  .tabs { display: flex; gap: 2px; margin-top: 20px; }
  .tab-btn {
    padding: 10px 18px; border: none; cursor: pointer; font-family: 'Inter', sans-serif;
    font-size: 12px; font-weight: 700; background: transparent;
    color: rgba(255,255,255,0.6); border-radius: 8px 8px 0 0;
    transition: all 0.2s; letter-spacing: 0.3px; text-transform: uppercase;
  }
  .tab-btn:hover { color: rgba(255,255,255,0.95); background: rgba(255,255,255,0.08); }
  .tab-btn.active { font-weight: 800; background: #f0f4f8; color: #00ADEE; }

  .period-bar { background: #fff; border-bottom: 1px solid #dde3ea; box-shadow: 0 1px 4px rgba(0,0,0,0.04); }
  .period-inner { max-width: 780px; margin: 0 auto; padding: 11px 24px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

  .main { max-width: 780px; margin: 0 auto; padding: 28px 24px 72px; }
  .tab-panel { display: none; opacity: 0; transition: opacity 0.2s; }
  .tab-panel.active { display: block; opacity: 1; }

  /* ── Cards ── */
  .card {
    background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
    padding: 28px; box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.04);
    margin-bottom: 16px;
  }
  .card-sm {
    background: #fff; border: 1px solid #e2e8f0; border-radius: 10px;
    padding: 14px 18px; box-shadow: 0 1px 3px rgba(0,0,0,0.03);
    margin-bottom: 8px;
  }

  /* ── Timer ── */
  .timer-card {
    background: linear-gradient(135deg, #1e1d3a 0%, #29284B 60%, #363568 100%);
    border-radius: 14px; padding: 24px 28px; color: #fff;
    box-shadow: 0 8px 32px rgba(41,40,75,0.4), 0 2px 8px rgba(0,0,0,0.15);
    margin-bottom: 16px; position: relative; overflow: hidden;
  }
  .timer-card::before {
    content: ''; position: absolute; top: -40px; right: -40px;
    width: 160px; height: 160px; border-radius: 50%;
    background: rgba(0,173,238,0.08); pointer-events: none;
  }
  .timer-label {
    font-size: 10px; font-weight: 700; letter-spacing: 2px;
    color: #F6921E; text-transform: uppercase; margin-bottom: 12px;
  }
  .timer-display {
    font-family: ui-monospace, 'SF Mono', Menlo, monospace;
    font-size: 56px; font-weight: 700; letter-spacing: 2px;
    color: rgba(255,255,255,0.28); margin-bottom: 20px; line-height: 1;
    transition: color 0.4s ease;
  }
  .timer-display.running { color: #4ade80; text-shadow: 0 0 20px rgba(74,222,128,0.4); }
  .timer-btns { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

  /* ── Form ── */
  label.field-label {
    display: block; font-family: 'Inter', sans-serif; font-size: 10px; font-weight: 700; letter-spacing: 1px;
    text-transform: uppercase; color: #64748b; margin-bottom: 7px;
  }
  input[type=text], input[type=number], input[type=date], input[type=email], select, textarea {
    width: 100%; padding: 10px 13px; border: 1.5px solid #e2e8f0; border-radius: 8px;
    font-family: inherit; font-size: 14px; color: #18181b; background: #fff; outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
  }
  input:focus, select:focus, textarea:focus {
    border-color: #00ADEE;
    box-shadow: 0 0 0 3px rgba(0,173,238,0.12);
  }
  textarea { resize: vertical; line-height: 1.65; }
  .field-row { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 22px; }
  .field-group { margin-bottom: 18px; }
  .divider { height: 1px; background: #f1f5f9; margin: 4px 0 22px; }

  /* ── Step indicator ── */
  .step-label { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
  .step-num {
    width: 24px; height: 24px; border-radius: 50%; font-size: 11px; font-weight: 700;
    flex-shrink: 0; display: flex; align-items: center; justify-content: center;
    background: #e2e8f0; color: #94a3b8; transition: all 0.25s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  }
  .step-num.active { background: #00ADEE; color: #fff; box-shadow: 0 2px 8px rgba(0,173,238,0.4); }
  .step-num.done { background: #00ADEE; color: #fff; }
  .step-text { font-family: 'Inter', sans-serif; font-size: 12px; font-weight: 700; color: #94a3b8; transition: color 0.2s; letter-spacing: 0.2px; }
  .step-text.active { color: #18181b; }

  /* ── Entity / choice buttons ── */
  .choice-group { display: flex; gap: 10px; margin-bottom: 26px; flex-wrap: wrap; }
  .choice-btn {
    flex: 1; min-width: 80px; padding: 12px 8px; border-radius: 10px; cursor: pointer;
    font-family: inherit; font-weight: 700; font-size: 13px;
    transition: all 0.18s ease; border: 2px solid #e2e8f0;
    background: #fff; color: #64748b; text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  }
  .choice-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
  .choice-btn .badge { font-size: 10px; opacity: 0.7; display: block; margin-bottom: 3px; letter-spacing: 0.5px; }

  /* ── Buttons ── */
  .btn {
    font-family: 'Inter', inherit; font-weight: 700; cursor: pointer; border-radius: 8px;
    font-size: 13px; padding: 9px 18px; border: 1.5px solid transparent;
    transition: all 0.18s ease; letter-spacing: 0.2px;
  }
  .btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
  .btn:active { transform: translateY(0); }
  .btn-primary { background: #00ADEE; color: #fff; border-color: #00ADEE; box-shadow: 0 2px 8px rgba(0,173,238,0.3); }
  .btn-primary:hover { background: #009fd8; box-shadow: 0 4px 16px rgba(0,173,238,0.4); }
  .btn-orange { background: #F6921E; color: #fff; border-color: #F6921E; box-shadow: 0 2px 8px rgba(246,146,30,0.3); }
  .btn-orange:hover { background: #e8820e; box-shadow: 0 4px 16px rgba(246,146,30,0.4); }
  .btn-ghost { background: transparent; color: #64748b; border-color: #e2e8f0; }
  .btn-ghost:hover { background: #f8fafc; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
  .btn-danger { background: transparent; color: #FF585D; border-color: #ffb3b5; }
  .btn-danger:hover { background: #fff0f0; }
  .btn-sm { font-size: 12px; padding: 5px 12px; border-radius: 6px; }
  .btn-lg { font-size: 15px; padding: 13px 24px; border-radius: 10px; }
  .btn-full { width: 100%; }
  .btn-disabled { background: #f8fafc; color: #cbd5e1; border-color: #e2e8f0; cursor: default; box-shadow: none; }
  .btn-disabled:hover { transform: none; box-shadow: none; }
  .btn-stop { background: #FF585D; color: #fff; border-color: #FF585D; box-shadow: 0 2px 8px rgba(255,88,93,0.35); }
  .btn-timer-reset { background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.55); border: 1.5px solid rgba(255,255,255,0.15); }
  .btn-timer-reset:hover { background: rgba(255,255,255,0.14); box-shadow: none; }

  /* ── Step-1 row: question on the left, Simple | Advanced toggle on the right ── */
  .step1-row { justify-content: space-between; flex-wrap: wrap; gap: 8px 12px; }
  .step1-left { display: flex; align-items: center; gap: 10px; }
  .mode-toggle { display: inline-flex; gap: 3px; background: #f1f5f9; padding: 3px; border-radius: 8px; }
  .mode-btn {
    font-family: inherit; font-size: 12px; font-weight: 700; padding: 6px 14px; border-radius: 6px;
    border: none; background: transparent; color: #64748b; cursor: pointer; transition: all 0.15s; min-height: 0;
  }
  .mode-btn.on { background: #00ADEE; color: #fff; box-shadow: 0 1px 4px rgba(0,173,238,0.35); }

  /* ── Allocation table (Advanced mode) ── */
  .alloc-table { border: 1.5px solid #e2e8f0; border-radius: 11px; overflow: hidden; margin-bottom: 12px; }
  .alloc-head, .alloc-row {
    display: grid; grid-template-columns: 104px 150px minmax(0,1fr) 84px 56px 26px;
    gap: 8px; align-items: center; padding: 10px 14px;
  }
  .alloc-head { padding: 9px 14px; background: #f8fafc; border-bottom: 1px solid #e2e8f0; }
  .alloc-head span { font-size: 10px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: #94a3b8; }
  .alloc-r { text-align: right; }
  .alloc-row { border-bottom: 1px solid #f1f5f9; }
  .alloc-row:last-child, .alloc-sub:last-child { border-bottom: none; }
  .alloc-table select, .alloc-table input[type=number], .alloc-table input[type=text] {
    font-family: inherit; font-size: 13px; font-weight: 600; padding: 7px 10px; min-height: 0;
    border: 1.5px solid #e2e8f0; border-radius: 7px; background: #fff; color: #18181b; width: 100%; min-width: 0;
  }
  .alloc-table select { cursor: pointer; }
  .alloc-entity { text-align: center; font-weight: 800; }
  /* A chosen entity paints the select in its brand colour (set as --ent inline) */
  .alloc-entity.on { text-align-last: center; background: var(--ent) !important; border-color: var(--ent) !important; color: #fff !important; }
  .alloc-prog.on { color: #00ADEE; }
  .alloc-dash { font-size: 13px; color: #cbd5e1; padding: 7px 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .alloc-warn { color: #b45309; font-size: 12px; }
  .alloc-share { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
  .alloc-table .alloc-pct { width: 64px; text-align: right; font-weight: 700; font-size: 14px; padding: 7px 8px; }
  /* No spinner arrows — they eat the width a 3-digit share needs */
  .alloc-table input[type=number] { -moz-appearance: textfield; appearance: textfield; }
  .alloc-table input[type=number]::-webkit-inner-spin-button, .alloc-table input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
  .alloc-pct-sign { font-size: 12px; color: #94a3b8; }
  .alloc-time { font-size: 13px; font-weight: 700; color: #64748b; text-align: right; white-space: nowrap; }
  .alloc-del {
    font-family: inherit; font-size: 13px; color: #cbd5e1; background: none; border: none;
    cursor: pointer; padding: 4px; border-radius: 6px; line-height: 1; min-height: 0;
  }
  .alloc-del:hover { color: #FF585D; background: #fff0f0; }
  .alloc-del:disabled { opacity: 0.35; cursor: default; background: none; color: #cbd5e1; }
  /* Lobbying / political sublines — attached to the row above */
  .alloc-sub { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 9px 14px 10px 30px; border-bottom: 1px solid #f1f5f9; }
  .alloc-sub-lobby { background: linear-gradient(135deg, #fffbf5 0%, #fff8ef 100%); }
  .alloc-sub-political { background: linear-gradient(135deg, #faf5ff 0%, #f5f0ff 100%); }
  .alloc-sub-arrow { font-size: 12px; color: #c4720d; }
  .alloc-sub-political .alloc-sub-arrow { color: #7C3AED; }
  .alloc-sub-label { font-size: 10px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: #b45309; }
  .alloc-sub-political .alloc-sub-label { color: #6d28d9; }
  .alloc-tag {
    font-family: inherit; font-size: 12px; font-weight: 700; padding: 5px 11px; border-radius: 6px;
    border: 1.5px solid #e4e4e7; background: #fff; color: #52525b; cursor: pointer; min-height: 0; transition: all 0.15s;
  }
  .alloc-tag:hover { transform: translateY(-1px); box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
  .alloc-sub-pct { display: flex; align-items: center; gap: 5px; margin-left: auto; font-size: 12px; color: #b45309; white-space: nowrap; }
  .alloc-sub-political .alloc-sub-pct { color: #6d28d9; }
  .alloc-table .alloc-sub-pct input { width: 60px; text-align: right; font-weight: 700; }
  .alloc-sub-hint { font-size: 11px; color: #a1a1aa; margin-left: auto; }
  .alloc-table .alloc-candidate { flex: 1; min-width: 140px; max-width: 260px; width: auto; }
  .alloc-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; }
  .alloc-foot-btns { display: flex; gap: 8px; flex-wrap: wrap; }
  .alloc-btn { border: 1.5px solid #00ADEE; color: #00ADEE; background: #fff; }
  .alloc-foot-total { display: flex; align-items: center; gap: 10px; }
  .alloc-allocated { font-size: 12px; color: #94a3b8; }
  .alloc-chip { font-size: 12px; font-weight: 800; border-radius: 6px; padding: 5px 11px; border: 1px solid; white-space: nowrap; }
  .alloc-chip.ok  { color: #15803d; background: #f0fff4; border-color: #86efac; }
  .alloc-chip.bad { color: #b91c1c; background: #fff0f0; border-color: #ffb3b5; }

  .lobby-pct-panel {
    display: flex; align-items: center; gap: 12px; margin-bottom: 26px;
    background: linear-gradient(135deg, #fffbf5 0%, #fff8ef 100%);
    border: 1px solid rgba(246,146,30,0.25); border-radius: 10px;
    padding: 14px 16px; flex-wrap: wrap;
  }
  .lobby-pct-panel label.field-label { margin-bottom: 0; white-space: nowrap; color: #b45309; }
  .political-panel {
    background: linear-gradient(135deg, #faf5ff 0%, #f5f0ff 100%);
    border: 1.5px solid rgba(124,58,237,0.25); border-radius: 10px;
    padding: 16px 18px; margin-bottom: 26px;
  }
  .political-panel label.field-label { color: #6d28d9; }

  /* ── Suggestions ── */
  .suggestions-wrap { position: relative; }
  .suggestions-box {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 50;
    background: #fff; border: 1.5px solid #00ADEE; border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.14); margin-top: 6px; overflow: hidden; display: none;
  }
  .suggestions-box.open { display: block; animation: fadeSlideDown 0.15s ease; }
  @keyframes fadeSlideDown { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
  .suggestions-header {
    padding: 9px 14px 7px; font-size: 10px; font-weight: 700; color: #94a3b8;
    letter-spacing: 0.9px; text-transform: uppercase; border-bottom: 1px solid #f1f5f9;
    background: #fafcff;
  }
  .suggestion-item {
    width: 100%; padding: 11px 14px; border: none; border-bottom: 1px solid #f1f5f9;
    background: transparent; cursor: pointer; text-align: left; font-family: inherit;
    display: flex; flex-direction: column; gap: 5px; transition: background 0.12s;
  }
  .suggestion-item:last-child { border-bottom: none; }
  .suggestion-item:hover { background: #f0f9ff; }
  .suggestion-desc { font-size: 13px; font-weight: 600; color: #18181b; line-height: 1.35; }
  .suggestion-meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

  /* ── Pills ── */
  .pill { font-size: 10px; font-weight: 700; letter-spacing: 0.6px; padding: 2px 8px; border-radius: 5px; color: #fff; display: inline-block; }
  .pill-fn { font-size: 11px; color: #64748b; font-weight: 500; }
  .pill-prog { font-size: 11px; color: #00ADEE; font-weight: 600; }
  .pill-lobby-direct { background: #fff0f0; color: #cc2f33; }
  .pill-lobby-grassroots { background: #fef9c3; color: #854d0e; }
  .pill-lobbying-tag { font-size: 10px; background: #fff0f0; color: #cc2f33; padding: 2px 8px; border-radius: 5px; font-weight: 700; }
  .pill-political-tag { font-size: 10px; background: #f5f0ff; color: #6d28d9; padding: 2px 8px; border-radius: 5px; font-weight: 700; }
  body.dark .pill-political-tag { background: #2a1a4d !important; color: #c4b5fd !important; }

  /* ── Period nav ── */
  .view-toggle { display: flex; border: 1.5px solid #00ADEE; border-radius: 8px; overflow: hidden; }
  .view-toggle-btn { padding: 6px 14px; border: none; cursor: pointer; font-family: inherit; font-size: 12px; font-weight: 600; background: #fff; color: #00ADEE; transition: all 0.15s; }
  .view-toggle-btn:hover { background: #f0f9ff; }
  .view-toggle-btn.active { background: #00ADEE; color: #fff; }
  .period-nav-btn {
    border: 1.5px solid #e2e8f0; background: #fff; border-radius: 8px;
    padding: 5px 12px; cursor: pointer; font-size: 16px; color: #64748b;
    font-family: inherit; transition: all 0.15s;
  }
  .period-nav-btn:hover { background: #f8fafc; border-color: #cbd5e1; }
  .period-label { font-family: 'Inter', sans-serif; font-size: 13px; font-weight: 700; color: #29284B; min-width: 220px; text-align: center; }
  .current-link { background: none; border: none; cursor: pointer; font-size: 12px; color: #00ADEE; font-family: inherit; text-decoration: underline; transition: opacity 0.15s; }
  .current-link:hover { opacity: 0.75; }
  .entity-filter { width: auto !important; font-size: 12px; padding: 6px 10px !important; margin-left: auto; border-radius: 8px !important; }

  /* ── Summary strip ── */
  .summary-strip {
    background: #fff; border: 1px solid #e2e8f0; border-radius: 10px;
    padding: 14px 20px; margin-bottom: 16px; display: flex; gap: 28px; flex-wrap: wrap;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  }
  .summary-item-label { font-family: 'Inter', sans-serif; font-size: 10px; font-weight: 700; color: #94a3b8; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 3px; }
  .summary-item-val { font-family: 'Inter', sans-serif; font-size: 16px; font-weight: 800; color: #29284B; }

  /* ── History entry ── */
  .entry-card {
    background: #fff; border-radius: 10px; border: 1px solid #e2e8f0;
    padding: 14px 18px; margin-bottom: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    transition: box-shadow 0.2s, transform 0.2s;
  }
  .entry-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.08); transform: translateY(-1px); }
  .entry-meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 7px; }
  .entry-desc { font-size: 14px; line-height: 1.55; color: #1e293b; }
  .entry-right { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; flex-shrink: 0; }
  .entry-dur { font-family: 'Inter', sans-serif; font-size: 16px; font-weight: 800; color: #29284B; letter-spacing: -0.3px; }
  .entry-actions { display: flex; gap: 6px; }
  .entry-date { font-size: 12px; color: #94a3b8; }
  .entry-fn-tag { font-size: 11px; background: #f1f5f9; padding: 2px 8px; border-radius: 5px; color: #64748b; font-weight: 500; }
  .entry-prog { font-size: 12px; color: #00ADEE; font-weight: 700; }
  /* Split entry: stacked share bar + legend (the only thing a split adds to the card) */
  .entry-split-bar { display: flex; gap: 2px; margin-top: 10px; height: 7px; border-radius: 4px; overflow: hidden; background: #f1f5f9; }
  .entry-split-bar span { display: block; height: 100%; }
  .entry-split-legend { display: flex; gap: 6px 14px; flex-wrap: wrap; margin-top: 8px; }
  .entry-split-legend > span { font-size: 11px; color: #64748b; display: inline-flex; align-items: center; gap: 5px; }
  .entry-split-legend i { display: inline-block; width: 7px; height: 7px; border-radius: 2px; flex: none; }
  .entry-split-legend em { font-style: normal; font-weight: 700; font-size: 10px; }
  .entry-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }

  /* ── Report cards ── */
  .report-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
  .report-card {
    background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 20px 18px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.04);
    transition: transform 0.2s, box-shadow 0.2s;
  }
  .report-card:hover { transform: translateY(-2px); box-shadow: 0 6px 24px rgba(0,0,0,0.09); }
  .report-card-label { font-family: 'Inter', sans-serif; font-size: 10px; font-weight: 700; color: #94a3b8; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 8px; }
  .report-card-val { font-family: 'Inter', sans-serif; font-size: 32px; font-weight: 900; line-height: 1; letter-spacing: -0.5px; }
  .report-card-sub { font-size: 12px; color: #94a3b8; margin-top: 6px; font-weight: 500; }
  .bar-section {
    background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 22px;
    margin-bottom: 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  }
  .bar-section-title { font-family: 'Inter', sans-serif; font-size: 10px; font-weight: 800; letter-spacing: 1.5px; color: #94a3b8; text-transform: uppercase; margin-bottom: 18px; }
  .bar-row { margin-bottom: 14px; }
  .bar-row-header { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
  .bar-row-label { font-weight: 600; color: #1e293b; }
  .bar-row-val { color: #64748b; font-weight: 500; }
  .bar-track { height: 7px; background: #f1f5f9; border-radius: 4px; overflow: hidden; }
  .bar-fill { height: 100%; border-radius: 4px; transition: width 0.6s cubic-bezier(0.4,0,0.2,1); }
  .joint-note {
    background: linear-gradient(135deg, #fffbf5 0%, #fff8ef 100%);
    border: 1px solid rgba(246,146,30,0.25); border-radius: 10px;
    padding: 14px 18px; margin-bottom: 20px; font-size: 13px; color: #92400e;
    line-height: 1.5;
  }

  /* ── Settings ── */
  .settings-prog-card {
    background: #fff; border: 1px solid #e2e8f0; border-radius: 10px;
    padding: 16px 18px; margin-bottom: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  }
  .settings-prog-row { display: flex; align-items: flex-start; gap: 12px; }
  .settings-prog-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
  /* Compact collapsed program rows */
  .prog-row {
    display: flex; align-items: center; gap: 10px; cursor: pointer;
    padding: 11px 14px; border: 1px solid #e2e8f0; border-radius: 9px;
    background: #fff; margin-bottom: 7px; box-shadow: 0 1px 2px rgba(0,0,0,0.03);
    transition: border-color 0.15s, box-shadow 0.15s;
  }
  .prog-row:hover { border-color: #cbd5e1; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
  .prog-row.expanded { border-color: #7ecff5; box-shadow: 0 2px 10px rgba(0,173,238,0.12); }
  .prog-row-chevron { color: #94a3b8; font-size: 12px; transition: transform 0.18s; flex-shrink: 0; }
  .prog-row.expanded .prog-row-chevron { transform: rotate(90deg); }
  .prog-row-name { font-size: 14px; font-weight: 600; color: #1e293b; flex: 1; }
  .prog-badge { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 5px; letter-spacing: 0.4px; }
  .prog-row-edit {
    border: 1px solid #7ecff5; border-top: none; border-radius: 0 0 9px 9px;
    background: #fafdff; padding: 16px 16px 18px; margin-top: -10px; margin-bottom: 12px;
  }
  body.dark .prog-row { background: var(--surface) !important; border-color: var(--border) !important; }
  body.dark .prog-row-name { color: var(--text) !important; }
  body.dark .prog-row-edit { background: var(--surface2) !important; border-color: #1a4a6e !important; }
  .add-prog-box {
    background: linear-gradient(135deg, #f0f9ff 0%, #e6f6fd 100%);
    border: 1.5px dashed #7ecff5; border-radius: 12px; padding: 20px 18px;
  }
  .add-prog-title { font-family: 'Inter', sans-serif; font-size: 11px; font-weight: 800; color: #0082b3; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 16px; }
  .vsep { width: 1px; height: 16px; background: #e2e8f0; display: inline-block; }

  /* ── Inline edit ── */
  .edit-form { display: flex; flex-direction: column; gap: 10px; }
  .edit-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
  .edit-actions { display: flex; gap: 8px; justify-content: flex-end; }
  .dur-row { display: flex; gap: 4px; align-items: center; }
  .dur-label { font-size: 12px; color: #94a3b8; }

  /* ── Programs list (no programs) ── */
  .no-programs { font-size: 13px; color: #94a3b8; margin-bottom: 24px; line-height: 1.6; }
  .no-programs a { color: #00ADEE; cursor: pointer; font-weight: 600; text-decoration: none; }
  .no-programs a:hover { text-decoration: underline; }

  /* ── Toast ── */
  .toast {
    position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(8px);
    background: #1e293b; color: #fff; padding: 12px 24px; border-radius: 10px;
    font-size: 13px; font-weight: 600; letter-spacing: 0.1px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25); border: 1px solid rgba(255,255,255,0.08);
    z-index: 10000; white-space: nowrap; display: none; opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
  }
  .toast.err { background: #FF585D; }
  .toast.show { display: block; opacity: 1; transform: translateX(-50%) translateY(0); }

  /* ── Modal (rejection note, etc.) ── */
  .modal-overlay {
    position: fixed; inset: 0; z-index: 9998; background: rgba(15,20,32,0.55);
    display: none; align-items: center; justify-content: center; padding: 20px;
  }
  .modal-overlay.show { display: flex; }
  .modal-card {
    width: min(460px, 94vw); background: #fff; color: #29284B;
    border: 1px solid #e5e7eb; border-radius: 14px; padding: 22px 22px 18px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  }
  .modal-title { font-size: 16px; font-weight: 800; }
  .modal-sub { font-size: 13px; color: #71717a; margin-top: 4px; }
  .modal-textarea {
    width: 100%; box-sizing: border-box; margin-top: 14px; min-height: 96px; resize: vertical;
    padding: 10px 12px; border: 1px solid #d4d4d8; border-radius: 9px;
    font-family: inherit; font-size: 13px; color: #29284B;
  }
  .modal-textarea:focus { outline: none; border-color: #00ADEE; }
  .modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
  body.dark .modal-card { background: var(--surface) !important; color: var(--text) !important; border-color: var(--border) !important; }
  body.dark .modal-sub { color: var(--muted) !important; }
  body.dark .modal-textarea { background: var(--bg) !important; color: var(--text) !important; border-color: var(--border) !important; }

  /* ── Settings sub-navigation (pills) ── */
  .settings-nav { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 28px; }
  .settings-pill {
    border: 1px solid transparent; cursor: pointer; font-family: inherit; font-size: 13px;
    font-weight: 600; padding: 7px 15px; border-radius: 999px;
    background: rgba(128,128,128,0.10); color: inherit;
  }
  .settings-pill.active { background: #00ADEE; color: #fff; }
  .settings-page { display: none; }
  .settings-page.active { display: block; }

  /* ── Empty state ── */
  .empty {
    text-align: center; color: #94a3b8; padding: 64px 0; font-size: 15px;
    display: flex; flex-direction: column; align-items: center; gap: 10px;
  }
  .empty::before { content: '○'; font-size: 32px; opacity: 0.3; display: block; }

  /* ── Submitted period ── */
  .period-locked-badge {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 5px;
    background: #f0fff4; color: #166534; border: 1px solid #86efac;
    font-family: 'Inter', sans-serif; letter-spacing: 0.3px;
  }
  body.dark .period-locked-badge { background: #052e16; color: #4ade80; border-color: #166534; }
  .entry-card.locked { opacity: 0.8; }
  .entry-card.locked .entry-desc { color: #64748b; }
  body.dark .entry-card.locked .entry-desc { color: var(--muted); }
  .btn-submit { background: #166534; color: #fff; border-color: #166534; box-shadow: 0 2px 8px rgba(22,101,52,0.3); }
  .btn-submit:hover { background: #14532d; box-shadow: 0 4px 14px rgba(22,101,52,0.4); }
  .btn-unlock { background: transparent; color: #64748b; border-color: #e2e8f0; }
  .btn-unlock:hover { background: #f8fafc; }
  body.dark .btn-unlock { color: var(--muted); border-color: var(--border); }

  @media (max-width: 480px) {
    .report-cards { grid-template-columns: 1fr 1fr; }
    .edit-grid-3 { grid-template-columns: 1fr 1fr; }
    .main { padding: 20px 16px 60px; }
    .header-inner { padding: 16px 16px 0; }
  }

  /* ── Dark mode ── */
  body.dark {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface2: #222536;
    --border: #2e3148;
    --text: #e8eaf0;
    --muted: #7b8099;
    --accent: #7ecff5;
    color-scheme: dark;
  }

  /* Base */
  body.dark { background: var(--bg) !important; color: var(--text) !important; }
  body.dark * { color: inherit; }

  /* Header */
  body.dark .header { background: #16152a !important; }
  body.dark .header-title { color: #fff !important; }
  body.dark .header-sub { color: rgba(255,255,255,0.6) !important; }
  body.dark .tab-btn { color: rgba(255,255,255,0.65) !important; background: transparent !important; }
  body.dark .tab-btn.active { background: var(--bg) !important; color: #00ADEE !important; }
  body.dark .header { box-shadow: 0 2px 12px rgba(0,0,0,0.4) !important; }

  /* Period bar */
  body.dark .period-bar { background: #0d1a24 !important; border-color: var(--border) !important; }
  body.dark .period-label { color: var(--accent) !important; font-family: 'Inter', sans-serif !important; }
  body.dark .period-nav-btn { background: var(--surface) !important; border-color: var(--border) !important; color: var(--muted) !important; }
  body.dark .view-toggle { border-color: #00ADEE !important; }
  body.dark .view-toggle-btn { background: var(--surface) !important; color: #00ADEE !important; }
  body.dark .view-toggle-btn.active { background: #00ADEE !important; color: #fff !important; }
  body.dark .current-link { color: #00ADEE !important; }
  body.dark .entity-filter { background: var(--surface) !important; border-color: var(--border) !important; color: var(--text) !important; }

  /* Main content area */
  body.dark .main { background: var(--bg) !important; }
  body.dark body { background: var(--bg) !important; }

  /* Cards */
  body.dark .card, body.dark .card-sm { background: var(--surface) !important; border-color: var(--border) !important; }
  body.dark .timer-card { background: #0d1f2e !important; }

  /* Form elements */
  body.dark input[type=text], body.dark input[type=number],
  body.dark input[type=date], body.dark input[type=email], body.dark select, body.dark textarea {
    background: var(--surface2) !important; border-color: var(--border) !important;
    color: var(--text) !important;
  }
  body.dark input:focus, body.dark select:focus, body.dark textarea:focus { border-color: #00ADEE !important; }
  body.dark label.field-label { color: var(--muted) !important; }
  body.dark .divider { background: var(--border) !important; }

  /* Step labels */
  body.dark .step-num:not(.active):not(.done) { background: #3a3d55 !important; color: #c8cce0 !important; }
  body.dark .step-num.active { background: #00ADEE !important; color: #fff !important; box-shadow: 0 2px 8px rgba(0,173,238,0.4) !important; }
  body.dark .step-num.done { background: #00ADEE !important; color: #fff !important; }
  body.dark .step-text { color: var(--muted) !important; }
  body.dark .step-text.active { color: var(--text) !important; }

  /* Choice / function buttons */
  /* choice-btn dark mode handled entirely by JS to avoid !important conflicts */

  /* Simple | Advanced toggle + allocation table */
  body.dark .mode-toggle { background: var(--surface2) !important; }
  body.dark .mode-btn { color: var(--muted) !important; }
  body.dark .mode-btn.on { background: #00ADEE !important; color: #fff !important; }
  body.dark .alloc-table { border-color: var(--border) !important; }
  body.dark .alloc-head { background: var(--surface2) !important; border-color: var(--border) !important; }
  body.dark .alloc-head span { color: var(--muted) !important; }
  body.dark .alloc-row, body.dark .alloc-sub { border-color: var(--border) !important; }
  body.dark .alloc-table select, body.dark .alloc-table input { background: var(--surface2) !important; border-color: #4a4d6a !important; color: var(--text) !important; }
  body.dark .alloc-entity.on { background: var(--ent) !important; border-color: var(--ent) !important; color: #fff !important; }
  body.dark .alloc-prog.on { color: #7dd3fc !important; }
  body.dark .alloc-dash { color: #4a4d6a !important; }
  body.dark .alloc-time { color: var(--muted) !important; }
  body.dark .alloc-pct-sign, body.dark .alloc-allocated { color: var(--muted) !important; }
  body.dark .alloc-sub-lobby { background: #1e1608 !important; }
  body.dark .alloc-sub-political { background: #160d28 !important; }
  body.dark .alloc-tag:not(.on) { background: #2a2d45 !important; border-color: #4a4d6a !important; color: #c8cce0 !important; }
  body.dark .alloc-btn { background: transparent !important; }
  body.dark .alloc-chip.ok  { background: #0f2a18 !important; border-color: #166534 !important; color: #86efac !important; }
  body.dark .alloc-chip.bad { background: #2a1214 !important; border-color: #7f1d1d !important; color: #fca5a5 !important; }
  body.dark .entry-split-bar { background: var(--surface2) !important; }
  body.dark .entry-split-legend > span { color: var(--muted) !important; }

  /* Lobby / political panels */
  body.dark .lobby-pct-panel { background: #1e1608 !important; border-color: rgba(246,146,30,0.3) !important; }
  body.dark .political-panel { background: #160d28 !important; border-color: rgba(124,58,237,0.4) !important; }
  body.dark .political-panel label.field-label { color: #c4b5fd !important; }

  /* Suggestions */
  body.dark .suggestions-box { background: var(--surface) !important; border-color: #00ADEE !important; }
  body.dark .suggestions-header { color: var(--muted) !important; border-color: var(--border) !important; }
  body.dark .suggestion-item { border-color: var(--border) !important; background: transparent !important; }
  body.dark .suggestion-item:hover { background: #0d2033 !important; }
  body.dark .suggestion-desc { color: var(--text) !important; }
  body.dark .pill-fn { color: var(--muted) !important; }

  /* Summary strip */
  body.dark #notif-panel { background: var(--surface) !important; color: var(--text) !important; border-color: var(--border) !important; }
  body.dark .summary-strip { background: var(--surface) !important; border-color: var(--border) !important; }
  body.dark .summary-item-label { color: var(--muted) !important; }
  body.dark .summary-item-val { color: var(--accent) !important; }

  /* History entries */
  body.dark .entry-card { background: var(--surface) !important; border-color: var(--border) !important; }
  body.dark .entry-date { color: var(--muted) !important; }
  body.dark .entry-fn-tag { background: var(--surface2) !important; color: var(--muted) !important; }
  body.dark .entry-desc { color: var(--text) !important; }
  body.dark .entry-dur { color: var(--accent) !important; }

  /* Report */
  body.dark .report-card { background: var(--surface) !important; border-color: var(--border) !important; }
  body.dark .report-card-label { color: var(--muted) !important; }
  body.dark .report-card-sub { color: var(--muted) !important; }
  body.dark .bar-section { background: var(--surface) !important; border-color: var(--border) !important; }
  body.dark .bar-section-title { color: var(--muted) !important; }
  body.dark .bar-track { background: var(--surface2) !important; }
  body.dark .joint-note { background: #1e1608 !important; border-color: rgba(246,146,30,0.3) !important; color: #e0a050 !important; }

  /* Settings */
  body.dark .settings-prog-card { background: var(--surface) !important; border-color: var(--border) !important; }
  body.dark .add-prog-box { background: #0d1a24 !important; border-color: #1a4a6e !important; }
  body.dark .add-prog-title { color: var(--accent) !important; }
  body.dark .vsep { background: var(--border) !important; }

  /* Buttons */
  body.dark .btn-ghost { background: transparent !important; color: #c8cce0 !important; border-color: #4a4d6a !important; }
  body.dark [style*="border: 2px solid #e2e8f0"] { border-color: #4a4d6a !important; color: #c8cce0 !important; }
  body.dark [style*="border:2px solid #e2e8f0"] { border-color: #4a4d6a !important; color: #c8cce0 !important; }
  body.dark [style*="border-color: #e2e8f0"] { border-color: #4a4d6a !important; }
  body.dark .btn-disabled { background: transparent !important; color: var(--muted) !important; border-color: var(--border) !important; }

  /* Misc text */
  body.dark .no-programs { color: var(--muted) !important; }
  body.dark .empty { color: var(--muted) !important; }
  body.dark .timer-label { color: #F6921E !important; }
  body.dark .add-prog-box label.field-label { color: var(--muted) !important; }

  /* Inline styles that need overriding */
  body.dark [style*="color:#52525b"] { color: var(--muted) !important; }
  body.dark [style*="color:#64748b"] { color: var(--muted) !important; }
  body.dark [style*="color:#94a3b8"] { color: var(--muted) !important; }
  body.dark [style*="color:#1e293b"] { color: var(--text) !important; }
  body.dark [style*="color:#18181b"] { color: var(--text) !important; }
  body.dark [style*="color:#a1a1aa"] { color: var(--muted) !important; }
  body.dark [style*="color:#00527a"] { color: var(--accent) !important; }
  body.dark [style*="background:#fff"]:not(.pill):not([class*="btn-primary"]):not([class*="btn-orange"]):not([class*="btn-stop"]):not(.view-toggle-btn) { background: var(--surface) !important; }
  body.dark [style*="background:#f4f4f5"] { background: var(--surface2) !important; }
  body.dark [style*="background:#f7fbfe"] { background: var(--bg) !important; }
  body.dark [style*="background:#f0f4f8"] { background: var(--bg) !important; }
  body.dark [style*="background:#e6f6fd"] { background: #0d2033 !important; }
  body.dark [style*="background:#f9f9f9"] { background: var(--surface2) !important; }
  body.dark [style*="border-color:#e4e4e7"] { border-color: #4a4d6a !important; }
  body.dark [style*="border: 2px solid #e2e8f0"], body.dark [style*="border:2px solid #e2e8f0"] { border-color: #4a4d6a !important; }
  /* program-list dark mode handled by JS */
  /* lobby-btn dark mode handled by JS */
  body.dark .pill-lobbying-tag { background: #5c1a1c !important; color: #ff9a9c !important; }
  /* fn-btns dark mode handled by JS */


  /* ════════════════════════════════════════════════════════════════════
     MOBILE APP SHELL  —  bottom nav, "More" sheet, responsive overhaul
     ════════════════════════════════════════════════════════════════════ */

  :root { --bnav-h: 56px; }

  html { -webkit-text-size-adjust: 100%; }
  body { overflow-x: hidden; }
  button { -webkit-tap-highlight-color: transparent; }

  /* ── Bottom navigation (hidden on desktop, shown ≤640px) ── */
  .bottom-nav {
    display: none;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 900;
    height: calc(var(--bnav-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: rgba(255,255,255,0.92);
    -webkit-backdrop-filter: saturate(180%) blur(18px);
    backdrop-filter: saturate(180%) blur(18px);
    border-top: 1px solid #e2e8f0;
    box-shadow: 0 -1px 12px rgba(15,23,42,0.06);
  }
  .bnav-btn {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; border: none; background: none; cursor: pointer; padding: 6px 2px 4px;
    font-family: inherit; font-size: 10px; font-weight: 600; letter-spacing: 0.2px;
    color: #94a3b8; transition: color 0.15s; min-width: 0;
  }
  .bnav-btn svg { width: 24px; height: 24px; stroke-width: 2; transition: transform 0.15s; }
  .bnav-btn span { line-height: 1; }
  .bnav-btn.active { color: #00ADEE; }
  .bnav-btn.active svg { transform: translateY(-1px); }
  .bnav-btn:active svg { transform: scale(0.88); }

  /* ── "More" bottom sheet ── */
  .more-sheet-overlay {
    display: none; position: fixed; inset: 0; z-index: 950;
    background: rgba(15,20,32,0.45); opacity: 0; transition: opacity 0.22s ease;
  }
  .more-sheet-overlay.show { display: block; }
  .more-sheet-overlay.open { opacity: 1; }
  .more-sheet {
    position: absolute; left: 0; right: 0; bottom: 0;
    background: #fff; border-radius: 20px 20px 0 0;
    padding: 8px 16px calc(20px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -8px 40px rgba(0,0,0,0.25);
    transform: translateY(100%); transition: transform 0.26s cubic-bezier(0.22,1,0.36,1);
    max-height: 80vh; overflow-y: auto;
  }
  .more-sheet-overlay.open .more-sheet { transform: translateY(0); }
  .more-sheet-grip {
    width: 40px; height: 4px; border-radius: 2px; background: #cbd5e1;
    margin: 6px auto 12px;
  }
  .more-sheet-acct {
    font-size: 12px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase;
    color: #94a3b8; padding: 2px 6px 12px;
  }
  .more-item {
    width: 100%; display: flex; align-items: center; gap: 14px;
    padding: 14px 8px; border: none; background: none; cursor: pointer;
    font-family: inherit; font-size: 16px; font-weight: 600; color: #1e293b;
    text-align: left; border-radius: 10px; transition: background 0.12s;
  }
  .more-item:active { background: #f1f5f9; }
  .more-item svg { width: 22px; height: 22px; flex-shrink: 0; color: #64748b; }
  .more-item.active { color: #00ADEE; }
  .more-item.active svg { color: #00ADEE; }
  .more-item-danger { color: #e11d48; }
  .more-item-danger svg { color: #e11d48; }
  .more-sheet-divider { height: 1px; background: #f1f5f9; margin: 8px 0; }

  /* dark mode — bottom nav + sheet */
  body.dark .bottom-nav { background: rgba(20,20,34,0.92); border-top-color: var(--border); }
  body.dark .bnav-btn { color: var(--muted); }
  body.dark .bnav-btn.active { color: #00ADEE; }
  body.dark .more-sheet { background: var(--surface); }
  body.dark .more-item { color: var(--text); }
  body.dark .more-item svg { color: var(--muted); }
  body.dark .more-item:active { background: var(--surface2); }
  body.dark .more-sheet-divider { background: var(--border); }
  body.dark .more-sheet-grip { background: #3a3d55; }
  body.dark .more-item-danger, body.dark .more-item-danger svg { color: #fb7185; }

  /* ══════════════════  ≤ 640px : phone layout  ══════════════════ */
  @media (max-width: 640px) {
    .bottom-nav { display: flex; }

    /* Move nav to the bottom bar → hide the top tab strip */
    .header .tabs { display: none; }
    .header-inner { padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 14px; }
    .header-title { font-size: 17px; }
    .header-sub { font-size: 10px; }
    .header-logo { width: 36px; height: 36px; }
    #logout-btn { display: none !important; }        /* lives in the More sheet */
    #acct-name  { display: none !important; }

    /* Content clears the fixed bottom nav */
    .main { padding: 18px 16px calc(var(--bnav-h) + env(safe-area-inset-bottom, 0px) + 28px); }

    /* Stop iOS from zooming on focus: inputs must be ≥16px */
    input[type=text], input[type=number], input[type=date], input[type=time],
    input[type=email], input[type=password], select, textarea {
      font-size: 16px;
    }

    /* Cards / timer breathe less on small screens */
    .card { padding: 20px 16px; }
    .timer-card { padding: 20px 18px; }
    .timer-display { font-size: 44px; letter-spacing: 1px; }
    .timer-btns { gap: 8px; }
    .timer-btns .btn { flex: 1 1 auto; min-height: 46px; }
    #timer-start-row { flex-wrap: wrap; }

    /* Comfortable touch targets */
    .btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
    .btn-sm { min-height: 34px; }
    .choice-btn { min-height: 50px; }
    .view-toggle-btn, .period-nav-btn, .settings-pill { min-height: 40px; }

    /* Entity / function choice grids: 2-up so labels stay legible */
    .choice-group { gap: 8px; }
    .choice-btn { min-width: calc(50% - 4px); flex: 1 1 calc(50% - 4px); }

    /* Leave form: stack fields full-width so the native date pickers, which
       won't shrink below their intrinsic width, stop overlapping. */
    .leave-fields { flex-direction: column; gap: 14px; }
    .leave-fields > .field-group { width: 100% !important; min-width: 0 !important; flex: 1 1 100% !important; }

    /* iOS renders date/time inputs as native controls with an intrinsic width
       that ignores width:100% and overflows the card. Normalize them so they
       size like a normal full-width field (still tap to open the picker). */
    input[type=date], input[type=time] {
      -webkit-appearance: none;
      appearance: none;
      min-width: 0;
      max-width: 100%;
    }
    input[type=date]::-webkit-date-and-time-value,
    input[type=time]::-webkit-date-and-time-value { text-align: left; margin: 0; }

    /* Period bar → stacked groups */
    .period-inner { padding: 10px 16px; gap: 8px; }
    .view-toggle { width: 100%; }
    .view-toggle-btn { flex: 1; padding: 8px 6px; }
    .period-label { min-width: 0; flex: 1; font-size: 12px; }
    .entity-filter { width: 100% !important; margin-left: 0 !important; font-size: 14px !important; min-height: 42px; }
    #period-current { margin-left: auto; }

    /* Report summary cards: 2-up */
    .report-cards { grid-template-columns: 1fr 1fr; gap: 10px; }
    .report-card { padding: 16px 14px; }
    .report-card-val { font-size: 26px; }
    .bar-section { padding: 18px 16px; }
    .summary-strip { gap: 16px 24px; padding: 14px 16px; }

    /* History entries: keep duration beside text but allow wrap */
    .entry-card { padding: 13px 15px; }
    .entry-row { gap: 10px; }

    /* Allocation table: each line becomes a small card
       (entity | function | ✕) / (program) / (share · time) */
    .alloc-head { display: none; }
    .alloc-row {
      grid-template-columns: 1fr 1fr 28px;
      grid-template-areas: "ent fn del" "prog prog prog" "share time time";
      padding: 12px; row-gap: 8px;
    }
    .alloc-row > .alloc-entity { grid-area: ent; }
    .alloc-row > .alloc-fn { grid-area: fn; }
    .alloc-row > .alloc-prog, .alloc-row > .alloc-dash { grid-area: prog; white-space: normal; }
    .alloc-row > .alloc-share { grid-area: share; justify-content: flex-start; }
    .alloc-row > .alloc-time { grid-area: time; text-align: left; align-self: center; }
    .alloc-row > .alloc-del { grid-area: del; justify-self: end; }
    .alloc-table select, .alloc-table input[type=number], .alloc-table input[type=text] { font-size: 16px; min-height: 40px; }
    .alloc-sub { padding-left: 14px; }
    .alloc-sub-pct, .alloc-sub-hint { margin-left: 0; }
    .alloc-table .alloc-candidate { min-width: 100%; max-width: none; }
    .alloc-foot { flex-direction: column; align-items: stretch; }
    .alloc-foot-total { justify-content: space-between; }

    /* Settings program editor stacks */
    .settings-prog-row { flex-direction: column; }

    /* Toast sits above the nav bar */
    .toast {
      bottom: calc(var(--bnav-h) + env(safe-area-inset-bottom, 0px) + 16px);
      max-width: calc(100vw - 32px); white-space: normal; text-align: center;
    }
  }

  @media (max-width: 380px) {
    .edit-grid-3 { grid-template-columns: 1fr; }
    .timer-display { font-size: 38px; }
    .bnav-btn span { font-size: 9px; }
  }

  /* ══════════════════  History: List / Calendar view  ══════════════════ */

  /* Segmented toggle (distinct from the period bar's .view-toggle so it
     doesn't get swept up by that control's click handler). */
  .hv-toggle {
    display: inline-flex; gap: 0; margin-bottom: 16px;
    border: 1.5px solid #00ADEE; border-radius: 10px; overflow: hidden;
  }
  .hv-btn {
    font-family: 'Inter', sans-serif; font-size: 13px; font-weight: 700;
    padding: 8px 18px; border: none; background: #fff; color: #00ADEE;
    cursor: pointer; transition: background 0.15s, color 0.15s;
  }
  .hv-btn.active { background: #00ADEE; color: #fff; }

  .cal-wrap { margin-top: 4px; }
  .cal-weekdays, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
  .cal-weekdays { margin-bottom: 6px; }
  .cal-weekday {
    font-size: 11px; font-weight: 700; color: #94a3b8; text-align: center;
    text-transform: uppercase; letter-spacing: 0.5px;
  }
  .cal-cell {
    min-height: 88px; border: 1px solid #e5e7eb; border-radius: 10px;
    padding: 7px 8px; background: #fff; cursor: pointer; text-align: left;
    display: flex; flex-direction: column; gap: 4px;
    transition: border-color 0.12s, background 0.12s, box-shadow 0.12s;
  }
  .cal-cell:hover { border-color: #00ADEE; }
  .cal-cell.out { background: transparent; border-color: transparent; cursor: default; }
  .cal-cell.out:hover { border-color: transparent; }
  .cal-cell.locked { background: #f8fafc; cursor: default; }
  .cal-cell.today .cal-daynum-n {
    background: #00ADEE; color: #fff; border-radius: 50%;
    width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center;
  }
  .cal-cell.selected { border-color: #00ADEE; box-shadow: inset 0 0 0 2px #00ADEE; background: #f0faff; }
  .cal-daynum {
    display: flex; align-items: center; justify-content: space-between;
    font-size: 12px; font-weight: 700; color: #29284B; min-height: 22px;
  }
  .cal-cell.out .cal-daynum { color: #cbd5e1; font-weight: 500; }
  .cal-lock { font-size: 11px; line-height: 1; opacity: 0.6; }
  .cal-total { font-size: 12px; font-weight: 700; color: #00ADEE; margin-top: auto; }
  .cal-dots { display: flex; gap: 3px; flex-wrap: wrap; }
  .cal-dot { width: 7px; height: 7px; border-radius: 50%; }

  .cal-day-detail { margin-top: 20px; }
  .cal-day-head {
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
    gap: 10px; margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid #e5e7eb;
  }
  .cal-day-title { font-family: 'Inter', sans-serif; font-size: 15px; font-weight: 700; color: #29284B; }
  .cal-day-title .cal-day-sum { color: #00ADEE; margin-left: 8px; }
  .cal-day-lock { font-size: 12px; font-weight: 600; color: #94a3b8; }
  .cal-day-empty { color: #94a3b8; font-size: 14px; padding: 8px 0; }

  /* Dark theme */
  body.dark .hv-btn { background: var(--surface); color: #00ADEE; }
  body.dark .hv-btn.active { background: #00ADEE; color: #fff; }
  body.dark .hv-toggle { border-color: #00ADEE; }
  body.dark .cal-cell { background: var(--surface); border-color: var(--border); }
  body.dark .cal-cell:hover { border-color: #00ADEE; }
  body.dark .cal-cell.out { background: transparent; border-color: transparent; }
  body.dark .cal-cell.locked { background: var(--surface2); }
  body.dark .cal-cell.selected { background: #0d2735; }
  body.dark .cal-daynum { color: var(--text); }
  body.dark .cal-cell.out .cal-daynum { color: #4b5069; }
  body.dark .cal-day-title { color: var(--text); }
  body.dark .cal-day-head { border-color: var(--border); }

  @media (max-width: 640px) {
    .cal-weekdays, .cal-grid { gap: 4px; }
    .cal-cell { min-height: 62px; padding: 5px; border-radius: 8px; }
    .cal-weekday { font-size: 10px; }
    .cal-daynum { font-size: 11px; min-height: 18px; }
    .cal-cell.today .cal-daynum-n { width: 18px; height: 18px; font-size: 10px; }
    .cal-total { display: none; }              /* rely on dots + tap-to-open on phones */
    .cal-dot { width: 6px; height: 6px; }
  }

  /* ══════════════════  Add-entry tray (calendar backfill)  ══════════════════ */
  /* Centered popup on desktop; bottom sheet on phones. Hosts the reparented Log
     entry form, so the form itself keeps all its own styling — see the .card
     neutralizer below so it sits flush instead of a card-inside-a-card. */
  .entry-ov {
    display: none; position: fixed; inset: 0; z-index: 9990;
    background: rgba(15,20,32,0.55); opacity: 0; transition: opacity 0.22s ease;
    align-items: center; justify-content: center; padding: 20px;
  }
  .entry-ov.show { display: flex; }
  .entry-ov.open { opacity: 1; }
  .entry-dialog {
    display: flex; flex-direction: column; width: min(560px, 96vw); max-height: 88vh;
    background: #fff; border: 1px solid #e5e7eb; border-radius: 16px; overflow: hidden;
    box-shadow: 0 24px 70px rgba(0,0,0,0.4);
    transform: translateY(12px) scale(0.98); opacity: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
  }
  .entry-ov.open .entry-dialog { transform: none; opacity: 1; }
  .entry-head {
    flex-shrink: 0; display: flex; align-items: center; justify-content: space-between;
    gap: 12px; padding: 15px 18px; border-bottom: 1px solid #e5e7eb;
  }
  .entry-title { font-family: 'Inter', sans-serif; font-size: 16px; font-weight: 800; color: #29284B; }
  .entry-close {
    flex-shrink: 0; border: none; background: #f1f5f9; color: #64748b;
    width: 32px; height: 32px; border-radius: 8px; font-size: 14px; cursor: pointer;
    display: flex; align-items: center; justify-content: center; transition: background 0.12s;
  }
  .entry-close:hover { background: #e2e8f0; }
  .entry-body { flex: 1; overflow-y: auto; padding: 18px; }
  /* Reparented form card sits flush inside the dialog (no nested card chrome). */
  .entry-body > .card { border: none; box-shadow: none; padding: 0; margin: 0; background: transparent; }

  body.dark .entry-dialog { background: var(--surface); border-color: var(--border); color: var(--text); }
  body.dark .entry-head { border-color: var(--border); }
  body.dark .entry-title { color: var(--text); }
  body.dark .entry-close { background: var(--surface2); color: var(--muted); }
  body.dark .entry-close:hover { background: var(--border); }

  @media (max-width: 640px) {
    .entry-ov { align-items: flex-end; justify-content: stretch; padding: 0; }
    .entry-dialog {
      width: 100%; max-width: 100%; max-height: 92vh; border-radius: 20px 20px 0 0;
      transform: translateY(100%); opacity: 1;
      transition: transform 0.26s cubic-bezier(0.22,1,0.36,1);
    }
    .entry-ov.open .entry-dialog { transform: translateY(0); }
    .entry-body { padding: 16px 16px calc(18px + env(safe-area-inset-bottom, 0px)); }
  }
