:root {
  /* Optimize by PerfectFill. Scales from PerfectFill-Home's tailwind.config.ts (Waitlist's
     design standard v1.0, with Optimize's amber): warm neutrals, a warm near-black ground,
     and amber for "upgrade" moments. On white, amber text uses 700 (#9A5416) for contrast. */
  --bg-color: #F7F7F5;        /* neutral-50 */
  --card-bg: #FFFFFF;

  --ground: #100A05;          /* Optimize's near-black: primary buttons, dark bands */
  --ground-hover: #262625;    /* neutral-800 */
  --amber: #EEA23F;           /* optimize-400: the brand moment */
  --amber-strong: #E08A22;    /* optimize-500: toggles, active underlines */
  --amber-tint: #FEF7EC;      /* optimize-50: hover and selected rows */

  --primary-accent: #9A5416;  /* optimize-700: accent text, links, focus */
  --primary-hover: #7C4317;   /* optimize-800 */
  --secondary-accent: #5E5E5A;/* neutral-600 */

  --text-color: #3A3A38;      /* neutral-700 */
  --heading-color: #1A1A19;   /* neutral-900 */
  --label-color: #5E5E5A;     /* neutral-600 */
  --muted-text: #A8A8A2;      /* neutral-400 */

  --border-color: #E4E4DE;    /* neutral-200 */
  --border-light: #F0F0EC;    /* neutral-100 */

  --score-bg: #EF4444;        /* Rose 500 */
  --success-color: #10B981;   /* Emerald 500 */
  --info-color: #0EA5E9;      /* Sky 500 */
  --warning-color: #F59E0B;   /* Amber 500 */

  /* Same faces as Waitlist and PerfectFill (loaded in app/index.html). */
  --font-body: 'Chivo', Helvetica, Arial, sans-serif;
  --font-display: 'Archivo', Helvetica, Arial, sans-serif;
  --font-mono: 'Chivo Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Shadows & Geometry */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius-md: 6px;
  --radius-lg: 10px;          /* Waitlist's dashboard cards */
  --radius-xl: 16px;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-color);
  color: var(--text-color);
  margin: 0; padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Headlines in Archivo at its widest, as on the public site. */
h1, h2, h3, h4, h5 {
  color: var(--heading-color); font-weight: 700; margin-top: 0;
  font-family: var(--font-display); font-stretch: 125%; letter-spacing: -0.015em;
}
h2 { font-size: 1.5rem; }
h3 { font-size: 1.125rem; margin-bottom: 0.75rem; }
p { line-height: 1.5; }
/* Mono for labels and data, as in Waitlist's dashboard. */
.mono { font-family: var(--font-mono); }

/* --- APP HEADER --- */
.app-header {
    display: flex; justify-content: space-between; align-items: center;
    height: 72px; padding: 0 24px;
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky; top: 0; z-index: 1000;
}
.logo {
    display: inline-flex; align-items: center; gap: 10px;
    font-family: var(--font-display); font-stretch: 125%; font-weight: 700; font-size: 1.3rem;
    letter-spacing: -0.015em; color: var(--heading-color); text-decoration: none;
}
.logo svg { width: 30px; height: 30px; flex: none; color: var(--ground); }
.logo .logo-by {
    font-family: var(--font-mono); font-stretch: normal; font-weight: 400; font-size: 0.68rem;
    letter-spacing: 0.14em; text-transform: uppercase; color: var(--label-color);
}
.nav-controls { display: flex; align-items: center; gap: 12px; }
/* Phones: the wordmark alone, so the property picker and menu still fit. */
@media (max-width: 640px) {
    .app-header { padding: 0 16px; }
    .logo { font-size: 1.1rem; }
    .logo .logo-by { display: none; }
    /* The upload row stacks: file picker, then a full-width Calculate button. */
    #manual-upload-wrapper { flex-wrap: wrap; }
    .file-control { min-width: 0; flex-basis: 100%; }
    .button-control { width: 100%; }
    .button-control label { display: none; }
    .cta-btn { width: 100%; }
}

/* --- BUTTONS & INPUTS --- */
.primary-btn, .outline-btn, .pms-btn, .undo-accept-btn, .undo-completed-btn {
    font-family: var(--font-body); font-weight: 500; font-size: 0.875rem;
    padding: 0.625rem 1rem; border-radius: var(--radius-md);
    cursor: pointer; transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex; align-items: center; justify-content: center;
}
/* Primary actions read like Waitlist's: near-black, mono, uppercase. */
.primary-btn {
    background-color: var(--ground); color: white; border: none; box-shadow: var(--shadow-sm);
    font-family: var(--font-mono); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.1em;
}
.primary-btn:hover:not(:disabled) { background-color: var(--ground-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.primary-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.outline-btn { background-color: transparent; color: var(--text-color); border: 1px solid var(--border-color); }
.outline-btn:hover { background-color: var(--bg-color); border-color: var(--secondary-accent); color: var(--heading-color); }

.danger-btn { background-color: var(--score-bg); color: white; border: none; }
.danger-btn:hover { background-color: #DC2626; transform: translateY(-1px); box-shadow: var(--shadow-md); }

.small-btn { padding: 0.4rem 0.75rem; font-size: 0.8rem; }
.w-full { width: 100%; }
.danger-text { color: var(--score-bg); border-color: #FECACA; }
.danger-text:hover { background-color: #FEF2F2; color: #DC2626; border-color: #FCA5A5; }

.modern-input, .modern-select, .modern-file-input {
    width: 100%; padding: 0.625rem 0.75rem; font-family: var(--font-body); font-size: 0.875rem;
    color: var(--heading-color); background-color: #FFFFFF;
    border: 1px solid var(--border-color); border-radius: var(--radius-md);
    box-sizing: border-box; transition: border-color 0.2s, box-shadow 0.2s;
}
.modern-input:focus, .modern-select:focus { outline: none; border-color: var(--primary-accent); box-shadow: 0 0 0 3px rgba(238, 162, 63, 0.1); }
.modern-select { cursor: pointer; padding-right: 2rem; }
textarea.modern-input { resize: vertical; min-height: 80px; }

.icon-btn {
    background: none; border: none; cursor: pointer; color: var(--secondary-accent);
    padding: 0.5rem; display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-md); transition: all 0.2s;
}
.icon-btn:hover { color: var(--primary-accent); background-color: #FEF7EC; transform: rotate(15deg); }

/* --- STRUCTURAL CLASSES & SPACING --- */
.main-content { padding: 2rem 1.5rem; max-width: 1280px; margin: 0 auto; }
.modern-card { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 1.5rem; }
.center-card { text-align: center; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.helper-text { font-size: 0.8rem; color: var(--label-color); margin: 0 0 0.5rem 0; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--muted-text); font-size: 0.95rem; }
.divider { height: 1px; background: var(--border-color); margin: 1.5rem 0; width: 100%; }

/* --- CONTROLS CONTAINER --- */
.controls-container {
    display: flex; align-items: flex-end; gap: 1.5rem; flex-wrap: wrap; margin-bottom: 2rem;
}
.control-item { display: flex; flex-direction: column; gap: 0.5rem; }
.control-item label { font-weight: 600; font-size: 0.85rem; color: var(--heading-color); }
.file-control { flex-grow: 1; min-width: 250px; }
.date-control { width: 180px; flex-shrink: 0; }
.button-control { width: auto; flex-shrink: 0; }
.cta-btn { height: 42px; font-weight: 600; padding: 0 1.5rem; }

/* --- TABS --- */
.tabs { display: flex; border-bottom: 1px solid var(--border-color); margin-bottom: 1.5rem; gap: 1rem; }
/* Mono, uppercase tabs with an amber underline, like Waitlist's dashboard labels. */
.tab {
    padding: 0.85rem 0.5rem; cursor: pointer; color: var(--label-color); font-weight: 500;
    font-family: var(--font-mono); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.1em;
    border-bottom: 2px solid transparent; transition: all 0.2s; position: relative;
}
.tab:hover { color: var(--heading-color); }
.tab.active { color: var(--heading-color); border-bottom-color: var(--amber-strong); }
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.4s ease-out forwards; }

.sub-tabs-nav { display: flex; border-bottom: 1px solid var(--border-color); margin-bottom: 1.5rem; gap: 1rem; overflow-x: auto; }
.sub-tab-btn { background: none; border: none; padding: 0.75rem 0.5rem; font-size: 0.875rem; font-weight: 500; color: var(--label-color); cursor: pointer; border-bottom: 2px solid transparent; transition: all 0.2s; white-space: nowrap;}
.sub-tab-btn:hover { color: var(--heading-color); }
.sub-tab-btn.active { color: var(--heading-color); border-bottom: 2px solid var(--amber-strong); font-weight: 600; }

/* --- MATRICES & TABLES --- */
.modern-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; border: 1px solid var(--border-color); }
.modern-table th, .modern-table td { border: 1px solid var(--border-color); }
/* Column headers in small mono caps, as in Waitlist's guest list. */
.modern-table th {
    background: var(--bg-color); color: var(--label-color); padding: 0.75rem 1rem; text-align: left; white-space: nowrap;
    font-family: var(--font-mono); font-size: 0.68rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.12em;
}
.modern-table td { padding: 0.75rem 1rem; color: var(--heading-color); vertical-align: middle; }
.modern-table tr:hover td { background-color: var(--amber-tint); }

.table-wrapper { background: var(--card-bg); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow-x: auto; margin-bottom: 1.5rem; }

/* Badges */
.badge { display: inline-flex; align-items: center; justify-content: center; padding: 0.15rem 0.5rem; border-radius: 9999px; font-weight: 600; font-size: 0.75rem; line-height: 1.2;}
.badge-success { background: #DCFCE7; color: #059669; }
.badge-warning { background: #FEF3C7; color: #D97706; }
.badge-danger { background: #FEE2E2; color: #DC2626; }
.badge-neutral { background: #F0F0EC; color: #5E5E5A; }
.badge-primary { background: #FEF7EC; color: #9A5416; }

/* --- UPGRADE CARDS --- */
.rec-card {
    background: var(--card-bg); border: 1px solid var(--border-color); border-radius: var(--radius-lg);
    padding: 1.25rem; margin-bottom: 1rem; display: flex; align-items: center; justify-content: space-between;
    box-shadow: var(--shadow-sm); transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s;
}
.rec-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.rec-card.completed { border-left: 4px solid var(--success-color); }

.rec-info { flex-grow: 1; }
.rec-info h3 { margin-bottom: 0.25rem; font-size: 1.05rem; }
.rec-details { font-size: 0.85rem; color: var(--label-color); line-height: 1.6; }
.rec-details strong { color: var(--heading-color); }
.rec-actions { display: flex; flex-direction: column; gap: 0.5rem; min-width: 140px; margin-left: 1rem;}

/* --- MODALS --- */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(16, 10, 5, 0.5); backdrop-filter: blur(4px);
    display: flex; justify-content: center; align-items: center; z-index: 2000;
    opacity: 0; animation: fadeIn 0.2s forwards;
}
.modal-content {
    background: var(--card-bg); width: 90%; max-width: 550px;
    border-radius: var(--radius-xl); box-shadow: var(--shadow-lg);
    display: flex; flex-direction: column; max-height: 90vh;
    transform: scale(0.95) translateY(10px); animation: scaleUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.modal-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border-light); display: flex; justify-content: space-between; align-items: center; }
.modal-header h2 { margin: 0; font-size: 1.25rem; }
.modal-body { padding: 1.5rem; overflow-y: auto; }
.modal-footer { padding: 1.25rem 1.5rem; border-top: 1px solid var(--border-light); background: #F7F7F5; border-radius: 0 0 var(--radius-xl) var(--radius-xl); }

.close-btn { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--label-color); transition: color 0.2s; padding: 0.25rem; line-height: 1; }
.close-btn:hover { color: var(--heading-color); }

/* --- LOGIN --- */
/* Sign-in: Waitlist's layout (waitlist.perfectfill.com/login) in Optimize's colors. The form
   sits on white at the left; the brand panel fills the right from 1024px up. */
#login-container {
    position: fixed; inset: 0; z-index: 3000; overflow-y: auto;
    display: flex; background: #fff; color: var(--heading-color);
}
.login-form-side {
    flex: 1; display: flex; flex-direction: column; justify-content: center;
    padding: 3rem 1.5rem; position: relative; overflow: hidden;
}
/* Phones and tablets: a faint amber corner, as Waitlist has a navy one. */
.login-form-side::before {
    content: ''; position: absolute; top: 0; right: 0; width: 16rem; height: 16rem;
    background: var(--amber-tint); border-bottom-left-radius: 100%; z-index: -1;
}
.login-form-inner { width: 100%; max-width: 24rem; margin: 0 auto; }
.login-mobile-mark { margin-bottom: 2.5rem; }
.login-title { font-size: 1.9rem; margin: 0 0 0.5rem; color: #010101; }
.login-sub { color: var(--label-color); margin: 0 0 2rem; }

.login-google-btn {
    width: 100%; height: 3.5rem; display: flex; align-items: center; justify-content: center; gap: 0.75rem;
    background: var(--ground); color: #fff; border: none; border-radius: 12px; cursor: pointer;
    font-family: var(--font-body); font-size: 1rem; font-weight: 700;
    box-shadow: 0 14px 30px -12px rgba(16, 10, 5, 0.55); transition: background 0.2s, transform 0.2s;
}
.login-google-btn:hover { background: var(--ground-hover); transform: translateY(-1px); }
.login-google-btn:focus-visible { outline: 3px solid rgba(238, 162, 63, 0.6); outline-offset: 2px; }
.login-google-g { width: 26px; height: 26px; border-radius: 6px; background: #fff; display: inline-flex; align-items: center; justify-content: center; }
.login-google-g svg { width: 16px; height: 16px; }
.login-arrow { transition: transform 0.3s; }
.login-google-btn:hover .login-arrow { transform: translateX(4px); }

#error-message { font-size: 0.85rem; color: var(--label-color); min-height: 1.25rem; margin: 0.75rem 0 0; }
#error-message.is-error { color: #B91C1C; }
.login-help { margin: 1.75rem 0 0; padding-top: 1.5rem; border-top: 1px solid var(--border-color); font-size: 0.9rem; color: var(--label-color); text-align: center; }
.login-contact { margin: 0.75rem 0 0; font-size: 0.9rem; color: var(--label-color); text-align: center; }
.login-contact a { color: var(--ground); font-weight: 700; text-decoration: none; }
.login-contact a:hover { color: var(--primary-accent); }

/* Brand panel: an amber gradient, a faint dot grid fading down, a stacked feed. */
.login-brand-side {
    display: none; flex: 1; position: relative; overflow: hidden; color: #010101;
    background: radial-gradient(120% 90% at 100% 0%, #F8D49C 0%, #EEA23F 45%, #E08A22 100%);
}
.login-dots {
    position: absolute; inset: 0; opacity: 0.6;
    background-image: radial-gradient(rgba(1, 1, 1, 0.08) 1px, transparent 1px); background-size: 22px 22px;
    -webkit-mask-image: linear-gradient(to bottom, #000, transparent 85%); mask-image: linear-gradient(to bottom, #000, transparent 85%);
}
.login-brand-inner { position: relative; width: 100%; display: flex; flex-direction: column; justify-content: space-between; padding: 4rem; box-sizing: border-box; }
.login-eyebrow { margin: 0; font-family: var(--font-mono); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.22em; }
.login-brand-body { max-width: 28rem; display: flex; flex-direction: column; gap: 2.5rem; }
.login-wordmark {
    margin: 0; font-family: var(--font-display); font-stretch: 125%; font-weight: 700;
    /* Scales with the window so it fits the panel at 1024px; caps at Waitlist's 80px. */
    font-size: clamp(52px, 5.5vw, 80px); line-height: 0.92; letter-spacing: -0.02em; white-space: nowrap;
}
/* Waitlist ends its name with a navy "!"; Optimize ends with the mark's lit room. */
.login-wordmark-room {
    display: inline-block; width: 0.26em; height: 0.26em; margin-left: 0.06em;
    border-radius: 22%; background: var(--ground); vertical-align: baseline;
}
.login-by-line { margin: 1rem 0 0; font-family: var(--font-mono); font-size: 1.125rem; letter-spacing: 0.04em; }
.login-pitch { margin: 1.5rem 0 0; font-size: 1.125rem; line-height: 1.6; color: #1A1A19; }
.login-feed { position: relative; height: 264px; }
.feed-card {
    position: absolute; background: #fff; border-radius: 14px; padding: 1rem 1.25rem;
    box-shadow: 0 18px 40px -12px rgba(58, 28, 8, 0.4);
}
.feed-card p { margin: 0; font-size: 14px; line-height: 1.6; color: #010101; }
.feed-1 { top: 0; left: 1.5rem; right: 0; transform: rotate(-1.5deg); opacity: 0.85; }
.feed-2 { top: 80px; left: 0; right: 1rem; transform: rotate(0.75deg); }
.feed-3 { top: 172px; left: 2.5rem; right: -0.5rem; transform: rotate(-0.5deg); }
.feed-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.4rem; }
.feed-label { font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: 0.14em; color: #5E5E5A; }
.feed-chip { font-family: var(--font-mono); font-size: 9px; text-transform: uppercase; letter-spacing: 0.1em; padding: 2px 8px; border-radius: 4px; white-space: nowrap; }
.chip-neutral { background: #F0F0EC; color: #3A3A38; }
.chip-amber { background: #FCEBCF; color: #7C4317; }
.chip-green { background: #E4F6EA; color: #1F7A44; }
.login-legal { display: flex; gap: 1.5rem; font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; }
.login-legal a { color: rgba(1, 1, 1, 0.7); text-decoration: none; }
.login-legal a:hover { color: #010101; }

@media (min-width: 1024px) {
    .login-form-side { padding: 3rem 5rem; }
    .login-form-side::before, .login-mobile-mark { display: none; }
    .login-brand-side { display: flex; }
}
@media (min-width: 1280px) {
    .login-form-side { padding: 3rem 6rem; }
}

/* --- TOGGLE SWITCH --- */
.toggle-container { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border-color); display: flex; align-items: center; justify-content: space-between; }
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0;}
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: var(--border-color); transition: .3s; border-radius: 24px; }
.slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: white; transition: .3s; border-radius: 50%; box-shadow: var(--shadow-sm); }
input:checked + .slider { background-color: var(--amber-strong); }
input:checked + .slider:before { transform: translateX(20px); }

/* --- OOO STYLES --- */
.ooo-stack { display: flex; flex-direction: column; gap: 1rem; background: var(--bg-color); padding: 1.25rem; border-radius: var(--radius-md); border: 1px solid var(--border-color); }
.input-group { display: flex; flex-direction: column; width: 100%; }
.input-group label { font-size: 0.75rem; font-weight: 600; margin-bottom: 0.35rem; color: var(--label-color); text-transform: uppercase; letter-spacing: 0.5px; }

/* --- STATS GRIDS --- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
/* Typographic stat cards: no card chrome at all. Oversized numerals carry the
   emphasis; the label is demoted beneath a hairline rule. column-reverse puts
   the value visually on top while the HTML keeps its h4-then-value order, so no
   markup changes are needed anywhere that renders a .stat-card. */
.stat-card {
  background: transparent;
  border: none;
  box-shadow: none;
  border-radius: 0;
  padding: 0;
  text-align: left;
  display: flex;
  flex-direction: column-reverse;
}
.stat-card h4 {
  color: var(--label-color);
  font-family: var(--font-mono);
  font-stretch: normal;
  font-size: 0.68rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  border-top: 1px solid var(--border-color);
  margin: 0.5rem 0 0 0;
  padding-top: 0.4rem;
}
.stat-card .value {
  font-family: var(--font-display);
  font-stretch: 125%;
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--heading-color);
}
.stat-card.success .value { color: #0F6B52; }
.stat-card.primary .value { color: #262625; }
.stat-card.warning .value { color: #5E5E5A; }
.stat-card.neutral .value { color: #262625; }

/* --- LOADER --- */
#loader { display: none; text-align: center; padding: 3rem; color: var(--label-color); font-weight: 500; font-size: 1rem; }
.spinner { border: 3px solid var(--border-light); border-radius: 50%; border-top: 3px solid var(--primary-accent); width: 32px; height: 32px; animation: spin 0.8s linear infinite; margin: 0 auto 1rem; }

/* --- ANIMATIONS --- */
.hidden { display: none !important; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleUp { from { opacity: 0; transform: scale(0.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* Staggered entry classes injected by JS */
.stagger-item { opacity: 0; animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards; }

/* View Transitions Support (Chrome 111+) */
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.3s; }

/* =========================================================================
   ADMIN MODULE CSS 
   ========================================================================= */
.admin-page { position: fixed; inset: 0; z-index: 2500; display: flex; flex-direction: column; background: #F0F0EC; overflow-y: auto; animation: adminFade .3s ease both; }
@keyframes adminFade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* Admin bands: the public site's dark hero ground with its amber glow. */
.admin-header { background: radial-gradient(55% 140% at 90% 0%, rgba(238, 162, 63, 0.26), transparent 70%), var(--ground); color: #fff; padding: 2.25rem 2.5rem; flex-shrink: 0; }
.admin-header-inner { max-width: 1240px; margin: 0 auto; display: flex; justify-content: space-between; align-items: flex-start; gap: 1.5rem; flex-wrap: wrap; }
.admin-eyebrow { display: flex; align-items: center; gap: .75rem; font-family: var(--font-mono); font-size: .7rem; font-weight: 500; letter-spacing: .16em; text-transform: uppercase; color: rgba(255,255,255,.65); margin-bottom: .9rem; }
.admin-eyebrow .mark { width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; color: #fff; }
.mark svg { width: 100%; height: 100%; }
.admin-header h1 { font-size: 1.9rem; font-weight: 800; letter-spacing: -.02em; margin: 0 0 .5rem; }
.admin-header p { margin: 0; font-size: 1rem; line-height: 1.5; color: rgba(255,255,255,.8); max-width: 640px; }
.admin-header-actions { display: flex; gap: .75rem; flex-shrink: 0; }

.btn-ghost-light { background: rgba(255,255,255,.1); color: #fff; border: 1px solid rgba(255,255,255,.25); padding: .7rem 1.15rem; border-radius: 8px; font-family: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; transition: background .15s; }
.btn-ghost-light:hover { background: rgba(255,255,255,.2); }
.btn-on-dark { background: var(--amber); color: #010101; border: none; padding: .75rem 1.25rem; border-radius: var(--radius-md); font-family: var(--font-mono); font-weight: 500; font-size: .75rem; text-transform: uppercase; letter-spacing: .1em; cursor: pointer; display: inline-flex; align-items: center; gap: .5rem; box-shadow: 0 6px 16px rgba(0,0,0,.18); transition: transform .15s; }
.btn-on-dark:hover { transform: translateY(-1px); }

.admin-body { flex: 1; padding: 1.75rem 2.5rem 3rem; }
.admin-body-inner { max-width: 1240px; margin: 0 auto; }

.admin-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.75rem; }
.admin-stat { background: #fff; border: 1px solid #E4E4DE; border-radius: 12px; padding: 1.15rem 1.35rem; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.admin-stat .label { font-family: var(--font-mono); font-size: .68rem; font-weight: 500; letter-spacing: .12em; text-transform: uppercase; color: #5E5E5A; margin-bottom: .4rem; }
.admin-stat .value { font-family: var(--font-display); font-stretch: 125%; font-size: 1.7rem; font-weight: 700; color: #1A1A19; }
.admin-stat .value.accent { color: #9A5416; }

.admin-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.admin-search { position: relative; flex: 1; min-width: 240px; max-width: 380px; }
.admin-search svg { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: #A8A8A2; }
.admin-search input { width: 100%; padding: .65rem .9rem .65rem 2.4rem; font-family: inherit; font-size: .9rem; color: #1A1A19; background: #fff; border: 1px solid #E4E4DE; border-radius: 8px; }
.admin-search input:focus { outline: none; border-color: #9A5416; box-shadow: 0 0 0 3px rgba(238, 162, 63,.12); }
.admin-count { font-size: .85rem; color: #5E5E5A; }
.admin-count strong { color: #1A1A19; }

.admin-table-card { background: #fff; border: 1px solid #E4E4DE; border-radius: 14px; box-shadow: 0 1px 3px rgba(0,0,0,.06); overflow: hidden; }
.admin-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.admin-table thead tr { background: #F7F7F5; border-bottom: 1px solid #E4E4DE; }
.admin-table th { text-align: left; padding: .9rem 1rem; font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #5E5E5A; }
.admin-table th:first-child { padding-left: 1.5rem; }
.admin-table th:last-child { padding-right: 1.5rem; text-align: right; }
.admin-table td { padding: 1rem; border-bottom: 1px solid #F0F0EC; vertical-align: middle; }
.admin-table td:first-child { padding-left: 1.5rem; }
.admin-table td:last-child { padding-right: 1.5rem; }
.admin-table tbody tr:hover { background: #FEF7EC; }

.admin-user { display: flex; align-items: center; gap: .85rem; }
.admin-avatar { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; color: #fff; }
.admin-user .name { font-weight: 600; color: #1A1A19; }
.admin-user .email { font-size: .82rem; color: #5E5E5A; }

.role-pill { display: inline-flex; align-items: center; gap: .4rem; padding: .3rem .65rem; border-radius: 9999px; font-size: .76rem; font-weight: 600; }
.role-pill .dot { width: 6px; height: 6px; border-radius: 50%; }
.role-pill.admin { background: #FEF7EC; color: #9A5416; }
.role-pill.admin .dot { background: #9A5416; }
.role-pill.propadmin { background: #ECFDF5; color: #047857; }
.role-pill.propadmin .dot { background: #047857; }
.role-pill.user { background: #F0F0EC; color: #5E5E5A; }
.role-pill.user .dot { background: #5E5E5A; }

.prop-all { display: inline-flex; align-items: center; padding: .28rem .6rem; border-radius: 6px; font-size: .74rem; font-weight: 600; background: #FEF7EC; color: #9A5416; }
.prop-chips { display: flex; flex-wrap: wrap; gap: .35rem; max-width: 320px; }
.prop-chip { display: inline-flex; align-items: center; padding: .24rem .5rem; border-radius: 6px; font-size: .72rem; font-weight: 600; background: #F0F0EC; color: #5E5E5A; font-family: var(--font-mono); }

.admin-lastseen { color: #5E5E5A; white-space: nowrap; }
.admin-row-actions { display: flex; gap: .4rem; justify-content: flex-end; }
.icon-action { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; background: #fff; border: 1px solid #E4E4DE; border-radius: 8px; color: #5E5E5A; cursor: pointer; transition: all .15s; }
.icon-action.edit:hover { border-color: #9A5416; color: #9A5416; background: #FEF7EC; }
.icon-action.remove:hover { border-color: #EF4444; color: #EF4444; background: #FEF2F2; }
.admin-empty { padding: 3.5rem 1rem; text-align: center; color: #A8A8A2; font-size: .95rem; }

/* ---- create/edit form ---- */
.admin-form-card { max-width: 960px; margin: 0 auto; background: #fff; border: 1px solid #E4E4DE; border-radius: 14px; box-shadow: 0 1px 3px rgba(0,0,0,.06); padding: 2.25rem; display: flex; flex-direction: column; gap: 2.25rem; }
.admin-header.narrow .admin-header-inner { max-width: 960px; }
.admin-crumb { display: flex; align-items: center; gap: .5rem; font-family: var(--font-mono); font-size: .7rem; font-weight: 500; letter-spacing: .16em; text-transform: uppercase; color: rgba(255,255,255,.65); margin-bottom: .9rem; }
.admin-crumb a { color: rgba(255,255,255,.65); text-decoration: none; }
.admin-crumb a:hover { color: #fff; }

.field-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.field label { display: block; font-weight: 600; color: #1A1A19; margin-bottom: .55rem; font-size: .92rem; }
.field input { width: 100%; padding: .75rem .85rem; border: 1px solid #E4E4DE; border-radius: 8px; font-family: inherit; font-size: .95rem; color: #1A1A19; }
.field input:focus { outline: none; border-color: #9A5416; box-shadow: 0 0 0 3px rgba(238, 162, 63,.12); }

.role-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.role-card { padding: 1.1rem 1.2rem; cursor: pointer; border: 2px solid #E4E4DE; background: #fff; border-radius: 10px; transition: all .15s; }
.role-card.selected { border-color: #9A5416; background: #FEF7EC; }
.role-card .rc-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .4rem; }
.role-card .rc-title { font-weight: 700; color: #1A1A19; font-size: 1.02rem; }
.role-card .rc-desc { color: #5E5E5A; font-size: .86rem; line-height: 1.45; }
.radio { width: 18px; height: 18px; border-radius: 50%; border: 2px solid #D8D8D2; display: inline-flex; align-items: center; justify-content: center; }
.role-card.selected .radio { border-color: #9A5416; }
.radio .rdot { width: 8px; height: 8px; border-radius: 50%; background: transparent; }
.role-card.selected .radio .rdot { background: #9A5416; }

.assign-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .75rem; }
.assign-head label { font-weight: 600; color: #1A1A19; font-size: .92rem; }
.assign-hint { font-size: .82rem; color: #5E5E5A; }
.assign-hint.locked { color: #9A5416; }
.prop-grid { border: 1px solid #E4E4DE; border-radius: 10px; background: #F7F7F5; padding: 1.15rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .6rem; }
.prop-grid.locked { opacity: .5; pointer-events: none; }
.prop-opt { display: flex; align-items: center; gap: .55rem; padding: .6rem .7rem; background: #fff; border: 1px solid #E4E4DE; border-radius: 8px; cursor: pointer; transition: all .15s; }
.prop-opt.on { background: #FEF7EC; border-color: #F8D49C; }
.prop-box { width: 17px; height: 17px; border-radius: 5px; flex-shrink: 0; border: 2px solid #D8D8D2; background: #fff; display: inline-flex; align-items: center; justify-content: center; }
.prop-opt.on .prop-box { border-color: #9A5416; background: #9A5416; }
.prop-box svg { opacity: 0; }
.prop-opt.on .prop-box svg { opacity: 1; }
.prop-opt .code { font-family: var(--font-mono); font-size: .8rem; font-weight: 600; color: #3A3A38; }

.admin-note { background: #FEF3C7; border: 1px solid #FDE68A; color: #92400E; padding: 1rem 1.15rem; border-radius: 10px; display: flex; gap: .85rem; align-items: flex-start; }
.admin-note p { margin: 0; line-height: 1.5; font-size: .9rem; }

/* =========================================================================
   SIDE NAVIGATION PANEL
   ========================================================================= */
.app-side-panel-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  z-index: 2999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.app-side-panel-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.app-side-panel {
  position: fixed;
  top: 0;
  right: -320px; /* Hidden off-screen to the right */
  width: 320px;
  height: 100vh;
  background-color: #F7F7F5;
  box-shadow: -4px 0 25px rgba(0, 0, 0, 0.1);
  z-index: 3000;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  border-left: 1px solid #E4E4DE;
}

.app-side-panel.active {
  right: 0; /* Slide in */
}

/* Gemini-style Pill Buttons */
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 18px;
  margin: 4px 16px;
  border-radius: 9999px; /* Full pill shape */
  color: #262625;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.sidebar-link .material-icons {
  color: #5E5E5A;
  font-size: 1.25rem;
  transition: color 0.2s ease;
}

.sidebar-link:hover {
  background-color: #FEF7EC; /* Light purple accent */
  color: #100A05;
}

.sidebar-link:hover .material-icons {
  color: #100A05;
}

/* Special styling for the Sign Out button */
.sidebar-link.danger-link:hover {
  background-color: #FEF2F2;
  color: #DC2626;
}
.sidebar-link.danger-link:hover .material-icons {
  color: #DC2626;
}

/* Make Admin/Portal page titles white */
.admin-header h1 {
  color: #FFFFFF !important;
}

/* =========================================================================
   SETTINGS ACCORDION
   Native <details>/<summary>. Collapsed sections keep their inputs in the DOM,
   so readAvailabilityThresholds/readRateThresholds still read them correctly.
   ========================================================================= */
.settings-section {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 0.75rem;
  background: var(--card-bg);
  overflow: hidden;
}
.settings-section > summary {
  padding: 1rem 1.25rem;
  cursor: pointer;
  font-weight: 600;
  color: var(--heading-color);
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  list-style: none;
  transition: background 0.15s;
}
.settings-section > summary::-webkit-details-marker { display: none; }
.settings-section > summary:hover { background: var(--bg-color); }
.settings-section > summary::after {
  content: 'expand_more';
  font-family: 'Material Icons';
  font-size: 1.25rem;
  color: var(--label-color);
  transition: transform 0.2s;
}
.settings-section[open] > summary::after { transform: rotate(180deg); }
.settings-section[open] > summary { border-bottom: 1px solid var(--border-color); }
.settings-section .section-body { padding: 1.25rem; }
.settings-section .section-body > .input-group { margin-bottom: 1rem; }
.settings-section .section-body > .input-group:last-child { margin-bottom: 0; }
.summary-hint {
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--muted-text);
  margin-left: 0.75rem;
}


/* Custom path tier rows (#17) — draggable sort-priority list */
.tier-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0.6rem 0.75rem;
  margin-bottom: 6px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: grab;
}
.tier-row.dragging { opacity: 0.4; }
.tier-row.drag-over { border-color: var(--primary-accent); }
.tier-row .handle { color: var(--muted-text); font-size: 1.1rem; cursor: grab; }
.tier-row .tier-label { flex: 1; font-weight: 500; font-size: 0.9rem; }
.tier-row .tier-rank {
  min-width: 22px; height: 22px; border-radius: 50%;
  background: var(--border-light); color: var(--label-color);
  font-size: 0.75rem; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
}
.tier-row.off { opacity: 0.5; }
.tier-row.off .tier-rank { visibility: hidden; }

/* Labels wrap to two lines at some widths; reserving the space keeps every
   value on the same baseline across the row instead of staircasing. */
.stat-card h4 { min-height: 2.4em; display: flex; align-items: flex-start; }

/* Secondary figure under the headline number. Sits BEFORE .value in the DOM
   because the card is column-reverse, which flips it to below. */
.stat-sub {
  font-size: 0.8rem;
  color: var(--label-color);
  margin-top: 0.15rem;
}

/* Status line for the loaded PMS extract. Present in every state, including
   the good one — a banner that only appears on failure trains people not to
   look at it. */
.report-banner { padding: 10px 14px; border-radius: 8px; font-size: 0.85rem; margin-bottom: 1rem; display: flex; align-items: center; gap: 8px; }
.report-banner.hidden { display: none; }
.report-banner.rb-current { background: #F0F0EC; color: #5E5E5A; }
.report-banner.rb-stale   { background: #FEF3C7; color: #92400E; font-weight: 500; }
.report-banner.rb-unknown { background: #FEF3C7; color: #92400E; }
.report-banner.rb-future  { background: #FEE2E2; color: #B91C1C; font-weight: 500; }

/* --- PATH PLAYBACK WIDGET (accepted-path animation) ---------------------
   Chrome only. The matrix table inside #pb-grid-container keeps its inline
   styles, so nothing here can change the numbers people read. */
.pb-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-top: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.pb-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem;
}
.pb-title { margin: 0; font-size: 1.1rem; color: var(--heading-color); }
.pb-legend { margin: 4px 0 0 0; font-size: 0.875rem; color: var(--label-color); }
.pb-dot { font-weight: 700; margin-left: 0.75rem; }
.pb-legend .pb-dot:first-child { margin-left: 0; }
.pb-freed { color: #22C55E; }
.pb-taken { color: #EF4444; }

.pb-actions { display: flex; gap: 8px; flex-shrink: 0; }
.pb-btn {
  border: 1px solid transparent; padding: 8px 16px;
  border-radius: 6px; cursor: pointer; font-weight: 600;
  font-family: inherit; font-size: 0.875rem;
}
.pb-primary { background: var(--primary-accent); color: #fff; }
.pb-primary:hover:not(:disabled) { background: var(--primary-hover); }
.pb-ghost { background: var(--border-light); color: #5E5E5A; border-color: #D8D8D2; }
.pb-ghost:hover:not(:disabled) { background: var(--border-color); }
.pb-btn:disabled, .pb-nudge:disabled { opacity: 0.45; cursor: default; }

/* --- transport row --- */
.pb-transport {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin-bottom: 1rem;
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}
.pb-nudge {
  width: 30px; height: 30px; flex-shrink: 0;
  border: 1px solid #D8D8D2; background: var(--card-bg);
  border-radius: 6px; cursor: pointer;
  font-size: 1.1rem; line-height: 1; color: #5E5E5A;
}
.pb-nudge:hover:not(:disabled) { background: var(--border-light); }
.pb-count {
  flex-shrink: 0; font-size: 0.8rem; font-weight: 600;
  color: var(--label-color); min-width: 92px; text-align: right;
  font-variant-numeric: tabular-nums;
}
.pb-speed-wrap {
  flex-shrink: 0; display: flex; align-items: center; gap: 6px;
  font-size: 0.8rem; color: var(--label-color);
}
select.pb-speed {
  padding: 4px 6px; font-family: inherit; font-size: 0.8rem;
  border: 1px solid #D8D8D2; border-radius: 6px;
  background: var(--card-bg); color: var(--text-color);
}

/* Range input needs pseudo-element rules, which is why this widget could not
   stay fully inline-styled. */
.pb-scrub {
  flex: 1; min-width: 120px; height: 6px; margin: 0;
  -webkit-appearance: none; appearance: none;
  background: var(--border-color); border-radius: 3px;
  cursor: pointer; outline: none;
}
.pb-scrub:disabled { cursor: default; opacity: 0.5; }
.pb-scrub:focus-visible { box-shadow: 0 0 0 3px rgba(238, 162, 63, 0.25); }
.pb-scrub::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--primary-accent);
  border: 2px solid #fff; box-shadow: var(--shadow-sm);
  cursor: pointer;
}
.pb-scrub::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--primary-accent);
  border: 2px solid #fff; box-shadow: var(--shadow-sm);
  cursor: pointer;
}
.pb-scrub::-moz-range-track { height: 6px; background: var(--border-color); border-radius: 3px; }

/* --- status + reasoning --- */
.pb-status {
  font-size: 0.95rem; color: var(--primary-accent); font-weight: 600;
  margin-bottom: 0.75rem; min-height: 2.9rem;
  display: flex; align-items: center; flex-wrap: wrap; gap: 0 4px;
  border-left: 3px solid var(--primary-accent); padding-left: 8px;
}
.pb-final {
  font-weight: 600; font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--label-color);
  background: var(--border-light); border-radius: 4px;
  padding: 2px 6px; margin-left: 6px;
}
.pb-why {
  background: #FAF9F5; border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px; margin-bottom: 1rem;
  /* Reserved so a two-line headline plus one effect does not push the grid
     down and back up again on every step. Longer content still grows. */
  min-height: 118px; box-sizing: border-box;
}
.pb-why-head {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--muted-text); margin-bottom: 6px;
}
.pb-why-headline {
  font-size: 0.925rem; font-weight: 600; line-height: 1.45;
  color: var(--heading-color);
}
.pb-why-empty { font-size: 0.875rem; color: var(--label-color); line-height: 1.45; }
.pb-why-list {
  margin: 8px 0 0 0; padding-left: 1.1rem;
  font-size: 0.85rem; color: var(--text-color); line-height: 1.5;
}
.pb-why-list li { margin-bottom: 2px; }
.pb-why-warn { color: #92400E; }
.pb-why-warn li::marker { content: '\26A0  '; }
.pb-why-facts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.pb-pill {
  font-size: 0.72rem; font-weight: 600; color: var(--label-color);
  background: var(--card-bg); border: 1px solid var(--border-color);
  border-radius: 999px; padding: 2px 8px;
}
.pb-grid { overflow-x: auto; }

/* --- the matrix itself ---------------------------------------------------
   Fixed layout plus a reserved second line in every cell. Previously the
   (+3 / -1) badge appeared only on cells a move touched, which changed both
   the row height and the column width, so the whole grid jittered as the
   animation ran. Scoped to the widget: .matrix-table is not used elsewhere. */
#pb-grid-container .matrix-table {
  width: 100%; min-width: 880px;
  border-collapse: collapse; table-layout: fixed;
  text-align: center; font-size: 0.875rem;
}
#pb-grid-container .pb-col-label { width: 120px; }
.pb-th, .pb-cell, .pb-rowlabel { border: 1px solid var(--border-color); }
.pb-th {
  padding: 10px 4px; background: var(--bg-color);
  font-weight: 600; color: var(--text-color);
}
.pb-th-label, .pb-rowlabel { text-align: left; padding-left: 12px; }
.pb-rowlabel { font-weight: 700; padding-right: 8px; }
.pb-cell {
  padding: 8px 4px; vertical-align: middle;
  transition: background 0.3s ease, color 0.3s ease;
}
/* Explicit heights, not min-heights: the badge line must occupy space even
   when it is empty, which a min-height on an empty inline-block will not do. */
.pb-cell-count { display: block; font-size: 1rem; line-height: 1.35; height: 1.35em; }
.pb-cell-badge {
  display: block; font-size: 0.68rem; font-weight: 700;
  line-height: 1.2; height: 1.2em; white-space: nowrap;
}

@media (max-width: 720px) {
  .pb-transport { flex-wrap: wrap; }
  .pb-scrub { order: 5; flex-basis: 100%; }
  .pb-count { min-width: 0; }
}
