/* Company dashboard (admin.html). Builds on styles.css. */
.admin-page {
  --surface-1: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --baseline: #c3c2b7;
  --series-1: #2a78d6;
  --track: #eef3fa;
  --good: #0ca30c;
  --good-text: #006300;
  --critical: #d03b3b;
}
.admin-page .admin-inner, .admin-wrap { max-width: 1120px; }
.admin-wrap { margin: 0 auto; padding: 16px 16px 48px; }
.top-link { color: #fff; border-color: rgba(255, 255, 255, .35); text-decoration: none; display: inline-flex; align-items: center; }
.admin-h1 { margin: 0 0 8px; font-size: 22px; }

.demo-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.demo-actions { display: flex; gap: 8px; }

/* Filters: one row */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.seg-group { display: inline-flex; background: #e4e9ef; border-radius: 10px; padding: 3px; gap: 2px; }
.seg-group button {
  border: 0; background: transparent; border-radius: 8px; min-height: 38px; padding: 0 12px;
  font: inherit; font-size: 15px; font-weight: 600; color: var(--muted); cursor: pointer;
}
.seg-group button[aria-pressed="true"] { background: #fff; color: var(--brand); box-shadow: 0 1px 3px rgba(16, 24, 40, .12); }
.filters select, .table-tools select, .table-tools input {
  min-height: 42px; border: 1.5px solid var(--line); border-radius: 10px; padding: 0 10px; font: inherit; font-size: 15px; background: #fff; color: var(--text);
}
.rep-filter select { min-width: 190px; }

.admin-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.admin-tabs button {
  border: 0; background: none; font: inherit; font-weight: 700; font-size: 16px; color: var(--muted);
  padding: 10px 12px; border-bottom: 3px solid transparent; margin-bottom: -1px; cursor: pointer; white-space: nowrap;
}
.admin-tabs button[aria-pressed="true"] { color: var(--brand); border-bottom-color: var(--brand-2); }
.load-msg { margin: 8px 0; }

/* Stat tiles */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { background: var(--surface-1); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi-label { font-size: 14px; color: var(--text-secondary); }
.kpi-value { font-size: 30px; font-weight: 650; color: var(--text-primary); line-height: 1.15; margin: 2px 0; }
.kpi-hero .kpi-value { font-size: 48px; }
.kpi-note { font-size: 13px; color: var(--text-muted); }
@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-hero { grid-column: 1 / -1; order: -1; }
}

/* Charts */
.viz-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 900px) { .viz-grid { grid-template-columns: 1fr; } }
.viz-card { background: var(--surface-1); min-width: 0; }
.viz-title { margin: 0; font-size: 17px; color: var(--text-primary); }
.viz-sub { margin: 2px 0 12px; font-size: 14px; color: var(--text-secondary); }
.chart { width: 100%; min-height: 40px; position: relative; }
.chart svg { display: block; overflow: visible; }
.chart .bar { fill: var(--series-1); }
.chart .track { fill: var(--track); }
.chart .grid { stroke: var(--gridline); stroke-width: 1; shape-rendering: crispEdges; }
.chart .axis { stroke: var(--baseline); stroke-width: 1; shape-rendering: crispEdges; }
.chart .t-label { font-size: 14px; font-weight: 600; fill: var(--text-primary); }
.chart .t-muted { font-size: 13px; font-weight: 400; fill: var(--text-secondary); }
.chart .t-value { font-size: 14px; font-weight: 600; fill: var(--text-primary); font-variant-numeric: tabular-nums; }
.chart .t-tick { font-size: 12px; fill: var(--text-muted); font-variant-numeric: tabular-nums; }
.viz-tip {
  position: fixed; z-index: 60; pointer-events: none; background: #fff; color: var(--text-primary);
  border: 1px solid rgba(11, 11, 11, .10); border-radius: 8px; padding: 8px 10px; font-size: 14px; line-height: 1.35;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .14); max-width: 260px;
}
.viz-table { margin-top: 10px; font-size: 14px; }
.viz-table summary { cursor: pointer; color: var(--brand-2); font-weight: 600; }
.viz-table table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.viz-table th, .viz-table td { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: left; }

/* Tables */
.table-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.table-tools input[type="search"] { flex: 1 1 240px; min-width: 0; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.data-table th {
  text-align: left; font-size: 13px; font-weight: 600; color: var(--text-secondary); padding: 8px 10px;
  border-bottom: 1px solid var(--baseline); white-space: nowrap; position: sticky; top: 0; background: #fff;
}
.data-table td { padding: 9px 10px; border-bottom: 1px solid var(--gridline); vertical-align: top; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.data-table .nowrap { white-space: nowrap; }
.data-table .wrap-cell { min-width: 160px; max-width: 280px; }
.data-table .sub { color: var(--text-muted); font-size: 13px; }
.data-table .empty-cell { text-align: center; color: var(--muted); padding: 24px; }
.data-table a { color: var(--brand-2); }
.status-select { min-height: 36px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 14px; background: #fff; }

/* Status: icon + label, never color alone */
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; background: #eef0f3; color: var(--text-secondary); }
.pill-approved { background: #e7f0fb; color: #1c5cab; }
.pill-sent { background: #e7f0fb; color: #1c5cab; }
.pill-signed { background: #e3f4e3; color: var(--good-text); }
.pill-lost { background: #fbeaea; color: #a02c2c; }

/* Team map (Map tab) */
.map-tools { align-items: center; }
.team-map { height: min(68vh, 620px); min-height: 360px; border-radius: 12px; border: 1px solid var(--gridline); margin-top: 10px; z-index: 0; }
.map-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 14px; color: var(--text-secondary); margin-top: 10px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.2); }
.map-pop { font-size: 14px; line-height: 1.4; }
.map-pop ul { margin: 6px 0; padding-left: 18px; }
.map-pop .sub { color: var(--text-muted); font-size: 13px; }

/* Statuses after signing */
.pill-deposit_paid, .pill-in_progress, .pill-completed_unpaid { background: #e3f4e3; color: var(--good-text); }
.pill-completed_paid { background: #0ca30c; color: #fff; }
.pdf-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.pdf-btns .btn { min-height: 32px; padding: 0 10px; font-size: 13px; }

/* Services tab */
.kpis-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.viz-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; align-items: flex-start; }

/* Team */
.invite-form { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.invite-form input, .invite-form select { min-height: 42px; border: 1.5px solid var(--line); border-radius: 10px; padding: 0 10px; font: inherit; font-size: 15px; flex: 1 1 180px; min-width: 0; }
.invite-form .btn { flex: none; min-height: 42px; }
.inv-msg { margin-top: 10px; font-size: 15px; }
.inv-msg .ok { color: var(--good-text); }
.inv-msg .bad { color: var(--error); }
.inv-link { display: flex; gap: 6px; margin-top: 6px; }
.inv-link input { flex: 1; min-width: 0; min-height: 36px; font-size: 13px; border: 1px solid var(--line); border-radius: 8px; padding: 0 8px; }
.row-off td { color: var(--text-muted); }
.team-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.code-tag { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; letter-spacing: .05em; }

/* Map: GPS check-in icon (diamond) and far-away flag */
.gps-icon { width: 10px; height: 10px; opacity: .9; transform: rotate(45deg); border: 2px solid #fff; box-shadow: 0 0 0 1.5px #17212b; background: #17212b; }
.gps-icon.far { background: #d03b3b; box-shadow: 0 0 0 1.5px #a02c2c; }
.legend-gps { width: 10px; height: 10px; transform: rotate(45deg); background: #17212b; display: inline-block; margin: 0 2px; }
.legend-gps.far { background: #d03b3b; }
.kpi-value.kpi-text { font-size: 22px; }
.danger-btn { color: var(--error); }

.map-tools select { width: auto; flex: 0 1 auto; min-width: 0; }
@media (max-width: 600px) { .map-tools select { flex: 1 1 45%; } }
.table-tools select { width: auto; flex: 0 1 auto; min-width: 0; }
.table-tools .btn { flex: none; }
.status-select { width: auto; min-width: 190px; }

/* Customers: other salespeople who quoted the same customer */
.also { margin-top: 4px; }
.also-row { font-size: 0.85em; line-height: 1.35; }

/* ---------- Step 7 ---------- */
.custom-range { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.custom-range input[type="date"] { min-height: 42px; border: 1.5px solid var(--line); border-radius: 10px; padding: 0 8px; font: inherit; font-size: 15px; background: #fff; }
.inline-check { display: inline-flex; align-items: center; gap: 6px; font-size: 15px; }
.inline-check input[type="number"] { width: 110px; min-height: 38px; border: 1.5px solid var(--line); border-radius: 8px; padding: 0 8px; font: inherit; }
.small-link { font-size: 13px; padding: 0; min-height: 0; margin-top: 4px; }
.data-table tr.locked td { color: var(--text-muted); }
.data-table tr.row-total td { font-weight: 650; border-top: 1px solid var(--baseline); }
.data-table tr.row-off td { font-style: italic; }
.detail-row { border-bottom: 1px solid var(--gridline); padding: 10px 0; font-size: 15px; }
.detail-row:last-child { border-bottom: 0; }
.modal-wide { max-width: 640px; max-height: 86vh; overflow-y: auto; }
.chart-legend { margin: 0 0 8px; }
.chart .band .xhair { stroke: var(--baseline); stroke-width: 1; opacity: 0; }
.chart .band:hover .xhair { opacity: 1; }
.kpis-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 600px) { .kpis-3 { grid-template-columns: 1fr 1fr; } }

/* Lead matrix: sequential blue, darker = higher conversion */
.heat-table td.heat { text-align: center; line-height: 1.2; border: 2px solid var(--surface-1); border-radius: 6px; }
.heat-table td.heat span { font-size: 12px; opacity: .85; }
.heat-table td.heat-empty { text-align: center; color: var(--text-muted); }

/* Settings, prices */
.setting-row { margin-top: 6px; }
.price-h { font-size: 16px; margin: 18px 0 8px; }
.price-h .sub { font-weight: 400; font-size: 13px; color: var(--text-muted); }
.price-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px 14px; }
.price-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--text-secondary); font-weight: 600; }
.price-grid input, .price-grid select, .price-svcs input, .price-svcs select, .add-svc input, .add-svc select {
  min-height: 40px; border: 1.5px solid var(--line); border-radius: 8px; padding: 0 8px; font: inherit; font-size: 15px; background: #fff; color: var(--text); width: 100%; min-width: 0;
}
.price-svcs input[type="number"] { width: 100px; }
.price-svcs input:not([type]) { min-width: 160px; }
.price-svcs .pick-box.small { width: 22px; height: 22px; min-height: 0; }
.add-svc { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.add-svc input { flex: 2 1 200px; width: auto; }
.add-svc select { flex: 1 1 200px; width: auto; }
.price-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; }
#priceMsg, #listMsg, #setMsg, #backupMsg { font-size: 15px; }
#priceMsg .ok, #listMsg .ok, #setMsg .ok { color: var(--good-text); }
#priceMsg .bad, #listMsg .bad, #setMsg .bad { color: var(--error); }
#leadSourcesBox { width: 100%; min-height: 150px; border: 1.5px solid var(--line); border-radius: 10px; padding: 8px 10px; font: inherit; font-size: 15px; }

/* Storage meter and backup progress */
.meter, .progress { height: 14px; border-radius: 7px; background: var(--track); overflow: hidden; margin: 8px 0; }
.meter-fill, .progress-fill { height: 100%; width: 0; background: var(--series-1); border-radius: 7px; transition: width .3s; }
.meter.warn .meter-fill { background: #eda100; }
.meter.full .meter-fill { background: var(--critical); }
.store-line { font-size: 15px; margin: 4px 0 10px; }
.owner-box { margin-top: 6px; }
.sched-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 8px 0; }
.sched-row select, .sched-row input[type="number"] { min-height: 42px; border: 1.5px solid var(--line); border-radius: 10px; padding: 0 10px; font: inherit; font-size: 15px; background: #fff; }
.sched-row input[type="number"] { width: 90px; }
.data-table .legend-dot { display: inline-block; vertical-align: -1px; border: 0; box-shadow: none; width: 10px; height: 10px; }
.price-svcs select { min-width: 190px; } .price-grid .sub { font-weight: 400; font-size: 12px; color: var(--text-muted); }
.table-tools input[type="checkbox"], .sched-row input[type="checkbox"], .inline-check input[type="checkbox"] {
  width: 20px; height: 20px; min-height: 0; flex: none; padding: 0; margin: 0; accent-color: var(--brand); }
.table-tools label.inline-check, .sched-row label { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }

/* Step 8: Email, Logs, Data tabs */
.tab-badge { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 10px; background: var(--error); color: #fff; font-size: 12px; line-height: 20px; text-align: center; }
.mail-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 10px; }
.mail-form label, .ret-grid label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 14px; color: var(--text-secondary); }
.mail-form .wide { grid-column: 1 / -1; }
.mail-form input, .mail-form select, .mail-form textarea, .ret-grid select, .test-row input, .fix-addr, .del-search {
  min-height: 42px; border: 1.5px solid var(--line); border-radius: 10px; padding: 8px 10px; font: inherit; font-size: 15px; background: #fff; color: var(--text); width: 100%; box-sizing: border-box;
}
.mail-form textarea { resize: vertical; font-family: inherit; }
@media (max-width: 700px) { .mail-form { grid-template-columns: 1fr; } }
.test-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.test-row input { max-width: 320px; }
.ret-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin: 12px 0; }
.fix-addr { min-width: 210px; }
.row-msg { font-size: 13px; }
.del-search { max-width: 420px; margin: 10px 0 6px; }
.viz-h3 { margin: 16px 0 6px; font-size: 15px; color: var(--text-secondary); }
.kpis-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.kpis-5 .kpi-value { font-size: 26px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.log-pre { white-space: pre-wrap; word-break: break-all; max-width: 520px; max-height: 240px; overflow: auto; background: #f4f6f8; padding: 8px; border-radius: 8px; font-size: 12px; }
.log-table tr.log-error td { background: #fdf0ef; }
.log-table tr.log-warn td { background: #fffaeb; }
.link-btn.danger, .danger { color: var(--error); }
.ns-off { opacity: .6; }
@media (max-width: 900px) { .kpis-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.del-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; border-bottom: 1px solid var(--gridline); padding: 10px 0; }

/* ---------- Step 9 ---------- */
/* Tabs: wrap onto 2-3 rows on a narrow screen; past 12 the rest go under "More" (admin.js layoutTabs) */
.admin-tabs { flex-wrap: wrap; overflow: visible; row-gap: 0; position: relative; }
.admin-tabs button { padding: 10px 11px; }
.tab-more { position: relative; display: flex; }
.tab-more[hidden] { display: none; }
.tab-more-btn.active { color: var(--brand); border-bottom-color: var(--brand-2) !important; }
.tab-more-btn.has-badge::after { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--error); margin-left: 6px; vertical-align: middle; }
.tab-menu { position: absolute; right: 0; top: 100%; z-index: 600; background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.16); padding: 6px; min-width: 200px; display: grid; }
.tab-menu[hidden] { display: none; }
.admin-tabs .tab-menu button { text-align: left; border-bottom: 0; border-left: 3px solid transparent; margin: 0; border-radius: 6px; padding: 10px 12px; }
.admin-tabs .tab-menu button[aria-pressed="true"] { border-left-color: var(--brand-2); background: #eef4fa; }
.admin-tabs .tab-menu button:hover { background: #f3f6f9; }
@media (max-width: 640px) {
  .tab-more { flex-basis: auto; }
  .tab-menu { right: auto; left: 0; }
}
.older-toggle { white-space: nowrap; font-size: 14px; }
.list-gap { margin-top: 18px; }

/* CSV export panel */
.csv-panel { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin: 10px 0 14px; background: #fafcfe; }
.csv-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.csv-count { color: var(--muted); font-size: 14px; }
.csv-cols summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.csv-col-tools { display: flex; gap: 14px; margin: 4px 0 8px; }
.csv-col-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; max-height: 360px; overflow: auto; }
.csv-group { border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px 8px; margin: 0; display: grid; gap: 2px; }
.csv-group legend { font-weight: 700; font-size: 13px; color: var(--muted); padding: 0 4px; }
.csv-group .inline-check { font-size: 14px; }
.csv-preview { max-height: 420px; overflow: auto; margin-top: 8px; }
.csv-preview td, .csv-preview th { white-space: nowrap; font-size: 13px; }

/* Commission */
.com-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px 16px; margin: 6px 0 10px; }
.com-form label { display: grid; gap: 4px; font-weight: 600; font-size: 14px; }
.com-form .wide { grid-column: 1 / -1; }
.com-form fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px 12px; display: grid; gap: 8px; }
.com-form legend { font-weight: 700; font-size: 14px; padding: 0 4px; }
.com-form [hidden] { display: none !important; }
.com-form .inline-check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.com-form .inline-check input { width: 90px; }

/* Logs */
.log-switch { margin-bottom: 12px; }
.rep-shot-big { max-width: 100%; border: 1px solid var(--line); border-radius: 8px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.narrow-only { display: none; }
@media (max-width: 640px) {
  .wide-only { display: none; }
  .narrow-only { display: inline; }
  .admin-page .topbar .top-link { padding: 0 10px; }
}

/* TEST sample data (Data -> Sample data) */
.test-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  background: #fde8c8; border: 2px dashed #c46a00; color: #5a3200; }
.test-view-btn[aria-pressed="true"] { background: #fde8c8; border-color: #c46a00; color: #5a3200; }
.test-count { margin: 10px 0; font-weight: 600; }
.test-count .test-break { font-weight: 400; color: var(--muted); font-size: 14px; }
.test-tag { display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .04em; padding: 1px 6px; border-radius: 6px;
  background: #fde8c8; color: #5a3200; border: 1px solid #c46a00; vertical-align: middle; }
