:root {
    /* GHL-native palette */
    --bg-page: #F9FAFB;
    --bg-card: #FFFFFF;
    --border: #E5E7EB;
    --border-light: #F3F4F6;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.08);

    --text: #111827;
    --text-muted: #6B7280;
    --text-subtle: #9CA3AF;

    --primary: #2563EB;
    --primary-hover: #1D4ED8;
    --primary-soft: #EFF6FF;
    --primary-border: #BFDBFE;

    /* Pipeline pastels (from GHL screenshots) */
    --pipe-blue: #DBEAFE;   --pipe-blue-text: #1E40AF;
    --pipe-pink: #FCE7F3;   --pipe-pink-text: #9D174D;
    --pipe-yellow: #FEF3C7; --pipe-yellow-text: #92400E;
    --pipe-peach: #FFEDD5;  --pipe-peach-text: #9A3412;
    --pipe-green: #D1FAE5;  --pipe-green-text: #065F46;
    --pipe-purple: #EDE9FE; --pipe-purple-text: #5B21B6;

    /* Status lifecycle */
    --st-draft: #6B7280;       --st-draft-soft: #F3F4F6;       --st-draft-border: #D1D5DB;
    --st-option: #D97706;      --st-option-soft: #FEF3C7;      --st-option-border: #FCD34D;
    --st-confirmed: #2563EB;   --st-confirmed-soft: #DBEAFE;   --st-confirmed-border: #93C5FD;
    --st-progress: #059669;    --st-progress-soft: #D1FAE5;    --st-progress-border: #6EE7B7;
    --st-done: #7C3AED;        --st-done-soft: #EDE9FE;        --st-done-border: #C4B5FD;
    --st-invoiced: #334155;    --st-invoiced-soft: #E2E8F0;    --st-invoiced-border: #94A3B8;

    --danger: #DC2626;
    --danger-soft: #FEE2E2;
    --danger-border: #FCA5A5;

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
  }

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

  html, body {
    background: var(--bg-page);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
  }

  body { padding: 20px; }

  /* Mockup frame */
  .screens { max-width: 1440px; margin: 0 auto; }

  .intro {
    margin-bottom: 20px;
    padding: 20px 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
  }
  .intro h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
  .intro .sub { color: var(--text-muted); font-size: 14px; }
  .intro p { margin-top: 10px; font-size: 14px; color: var(--text); }
  .intro code {
    background: var(--border-light);
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
  }

  .tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 6px 6px 0;
  }
  .tab {
    flex: 1;
    padding: 12px 16px;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    color: var(--text-muted);
    text-align: center;
    transition: all 0.15s;
    border-radius: var(--radius) var(--radius) 0 0;
  }
  .tab:hover { background: var(--border-light); color: var(--text); }
  .tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
  }

  .stage {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    min-height: 820px;
    overflow: hidden;
  }
  .mockup { display: none; }
  .mockup.active { display: block; }

  /* ── Mock app shell (module content only — lives inside GHL's iframe) ── */
  .app {
    background: var(--bg-card);
    min-height: 820px;
    display: flex;
    flex-direction: column;
  }

  .app-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
    gap: 16px;
    flex-wrap: wrap;
  }
  .topbar-left, .topbar-center, .topbar-right { display: flex; align-items: center; gap: 10px; }

  .page-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
  }
  .page-sub {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
  }

  .count-pill {
    display: inline-flex;
    align-items: center;
    background: var(--border-light);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 99px;
    margin-left: 8px;
  }

  .seg {
    display: inline-flex;
    background: var(--border-light);
    padding: 3px;
    gap: 2px;
    border-radius: var(--radius);
  }
  .seg button {
    padding: 7px 14px;
    background: transparent;
    border: none;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    transition: all 0.15s;
  }
  .seg button:hover { color: var(--text); }
  .seg button.active {
    background: var(--bg-card);
    color: var(--text);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
  }

  .btn {
    padding: 8px 14px;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    background: var(--bg-card);
    border: 1px solid var(--border);
    cursor: pointer;
    color: var(--text);
    border-radius: var(--radius);
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }
  .btn:hover { background: var(--border-light); border-color: #D1D5DB; }
  .btn.primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
  }
  .btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
  .btn.icon-btn {
    padding: 8px;
    width: 36px;
    height: 36px;
    justify-content: center;
  }

  .user-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px 4px 4px;
    background: var(--primary-soft);
    border: 1px solid var(--primary-border);
    border-radius: 99px;
    font-size: 13px;
    color: var(--primary);
    font-weight: 600;
  }
  .user-chip .av {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
  }

  .help-btn {
    padding: 8px 12px;
    background: var(--primary-soft);
    border: 1px solid var(--primary-border);
    color: var(--primary);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius);
    transition: all 0.15s;
  }
  .help-btn:hover { background: #DBEAFE; }

  /* ── DASHBOARD ── */
  .dash {
    padding: 24px;
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 20px;
    align-items: start;
  }

  .panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
  }
  .panel-head {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
  }
  .panel-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
  }
  .panel-explain {
    padding: 12px 20px;
    background: var(--primary-soft);
    border-bottom: 1px solid var(--primary-border);
    font-size: 12px;
    color: var(--primary);
  }

  /* Inbox cards from GHL */
  .inbox-card {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-light);
    cursor: grab;
    position: relative;
    background: var(--bg-card);
    transition: background 0.15s;
  }
  .inbox-card:hover { background: var(--primary-soft); }
  .inbox-card:last-child { border-bottom: none; }
  .inbox-card-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
  }
  .inbox-client {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
  }
  .inbox-trigger {
    font-size: 11px;
    color: var(--primary);
    white-space: nowrap;
    font-weight: 500;
  }
  .inbox-meta {
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-muted);
  }
  .inbox-badges {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    flex-wrap: wrap;
    align-items: center;
  }
  .ghl-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: var(--primary-soft);
    border: 1px solid var(--primary-border);
    color: var(--primary);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    border-radius: var(--radius-sm);
  }
  .type-badge {
    padding: 2px 8px;
    background: var(--border-light);
    border: 1px solid var(--border);
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
  }

  /* Dashboard right column */
  .dash-right { display: flex; flex-direction: column; gap: 20px; }

  .sched-row {
    display: grid;
    grid-template-columns: 80px 1fr auto;
    gap: 14px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-light);
    align-items: center;
  }
  .sched-row:last-child { border-bottom: none; }
  .sched-row.clickable { cursor: pointer; transition: background 0.15s; }
  .sched-row.clickable:hover { background: var(--primary-soft); }
  .sched-time {
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
  }
  .sched-main { display: flex; flex-direction: column; gap: 2px; }
  .sched-client { font-size: 14px; font-weight: 600; color: var(--text); }
  .sched-addr { font-size: 12px; color: var(--text-muted); }
  .sched-right { display: flex; align-items: center; gap: 10px; }

  .avatars { display: flex; }
  .avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    border: 2px solid var(--bg-card);
    margin-left: -6px;
  }
  .avatar:first-child { margin-left: 0; }
  .avatar.alt-1 { background: #0F766E; }
  .avatar.alt-2 { background: #D97706; }
  .avatar.alt-3 { background: #7C3AED; }

  .status-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid;
    border-radius: 99px;
    white-space: nowrap;
  }
  .status-pill::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
  }
  .status-pill.draft     { color: var(--st-draft);     background: var(--st-draft-soft);     border-color: var(--st-draft-border); }
  .status-pill.option    { color: var(--st-option);    background: var(--st-option-soft);    border-color: var(--st-option-border); }
  .status-pill.confirmed { color: var(--st-confirmed); background: var(--st-confirmed-soft); border-color: var(--st-confirmed-border); }
  .status-pill.progress  { color: var(--st-progress);  background: var(--st-progress-soft);  border-color: var(--st-progress-border); }
  .status-pill.done      { color: var(--st-done);      background: var(--st-done-soft);      border-color: var(--st-done-border); }
  .status-pill.invoiced  { color: var(--st-invoiced);  background: var(--st-invoiced-soft);  border-color: var(--st-invoiced-border); }

  .attention-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 14px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-light);
    align-items: center;
    background: var(--st-option-soft);
  }
  .attention-row:last-child { border-bottom: none; }
  .attention-row.clickable { cursor: pointer; transition: background 0.15s; }
  .attention-row.clickable:hover { background: var(--st-option-border); }
  .attention-main { display: flex; flex-direction: column; gap: 2px; }
  .attention-client { font-size: 14px; font-weight: 600; color: var(--text); }
  .attention-reason { font-size: 12px; color: var(--st-option); }

  /* Undo toast strip */
  .undo-strip {
    margin: 20px 24px;
    padding: 12px 20px;
    background: var(--text);
    color: #fff;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    box-shadow: var(--shadow-lg);
  }
  .undo-strip .msg { font-size: 13px; }
  .undo-strip .msg strong { color: #93C5FD; }
  .undo-strip .actions { display: flex; gap: 14px; align-items: center; }
  .undo-strip .undo {
    background: #fff;
    color: var(--text);
    padding: 6px 14px;
    border: none;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border-radius: var(--radius);
  }
  .undo-strip .timer { font-size: 12px; opacity: 0.75; }

  /* ── PLANNER (4-WEEK) ── */
  .planner-body {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 700px;
  }

  .inbox-rail {
    border-right: 1px solid var(--border);
    background: var(--bg-page);
    overflow-y: auto;
  }
  .inbox-rail-head {
    padding: 12px 16px;
    background: var(--primary-soft);
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .inbox-mini {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    cursor: grab;
    background: var(--bg-card);
    margin: 8px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
  }
  .inbox-mini:hover { box-shadow: var(--shadow-md); }
  .inbox-mini-client { font-size: 13px; font-weight: 600; color: var(--text); }
  .inbox-mini-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    display: flex;
    gap: 6px;
    align-items: center;
  }

  .calendar-area { display: flex; flex-direction: column; }

  /* Filter bar */
  .filter-bar {
    padding: 12px 20px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
  }
  .filter-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    margin-right: 4px;
  }
  .filter-chip {
    padding: 5px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text);
    border-radius: 99px;
  }
  .filter-chip:hover { background: var(--border-light); }
  .filter-chip.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    font-weight: 600;
  }
  .filter-search {
    padding: 6px 12px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    font-family: var(--font);
    font-size: 12px;
    min-width: 220px;
    border-radius: var(--radius);
  }
  .filter-search:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
  }

  /* Grid */
  .cal-grid { overflow-x: auto; background: var(--bg-card); }

  .cal-weekhdr, .cal-dayhdr, .cal-row {
    display: grid;
    grid-template-columns: 140px repeat(28, minmax(85px, 1fr));
  }

  .cal-weekhdr {
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-page);
  }
  .weekhdr-label {
    padding: 8px 12px;
    border-right: 1px solid var(--border);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
  }
  .weekhdr-cell {
    padding: 8px 4px;
    text-align: center;
    border-right: 1px solid var(--border);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
  }
  .weekhdr-cell.wk-start { color: var(--primary); }

  .cal-dayhdr { border-bottom: 1px solid var(--border); }
  .dayhdr-label {
    padding: 10px 14px;
    border-right: 1px solid var(--border);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
  }
  .dayhdr-cell {
    padding: 6px 2px;
    text-align: center;
    border-right: 1px solid var(--border-light);
    font-size: 11px;
    background: var(--bg-card);
  }
  .dayhdr-cell.weekend { background: var(--bg-page); }
  .dayhdr-cell.today .dayhdr-num-circle {
    background: var(--primary);
    color: #fff;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 11px;
  }
  .dayhdr-dow { font-size: 10px; color: var(--text-muted); text-transform: uppercase; font-weight: 600; letter-spacing: 0.3px; }
  .dayhdr-num { font-size: 12px; font-weight: 600; margin-top: 2px; display: inline-block; }
  .dayhdr-cell.today .dayhdr-dow { color: var(--primary); }

  .cal-row {
    border-bottom: 1px solid var(--border-light);
    min-height: 92px;
  }
  .cal-rowlabel {
    padding: 12px 14px;
    border-right: 1px solid var(--border);
    background: var(--bg-page);
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  .rowlabel-name { font-size: 13px; font-weight: 600; color: var(--text); }
  .rowlabel-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

  .cal-cell {
    border-right: 1px solid var(--border-light);
    padding: 6px 4px;
    min-height: 92px;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  .cal-cell.weekend { background: var(--bg-page); }
  .cal-cell.today { background: var(--primary-soft); }

  /* Job bubble */
  .bubble {
    padding: 8px 10px;
    font-size: 11px;
    border-left: 3px solid;
    background: var(--bg-card);
    border-top: 1px solid var(--border-light);
    border-right: 1px solid var(--border-light);
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    overflow: hidden;
    line-height: 1.4;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
  }
  .bubble:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
  .bubble.bl-draft     { border-left-color: var(--st-draft);     background: var(--st-draft-soft); }
  .bubble.bl-option    { border-left-color: var(--st-option);    background: var(--st-option-soft); }
  .bubble.bl-confirmed { border-left-color: var(--st-confirmed); background: var(--st-confirmed-soft); }
  .bubble.bl-progress  { border-left-color: var(--st-progress);  background: var(--st-progress-soft); }
  .bubble.bl-done      { border-left-color: var(--st-done);      background: var(--st-done-soft); }
  .bubble.bl-invoiced  { border-left-color: var(--st-invoiced);  background: var(--st-invoiced-soft); }
  .bubble.conflict     { box-shadow: 0 0 0 2px var(--danger-border); }
  .bubble-client { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
  .bubble-type { font-size: 11px; font-weight: 400; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
  .bubble-time { font-size: 11px; font-weight: 400; color: var(--text-subtle); margin-top: 2px; }
  .bubble-ghl {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
    margin-right: 4px;
    vertical-align: middle;
  }
  .bubble-cont {
    color: var(--text-muted);
    font-weight: 500;
    margin-right: 2px;
  }
  .bubble-multi {
    border-style: dashed;
    border-top-style: solid;
    border-bottom-style: solid;
  }
  .bubble-multi.bubble-multi-start {
    border-right-style: dashed;
    border-left-style: solid;
  }
  .bubble-multi.bubble-multi-end {
    border-left-style: dashed;
    border-right-style: solid;
  }
  .bubble-multi.bubble-multi-mid {
    border-left-style: dashed;
    border-right-style: dashed;
  }

  .bubble-bar {
    font-size: 11px;
    padding: 6px 10px;
    border-left: 3px solid var(--st-confirmed);
    background: var(--st-confirmed-soft);
    color: var(--st-confirmed);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-radius: var(--radius-sm);
  }

  /* ── LIST VIEW ── */
  .list-body { padding: 0; background: var(--bg-page); }

  .list-toolbar {
    padding: 14px 24px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    align-items: center;
  }
  .list-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
  .list-search {
    padding: 8px 12px 8px 34px;
    border: 1px solid var(--border);
    background: var(--bg-card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E") no-repeat 10px center;
    font-family: var(--font);
    font-size: 13px;
    min-width: 260px;
    border-radius: var(--radius);
  }

  .phase-group {
    margin: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
  }
  .phase-head {
    padding: 14px 20px;
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
  }
  .phase-head .phase-label-group { display: flex; align-items: center; gap: 10px; }
  .phase-head .phase-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
  }
  .phase-head .phase-count {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
  }
  .phase-head .collapse {
    font-size: 14px;
    color: var(--text-muted);
  }

  .phase-head.draft     { background: var(--st-draft-soft); color: var(--st-draft); }
  .phase-head.draft .phase-dot { background: var(--st-draft); }
  .phase-head.option    { background: var(--st-option-soft); color: var(--st-option); }
  .phase-head.option .phase-dot { background: var(--st-option); }
  .phase-head.confirmed { background: var(--st-confirmed-soft); color: var(--st-confirmed); }
  .phase-head.confirmed .phase-dot { background: var(--st-confirmed); }
  .phase-head.progress  { background: var(--st-progress-soft); color: var(--st-progress); }
  .phase-head.progress .phase-dot { background: var(--st-progress); }
  .phase-head.done      { background: var(--st-done-soft); color: var(--st-done); }
  .phase-head.done .phase-dot { background: var(--st-done); }
  .phase-head.invoiced  { background: var(--st-invoiced-soft); color: var(--st-invoiced); }
  .phase-head.invoiced .phase-dot { background: var(--st-invoiced); }

  .list-row {
    display: grid;
    grid-template-columns: 100px 200px 2fr 1.3fr 130px 130px 100px 130px;
    gap: 14px;
    padding: 12px 20px;
    border-top: 1px solid var(--border-light);
    align-items: center;
    cursor: pointer;
    font-size: 13px;
  }
  .list-row:hover { background: var(--primary-soft); }

  .list-date { font-weight: 600; font-size: 12px; color: var(--text); }
  .list-date .dow { color: var(--text-muted); font-weight: 500; margin-right: 3px; }
  .list-client-cell { display: flex; flex-direction: column; gap: 2px; }
  .list-client {
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text);
  }
  .list-source { font-size: 11px; color: var(--primary); }
  .list-addr { font-size: 12px; color: var(--text-muted); }
  .list-type { font-size: 12px; }
  .list-resource { font-size: 12px; color: var(--text-muted); }

  /* ── DRAWER ── */
  .drawer-stage {
    position: relative;
    min-height: 700px;
    overflow: hidden;
    background: var(--bg-page);
  }
  .drawer-bg {
    filter: blur(2px) brightness(0.98);
    opacity: 0.7;
    pointer-events: none;
    padding: 24px;
  }
  .drawer-bg-placeholder {
    height: 600px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-subtle);
    font-size: 13px;
    font-style: italic;
  }
  .drawer {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 440px;
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
  }
  .drawer-head {
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border-light);
  }
  .drawer-head-top {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 8px;
  }
  .drawer-close {
    padding: 4px 8px;
    background: transparent;
    border: 1px solid var(--border);
    font-family: var(--font);
    cursor: pointer;
    font-size: 16px;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .drawer-close:hover { background: var(--border-light); }
  .drawer-client {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .drawer-client a {
    color: var(--primary);
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    padding: 2px 8px;
    background: var(--primary-soft);
    border-radius: 99px;
    border: 1px solid var(--primary-border);
  }
  .drawer-subline {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
  }

  .drawer-section {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-light);
  }
  .drawer-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    margin-bottom: 12px;
  }

  .lifecycle {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
  }
  .lifecycle-step {
    flex: 1;
    min-width: 78px;
    padding: 8px 6px;
    font-size: 10px;
    text-align: center;
    border: 1px solid var(--border);
    background: var(--bg-card);
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    font-weight: 600;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    transition: all 0.15s;
  }
  .lifecycle-step:hover { background: var(--border-light); }
  .lifecycle-step.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
  }
  .lifecycle-step.past {
    background: var(--primary-soft);
    color: var(--primary);
    border-color: var(--primary-border);
  }
  .lifecycle-hint {
    margin-top: 10px;
    font-size: 11px;
    color: var(--text-muted);
  }

  .info-row {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 12px;
    font-size: 13px;
    padding: 5px 0;
    color: var(--text);
  }
  .info-label { color: var(--text-muted); font-size: 12px; }

  .timeline { list-style: none; }
  .timeline-event {
    padding: 10px 0 10px 22px;
    border-left: 2px solid var(--border);
    margin-left: 5px;
    position: relative;
    font-size: 13px;
  }
  .timeline-event::before {
    content: '';
    position: absolute;
    left: -5px;
    top: 14px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 2px solid var(--bg-card);
  }
  .timeline-event.ghl::before { background: var(--primary); }
  .timeline-event.local::before { background: var(--st-progress); }
  .timeline-when { color: var(--text-muted); font-size: 11px; }
  .timeline-what { margin-top: 2px; color: var(--text); }

  /* ── CRM FLOW ── */
  .crm-body { padding: 24px; background: var(--bg-page); }
  .crm-intro {
    padding: 16px 20px;
    background: var(--primary-soft);
    border: 1px solid var(--primary-border);
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    font-size: 13px;
    color: var(--text);
  }
  .crm-intro strong { color: var(--primary); }

  .crm-flow {
    display: grid;
    grid-template-columns: 1fr 40px 1fr 40px 1fr;
    gap: 0;
    align-items: stretch;
    margin-bottom: 28px;
  }
  .flow-col {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
  }
  .flow-col-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--primary);
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-light);
  }
  .flow-item {
    padding: 10px 12px;
    background: var(--border-light);
    margin-bottom: 6px;
    font-size: 12px;
    color: var(--text);
    border-radius: var(--radius);
  }
  .flow-item:last-child { margin-bottom: 0; }
  .flow-item strong { font-weight: 600; color: var(--text); }
  .flow-item.accent {
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 600;
    border: 1px solid var(--primary-border);
  }
  .flow-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 24px;
    font-weight: 700;
  }

  .crm-rules-title {
    font-size: 15px;
    font-weight: 600;
    margin: 24px 0 12px;
    color: var(--text);
  }
  .rule-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 14px 18px;
    margin-bottom: 8px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 14px;
    align-items: center;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
  }
  .rule-desc { font-size: 13px; color: var(--text); line-height: 1.55; }
  .rule-desc strong { font-weight: 600; color: var(--primary); }
  .rule-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--st-progress);
    background: var(--st-progress-soft);
    padding: 4px 10px;
    border-radius: 99px;
    border: 1px solid var(--st-progress-border);
  }
  .rule-status::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--st-progress);
  }

  /* GHL pipeline-style cards for the CRM screen */
  .pipeline-preview {
    margin-top: 28px;
    padding: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
  }
  .pipeline-preview-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text);
  }
  .pipeline-preview-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 16px;
  }
  .pipeline-cols {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
  }
  .pipeline-col-header {
    padding: 12px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
  }
  .pipeline-col-header .mini {
    font-size: 11px;
    font-weight: 500;
    opacity: 0.8;
    margin-top: 2px;
  }
  .pipeline-col-header.c-blue   { background: var(--pipe-blue);   color: var(--pipe-blue-text); }
  .pipeline-col-header.c-pink   { background: var(--pipe-pink);   color: var(--pipe-pink-text); }
  .pipeline-col-header.c-yellow { background: var(--pipe-yellow); color: var(--pipe-yellow-text); }
  .pipeline-col-header.c-peach  { background: var(--pipe-peach);  color: var(--pipe-peach-text); }

  /* Legend */
  .lifecycle-legend {
    margin-top: 24px;
    padding: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
  }
  .legend-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 14px;
    color: var(--text);
  }
  .legend-flow {
    display: flex;
    gap: 0;
    align-items: stretch;
    border-radius: var(--radius);
    overflow: hidden;
  }
  .legend-step {
    flex: 1;
    padding: 14px 10px;
    text-align: center;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    position: relative;
  }
  .legend-step::after {
    content: '';
    position: absolute;
    right: -10px;
    top: 50%;
    transform: translateY(-50%);
    border-left: 10px solid;
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
    z-index: 2;
  }
  .legend-step:last-child::after { display: none; }
  .legend-step.draft     { background: var(--st-draft); }     .legend-step.draft::after     { border-left-color: var(--st-draft); }
  .legend-step.option    { background: var(--st-option); }    .legend-step.option::after    { border-left-color: var(--st-option); }
  .legend-step.confirmed { background: var(--st-confirmed); } .legend-step.confirmed::after { border-left-color: var(--st-confirmed); }
  .legend-step.progress  { background: var(--st-progress); }  .legend-step.progress::after  { border-left-color: var(--st-progress); }
  .legend-step.done      { background: var(--st-done); }      .legend-step.done::after      { border-left-color: var(--st-done); }
  .legend-step.invoiced  { background: var(--st-invoiced); }
  .legend-small {
    margin-top: 10px;
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.6;
  }

  .mock-footer {
    padding: 12px 24px;
    border-top: 1px solid var(--border);
    background: var(--bg-card);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-muted);
  }
  .mock-footer strong { color: var(--text); }

  /* Subtle GHL-style indicator dot */
  .live-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10B981;
    box-shadow: 0 0 0 3px rgba(16,185,129,0.15);
    margin-right: 6px;
  }

  /* Planner — drag/drop interaction states + collapsed rail */
  .bubble.dragging,
  .inbox-mini.dragging { opacity: 0.5; cursor: grabbing; }
  .bubble { cursor: grab; }
  .bubble:active { cursor: grabbing; }
  .cal-cell.drop-target,
  .inbox-rail.drop-target { background: var(--primary-soft); outline: 2px dashed var(--primary); outline-offset: -2px; }

  .inbox-rail { transition: all 0.15s ease; }
  /* When collapsed, drop the rail track entirely so calendar-area gets the
     remaining space. With `0 1fr` the calendar-area auto-placed in the
     0-px-wide first track and the grid appeared to vanish. */
  .planner-body.rail-collapsed { grid-template-columns: 1fr; }
  .planner-body.rail-collapsed .inbox-rail { display: none; }

  /* Inline rename input on resource label */
  .rowlabel-input {
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    padding: 2px 4px;
    border: 1px solid var(--primary);
    border-radius: var(--radius-sm);
    width: 100%;
    background: var(--bg-card);
    color: var(--text);
  }
  .rowlabel-input:focus { outline: none; box-shadow: 0 0 0 3px rgba(37,99,235,0.12); }

  /* Add-resource button in rail head */
  .rail-add-btn {
    background: transparent;
    border: 1px dashed var(--primary);
    color: var(--primary);
    padding: 6px 10px;
    font-family: var(--font);
    font-size: 12px;
    font-weight: 600;
    border-radius: var(--radius);
    cursor: pointer;
    margin: 8px;
    width: calc(100% - 16px);
  }
  .rail-add-btn:hover { background: var(--primary-soft); }

  /* Filter dropdown panel */
  .filter-dropdown {
    position: absolute;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 6px;
    z-index: 50;
    min-width: 180px;
    max-height: 280px;
    overflow-y: auto;
  }
  .filter-dropdown button {
    display: block;
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    padding: 6px 10px;
    font-family: var(--font);
    font-size: 13px;
    color: var(--text);
    border-radius: var(--radius-sm);
    cursor: pointer;
  }
  .filter-dropdown button:hover { background: var(--border-light); }
  .filter-dropdown button.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }

  /* ── PM-DRAWER (sliding side panel) ── */
  .pm-drawer-overlay {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.42);
    z-index: 90;
    opacity: 0;
    transition: opacity 0.18s ease;
  }
  .pm-drawer-overlay.open { opacity: 1; }
  .pm-drawer-overlay.hidden { display: none; }

  .pm-drawer-panel {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: 480px;
    max-width: 100vw;
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    box-shadow: -16px 0 40px rgba(15, 23, 42, 0.18);
    z-index: 91;
    transform: translateX(100%);
    transition: transform 0.22s ease;
    display: flex;
    flex-direction: column;
    font-family: var(--font);
    color: var(--text);
  }
  .pm-drawer-panel.open { transform: translateX(0); }
  .pm-drawer-panel.hidden { display: none; }
  @media (max-width: 640px) {
    .pm-drawer-panel { width: 100vw; }
  }

  .pm-drawer-content { display: flex; flex-direction: column; flex: 1; min-height: 0; }

  .pm-drawer-head {
    padding: 16px 20px 14px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-card);
    position: sticky; top: 0;
    z-index: 2;
  }
  .pm-drawer-head-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }
  .pm-drawer-head-actions { display: flex; gap: 8px; align-items: center; }
  .pm-drawer-title-input {
    font-family: var(--font);
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 4px 6px;
    background: transparent;
    width: 100%;
    margin-top: 8px;
  }
  .pm-drawer-title-input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px rgba(37,99,235,0.12); }
  .pm-drawer-title-input[readonly] { cursor: pointer; }
  .pm-drawer-subline {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
  }
  .pm-drawer-dirty {
    display: inline-block;
    margin-left: 8px;
    color: var(--st-option);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
  }

  .pm-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 8px;
  }

  .pm-drawer-section {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
  }
  .pm-drawer-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    margin-bottom: 10px;
  }

  /* Form grid for core fields */
  .pm-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 14px;
  }
  .pm-form-grid .full { grid-column: span 2; }
  @media (max-width: 640px) {
    .pm-form-grid { grid-template-columns: 1fr; }
    .pm-form-grid .full { grid-column: span 1; }
  }
  .pm-field { display: flex; flex-direction: column; gap: 4px; }
  .pm-field > label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
  }
  .pm-field > label .req { color: var(--danger); margin-left: 2px; }
  .pm-field input,
  .pm-field select,
  .pm-field textarea {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 13px;
    color: var(--text);
    background: var(--bg-card);
  }
  .pm-field input:focus,
  .pm-field select:focus,
  .pm-field textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
  }
  .pm-field textarea { resize: vertical; min-height: 96px; }

  /* Staff chips multi-select */
  .pm-staff-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  .pm-staff-chip {
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 99px;
    background: var(--bg-card);
    color: var(--text);
    font-size: 12px;
    cursor: pointer;
    user-select: none;
  }
  .pm-staff-chip:hover { background: var(--border-light); }
  .pm-staff-chip.active {
    background: var(--primary-soft);
    border-color: var(--primary-border);
    color: var(--primary);
    font-weight: 600;
  }

  /* Status stepper */
  .pm-stepper {
    display: flex;
    gap: 4px;
    flex-wrap: nowrap;
    overflow-x: auto;
  }
  .pm-step {
    flex: 1;
    min-width: 0;
    padding: 8px 6px;
    font-size: 10px;
    text-align: center;
    border: 1px solid var(--border);
    background: var(--bg-card);
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    font-weight: 600;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    transition: all 0.15s;
    white-space: nowrap;
  }
  .pm-step:hover { background: var(--border-light); }
  .pm-step.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
  }
  .pm-step.past {
    background: var(--st-progress-soft);
    color: var(--st-progress);
    border-color: var(--st-progress-border);
  }

  /* Timeline */
  .pm-timeline { list-style: none; margin: 0; padding: 0; }
  .pm-timeline-event {
    padding: 8px 0 8px 22px;
    border-left: 2px solid var(--border-light);
    margin-left: 5px;
    position: relative;
    font-size: 13px;
  }
  .pm-timeline-event::before {
    content: '';
    position: absolute;
    left: -5px;
    top: 12px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--st-progress);
    border: 2px solid var(--bg-card);
  }
  .pm-timeline-event.ghl::before { background: var(--primary); }
  .pm-timeline-when { color: var(--text-muted); font-size: 11px; }
  .pm-timeline-what { margin-top: 2px; color: var(--text); }

  /* GHL section */
  .pm-ghl-card {
    background: var(--primary-soft);
    border: 1px solid var(--primary-border);
    border-radius: var(--radius);
    padding: 12px 14px;
    font-size: 13px;
    color: var(--text);
  }
  .pm-ghl-card a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
  }
  .pm-ghl-card a:hover { text-decoration: underline; }
  .pm-ghl-card .meta { margin-top: 4px; font-size: 12px; color: var(--text-muted); }

  /* Action bar */
  .pm-drawer-actions {
    padding: 12px 20px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    bottom: 0;
    z-index: 2;
  }
  .pm-drawer-actions .left, .pm-drawer-actions .right { display: flex; gap: 8px; }
  .btn.danger {
    color: var(--danger);
    border-color: var(--danger-border);
    background: var(--bg-card);
  }
  .btn.danger:hover { background: var(--danger-soft); }
  .btn:disabled { opacity: 0.5; cursor: not-allowed; }

  /* Error toast (separate from undo) */
  .error-strip {
    background: var(--danger);
    color: #fff;
    padding: 12px 18px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    font-size: 13px;
  }
  .error-strip .dismiss {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.5);
    color: #fff;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    cursor: pointer;
  }

  /* ── RULES VIEW ── */
  .rules-page {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    max-width: 1100px;
    margin: 0 auto;
  }
  .rules-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 22px;
    box-shadow: var(--shadow-sm);
  }
  .rules-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
  }
  .rules-card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
  }
  .rules-card-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
  }

  .webhook-row {
    display: grid;
    grid-template-columns: 110px 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
  }
  .webhook-row:last-child { border-bottom: none; }
  .webhook-row .lbl {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
  }
  .webhook-row .val {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    color: var(--text);
    background: var(--border-light);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    white-space: nowrap;
  }
  .webhook-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
  }
  .webhook-status .dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: #9CA3AF;
    box-shadow: 0 0 0 3px rgba(156,163,175,0.18);
  }
  .webhook-status.live .dot {
    background: #10B981;
    box-shadow: 0 0 0 3px rgba(16,185,129,0.2);
  }

  /* Rule list */
  .rule-list { display: flex; flex-direction: column; gap: 10px; }
  .rule-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 14px;
    align-items: center;
    box-shadow: var(--shadow-sm);
  }
  .rule-item.disabled { opacity: 0.6; background: var(--border-light); }
  .rule-item-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
  }
  .rule-item-trigger {
    font-size: 12px;
    color: var(--text-muted);
  }
  .rule-item-trigger code {
    background: var(--border-light);
    padding: 1px 6px;
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px;
    color: var(--text);
  }
  .rule-item-action {
    font-size: 12px;
    color: var(--primary);
    margin-top: 2px;
  }
  .rule-item-actions { display: flex; gap: 6px; align-items: center; }

  .rule-toggle {
    position: relative;
    width: 38px; height: 22px;
    background: var(--border);
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s;
    border: none;
  }
  .rule-toggle::after {
    content: '';
    position: absolute;
    top: 2px; left: 2px;
    width: 18px; height: 18px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.15s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  }
  .rule-toggle.on { background: var(--primary); }
  .rule-toggle.on::after { transform: translateX(16px); }

  /* Rule editor + test dialog modals */
  .pm-modal-overlay {
    position: fixed; inset: 0;
    background: rgba(15,23,42,0.42);
    z-index: 80;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
  }
  .pm-modal-overlay.hidden { display: none; }
  .pm-modal {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
  }
  .pm-modal-head {
    padding: 18px 22px 14px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    position: sticky; top: 0;
    background: var(--bg-card);
    z-index: 1;
  }
  .pm-modal-title { font-size: 16px; font-weight: 700; color: var(--text); }
  .pm-modal-body { padding: 18px 22px; display: flex; flex-direction: column; gap: 14px; }
  .pm-modal-foot {
    padding: 14px 22px;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    position: sticky; bottom: 0;
    background: var(--bg-card);
  }

  /* Pipeline preview */
  .pipeline-preview-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
  }
  @media (max-width: 720px) {
    .pipeline-preview-grid { grid-template-columns: repeat(2, 1fr); }
  }
  .pipeline-stage-card {
    padding: 14px;
    border-radius: var(--radius);
    color: #fff;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 84px;
  }
  .pipeline-stage-card .name { font-size: 13px; font-weight: 700; }
  .pipeline-stage-card .hint { font-size: 11px; opacity: 0.92; }
  .pipeline-stage-card .ruletag {
    margin-top: 4px;
    background: rgba(255,255,255,0.22);
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 600;
    align-self: flex-start;
  }

  /* Test-dialog output */
  .test-output {
    background: var(--border-light);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text);
  }
  .test-output.matched { background: var(--st-progress-soft); border-color: var(--st-progress-border); }
  .test-output.unmatched { background: var(--st-option-soft); border-color: var(--st-option-border); }
  .test-output pre {
    background: var(--bg-card);
    padding: 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    font-size: 12px;
    margin-top: 8px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
  }

  /* ── Employees page ── */
  .employees-list { display: flex; flex-direction: column; }
  .employee-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 22px;
    border-bottom: 1px solid var(--border-light);
  }
  .employee-row:last-child { border-bottom: none; }
  .employee-row-left { display: flex; flex-direction: column; gap: 4px; }
  .employee-name { font-size: 14px; font-weight: 600; color: var(--text); }
  .employee-meta { display: flex; gap: 6px; flex-wrap: wrap; }
  .employee-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    background: var(--bg-page);
    color: var(--text-muted);
    border: 1px solid var(--border-light);
  }
  .employee-badge.ok {
    background: var(--st-progress-soft);
    color: var(--st-progress);
    border-color: var(--st-progress-border);
  }
  .employee-row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
  .employee-link-box {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
  }
  .employee-link-box input {
    width: 320px;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 12px;
    background: var(--bg-page);
    color: var(--text);
  }

  /* ── Chauffeur mobile view ── */
  .chf-shell {
    min-height: 100vh;
    background: var(--bg-page);
    color: var(--text);
    font-family: var(--font);
    display: flex;
    flex-direction: column;
  }
  .chf-head {
    background: var(--bg-card);
    padding: 16px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 5;
  }
  .chf-name { font-size: 18px; font-weight: 700; }
  .chf-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
  .chf-tabs {
    display: flex;
    gap: 4px;
    margin-top: 12px;
    background: var(--bg-page);
    padding: 4px;
    border-radius: var(--radius);
  }
  .chf-tab {
    flex: 1;
    padding: 9px 10px;
    border: none;
    background: transparent;
    border-radius: calc(var(--radius) - 2px);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    font-family: var(--font);
  }
  .chf-tab.active {
    background: var(--bg-card);
    color: var(--text);
    box-shadow: var(--shadow-sm);
  }
  .chf-list { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
  .chf-empty {
    padding: 36px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    font-style: italic;
  }
  .chf-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .chf-card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
  .chf-client { font-size: 16px; font-weight: 700; color: var(--text); }
  .chf-time   { font-size: 13px; color: var(--text-muted); white-space: nowrap; }
  .chf-meta   { font-size: 13px; color: var(--text); }
  .chf-meta a { color: var(--primary); text-decoration: none; }
  .chf-meta a:active { text-decoration: underline; }
  .chf-row    { display: flex; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--text-muted); }
  .chf-row .k { font-weight: 600; color: var(--text); }
  .chf-actions { display: flex; gap: 8px; margin-top: 6px; }
  .chf-action-btn {
    flex: 1;
    padding: 12px 10px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font);
    color: var(--text);
  }
  .chf-action-btn.active {
    background: var(--st-progress-soft);
    border-color: var(--st-progress-border);
    color: var(--st-progress);
  }
  .chf-action-btn.done {
    background: var(--st-done-soft);
    border-color: var(--st-done-border);
    color: var(--st-done);
  }
  .chf-error {
    padding: 14px;
    margin: 16px;
    background: var(--danger-soft);
    border: 1px solid var(--danger-border);
    border-radius: var(--radius);
    color: var(--danger);
    font-size: 13px;
  }
