/* ============================================================
   Pinnacle CRM — application chrome.
   Ivory ground, navy ink, clay accent. Newsreader + Inter.
   ============================================================ */
:root{
  --ivory:#F0EEE6; --ivory-2:#F6F4EC; --warm-white:#FAF9F5; --ivory-3:#E9E6DC;
  --navy:#1B3A5C; --navy-deep:#16314D; --ink:#23252A; --ink-soft:#5E6B78;
  --clay:#CC785C; --clay-deep:#B5613F; --clay-tint:rgba(204,120,92,0.16); --clay-tint-2:rgba(204,120,92,0.30);
  --ok:#3F8F5E; --warn:#C9913B; --danger:#B5613F;
  --sans:'Inter','SF Pro Text','Helvetica Neue',Arial,sans-serif;
  --serif:'Newsreader',Georgia,serif;
  --shadow:none;
  --rad:12px;
}
*,*::before,*::after{ box-sizing:border-box; }
html,body{ margin:0; height:100%; background:var(--ivory); color:var(--ink); font-family:var(--sans); font-size:14px; line-height:1.5;
  -webkit-font-smoothing:antialiased; -moz-osx-font-smoothing:grayscale; }
button,input,select,textarea{ font:inherit; color:inherit; }
a{ color:var(--clay); text-decoration:none; }
a:hover{ color:var(--clay-deep); }
::selection{ background:var(--clay-tint-2); }
*{ scrollbar-width:thin; scrollbar-color:var(--ivory-3) transparent; }
*::-webkit-scrollbar{ width:9px; height:9px; }
*::-webkit-scrollbar-thumb{ background:var(--ivory-3); border-radius:8px; border:2px solid transparent; background-clip:content-box; }
*::-webkit-scrollbar-track{ background:transparent; }
h1,h2,h3,h4{ margin:0; font-weight:500; }
.icon{ width:1em; height:1em; display:inline-block; vertical-align:-0.125em; }

#root.booting{ display:flex; align-items:center; justify-content:center; height:100vh; }
#root.booting::after{ content:""; width:26px; height:26px; border:2px solid var(--ivory-3); border-top-color:var(--clay); border-radius:50%; animation:spin .8s linear infinite; }
@keyframes spin{ to{ transform:rotate(360deg); } }

/* ============ LOGIN ============ */
.login-wrap{ min-height:100vh; display:flex; align-items:center; justify-content:center; padding:24px; }
.login-card{ width:100%; max-width:380px; }
.login-brand{ display:flex; align-items:center; gap:14px; margin-bottom:26px; }
.login-brand img{ height:52px; width:auto; }
.login-brand.wordmark img{ height:76px; }
.login-brand.wordmark .sub{ font-family:var(--serif); font-style:italic; font-size:13px; color:var(--ink-soft); margin-top:8px; }
.login-brand .nm{ font-family:var(--serif); font-size:24px; color:var(--navy); line-height:1.1; }
.login-brand .sub{ font-family:var(--serif); font-style:italic; font-size:13px; color:var(--ink-soft); }
.login-card h1{ font-family:var(--serif); font-size:22px; color:var(--navy); margin-bottom:4px; }
.login-card .eyebrow{ margin-bottom:18px; }
.login-card form{ display:flex; flex-direction:column; gap:14px; margin-top:18px; }
.login-error{ color:var(--danger); font-size:13px; min-height:18px; }

/* ============ EYEBROW ============ */
.eyebrow{ font-family:var(--sans); font-weight:600; font-size:11px; letter-spacing:0.30em; text-transform:uppercase; color:var(--clay); display:flex; align-items:center; }
.eyebrow .d{ display:inline-block; width:22px; height:2px; background:var(--clay); margin-right:12px; }

/* ============ APP SHELL ============ */
.app-shell{ display:grid; grid-template-columns:248px 1fr; height:100vh; }
.sidebar{ background:linear-gradient(180deg, var(--navy) 0%, var(--navy-deep) 100%); color:var(--warm-white); display:flex; flex-direction:column; min-height:0; }
.sidebar-brand{ display:flex; align-items:center; gap:11px; padding:18px 20px; border-bottom:1px solid rgba(255,255,255,0.10); }
.sidebar-brand img{ height:30px; width:auto; }
.sidebar-brand img.chip{ background:rgba(255,255,255,0.92); border-radius:7px; padding:2px; }
.sidebar-brand .nm{ font-family:var(--serif); font-size:17px; color:var(--warm-white); line-height:1.05; }
.sidebar-brand .nm small{ display:block; font-family:var(--sans); font-size:9.5px; letter-spacing:0.22em; text-transform:uppercase; color:rgba(255,255,255,0.5); margin-top:2px; }
.nav{ flex:1; overflow-y:auto; padding:14px 12px; display:flex; flex-direction:column; gap:2px; }
.nav a{ display:flex; align-items:center; gap:12px; padding:9px 12px; border-radius:9px; color:rgba(255,255,255,0.72); font-size:13.5px; font-weight:500; transition:background-color .14s,color .14s; }
.nav a .icon{ width:17px; height:17px; opacity:0.8; transition:opacity .14s; }
.nav a:hover{ background:rgba(255,255,255,0.07); color:var(--warm-white); }
.nav a.active{ background:rgba(255,255,255,0.10); color:var(--warm-white); box-shadow:inset 3px 0 0 var(--clay); }
.nav a.active .icon{ opacity:1; color:var(--clay); filter:brightness(1.6); }
.nav .nav-sep{ height:1px; background:rgba(255,255,255,0.08); margin:10px 8px; }
.sidebar-foot{ padding:12px; border-top:1px solid rgba(255,255,255,0.10); }
.user-chip{ display:flex; align-items:center; gap:10px; padding:8px 10px; border-radius:9px; }
.user-chip .av{ width:30px; height:30px; border-radius:50%; background:var(--clay); color:#fff; display:flex; align-items:center; justify-content:center; font-weight:600; font-size:12px; flex-shrink:0; }
.user-chip .meta{ min-width:0; flex:1; }
.user-chip .meta .n{ font-size:13px; color:var(--warm-white); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.user-chip .meta .r{ font-size:10.5px; color:rgba(255,255,255,0.5); text-transform:uppercase; letter-spacing:0.12em; }
.user-chip .logout{ background:none; border:none; color:rgba(255,255,255,0.6); cursor:pointer; padding:4px; border-radius:6px; }
.user-chip .logout:hover{ color:var(--warm-white); background:rgba(255,255,255,0.08); }

.main{ min-width:0; display:flex; flex-direction:column; overflow:hidden; }
.topbar{ height:60px; flex-shrink:0; display:flex; align-items:center; gap:14px; padding:0 24px; background:var(--ivory); border-bottom:1px solid var(--ivory-3); }
.topbar .hamburger{ display:none; background:none; border:none; color:var(--navy); cursor:pointer; }
.search-box{ position:relative; flex:1; max-width:460px; }
.search-box .icon{ position:absolute; left:12px; top:50%; transform:translateY(-50%); width:16px; height:16px; color:var(--ink-soft); }
.search-box input{ width:100%; background:var(--warm-white); border:1px solid var(--ivory-3); border-radius:10px; padding:9px 12px 9px 36px; font-size:13.5px; color:var(--navy); }
.search-box input:focus{ outline:none; border-color:var(--clay); box-shadow:0 0 0 3px var(--clay-tint); }
.search-results{ position:absolute; top:46px; left:0; right:0; background:var(--warm-white); border:1px solid var(--ivory-3); border-radius:12px; z-index:40; overflow:hidden; max-height:60vh; overflow-y:auto; }
.search-results .grp{ font-size:10px; letter-spacing:0.2em; text-transform:uppercase; color:var(--ink-soft); padding:10px 14px 4px; }
.search-results a{ display:block; padding:8px 14px; color:var(--ink); font-size:13px; border-top:1px solid var(--ivory-3); }
.search-results a:hover{ background:var(--ivory); }
.search-results a small{ color:var(--ink-soft); }

.content{ flex:1; overflow-y:auto; padding:26px 28px 60px; }
.page-head{ display:flex; align-items:flex-end; justify-content:space-between; gap:16px; margin-bottom:22px; flex-wrap:wrap; }
.page-head h1{ font-family:var(--serif); font-size:27px; color:var(--navy); letter-spacing:-0.01em; }
.page-head .sub{ color:var(--ink-soft); font-size:13px; margin-top:3px; }
.page-head-actions{ display:flex; gap:8px; flex-wrap:wrap; }

/* ============ BUTTONS ============ */
.btn{ font-family:var(--sans); font-weight:600; font-size:13px; border-radius:10px; padding:9px 15px; border:1.5px solid transparent; cursor:pointer; display:inline-flex; align-items:center; gap:7px; white-space:nowrap; transition:background-color .12s,color .12s,border-color .12s,box-shadow .12s; background:transparent; }
.btn .icon{ width:15px; height:15px; }
.btn:focus-visible{ outline:none; box-shadow:0 0 0 3px var(--clay-tint-2); }
.btn-primary{ background:var(--clay); color:#fff; border-color:var(--clay); box-shadow:0 1px 2px rgba(15,22,35,0.12); }
.btn-primary:hover{ background:var(--clay-deep); border-color:var(--clay-deep); box-shadow:0 2px 6px rgba(15,22,35,0.18); }
.btn-ghost{ background:transparent; color:var(--navy); border-color:var(--navy); }
.btn-ghost:hover{ background:var(--navy); color:var(--warm-white); }
.btn-subtle{ background:var(--warm-white); color:var(--navy); border-color:var(--ivory-3); }
.btn-subtle:hover{ border-color:var(--clay); color:var(--clay-deep); }
.btn-sm{ padding:6px 11px; font-size:12px; border-radius:8px; }
.btn-danger{ background:transparent; color:var(--danger); border-color:var(--danger); }
.btn-danger:hover{ background:var(--danger); color:#fff; }
.btn:disabled{ opacity:0.4; cursor:not-allowed; }
.icon-btn{ background:transparent; border:1px solid transparent; border-radius:8px; width:32px; height:32px; display:inline-flex; align-items:center; justify-content:center; color:var(--ink-soft); cursor:pointer; }
.icon-btn .icon{ width:16px; height:16px; }
.icon-btn:hover{ background:var(--ivory); color:var(--navy); border-color:var(--ivory-3); }
.icon-btn.danger:hover{ color:var(--danger); border-color:var(--danger); }

/* ============ CARDS / GRID ============ */
.cards{ display:grid; grid-template-columns:repeat(auto-fill,minmax(220px,1fr)); gap:14px; }
.card{ background:var(--warm-white); border:1px solid var(--ivory-3); border-radius:var(--rad); padding:16px 18px; box-shadow:var(--shadow); }
.card.clickable{ cursor:pointer; transition:border-color .14s, box-shadow .14s, transform .14s; }
.card.clickable:hover{ border-color:var(--clay); box-shadow:0 2px 4px rgba(15,22,35,0.06), 0 8px 22px rgba(15,22,35,0.09); transform:translateY(-1px); }
.stat{ display:flex; flex-direction:column; gap:3px; }
.stat .lbl{ font-size:11px; letter-spacing:0.14em; text-transform:uppercase; color:var(--ink-soft); }
.stat .val{ font-family:var(--serif); font-size:30px; color:var(--navy); }
.stat .val.clay{ color:var(--clay); }
.panel{ background:var(--warm-white); border:1px solid var(--ivory-3); border-radius:var(--rad); margin-bottom:18px; overflow:hidden; box-shadow:var(--shadow); }
.panel-head{ display:flex; align-items:center; justify-content:space-between; gap:12px; padding:14px 18px; border-bottom:1px solid var(--ivory-3); }
.panel-head h2{ font-family:var(--serif); font-size:18px; color:var(--navy); }
.panel-body{ padding:16px 18px; }
.panel-body.flush{ padding:0; }
.two-col{ display:grid; grid-template-columns:1fr 1fr; gap:18px; }
.grid-2{ display:grid; grid-template-columns:2fr 1fr; gap:18px; align-items:start; }
.col-stack{ display:flex; flex-direction:column; gap:18px; min-width:0; }
.col-stack .panel{ margin-bottom:0; }

/* ============ TABLES / LISTS ============ */
.table{ width:100%; border-collapse:collapse; }
.table th{ text-align:left; font-size:10.5px; letter-spacing:0.16em; text-transform:uppercase; color:var(--ink-soft); font-weight:600; padding:11px 16px; border-bottom:1px solid var(--ivory-3); }
.table th.r,.table td.r{ text-align:right; }
.table td{ padding:13px 16px; border-bottom:1px solid var(--ivory-3); vertical-align:middle; }
.table tr:last-child td{ border-bottom:none; }
.table tbody tr{ cursor:pointer; }
.table tbody tr:hover{ background:var(--ivory-2); }
.table .strong{ color:var(--navy); font-weight:500; }
.table .mono{ font-variant-numeric:tabular-nums; }
.muted{ color:var(--ink-soft); }
.empty{ text-align:center; color:var(--ink-soft); padding:40px 20px; font-size:13.5px; }
.empty .icon{ width:30px; height:30px; opacity:0.4; display:block; margin:0 auto 10px; }

/* ============ BADGES (restrained) ============ */
.badge{ display:inline-flex; align-items:center; gap:6px; font-size:11px; font-weight:600; letter-spacing:0.04em; padding:3px 9px 3px 8px; border-radius:20px; background:var(--warm-white); border:1px solid var(--ivory-3); color:var(--ink-soft); white-space:nowrap; }
.pill{ display:inline-flex; align-items:center; font-size:11.5px; font-weight:600; padding:3px 10px; border-radius:20px; background:var(--ivory-2); border:1px solid var(--ivory-3); color:var(--ink-soft); white-space:nowrap; }
.kpi-active{ border-color:var(--clay) !important; box-shadow:inset 0 -3px 0 var(--clay), var(--shadow) !important; }
.kpi-val{ font-size:24px; }
.kpi-sub{ font-size:12px; min-height:15px; }
.topbar-ico{ width:36px; height:36px; color:var(--ink-soft); }
.topbar-ico:hover{ color:var(--navy); background:var(--warm-white); border-color:var(--ivory-3); }
.badge-dot{ position:absolute; top:3px; right:2px; min-width:15px; height:15px; border-radius:8px; background:var(--danger); color:#fff; font-size:9.5px; font-weight:700; line-height:15px; text-align:center; padding:0 3px; }
.act-row{ display:flex; align-items:center; gap:12px; padding:10px 16px; border-bottom:1px solid var(--ivory-3); font-size:13.5px; }
.act-row:last-child{ border-bottom:none; }
.act-av{ width:28px; height:28px; border-radius:50%; background:var(--navy); color:#fff; display:flex; align-items:center; justify-content:center; font-size:10.5px; font-weight:600; flex-shrink:0; }
.act-main{ flex:1; min-width:0; }
.act-time{ font-size:12px; white-space:nowrap; }
.create-menu{ position:relative; }
.create-pop{ position:absolute; right:0; top:42px; background:var(--warm-white); border:1px solid var(--ivory-3); border-radius:12px; box-shadow:0 4px 18px rgba(15,22,35,0.12); padding:6px; z-index:60; min-width:185px; }
.create-pop a{ display:flex; align-items:center; gap:10px; padding:9px 12px; border-radius:8px; color:var(--ink); font-size:13.5px; font-weight:500; }
.create-pop a:hover{ background:var(--ivory-2); color:var(--navy); }
.create-pop a .icon{ width:16px; height:16px; color:var(--ink-soft); }
.badge::before{ content:""; width:6px; height:6px; border-radius:50%; background:var(--ink-soft); }
.badge-sent::before,.badge-scheduled::before{ background:#5B83A8; }
.badge-danger{ border-color:color-mix(in srgb, var(--danger) 35%, transparent); color:var(--danger); }
.badge-danger::before{ background:var(--danger); }
.badge-approved::before,.badge-completed::before,.badge-paid::before,.badge-done::before{ background:var(--ok); }
.badge-converted::before,.badge-in-progress::before{ background:var(--clay); }
.badge-declined::before,.badge-cancelled::before,.badge-void::before{ background:var(--danger); }
.badge-partial::before,.badge-on-hold::before,.badge-open::before{ background:var(--warn); }

/* ============ FORM FIELDS ============ */
.f-grid{ display:grid; grid-template-columns:1fr 1fr; gap:13px; }
.f-grid .full{ grid-column:1/-1; }
.f-wrap{ display:flex; flex-direction:column; min-width:0; }
.f-label{ font-size:11.5px; font-weight:500; color:var(--ink-soft); margin-bottom:5px; }
.f-input{ background:var(--warm-white); border:1px solid var(--ivory-3); color:var(--navy); font-size:13.5px; padding:9px 12px; border-radius:8px; width:100%; }
.f-input::placeholder{ color:var(--ink-soft); opacity:0.5; }
.f-input:focus{ outline:none; border-color:var(--clay); box-shadow:0 0 0 3px var(--clay-tint); }
textarea.f-input{ resize:vertical; min-height:74px; line-height:1.5; }
.f-hint{ font-size:11px; color:var(--ink-soft); margin-top:4px; }
.select-wrap{ position:relative; }
.select-wrap::after{ content:""; position:absolute; right:12px; top:50%; width:7px; height:7px; border-right:1.5px solid var(--navy); border-bottom:1.5px solid var(--navy); transform:translateY(-70%) rotate(45deg); pointer-events:none; }
select.f-input{ appearance:none; -webkit-appearance:none; padding-right:30px; cursor:pointer; }
.check-row{ display:flex; align-items:center; gap:10px; cursor:pointer; font-size:13px; color:var(--navy); }
.check-row input{ width:16px; height:16px; accent-color:var(--clay); }

/* ============ DETAIL HEADER ============ */
.detail-head{ display:flex; align-items:flex-start; gap:16px; margin-bottom:20px; flex-wrap:wrap; }
.detail-head .back{ margin-top:4px; }
.detail-title{ flex:1; min-width:200px; }
.detail-title h1{ font-family:var(--serif); font-size:25px; color:var(--navy); }
.detail-title .meta{ color:var(--ink-soft); font-size:13px; margin-top:4px; display:flex; gap:14px; flex-wrap:wrap; align-items:center; }
.kv{ display:grid; grid-template-columns:130px 1fr; gap:8px 14px; font-size:13.5px; }
.kv dt{ color:var(--ink-soft); }
.kv dd{ margin:0; color:var(--navy); }

/* ============ MEDIA GRID (canvassing photos) ============ */
.media-grid{ display:grid; grid-template-columns:repeat(auto-fill,minmax(132px,1fr)); gap:12px; }
.media-tile{ position:relative; border:1px solid var(--ivory-3); border-radius:10px; overflow:hidden; background:var(--ivory-2); aspect-ratio:1/1; cursor:pointer; }
.media-tile img{ width:100%; height:100%; object-fit:cover; display:block; }
.media-tile .cap{ position:absolute; left:0; right:0; bottom:0; background:linear-gradient(transparent,rgba(22,49,77,0.78)); color:#fff; font-size:11px; padding:14px 8px 6px; }
.media-tile .del{ position:absolute; top:6px; right:6px; background:rgba(22,49,77,0.7); color:#fff; border:none; border-radius:7px; width:26px; height:26px; display:none; align-items:center; justify-content:center; cursor:pointer; }
.media-tile:hover .del{ display:flex; }
.media-tile.pdf{ display:flex; align-items:center; justify-content:center; color:var(--ink-soft); font-size:12px; text-align:center; padding:10px; }
.attach-grid{ grid-template-columns:repeat(auto-fill,minmax(92px,1fr)); margin-top:4px; }
.attach-grid .media-tile{ aspect-ratio:1/1; }
.attach-grid .media-tile .del{ display:flex; top:4px; right:4px; width:22px; height:22px; }
.uploader{ border:1.5px dashed var(--ivory-3); border-radius:10px; padding:18px; text-align:center; color:var(--ink-soft); font-size:13px; cursor:pointer; transition:border-color .12s,background .12s; }
.uploader:hover,.uploader.drag{ border-color:var(--clay); background:var(--clay-tint); color:var(--clay-deep); }
.uploader .icon{ width:22px; height:22px; display:block; margin:0 auto 8px; }
.upload-row{ display:flex; gap:10px; align-items:center; flex-wrap:wrap; margin-bottom:14px; }

/* ============ NOTES / TIMELINE ============ */
.note-list{ display:flex; flex-direction:column; gap:10px; }
.note{ background:var(--ivory-2); border:1px solid var(--ivory-3); border-radius:10px; padding:11px 14px; }
.note .note-head{ display:flex; justify-content:space-between; gap:10px; font-size:11.5px; color:var(--ink-soft); margin-bottom:4px; }
.note .note-body{ font-size:13.5px; color:var(--ink); white-space:pre-wrap; line-height:1.5; }
.note .author{ font-weight:600; color:var(--navy); }
.add-note{ display:flex; flex-direction:column; gap:8px; margin-bottom:14px; }

/* ============ LIGHTBOX ============ */
.lightbox{ position:fixed; inset:0; background:rgba(22,49,77,0.86); z-index:90; display:flex; align-items:center; justify-content:center; padding:30px; }
.lightbox img{ max-width:94vw; max-height:90vh; border-radius:8px; }
.lightbox .lb-close{ position:absolute; top:18px; right:22px; background:rgba(255,255,255,0.14); color:#fff; border:none; width:40px; height:40px; border-radius:10px; cursor:pointer; font-size:20px; }

/* ============ QUOTE / INVOICE EDITOR (split pane) ============ */
.editor-split{ display:grid; grid-template-columns:minmax(420px,500px) 1fr; gap:0; height:calc(100vh - 60px); margin:-26px -28px -60px; }
.editor-pane{ overflow-y:auto; padding:24px 26px 80px; border-right:1.5px solid var(--clay); }
.editor-pane .form-section{ margin-bottom:26px; }
.editor-pane h2.sec{ font-family:var(--serif); font-size:20px; color:var(--navy); margin:4px 0 14px; }
.preview-pane{ overflow-y:auto; background:var(--ivory-2); padding:30px; }
.preview-frame{ margin:0 auto; overflow:hidden; }
.preview-frame .quote-page{ transform-origin:top left; }
.line-item{ background:var(--warm-white); border:1px solid var(--ivory-3); border-radius:10px; padding:13px 15px; margin-bottom:11px; }
.line-item .li-head{ display:flex; justify-content:space-between; align-items:center; margin-bottom:9px; }
.line-item .li-idx{ font-size:10px; letter-spacing:0.24em; text-transform:uppercase; color:var(--ink-soft); }
.li-row3{ display:grid; grid-template-columns:74px 1fr 1fr; gap:9px; }
.amount-box{ font-family:var(--serif); font-size:14px; color:var(--navy); padding:9px 12px; border:1px dashed var(--ivory-3); border-radius:8px; text-align:right; min-height:38px; font-variant-numeric:tabular-nums; }
.totals-mini{ background:var(--warm-white); border:1px solid var(--ivory-3); border-radius:10px; padding:12px 16px; margin-top:12px; }
.totals-mini .row{ display:flex; justify-content:space-between; padding:5px 0; font-size:13px; }
.totals-mini .row .lbl{ color:var(--ink-soft); text-transform:uppercase; letter-spacing:0.1em; font-size:11px; }
.totals-mini .row .val{ font-family:var(--serif); color:var(--navy); font-variant-numeric:tabular-nums; }
.totals-mini .row.grand{ border-top:1px solid var(--ivory-3); margin-top:5px; padding-top:9px; }
.totals-mini .row.grand .val{ font-size:18px; color:var(--clay); }
.editor-actions{ display:flex; gap:8px; flex-wrap:wrap; align-items:center; padding:14px 26px; border-bottom:1px solid var(--ivory-3); background:var(--ivory); position:sticky; top:0; z-index:5; }
.editor-actions .spacer{ flex:1; }
.editor-actions .created-by{ font-size:12px; color:var(--ink-soft); margin-left:12px; }
details.adv{ border:1px solid var(--ivory-3); border-radius:10px; background:var(--warm-white); margin-top:14px; }
details.adv>summary{ cursor:pointer; list-style:none; padding:11px 14px; font-weight:600; font-size:12px; color:var(--navy); }
details.adv>summary::-webkit-details-marker{ display:none; }
details.adv[open]>summary{ border-bottom:1px solid var(--ivory-3); }
details.adv>div{ padding:14px; }

/* ============ CALENDAR ============ */
.cal-head{ display:flex; align-items:center; justify-content:space-between; margin-bottom:14px; gap:12px; flex-wrap:wrap; }
.cal-head h2{ font-family:var(--serif); font-size:21px; color:var(--navy); }
.cal-grid{ display:grid; grid-template-columns:repeat(7,minmax(0,1fr)); gap:1px; background:var(--ivory-3); border:1px solid var(--ivory-3); border-radius:10px; overflow:hidden; }
.cal-dow{ background:var(--ivory); font-size:10.5px; letter-spacing:0.14em; text-transform:uppercase; color:var(--ink-soft); padding:8px; text-align:center; font-weight:600; }
.cal-cell{ background:var(--warm-white); min-width:0; min-height:104px; padding:6px 7px; display:flex; flex-direction:column; gap:4px; }
.cal-cell.other{ background:var(--ivory-2); }
.cal-cell .dnum{ font-size:12px; color:var(--ink-soft); font-variant-numeric:tabular-nums; }
.cal-cell.today .dnum{ color:#fff; background:var(--clay); width:22px; height:22px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-weight:600; }
.cal-event{ font-size:11px; padding:3px 6px; border-radius:6px; background:var(--clay-tint); color:var(--navy); cursor:pointer; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; border-left:2px solid var(--clay); }
.cal-event.task{ background:rgba(91,131,168,0.16); border-left-color:#5B83A8; }
.cal-event.done{ text-decoration:line-through; opacity:0.55; background:var(--ivory-2); border-left-color:var(--ivory-3); }
.cal-event .cal-sub{ opacity:0.6; }

/* ============ MODAL ============ */
.modal-overlay{ position:fixed; inset:0; background:rgba(22,49,77,0.36); z-index:80; display:flex; align-items:flex-start; justify-content:center; padding:40px 18px; opacity:0; transition:opacity .18s; overflow-y:auto; }
.modal-overlay.show{ opacity:1; }
.modal{ background:var(--ivory); border:1px solid var(--ivory-3); border-radius:16px; width:100%; max-width:480px; transform:translateY(-8px); transition:transform .18s; overflow:hidden; }
.modal-overlay.show .modal{ transform:translateY(0); }
.modal-wide{ max-width:680px; }
.modal-head{ display:flex; align-items:center; justify-content:space-between; padding:16px 20px; border-bottom:1px solid var(--ivory-3); }
.modal-head h3{ font-family:var(--serif); font-size:19px; color:var(--navy); }
.modal-body{ padding:20px; max-height:64vh; overflow-y:auto; }
.modal-body .f-grid{ margin-bottom:0; }
.modal-foot{ display:flex; align-items:center; gap:10px; padding:14px 20px; border-top:1px solid var(--ivory-3); background:var(--warm-white); }
.modal-foot-spacer{ flex:1; }
.confirm-msg{ font-size:14px; line-height:1.55; color:var(--ink); }

/* ============ TOAST ============ */
.toast-host{ position:fixed; bottom:22px; left:50%; transform:translateX(-50%); z-index:100; display:flex; flex-direction:column; gap:8px; align-items:center; }
.toast{ background:var(--navy); color:var(--warm-white); padding:11px 18px; border-radius:10px; font-size:13px; opacity:0; transform:translateY(10px); transition:opacity .2s,transform .2s; max-width:90vw; }
.toast.show{ opacity:1; transform:translateY(0); }
.toast-error{ background:var(--danger); }
.toast-success{ background:var(--ok); }

/* ============ MISC ============ */
.row-actions{ display:flex; gap:4px; justify-content:flex-end; }
.pill-row{ display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
.link-box{ display:flex; gap:8px; align-items:center; background:var(--ivory-2); border:1px solid var(--ivory-3); border-radius:9px; padding:8px 10px; font-size:12.5px; }
.link-box input{ flex:1; border:none; background:transparent; color:var(--navy); font-size:12.5px; }
.link-box input:focus{ outline:none; }
.chanmode{ font-size:10.5px; letter-spacing:0.14em; text-transform:uppercase; color:var(--ink-soft); }
.chanmode.live{ color:var(--ok); }

/* ============ ACCOUNTING EXPORT GRID ============ */
.export-grid{ display:grid; grid-template-columns:repeat(auto-fill,minmax(240px,1fr)); gap:14px; }
.export-card{ border:1px solid var(--ivory-3); border-radius:10px; padding:14px 16px; background:var(--warm-white); display:flex; flex-direction:column; gap:8px; }
.export-card .ec-title{ font-family:var(--serif); font-size:16px; color:var(--navy); }
.export-card .ec-desc{ font-size:12px; color:var(--ink-soft); line-height:1.5; flex:1; }
.export-card .btn{ align-self:flex-start; }
.coa-table td{ padding:6px 8px; }
.coa-table .f-input{ padding:6px 9px; font-size:12.5px; }
.map-grid{ display:grid; grid-template-columns:repeat(auto-fill,minmax(220px,1fr)); gap:10px; }
.map-grid .f-label{ text-transform:capitalize; }

/* ============ WEATHER ============ */
.wx-panel .wx-svg{ width:100%; height:100%; }
.wx-loading{ color:var(--ink-soft); font-size:13px; padding:6px 0; }
.wx-now{ display:flex; align-items:center; gap:14px; }
.wx-big{ width:52px; height:52px; color:var(--clay); flex-shrink:0; }
.wx-meta{ min-width:0; }
.wx-when{ font-size:11px; letter-spacing:0.1em; text-transform:uppercase; color:var(--ink-soft); }
.wx-cond{ font-family:var(--serif); font-size:21px; color:var(--navy); line-height:1.1; }
.wx-stats{ font-size:12.5px; color:var(--ink-soft); margin-top:2px; }
.wx-stats .lo{ color:var(--ink-soft); }
.wx-adv{ margin:12px 0 0; font-size:12.5px; font-weight:600; padding:7px 12px; border-radius:9px; border:1px solid var(--ivory-3); }
.wx-adv.ok{ color:var(--ok); background:rgba(63,143,94,0.08); border-color:rgba(63,143,94,0.25); }
.wx-adv.warn{ color:var(--clay-deep); background:var(--clay-tint); border-color:var(--clay); }
.wx-adv.bad{ color:var(--danger); background:color-mix(in srgb, var(--danger) 8%, transparent); border-color:var(--danger); }
.wx-strip{ display:grid; grid-template-columns:repeat(7,1fr); gap:4px; margin-top:14px; }
.wx-compact .wx-strip{ grid-template-columns:repeat(5,1fr); }
.wx-day{ text-align:center; padding:8px 2px; border-radius:9px; border:1px solid transparent; }
.wx-day.on{ background:var(--clay-tint); border-color:var(--clay); }
.wx-dn{ font-size:10.5px; letter-spacing:0.06em; text-transform:uppercase; color:var(--ink-soft); }
.wx-ic{ width:26px; height:26px; margin:4px auto; color:var(--navy); }
.wx-day.on .wx-ic{ color:var(--clay); }
.wx-hl{ font-size:12.5px; color:var(--navy); font-variant-numeric:tabular-nums; }
.wx-hl .lo{ color:var(--ink-soft); margin-left:3px; }
.wx-pp{ font-size:10.5px; color:#5B83A8; margin-top:1px; min-height:13px; }
.wx-foot{ display:flex; align-items:center; justify-content:space-between; gap:10px; margin-top:14px; flex-wrap:wrap; }
.wx-foot .muted{ font-size:11.5px; }
.wx-aqi{ display:inline-flex; align-items:center; gap:7px; margin-top:10px; font-size:12.5px; font-weight:600; padding:6px 11px; border-radius:9px; border:1px solid var(--ivory-3); }
.wx-aqi .wx-aqi-dot{ width:8px; height:8px; border-radius:50%; flex-shrink:0; }
.wx-aqi.ok{ color:var(--ok); } .wx-aqi.ok .wx-aqi-dot{ background:var(--ok); }
.wx-aqi.warn{ color:var(--warn); } .wx-aqi.warn .wx-aqi-dot{ background:var(--warn); }
.wx-aqi.bad{ color:var(--danger); } .wx-aqi.bad .wx-aqi-dot{ background:var(--danger); }
/* calendar event weather glance */
.cal-wx{ display:inline-block; width:13px; height:13px; vertical-align:-2px; color:var(--navy); margin-right:3px; }
.cal-wx:empty{ display:none; }
.cal-wx .wx-svg{ width:100%; height:100%; }
.cal-event.task .cal-wx{ display:none; }

/* ============ FILTER BAR ============ */
.filter-bar{ display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin-bottom:16px; }
.filter-bar .fb-group{ display:inline-flex; align-items:center; gap:6px; }
.filter-bar .fb-lbl{ font-size:11px; letter-spacing:0.1em; text-transform:uppercase; color:var(--ink-soft); }
.filter-bar .fb-input{ width:auto; padding:7px 10px; font-size:12.5px; }
.filter-bar select.fb-input{ appearance:none; -webkit-appearance:none; padding-right:28px; }
.filter-bar .select-wrap::after{ right:11px; }

/* ============ TIME TRACKING ============ */
.clock-row{ display:flex; align-items:center; gap:12px; flex-wrap:wrap; margin-bottom:14px; }
.clock-row .spacer{ flex:1; }
.clock-live{ font-size:13px; color:var(--ink-soft); }
.clock-live strong{ font-family:var(--serif); font-size:16px; color:var(--clay); font-variant-numeric:tabular-nums; }
.time-log{ display:flex; flex-direction:column; gap:14px; }
.time-day-head{ display:flex; justify-content:space-between; align-items:baseline; padding:0 0 6px; border-bottom:1px solid var(--ivory-3); margin-bottom:6px; }
.time-day-head span:first-child{ font-family:var(--sans); font-weight:600; font-size:11px; letter-spacing:0.1em; text-transform:uppercase; color:var(--ink-soft); }
.time-day-head .mono{ font-family:var(--serif); color:var(--navy); }
.time-entry{ display:flex; align-items:center; justify-content:space-between; gap:10px; padding:7px 0; }
.time-entry.open{ background:var(--clay-tint); margin:0 -10px; padding:7px 10px; border-radius:8px; }
.te-main{ min-width:0; display:flex; flex-direction:column; gap:1px; }
.te-user{ font-weight:600; color:var(--navy); font-size:13px; }
.te-span{ font-size:12.5px; color:var(--ink-soft); }
.te-note{ font-size:12px; color:var(--ink-soft); font-style:italic; }
.te-right{ display:flex; align-items:center; gap:4px; flex-shrink:0; }
.te-dur{ font-family:var(--serif); font-size:14px; color:var(--navy); font-variant-numeric:tabular-nums; margin-right:4px; }
.te-running{ color:var(--clay-deep); font-weight:600; font-family:var(--sans); font-size:12.5px; }

/* ============ BULK SELECT ============ */
.bulk-bar{ display:flex; align-items:center; gap:8px; background:var(--clay-tint); border:1px solid var(--ivory-3); border-left:3px solid var(--clay); border-radius:10px; padding:9px 14px; margin-bottom:14px; flex-wrap:wrap; }
.bulk-bar[hidden]{ display:none; }
.bulk-bar .spacer{ flex:1; }
.bulk-count{ font-weight:600; color:var(--navy); font-size:13px; }
.sel-cell{ width:42px; text-align:center; padding-left:16px !important; }
.sel-box{ width:16px; height:16px; accent-color:var(--clay); cursor:pointer; vertical-align:middle; }
.table tbody tr.row-sel,.table tbody tr.row-sel:hover{ background:var(--clay-tint); }

/* ============ EXPENSES / ALLOCATION / COSTING ============ */
.alloc-block{ margin-top:18px; border-top:1px solid var(--ivory-3); padding-top:16px; }
.alloc-head{ display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:10px; flex-wrap:wrap; }
.alloc-row{ display:grid; grid-template-columns:1fr 130px 34px; gap:8px; align-items:center; margin-bottom:8px; }
.alloc-tally{ font-size:13px; color:var(--ink-soft); margin-top:8px; }
.alloc-tally strong{ color:var(--navy); font-variant-numeric:tabular-nums; }
.alloc-warn{ color:var(--clay-deep); font-weight:600; }
.receipt-thumb{ display:inline-block; border:1px solid var(--ivory-3); border-radius:8px; overflow:hidden; max-width:160px; }
.receipt-thumb img{ display:block; max-width:160px; max-height:160px; object-fit:cover; }
.cost-grid{ display:grid; grid-template-columns:repeat(4,1fr); gap:12px; }
.cost-cell .lbl{ font-size:10.5px; letter-spacing:0.12em; text-transform:uppercase; color:var(--ink-soft); }
.cost-cell .val{ font-family:var(--serif); font-size:21px; color:var(--navy); font-variant-numeric:tabular-nums; margin-top:2px; }
.cost-cell .val.clay{ color:var(--clay); }
.cost-cell .val.neg, .table td.neg{ color:var(--danger); }
select.f-input.btn-sm{ font-size:12px; }
@media (max-width:680px){ .cost-grid{ grid-template-columns:repeat(2,1fr); } .alloc-row{ grid-template-columns:1fr 100px 30px; } }

/* ============ RESPONSIVE ============ */
@media (max-width:900px){
  .app-shell{ grid-template-columns:1fr; }
  .sidebar{ position:fixed; inset:0 auto 0 0; width:248px; z-index:60; transform:translateX(-100%); transition:transform .2s; }
  .sidebar.open{ transform:translateX(0); box-shadow:0 0 0 100vw rgba(22,49,77,0.4); }
  .topbar .hamburger{ display:inline-flex; }
  .two-col,.grid-2{ grid-template-columns:1fr; }
  .editor-split{ grid-template-columns:1fr; height:auto; margin:-26px -16px -60px; }
  .editor-pane{ border-right:none; border-bottom:1.5px solid var(--clay); height:auto; }
  .preview-pane{ padding:18px; }
  .content{ padding:20px 16px 50px; }
  .f-grid{ grid-template-columns:1fr; }
}

/* ===== Phone polish (crews + reps in the field) ===== */
@media (max-width:640px){
  .topbar{ padding:0 12px; gap:8px; }
  .create-menu .btn span{ display:none; }                      /* icon-only Create on phones */
  .create-menu .btn{ padding:9px 11px; }
  .topbar-ico{ width:34px; height:34px; }
  .cards{ grid-template-columns:repeat(auto-fit, minmax(104px, 1fr)); gap:8px; }
  .card.stat{ padding:10px 12px; border-radius:12px; }
  .stat .lbl{ font-size:9.5px; letter-spacing:.07em; }
  .stat .val, .kpi-val{ font-size:18px; }
  .kpi-sub{ font-size:10.5px; min-height:13px; }
  .page-head h1{ font-size:22px; }
  .page-head-actions .btn span{ display:none; }                /* icon-only page actions */
  .page-head-actions .btn{ padding:9px 11px; }
  .panel-body.flush{ overflow-x:auto; -webkit-overflow-scrolling:touch; }  /* wide tables scroll, never clip */
  .table th, .table td{ padding:10px 10px; font-size:13px; white-space:nowrap; }
  .table th:first-child, .table td:first-child{ padding-left:12px; padding-right:2px; }
  .filter-bar{ flex-wrap:wrap; gap:6px; }
  .filter-bar .fb-lbl{ display:none; }                       /* selects self-describe on phones */
  .filter-bar .fb-group{ flex:1 1 0; min-width:0; }
  .filter-bar .fb-group .select-wrap{ width:100%; }
  .filter-bar .fb-input{ width:100%; max-width:100%; text-overflow:ellipsis; }
  .cal-grid{ font-size:10px; }
  .cal-cell{ min-height:74px; padding:4px 4px; }
  .cal-event{ font-size:9.5px; padding:2px 4px; }
  .cal-time{ display:none; }   /* phone cells are too narrow — the name matters more than the time */
  .cal-wx{ display:none; }
  .cal-dow{ padding:6px 2px; font-size:9px; }
  .totals-mini{ max-width:100%; }
  .act-row{ padding:10px 12px; }
  .content{ padding:16px 10px 60px; }
}

/* ===== Catalog (admin) ===== */
.section-hint{ color:var(--ink-soft); font-size:12.5px; line-height:1.5; margin:4px 0 10px; }
.subsection-h{ font-size:12px; font-weight:600; letter-spacing:.06em; text-transform:uppercase; color:var(--navy); margin:14px 0 8px; }
.rec-list{ margin:4px 0 0; padding-left:18px; }
.rec-list li{ margin:3px 0; }
.cat-edit{ border:1px solid var(--ivory-3); border-radius:12px; padding:14px; margin-bottom:12px; background:var(--warm-white); }
.cat-edit-head{ display:flex; align-items:center; gap:14px; margin-bottom:6px; }
.cat-edit-head .check-row{ white-space:nowrap; }
.cat-edit .f-input{ margin-bottom:6px; }
.q-list{ margin-top:10px; padding-left:12px; border-left:2px solid var(--ivory-3); display:flex; flex-direction:column; gap:12px; }
.q-edit{ display:flex; flex-direction:column; gap:5px; }
.q-edit .qtype{ font-size:11px; color:var(--ink-soft); text-transform:uppercase; letter-spacing:.05em; }
.opt-grid{ display:grid; grid-template-columns:1fr 1fr; gap:6px; }
.opt-grid .opt{ font-size:13px; }
details.adv > summary{ cursor:pointer; list-style:none; }
details.adv > summary::-webkit-details-marker{ display:none; }
details.adv > summary h2::after{ content:' \25B8'; color:var(--ink-soft); font-weight:400; }
details.adv[open] > summary h2::after{ content:' \25BE'; }
#json-editor{ width:100%; white-space:pre; font-size:12px; line-height:1.45; }
@media (max-width:700px){ .opt-grid{ grid-template-columns:1fr; } }

/* ===== "More" action menu ===== */
.amenu{ position:relative; display:inline-block; }
.amenu-pop{ position:absolute; left:0; top:calc(100% + 6px); min-width:240px; max-width:min(280px, calc(100vw - 32px)); background:var(--warm-white); border:1px solid var(--ivory-3); border-radius:14px; box-shadow:0 12px 40px rgba(19,29,46,0.18); padding:6px; z-index:80; }
.amenu-item{ display:flex; align-items:center; gap:10px; width:100%; text-align:left; background:none; border:none; padding:10px 12px; border-radius:9px; font:inherit; font-size:13.5px; color:var(--ink); cursor:pointer; }
.amenu-item:hover{ background:var(--ivory-2); }
.amenu-item.danger{ color:var(--danger); }
.amenu-item svg{ width:15px; height:15px; flex:none; opacity:.75; }
.amenu-div{ height:1px; background:var(--ivory-3); margin:5px 8px; }
