@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&family=DM+Serif+Display&display=swap');

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

  :root {
    --gold:         #B8975A;
    --gold-light:   #D4B483;
    --gold-dark:    #8C6F3E;
    --ink:          #1A1A1A;
    --ink-muted:    #5A5A5A;
    --ink-faint:    #9A9A9A;
    --surface:      #FAFAF8;
    --surface-alt:  #F3F1EC;
    --border:       rgba(184,151,90,0.2);
    --border-strong:rgba(184,151,90,0.45);
    --red:          #C0392B;
    --red-bg:       #FEF0EF;
    --red-border:   rgba(192,57,43,0.25);
    --yellow:       #B7770D;
    --yellow-bg:    #FEF9E7;
    --yellow-border:rgba(183,119,13,0.3);
    --green:        #1E6B3C;
    --green-bg:     #EAFAF1;
    --green-border: rgba(30,107,60,0.25);
    --radius:       16px;
    --shadow:       0 1px 3px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.06);
  }

  html, body {
    font-family: 'DM Sans', sans-serif;
    background: var(--surface);
    color: var(--ink);
     overflow-x: hidden;
     max-width: 100%;
    min-height: 100vh;
  }

  /* Subtle gold grid background — same as portal */
  body::before {
    content: '';
    position: fixed; inset: 0;
    background-image:
      linear-gradient(rgba(184,151,90,0.04) 1px, transparent 1px),
      linear-gradient(90deg, rgba(184,151,90,0.04) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none; z-index: 0;
  }

  /* ── NAV ── */
  .nav {
    position: sticky; top: 0; z-index: 100;
    background: #fff;
    border-bottom: 1px solid var(--border-strong);
    box-shadow: 0 1px 8px rgba(0,0,0,0.06);
    display: flex; align-items: center;
    padding: 0 24px; gap: 4px;
  }
  .nav-brand {
    font-family: 'DM Serif Display', serif;
    color: var(--gold-dark);
    font-size: 15px;
    padding: 14px 0;
    margin-right: 16px;
    white-space: nowrap;
    letter-spacing: 0.02em;
  }
  .nav-links { display: flex; gap: 2px; flex: 1; }
  .nav-link {
    color: var(--ink-faint);
    text-decoration: none;
    padding: 14px 14px;
    font-size: 13px;
    font-weight: 500;
    border-bottom: 3px solid transparent;
    transition: all 0.15s;
    white-space: nowrap;
  }
  .nav-link:hover { color: var(--gold-dark); }
  .nav-link.active { color: var(--gold-dark); border-bottom-color: var(--gold); font-weight: 600; }

  /* ── LAYOUT ── */
  .container {
    position: relative; z-index: 1;
    max-width: 760px; margin: 0 auto;
    padding: 28px 20px 60px;
  }

  /* ── PAGE HEADER ── */
  .page-header {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 28px 28px 24px;
    margin-bottom: 28px;
    box-shadow: var(--shadow);
    position: relative; overflow: hidden;
  }
  .page-header::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
  }
  .page-header h1 {
    font-family: 'DM Serif Display', serif;
    font-size: 22px; font-weight: 400;
    color: var(--ink); margin-bottom: 4px;
  }
  .page-header p { font-size: 13px; color: var(--ink-faint); }

  /* ── SECTION TITLES ── */
  .section-label {
    font-size: 11px; font-weight: 600;
    letter-spacing: 0.1em; text-transform: uppercase;
    color: var(--ink-faint);
    margin-bottom: 12px; padding-left: 2px;
    display: flex; align-items: center; gap: 8px;
  }
  .section-label::after {
    content: ''; flex: 1; height: 1px; background: var(--border);
  }

  /* ── CARDS ── */
  .card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    margin-bottom: 16px;
    overflow: visible;
    transition: border-color 0.2s, box-shadow 0.2s;
  }
  .card:hover {
    border-color: var(--gold);
    box-shadow: 0 4px 16px rgba(184,151,90,0.15);
  }
  .card-header {
    padding: 13px 18px;
    font-size: 11px; font-weight: 600;
    letter-spacing: 0.08em; text-transform: uppercase;
    color: var(--ink-faint);
    background: var(--surface-alt);
    border-bottom: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
    display: flex; align-items: center; gap: 8px;
  }
  .card-header::before {
    content: ''; display: inline-block;
    width: 3px; height: 12px;
    background: linear-gradient(to bottom, var(--gold-light), var(--gold-dark));
    border-radius: 2px;
  }
  .card-body { padding: 18px; overflow: visible; }

  /* ── SP SELECTOR BAR ── */
  .sp-bar {
    background: var(--surface-alt);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    padding: 12px 18px;
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 20px;
    font-size: 13px; color: var(--ink-muted);
  }
  .sp-bar select {
    width: auto;
    color: var(--gold-dark);
    background: #fff;
    border: 1px solid var(--border-strong);
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    outline: none;
  }
  .sp-bar select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(184,151,90,0.12); }

  /* ── FORMS ── */
  .form-group { margin-bottom: 14px; }
  .form-group label {
    display: block;
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.07em;
    color: var(--ink-faint);
    margin-bottom: 5px;
  }
  .label-note { font-weight: 400; text-transform: none; color: var(--gold); letter-spacing: 0; font-size: 11px; }

  input[type="text"], input[type="tel"], input[type="date"],
  select, textarea {
    width: 100%;
    padding: 9px 13px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    font-family: 'DM Sans', sans-serif;
    font-size: 14px; color: var(--ink);
    background: #fff; outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
  }
  input:focus, select:focus, textarea:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(184,151,90,0.12);
  }
  textarea { resize: vertical; min-height: 72px; }
  .field-error { color: var(--red); font-size: 12px; margin-top: 4px; font-weight: 500; }
  .field-info  { color: var(--green); font-size: 12px; margin-top: 4px; font-weight: 500; }

  /* ── BUTTONS ── */
  .btn-primary {
    background: linear-gradient(135deg, var(--gold-light), var(--gold-dark));
    color: #fff; border: none;
    padding: 11px 24px;
    border-radius: 10px;
    font-family: 'DM Sans', sans-serif;
    font-size: 14px; font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.15s;
    box-shadow: 0 2px 8px rgba(184,151,90,0.3);
  }
  .btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }
  .btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
  .btn-secondary {
    background: #fff; color: var(--gold-dark);
    border: 1px solid var(--border-strong);
    padding: 8px 16px; border-radius: 10px;
    font-family: 'DM Sans', sans-serif;
    font-size: 13px; font-weight: 600; cursor: pointer;
    transition: border-color 0.15s;
  }
  .btn-secondary:hover { border-color: var(--gold); }
  .btn-full { width: 100%; margin-top: 6px; }
  .btn-link {
    background: none; border: none;
    color: var(--gold-dark); font-size: 13px;
    font-weight: 500; cursor: pointer;
    padding: 4px 0; text-decoration: underline;
    text-underline-offset: 2px;
  }

  /* ── BADGES ── */
  .badge {
    display: inline-block; padding: 2px 8px;
    border-radius: 20px; font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  }
  .badge.red    { background: var(--red-bg);    color: var(--red);    border: 1px solid var(--red-border); }
  .badge.yellow { background: var(--yellow-bg); color: var(--yellow); border: 1px solid var(--yellow-border); }
  .badge.green  { background: var(--green-bg);  color: var(--green);  border: 1px solid var(--green-border); }
  .badge.gold   { background: #FDF5E8; color: var(--gold-dark); border: 1px solid var(--border-strong); }

  /* ── CLIENT AUTOCOMPLETE ── */
  .client-search-wrap { position: relative; }
  .dropdown {
    position: absolute; top: 100%; left: 0; right: 0;
    background: #fff;
    border: 1px solid var(--border-strong);
    border-top: none;
    border-radius: 0 0 10px 10px;
    max-height: 280px; overflow-y: auto;
    z-index: 50;
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
  }
  .dd-item {
    padding: 9px 13px; cursor: pointer;
    border-bottom: 1px solid var(--border);
    font-size: 13px; transition: background 0.1s;
  }
  .dd-item:last-child { border-bottom: none; }
  .dd-item:hover { background: var(--surface-alt); }
  .dd-empty { color: var(--ink-faint); cursor: default; }
  .selected-tag {
    display: inline-flex; align-items: center; gap: 6px;
    background: #FDF5E8;
    border: 1px solid var(--border-strong);
    border-radius: 20px; padding: 4px 12px;
    font-size: 13px; font-weight: 500; color: var(--gold-dark);
    margin-top: 6px;
  }
  .selected-tag button {
    background: none; border: none; color: var(--gold-dark);
    cursor: pointer; font-size: 15px; line-height: 1; padding: 0;
  }
  .sub-form {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 10px; padding: 14px; margin-top: 8px;
  }
  .sub-form .form-group { margin-bottom: 10px; }

  /* ── BUFFER ZONE CARDS ── */
  .buffer-card { border-radius: var(--radius); overflow: hidden; margin-bottom: 16px; box-shadow: var(--shadow); }
  .zone-header {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 18px; font-weight: 600; font-size: 12px;
    letter-spacing: 0.04em;
  }
  .zone-header.red    { background: var(--red-bg);    color: var(--red);    border: 1px solid var(--red-border);    border-bottom: none; }
  .zone-header.yellow { background: var(--yellow-bg); color: var(--yellow); border: 1px solid var(--yellow-border); border-bottom: none; }
  .zone-header.green  { background: var(--green-bg);  color: var(--green);  border: 1px solid var(--green-border);  border-bottom: none; }
  .buffer-items { border: 1px solid var(--border); border-top: none; border-radius: 0 0 var(--radius) var(--radius); }
  .buffer-item {
    padding: 14px 18px; border-bottom: 1px solid var(--border);
    display: grid; grid-template-columns: 1fr auto;
    gap: 8px; align-items: start; background: #fff;
    transition: background 0.15s;
  }
  .buffer-item:last-child { border-bottom: none; }
  .buffer-item:hover { background: var(--surface-alt); }
  .bi-client { font-weight: 600; font-size: 14px; color: var(--ink); }
  .bi-sp     { color: var(--ink-faint); font-size: 12px; margin-top: 3px; }
  .bi-notes  { color: var(--ink-muted); font-size: 12px; margin-top: 4px; font-style: italic; }
  .bi-right  { text-align: right; }

  /* ── TIMELINE ── */
  .tl-item { padding: 14px 0; border-bottom: 1px solid var(--border); }
  .tl-item:last-child { border-bottom: none; }
  .tl-date   { font-size: 11px; color: var(--ink-faint); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
  .tl-outcome { font-weight: 600; font-size: 13px; margin: 4px 0; color: var(--ink); }
  .tl-convo  { color: var(--ink-muted); font-size: 13px; margin: 4px 0; line-height: 1.5; }
  .tl-nad {
    display: inline-flex; align-items: center; gap: 5px;
    background: #FDF5E8; border: 1px solid var(--border-strong);
    border-radius: 6px; padding: 4px 10px;
    font-size: 12px; font-weight: 500; color: var(--gold-dark);
    margin-top: 6px;
  }

  /* ── STATS ── */
  .stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 20px; }
  .stat-card {
    background: #fff; border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px;
    text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    position: relative; overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
  }
  .stat-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
  }
  .stat-card:hover { border-color: var(--gold); box-shadow: 0 4px 16px rgba(184,151,90,0.12); }
  .stat-value { font-family: 'DM Serif Display', serif; font-size: 30px; color: var(--gold-dark); }
  .stat-label { font-size: 11px; color: var(--ink-faint); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; margin-top: 4px; }

  /* ── SP TABLE ── */
  .sp-table { width: 100%; border-collapse: collapse; font-size: 13px; }
  .sp-table th { background: var(--surface-alt); color: var(--ink-faint); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; padding: 9px 14px; text-align: left; border-bottom: 1px solid var(--border); }
  .sp-table td { padding: 11px 14px; border-bottom: 1px solid var(--border); }
  .sp-table tr:last-child td { border-bottom: none; }
  .sp-table tr:hover td { background: var(--surface-alt); }
  .sp-table .num { font-weight: 600; color: var(--gold-dark); font-size: 15px; }

  /* ── SCHEDULE ITEMS ── */
  .schedule-item {
    padding: 10px 14px; border-radius: 10px; margin-bottom: 8px;
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    font-size: 13px; border: 1px solid;
  }
  .schedule-item.red    { background: var(--red-bg);    border-color: var(--red-border); }
  .schedule-item.yellow { background: var(--yellow-bg); border-color: var(--yellow-border); }
  .si-client { font-weight: 600; color: var(--ink); }
  .si-notes  { font-size: 12px; color: var(--ink-muted); margin-top: 2px; font-style: italic; }

  /* ── OUTCOME PILL ── */
  .outcome-pill {
    display: inline-block; padding: 3px 10px;
    border-radius: 20px; font-size: 11px; font-weight: 600;
    background: #FDF5E8; color: var(--gold-dark);
    border: 1px solid var(--border-strong);
  }

  /* ── PROGRESS BARS ── */
  .progress-bar-wrap { margin-bottom: 12px; }
  .progress-label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
  .progress-label .sp-name { font-weight: 600; color: var(--ink); }
  .progress-label .sp-num  { color: var(--gold-dark); font-weight: 600; }
  .progress-bar-bg { background: var(--surface-alt); border-radius: 20px; height: 7px; overflow: hidden; border: 1px solid var(--border); }
  .progress-bar-fill { height: 100%; background: linear-gradient(90deg, var(--gold-light), var(--gold-dark)); border-radius: 20px; transition: width 0.7s ease; }

  /* ── OUTCOME BREAKDOWN ── */
  .outcome-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
  .outcome-row:last-child { border-bottom: none; }
  .outcome-name { flex: 1; color: var(--ink-muted); }
  .outcome-count { font-weight: 600; color: var(--gold-dark); font-size: 15px; min-width: 24px; text-align: right; }
  .outcome-bar-bg { flex: 2; background: var(--surface-alt); border-radius: 20px; height: 6px; overflow: hidden; }
  .outcome-bar-fill { height: 100%; background: linear-gradient(90deg, var(--gold-light), var(--gold-dark)); border-radius: 20px; }

  /* ── BUFFER SUMMARY PILLS ── */
  .buffer-summary-row { display: flex; gap: 10px; }
  .bs-pill { flex: 1; text-align: center; padding: 14px 8px; border-radius: 12px; font-size: 12px; font-weight: 600; border: 1px solid; }
  .bs-pill .bs-num { font-size: 26px; font-family: 'DM Serif Display', serif; display: block; margin-bottom: 4px; }
  .bs-pill.red    { background: var(--red-bg);    color: var(--red);    border-color: var(--red-border); }
  .bs-pill.yellow { background: var(--yellow-bg); color: var(--yellow); border-color: var(--yellow-border); }
  .bs-pill.green  { background: var(--green-bg);  color: var(--green);  border-color: var(--green-border); }

  /* ── GREEN SUMMARY ── */
  .green-summary {
    background: var(--green-bg); border: 1px solid var(--green-border);
    border-radius: var(--radius); padding: 16px 20px;
    display: flex; align-items: center; justify-content: space-between;
    gap: 14px; font-size: 13px; color: var(--green);
  }

  /* ── FILTER & TAB BUTTONS ── */
  .filter-bar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
  .filter-btn {
    padding: 5px 14px; border-radius: 20px;
    border: 1px solid var(--border-strong);
    background: #fff; font-size: 12px; font-weight: 600;
    cursor: pointer; color: var(--ink-faint);
    transition: all 0.15s; font-family: 'DM Sans', sans-serif;
  }
  .filter-btn:hover { border-color: var(--gold); color: var(--gold-dark); }
  .filter-btn.active { border-color: var(--gold); background: #FDF5E8; color: var(--gold-dark); }

  .tab-row { display: flex; gap: 6px; margin-bottom: 14px; }
  .tab-btn {
    padding: 6px 16px; border-radius: 20px;
    border: 1px solid var(--border-strong);
    background: #fff; font-size: 12px; font-weight: 600;
    cursor: pointer; color: var(--ink-faint); font-family: 'DM Sans', sans-serif;
    transition: all 0.15s;
  }
  .tab-btn.active { border-color: var(--gold); background: #FDF5E8; color: var(--gold-dark); }

  /* ── EMPTY / LOADING ── */
  .empty-state   { color: var(--ink-faint); font-size: 13px; padding: 28px; text-align: center; }
  .loading-state { color: var(--ink-faint); font-size: 13px; padding: 20px; text-align: center; }
  .spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid var(--border-strong); border-top-color: var(--gold); border-radius: 50%; animation: spin 0.7s linear infinite; vertical-align: middle; margin-right: 6px; }
  @keyframes spin { to { transform: rotate(360deg); } }

  .hidden { display: none !important; }
  .mt8 { margin-top: 8px; }

  /* ── SECTION SPACING ── */
  .section { margin-bottom: 28px; }

  /* ── REFRESH BAR ── */
  .refresh-bar {
    display: flex; align-items: center; justify-content: space-between;
    font-size: 12px; color: var(--ink-faint); margin-bottom: 16px;
  }

@media (max-width: 600px) {
  /* Nav */
  .nav { padding: 0 8px; overflow-x: auto; }
  .nav-brand { display: none; }
  .nav-links { overflow-x: auto; flex-wrap: nowrap; }
  .nav-link { padding: 11px 10px; font-size: 11px; white-space: nowrap; }

  /* Layout */
  .container { padding: 14px 50px 60px; overflow-x: hidden}
  .page-header { padding: 20px 16px; border-radius: 14px; }
  .page-header h1 { font-size: 18px; }

  /* Cards */
  .card { border-radius: 12px; }
  .card-header { padding: 11px 14px; font-size: 10px; }
  .card-body { padding: 14px; }

  /* SP bar */
  .sp-bar { flex-wrap: wrap; gap: 6px; padding: 10px 14px; }
  .sp-bar select { width: 100%; }

  /* Forms */
  input[type="text"], input[type="tel"], input[type="date"],
  select, textarea { font-size: 16px; } /* prevents iOS zoom on focus */
  .btn-primary { padding: 13px 20px; font-size: 15px; } /* easier tap target */

  /* Stats */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-value { font-size: 24px; }

  /* Buffer */
  .buffer-summary-row { flex-direction: column; gap: 8px; }
  .buffer-item { grid-template-columns: 1fr; gap: 10px; }
  .bi-right { text-align: left; }

  /* Schedule items */
  .schedule-item { flex-direction: column; align-items: flex-start; gap: 6px; }

  /* Timeline */
  .tl-item { padding: 12px 0; }

  /* Progress bars */
  .progress-label { font-size: 12px; }

  /* Tabs & filters */
  .tab-row, .filter-bar { gap: 4px; }
  .tab-btn, .filter-btn { padding: 5px 10px; font-size: 11px; }

  /* Dropdown */
  .dropdown { max-height: 200px; }
}