/* ===========================================================================
   CustomOps — App shell + specialised views
   =========================================================================== */

#app { height: 100vh; display: grid; grid-template-columns: auto 1fr; }

/* ============================ SIDE RAIL ================================== */
.rail {
  width: var(--rail-w); background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; height: 100vh;
  z-index: var(--z-rail); transition: width var(--dur) var(--ease); position: relative;
}
body.rail-collapsed .rail { width: var(--rail-w-collapsed); }
body.rail-collapsed .rail .lbl-txt,
body.rail-collapsed .rail .nav-group-title,
body.rail-collapsed .rail .rail-foot .who,
body.rail-collapsed .rail .nav-badge { display: none; }
body.rail-collapsed .rail .nav-item { justify-content: center; padding-inline: 0; }
body.rail-collapsed .rail .brand-lockup .brand-txt { display: none; }

.brand-lockup {
  display: flex; align-items: center; gap: var(--s-5);
  padding: var(--s-6) var(--s-7); height: var(--topbar-h);
  border-bottom: 1px solid var(--line); flex-shrink: 0; overflow: hidden;
}
.brand-lockup img { height: 26px; width: auto; flex-shrink: 0; }
.brand-lockup .brand-txt { min-width: 0; }
.brand-lockup .brand-txt .p-name {
  font-size: var(--fs-md); font-weight: var(--fw-bold); letter-spacing: -.02em; line-height: 1.1;
}
.brand-lockup .brand-txt .p-sub {
  font-size: 9px; color: var(--text-3); letter-spacing: .05em;
  text-transform: uppercase; font-weight: var(--fw-semi);
  white-space: nowrap;                 /* must not wrap under the wordmark */
}

.rail-nav { flex: 1; overflow-y: auto; padding: var(--s-6) var(--s-5); }
.nav-group + .nav-group { margin-top: var(--s-7); }
.nav-group-title {
  padding: 0 var(--s-5) var(--s-4); font-size: var(--fs-2xs);
  text-transform: uppercase; letter-spacing: .12em; font-weight: var(--fw-bold);
  color: var(--text-4);
}
.nav-item {
  display: flex; align-items: center; gap: var(--s-5); width: 100%;
  height: 33px; padding: 0 var(--s-5); border-radius: var(--r-md);
  color: var(--text-2); font-size: var(--fs-md); font-weight: var(--fw-med);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
  position: relative; margin-bottom: 1px;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .82; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--brand-wash); color: var(--brand); font-weight: var(--fw-semi); }
.nav-item.active svg { opacity: 1; }
.nav-item.active::before {
  content:''; position:absolute; left:-5px; top:7px; bottom:7px; width:3px;
  background: var(--brand); border-radius: 0 var(--r-pill) var(--r-pill) 0;
}
.nav-badge {
  margin-left: auto; min-width: 19px; height: 18px; padding: 0 5px;
  border-radius: var(--r-pill); background: var(--surface-3); color: var(--text-3);
  font-size: var(--fs-2xs); font-weight: var(--fw-bold);
  display: grid; place-items: center;
}
.nav-item.active .nav-badge { background: var(--brand); color: #fff; }
.nav-badge.hot { background: var(--brand); color:#fff; }

.rail-foot { border-top: 1px solid var(--line); padding: var(--s-5); flex-shrink: 0; }
.rail-foot .who { min-width: 0; }
.user-btn {
  display: flex; align-items: center; gap: var(--s-5); width: 100%;
  padding: var(--s-4); border-radius: var(--r-md); transition: background var(--dur-fast) var(--ease);
}
.user-btn:hover { background: var(--surface-2); }

/* ============================ MAIN COLUMN ================================ */
.main { display: flex; flex-direction: column; height: 100vh; min-width: 0; }

.topbar {
  height: var(--topbar-h); flex-shrink: 0;
  display: flex; align-items: center; gap: var(--s-6);
  padding: 0 var(--s-8); border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(14px); position: relative; z-index: var(--z-sticky);
}
.crumbs { display:flex; align-items:center; gap: var(--s-4); font-size: var(--fs-md); min-width:0; }
.crumbs .sepr { color: var(--text-4); }
.crumbs .cur { font-weight: var(--fw-semi); }

.omnibox {
  display: flex; align-items: center; gap: var(--s-5);
  height: 32px; width: min(340px, 32vw); padding: 0 var(--s-5);
  background: var(--surface-inset); border: 1px solid var(--line);
  border-radius: var(--r-md); color: var(--text-3); font-size: var(--fs-md);
  transition: all var(--dur-fast) var(--ease);
}
.omnibox:hover { border-color: var(--line-strong); color: var(--text-2); }
.omnibox svg { width: 14px; height: 14px; }

.icon-btn {
  width: 32px; height: 32px; border-radius: var(--r-md); display: grid; place-items: center;
  color: var(--text-2); transition: all var(--dur-fast) var(--ease); position: relative; flex-shrink:0;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn .pip {
  position: absolute; top: 5px; right: 5px; width: 7px; height: 7px; border-radius: 50%;
  background: var(--brand); border: 1.5px solid var(--surface);
}

.subbar {
  min-height: var(--subbar-h); flex-shrink: 0;
  display: flex; align-items: center; gap: var(--s-5); flex-wrap: wrap;
  padding: var(--s-4) var(--s-8); border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.view { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.view-pad { padding: var(--s-8); max-width: var(--maxw); margin: 0 auto; }
.view-pad.wide { max-width: none; }
.view-pad.narrow { max-width: 1040px; }

.page-head { display:flex; align-items:flex-start; gap: var(--s-7); margin-bottom: var(--s-8); flex-wrap:wrap; }
.page-head h1 { font-size: var(--fs-2xl); }
.page-head .sub { color: var(--text-3); font-size: var(--fs-md); margin-top: var(--s-3); }

/* ============================ COMMAND PALETTE ============================ */
.palette-scrim {
  position: fixed; inset: 0; background: var(--overlay); backdrop-filter: blur(4px);
  z-index: var(--z-palette); display: flex; justify-content: center; padding-top: 12vh;
  animation: fadeIn var(--dur-fast) var(--ease) both;
}
.palette {
  width: min(620px, calc(100vw - 32px)); max-height: 62vh;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r-xl); box-shadow: var(--shadow-xl);
  display: flex; flex-direction: column; overflow: hidden; align-self: flex-start;
  animation: popIn var(--dur) var(--ease-out) both;
}
.palette-input { display: flex; align-items: center; gap: var(--s-6); padding: var(--s-7);
                 border-bottom: 1px solid var(--line); flex-shrink: 0; }
.palette-input svg { width: 17px; height: 17px; color: var(--text-3); }
.palette-input input { flex: 1; font-size: var(--fs-lg); background: none; }
.palette-input input::placeholder { color: var(--text-4); }
.palette-list { overflow-y: auto; padding: var(--s-4); }
.palette-sec { padding: var(--s-5) var(--s-5) var(--s-3); font-size: var(--fs-2xs);
               text-transform: uppercase; letter-spacing: .11em; font-weight: var(--fw-bold); color: var(--text-4); }
.palette-item {
  display: flex; align-items: center; gap: var(--s-6); width: 100%;
  padding: var(--s-5) var(--s-6); border-radius: var(--r-md); text-align: left;
  color: var(--text-2); font-size: var(--fs-md);
}
.palette-item .pi-ico { width: 26px; height: 26px; border-radius: var(--r-sm); display:grid; place-items:center;
                        background: var(--surface-3); color: var(--text-3); flex-shrink:0; }
.palette-item .pi-ico svg { width: 14px; height: 14px; }
.palette-item.sel { background: var(--brand-wash); color: var(--text); }
.palette-item.sel .pi-ico { background: var(--brand); color:#fff; }
.palette-foot { padding: var(--s-5) var(--s-7); border-top: 1px solid var(--line);
                background: var(--surface-2); display:flex; gap: var(--s-7); font-size: var(--fs-xs); color: var(--text-4); }

/* ============================ DISPATCH BOARD ============================= */
.board { display: flex; flex-direction: column; height: 100%; }
.board-scroll { flex: 1; overflow: auto; position: relative; }
.board-grid { display: grid; min-width: max-content; position: relative; }

.board-timecol { position: sticky; left: 0; z-index: 6; background: var(--surface-2);
                 border-right: 1px solid var(--line); width: 62px; }
.board-timecol .tick {
  height: var(--slot-h, 56px); border-bottom: 1px solid var(--line-soft);
  font-size: var(--fs-2xs); color: var(--text-4); padding: 3px var(--s-4) 0 0; text-align: right;
  font-weight: var(--fw-semi);
}
.board-head {
  position: sticky; top: 0; z-index: 8; background: var(--surface-2);
  border-bottom: 1px solid var(--line); display: flex;
}
.board-head .corner { width: 62px; flex-shrink: 0; border-right: 1px solid var(--line);
                      position: sticky; left: 0; z-index: 9; background: var(--surface-2); }
.tech-col-head {
  width: var(--col-w, 230px); flex-shrink: 0; padding: var(--s-5) var(--s-6);
  border-right: 1px solid var(--line-soft); display: flex; align-items: center; gap: var(--s-5);
}
.tech-col-head .util { margin-left: auto; text-align: right; }
.tech-col-head .util .pct { font-size: var(--fs-sm); font-weight: var(--fw-bold); }

.board-body { display: flex; position: relative; }
.tech-col {
  width: var(--col-w, 230px); flex-shrink: 0; border-right: 1px solid var(--line-soft);
  position: relative; background-image: repeating-linear-gradient(
    to bottom, transparent, transparent calc(var(--slot-h,56px) - 1px),
    var(--grid-line) calc(var(--slot-h,56px) - 1px), var(--grid-line) var(--slot-h,56px));
}
.tech-col.drop-ok { background-color: var(--tint-green); }
.tech-col.drop-bad { background-color: var(--tint-red); }

.appt {
  position: absolute; left: 4px; right: 4px; border-radius: var(--r-sm);
  padding: var(--s-4) var(--s-5); overflow: hidden; cursor: grab;
  border: 1px solid; font-size: var(--fs-sm); line-height: 1.28;
  transition: box-shadow var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
  box-shadow: var(--shadow-sm);
}
.appt:hover { box-shadow: var(--shadow); transform: translateY(-1px); z-index: 3; }
.appt:active { cursor: grabbing; }
.appt .a-time { font-size: var(--fs-2xs); opacity: .82; font-weight: var(--fw-semi); }
.appt .a-title { font-weight: var(--fw-semi); }
.appt .a-meta { font-size: var(--fs-2xs); opacity: .78; }
.appt.compact { padding: 2px var(--s-4); }
.appt.compact .a-meta { display: none; }

.appt.t-service   { background: var(--tint-blue);   border-color: color-mix(in srgb, var(--c-blue) 42%, transparent); color: var(--text); }
.appt.t-maint     { background: var(--tint-teal);   border-color: color-mix(in srgb, var(--c-teal) 42%, transparent); color: var(--text); }
.appt.t-install   { background: var(--tint-violet); border-color: color-mix(in srgb, var(--c-violet) 42%, transparent); color: var(--text); }
.appt.t-emergency { background: var(--brand-wash-2);border-color: var(--brand); color: var(--text); }
.appt.t-inspect   { background: var(--tint-amber);  border-color: color-mix(in srgb, var(--c-amber) 42%, transparent); color: var(--text); }
.appt.t-warranty  { background: var(--tint-indigo); border-color: color-mix(in srgb, var(--c-indigo) 42%, transparent); color: var(--text); }
.appt.t-project   { background: var(--tint-orange); border-color: color-mix(in srgb, var(--c-orange) 42%, transparent); color: var(--text); }
.appt.is-done { opacity: .58; }
.appt .lock { position:absolute; top:3px; right:4px; opacity:.5; }

.now-line { position: absolute; left: 0; right: 0; height: 2px; background: var(--brand); z-index: 5; pointer-events: none; }
.now-line::before {
  content:''; position:absolute; left:-4px; top:-3px; width:8px; height:8px;
  border-radius:50%; background: var(--brand); box-shadow: 0 0 8px var(--brand-glow);
}

.unassigned-tray {
  border-top: 1px solid var(--line); background: var(--surface-2); flex-shrink: 0;
  max-height: 210px; display: flex; flex-direction: column;
}
.tray-head { padding: var(--s-5) var(--s-8); display: flex; align-items: center; gap: var(--s-5);
             border-bottom: 1px solid var(--line-soft); }
.tray-body { display: flex; gap: var(--s-5); padding: var(--s-6) var(--s-8); overflow-x: auto; }
.tray-card {
  width: 230px; flex-shrink: 0; padding: var(--s-5) var(--s-6);
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--brand);
  border-radius: var(--r-md); cursor: grab; transition: all var(--dur-fast) var(--ease);
}
.tray-card:hover { border-color: var(--line-strong); transform: translateY(-2px); box-shadow: var(--shadow); }

/* ============================ KANBAN ===================================== */
.kanban { display: flex; gap: var(--s-6); height: 100%; overflow-x: auto; padding-bottom: var(--s-5); }
.kcol {
  width: 296px; flex-shrink: 0; display: flex; flex-direction: column;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-lg);
  max-height: 100%;
}
.kcol.over { border-color: var(--brand); background: var(--brand-wash); }
.kcol-head {
  padding: var(--s-5) var(--s-6); display: flex; align-items: center; gap: var(--s-5);
  border-bottom: 1px solid var(--line-soft); flex-shrink: 0;
}
.kcol-head .kdot { width: 8px; height: 8px; border-radius: 50%; }
.kcol-head .ktitle { font-size: var(--fs-sm); font-weight: var(--fw-bold); text-transform: uppercase; letter-spacing: .07em; }
.kcol-body { padding: var(--s-5); display: flex; flex-direction: column; gap: var(--s-5); overflow-y: auto; flex: 1; min-height: 60px; }
.kcard {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: var(--s-6); cursor: grab; transition: all var(--dur-fast) var(--ease);
}
.kcard:hover { border-color: var(--line-strong); transform: translateY(-2px); box-shadow: var(--shadow); }
.kcard .kc-title { font-size: var(--fs-md); font-weight: var(--fw-semi); line-height: 1.32; }
.kcard .kc-meta { font-size: var(--fs-sm); color: var(--text-3); }
.kcol-foot { padding: var(--s-4) var(--s-5); border-top: 1px solid var(--line-soft); }

/* ============================ CALENDAR =================================== */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); border: 1px solid var(--line);
            border-radius: var(--r-lg); overflow: hidden; background: var(--surface); }
.cal-dow { padding: var(--s-5); text-align: center; background: var(--surface-2);
           font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .09em;
           font-weight: var(--fw-bold); color: var(--text-3); border-bottom: 1px solid var(--line); }
.cal-cell { min-height: 108px; padding: var(--s-4); border-right: 1px solid var(--line-soft);
            border-bottom: 1px solid var(--line-soft); position: relative; }
.cal-cell:nth-child(7n) { border-right: none; }
.cal-cell.off { background: var(--surface-2); color: var(--text-4); }
.cal-cell.today .cal-num { background: var(--brand); color: #fff; }
.cal-num { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
           font-size: var(--fs-sm); font-weight: var(--fw-semi); }
.cal-ev { font-size: var(--fs-2xs); padding: 1px var(--s-3); border-radius: var(--r-xs);
          margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }

/* ============================ MAP (schematic) ============================ */
.map-canvas {
  position: relative; border-radius: var(--r-lg); overflow: hidden;
  background:
    linear-gradient(var(--grid-line) 1px, transparent 1px) 0 0 / 34px 34px,
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px) 0 0 / 34px 34px,
    radial-gradient(700px 420px at 30% 30%, color-mix(in srgb, var(--c-teal) 12%, transparent), transparent 70%),
    var(--surface-inset);
  border: 1px solid var(--line);
}
.map-pin {
  position: absolute; transform: translate(-50%, -100%); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; z-index: 2;
}
.map-pin .pin-body {
  width: 26px; height: 26px; border-radius: 50% 50% 50% 4px; transform: rotate(45deg);
  display: grid; place-items: center; box-shadow: var(--shadow); border: 2px solid var(--surface);
}
.map-pin .pin-body span { transform: rotate(-45deg); font-size: 10px; font-weight: var(--fw-bold); color:#fff; }
.map-pin:hover { z-index: 5; }
.map-pin .pin-tip {
  position: absolute; bottom: calc(100% + 6px); white-space: nowrap; padding: 3px var(--s-5);
  background: var(--surface-4); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  font-size: var(--fs-xs); opacity: 0; transition: opacity var(--dur-fast) var(--ease); pointer-events: none;
}
.map-pin:hover .pin-tip { opacity: 1; }
.map-route { stroke: var(--brand); stroke-width: 2; fill: none; stroke-dasharray: 5 4; opacity: .7; }

/* ============================ ASSET TAG / QR ============================= */
.tag-label {
  width: 260px; background: #fff; color: #111; border-radius: 6px; padding: 10px;
  border: 1px solid #d8dde5; display: flex; flex-direction: column; gap: 6px;
  font-family: var(--font-ui);
}
.tag-label .tl-top { display: flex; align-items: center; gap: 8px; }
.tag-label .tl-top img { height: 15px; }
.tag-label .tl-main { display: flex; gap: 10px; align-items: center; }
.tag-label .tl-qr { width: 84px; height: 84px; flex-shrink: 0; }
.tag-label .tl-info { min-width: 0; font-size: 10px; line-height: 1.35; }
.tag-label .tl-id { font-family: var(--font-mono); font-size: 13px; font-weight: 700; letter-spacing: -.02em; }
.tag-label .tl-bc { width: 100%; height: 30px; }
.tag-label .tl-foot { font-size: 7.5px; color: #666; text-align: center; letter-spacing: .04em; }

.scan-frame {
  position: relative; aspect-ratio: 4/3; border-radius: var(--r-lg); overflow: hidden;
  background: radial-gradient(circle at 50% 45%, #1b2430, #0a0d13); display: grid; place-items: center;
}
.scan-frame .reticle {
  width: 58%; aspect-ratio: 1; border-radius: var(--r-lg); position: relative;
}
.scan-frame .reticle::before, .scan-frame .reticle::after {
  content:''; position:absolute; width: 28px; height: 28px; border: 3px solid var(--brand);
}
.scan-frame .reticle::before { top:0; left:0; border-right:0; border-bottom:0; border-radius: 6px 0 0 0; }
.scan-frame .reticle::after  { bottom:0; right:0; border-left:0; border-top:0; border-radius: 0 0 6px 0; }
.scan-line {
  position:absolute; left:6%; right:6%; height:2px; background: var(--brand);
  box-shadow: 0 0 14px var(--brand); animation: scanY 2.1s ease-in-out infinite;
}
@keyframes scanY { 0%,100% { top: 22% } 50% { top: 78% } }

/* ============================ INVOICE / DOC ============================== */
.doc {
  background: #fff; color: #14181f; border-radius: var(--r-lg); overflow: hidden;
  box-shadow: var(--shadow-lg); border: 1px solid var(--line);
}
.doc .doc-inner { padding: 40px; font-size: 12.5px; line-height: 1.55; }
.doc h1, .doc h2, .doc h3 { color: #0b0f16; }
.doc .doc-rule { height: 3px; background: var(--brand); border-radius: 2px; }
.doc table { font-size: 12px; }
.doc table th { text-align: left; padding: 8px 10px; background: #f2f4f8; color: #59637a;
                font-size: 9.5px; text-transform: uppercase; letter-spacing: .09em; font-weight: 700;
                border-bottom: 1px solid #dfe4ec; }
.doc table td { padding: 9px 10px; border-bottom: 1px solid #eceff4; }
.doc .tot-row td { border: none; padding: 4px 10px; }
.doc .tot-grand td { border-top: 2px solid #14181f; font-weight: 800; font-size: 14px; padding-top: 9px; }
.doc .paidstamp {
  border: 3px solid #16a34a; color: #16a34a; padding: 5px 16px; border-radius: 7px;
  font-weight: 800; letter-spacing: .16em; transform: rotate(-8deg); font-size: 17px;
}

/* ============================ OPTION CARDS (Good/Better/Best) ============ */
.opt-grid { display: grid; gap: var(--s-7); grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.opt-card {
  border: 1.5px solid var(--line); border-radius: var(--r-xl); padding: var(--s-8);
  background: var(--surface); position: relative; display: flex; flex-direction: column;
  transition: all var(--dur) var(--ease);
}
.opt-card:hover { border-color: var(--line-strong); transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.opt-card.rec { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand), var(--shadow-lg); }
.opt-card.rec::before {
  content: 'RECOMMENDED'; position: absolute; top: -9px; left: 50%; transform: translateX(-50%);
  background: var(--brand); color: #fff; font-size: var(--fs-2xs); font-weight: var(--fw-bold);
  letter-spacing: .12em; padding: 3px var(--s-6); border-radius: var(--r-pill); white-space: nowrap;
}
.opt-card.sel { border-color: var(--c-green); box-shadow: 0 0 0 1px var(--c-green); }
.opt-tier { font-size: var(--fs-2xs); text-transform: uppercase; letter-spacing: .14em;
            font-weight: var(--fw-bold); color: var(--text-3); }
.opt-price { font-size: var(--fs-3xl); font-weight: var(--fw-bold); letter-spacing: -.03em; }
.opt-feats { display: flex; flex-direction: column; gap: var(--s-5); font-size: var(--fs-md); }
.opt-feats li { display: flex; gap: var(--s-5); align-items: flex-start; }
.opt-feats svg { width: 14px; height: 14px; color: var(--c-green); flex-shrink: 0; margin-top: 3px; }

/* ============================ TROUBLESHOOTER ============================= */
.ts-stage {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl);
  padding: var(--s-10); box-shadow: var(--shadow);
}
.ts-q { font-size: var(--fs-2xl); font-weight: var(--fw-semi); letter-spacing: -.02em; line-height: 1.28; }
.ts-choices { display: grid; gap: var(--s-5); margin-top: var(--s-9); }
.ts-choice {
  display: flex; align-items: center; gap: var(--s-6); text-align: left; width: 100%;
  padding: var(--s-7); border: 1.5px solid var(--line); border-radius: var(--r-lg);
  background: var(--surface-2); transition: all var(--dur-fast) var(--ease);
}
.ts-choice:hover { border-color: var(--brand); background: var(--brand-wash); transform: translateX(4px); }
.ts-choice .ts-key {
  width: 26px; height: 26px; border-radius: var(--r-sm); flex-shrink: 0;
  display: grid; place-items: center; background: var(--surface-4); color: var(--text-2);
  font-size: var(--fs-sm); font-weight: var(--fw-bold); font-family: var(--font-mono);
}
.ts-choice:hover .ts-key { background: var(--brand); color: #fff; }
.ts-path { display: flex; align-items: center; gap: var(--s-4); flex-wrap: wrap; font-size: var(--fs-sm); }
.ts-path .step { padding: 2px var(--s-5); background: var(--surface-3); border-radius: var(--r-pill); color: var(--text-3); }
.ts-path .step.cur { background: var(--brand-wash); color: var(--brand); font-weight: var(--fw-semi); }

/* ============================ PORTAL (customer facing) =================== */
body.portal-mode { overflow: auto; }
.portal { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
.portal-nav {
  height: 68px; display: flex; align-items: center; gap: var(--s-7); padding: 0 var(--s-9);
  border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 20;
}
.portal-nav img { height: 34px; }
.portal-hero {
  padding: var(--s-13) var(--s-9); text-align: center; position: relative; overflow: hidden;
}
.portal-hero h1 { font-size: clamp(30px, 5vw, 50px); letter-spacing: -.032em; line-height: 1.06; }
.portal-hero .lede { font-size: var(--fs-lg); color: var(--text-2); max-width: 620px; margin: var(--s-7) auto 0; }
.portal-wrap { width: min(940px, calc(100vw - 32px)); margin: 0 auto; padding-bottom: var(--s-13); }
.step-rail { display: flex; align-items: center; gap: var(--s-5); }
.step-rail .sr { display: flex; align-items: center; gap: var(--s-4); font-size: var(--fs-sm); color: var(--text-4); }
.step-rail .sr .n {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  border: 1.5px solid var(--line-strong); font-size: var(--fs-xs); font-weight: var(--fw-bold);
}
.step-rail .sr.done .n { background: var(--c-green); border-color: var(--c-green); color: #04140A; }
.step-rail .sr.cur  .n { background: var(--brand); border-color: var(--brand); color: #fff; }
.step-rail .sr.cur { color: var(--text); font-weight: var(--fw-semi); }
.step-rail .conn { flex: 1; height: 1.5px; background: var(--line); min-width: 16px; }

.pick-grid { display: grid; gap: var(--s-6); grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.pick {
  padding: var(--s-8); border: 1.5px solid var(--line); border-radius: var(--r-lg);
  background: var(--surface); text-align: left; transition: all var(--dur-fast) var(--ease);
  display: flex; flex-direction: column; gap: var(--s-4);
}
.pick:hover { border-color: var(--brand); transform: translateY(-3px); box-shadow: var(--shadow); }
.pick.sel { border-color: var(--brand); background: var(--brand-wash); box-shadow: 0 0 0 1px var(--brand); }
.pick .p-ico { width: 38px; height: 38px; border-radius: var(--r-md); display: grid; place-items: center;
               background: var(--brand-wash); color: var(--brand); }
.pick .p-ico svg { width: 19px; height: 19px; }

.slot-grid { display: grid; gap: var(--s-5); grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); }
.slot {
  padding: var(--s-6); border: 1.5px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); font-size: var(--fs-md); text-align: center;
  transition: all var(--dur-fast) var(--ease);
}
.slot:hover:not(:disabled) { border-color: var(--brand); }
.slot.sel { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: var(--fw-semi); }
.slot:disabled { opacity: .32; text-decoration: line-through; cursor: not-allowed; }
.slot .s-cap { font-size: var(--fs-2xs); color: var(--text-4); display: block; margin-top: 2px; }
.slot.sel .s-cap { color: rgba(255,255,255,.8); }

/* ============================ POSTCARD DESIGNER ========================== */
.pc-stage { display: grid; gap: var(--s-8); grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.postcard {
  aspect-ratio: 6 / 4; border-radius: var(--r-md); overflow: hidden; position: relative;
  box-shadow: var(--shadow-lg); border: 1px solid var(--line); background: #fff; color: #12161d;
}
.pc-front { display: flex; flex-direction: column; justify-content: space-between; padding: 22px; height: 100%; }
.pc-front .pc-kicker { font-size: 10px; letter-spacing: .2em; text-transform: uppercase; font-weight: 800; }
.pc-front .pc-head { font-size: 27px; font-weight: 800; line-height: 1.03; letter-spacing: -.028em; }
.pc-front .pc-offer {
  display: inline-block; padding: 6px 14px; border-radius: 999px; font-weight: 800;
  font-size: 13px; background: #fff; color: var(--brand);
}
.pc-back { display: grid; grid-template-columns: 1.05fr 1fr; height: 100%; }
.pc-back .pc-msg { padding: 18px; border-right: 1px dashed #c9d0da; font-size: 10.5px; line-height: 1.5; }
.pc-back .pc-addr { padding: 18px; display: flex; flex-direction: column; }
.pc-back .pc-stamp { width: 42px; height: 50px; border: 1px dashed #b9c2cf; border-radius: 3px;
                     align-self: flex-end; display: grid; place-items: center; font-size: 7px; color: #9aa4b3; text-align:center; }
.pc-back .pc-to { margin-top: auto; font-size: 11px; line-height: 1.45; }
.pc-back .pc-imb { height: 14px; margin-top: 8px; }

/* ============================ DIALER / SMS =============================== */
.dialer { width: 272px; background: var(--surface-2); border: 1px solid var(--line);
          border-radius: var(--r-xl); padding: var(--s-7); }
.dial-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-5); }
.dial-key {
  aspect-ratio: 1.5; border-radius: var(--r-md); background: var(--surface-3);
  border: 1px solid var(--line); font-size: var(--fs-lg); font-weight: var(--fw-semi);
  display: grid; place-items: center; transition: all var(--dur-fast) var(--ease);
}
.dial-key:hover { background: var(--surface-4); }
.dial-key small { display: block; font-size: 7.5px; letter-spacing: .12em; color: var(--text-4); font-weight: var(--fw-bold); }

.sms-thread { display: flex; flex-direction: column; gap: var(--s-5); padding: var(--s-7); }
.sms {
  max-width: 78%; padding: var(--s-5) var(--s-6); border-radius: 16px; font-size: var(--fs-md);
  line-height: 1.42; position: relative;
}
.sms.out { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 5px; }
.sms.in  { align-self: flex-start; background: var(--surface-3); border-bottom-left-radius: 5px; }
.sms .sms-meta { font-size: var(--fs-2xs); opacity: .68; margin-top: 3px; }
.sms.sys { align-self: center; background: var(--surface-2); color: var(--text-3);
           font-size: var(--fs-xs); border-radius: var(--r-pill); padding: 3px var(--s-6); }

.wave { display: flex; align-items: center; gap: 2px; height: 24px; }
.wave i { width: 2.5px; background: var(--brand); border-radius: 2px; animation: wv 1s ease-in-out infinite; }
@keyframes wv { 0%,100% { height: 22% } 50% { height: 100% } }

/* ============================ FUNNEL / RADAR ============================= */
.funnel { display: flex; flex-direction: column; gap: var(--s-4); }
.funnel-row { display: flex; align-items: center; gap: var(--s-6); }
.funnel-bar {
  height: 34px; border-radius: var(--r-sm); display: flex; align-items: center;
  padding: 0 var(--s-6); color: #fff; font-weight: var(--fw-semi); font-size: var(--fs-sm);
  transition: width var(--dur-slow) var(--ease-out); min-width: 60px;
}

.radar-row { display: grid; grid-template-columns: 1fr auto; gap: var(--s-6); align-items: center;
             padding: var(--s-6); border-bottom: 1px solid var(--line-soft); }
.radar-row:hover { background: var(--surface-2); }
.age-meter { height: 5px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; width: 130px; }
.age-meter i { display: block; height: 100%; border-radius: var(--r-pill); }

/* ============================ CHARTS ===================================== */
.chart-wrap { position: relative; width: 100%; }
.chart-wrap svg { display: block; width: 100%; overflow: visible; }
.chart-grid line { stroke: var(--grid-line); stroke-width: 1; }
.chart-axis text { fill: var(--text-4); font-size: 10px; font-family: var(--font-ui); }
.chart-tip {
  position: absolute; pointer-events: none; padding: var(--s-4) var(--s-6);
  background: var(--surface-4); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  font-size: var(--fs-sm); box-shadow: var(--shadow); white-space: nowrap; z-index: 4;
  transform: translate(-50%, -125%); opacity: 0; transition: opacity var(--dur-fast) var(--ease);
}
.chart-tip.on { opacity: 1; }
.legend { display: flex; gap: var(--s-7); flex-wrap: wrap; font-size: var(--fs-sm); color: var(--text-3); }
.legend .lg-item { display: flex; align-items: center; gap: var(--s-4); }
.legend .sw { width: 9px; height: 9px; border-radius: 2px; }

/* ============================ CHECKLIST ================================== */
.chk-item {
  display: flex; align-items: flex-start; gap: var(--s-5); padding: var(--s-5) var(--s-6);
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2);
  transition: all var(--dur-fast) var(--ease);
}
.chk-item:hover { border-color: var(--line-strong); }
.chk-item.done { background: var(--tint-green); border-color: color-mix(in srgb, var(--c-green) 30%, transparent); }
.chk-item.done .chk-txt { text-decoration: line-through; color: var(--text-3); }
.chk-item.fail { background: var(--tint-red); border-color: color-mix(in srgb, var(--c-red) 30%, transparent); }

/* ============================ PHASE TRACKER ============================== */
.phase-track { display: flex; align-items: stretch; gap: 3px; }
.phase-node {
  flex: 1; min-width: 0; padding: var(--s-5) var(--s-6); background: var(--surface-2);
  border: 1px solid var(--line); position: relative; text-align: center;
}
.phase-node:first-child { border-radius: var(--r-md) 0 0 var(--r-md); }
.phase-node:last-child  { border-radius: 0 var(--r-md) var(--r-md) 0; }
.phase-node .pn-label { font-size: var(--fs-xs); font-weight: var(--fw-semi); }
.phase-node .pn-date  { font-size: var(--fs-2xs); color: var(--text-4); margin-top: 2px; }
.phase-node.done    { background: var(--tint-green); border-color: color-mix(in srgb, var(--c-green) 34%, transparent); }
.phase-node.current { background: var(--brand-wash); border-color: var(--brand); }
.phase-node.blocked { background: var(--tint-red); border-color: color-mix(in srgb, var(--c-red) 34%, transparent); }
.phase-node.current::after {
  content:''; position:absolute; left:0; right:0; bottom:-1px; height:2px; background: var(--brand);
}

/* ============================ SPLIT PANE ================================= */
.split { display: grid; grid-template-columns: 340px 1fr; height: 100%; min-height: 0; }
.split.wide-l { grid-template-columns: 420px 1fr; }
.split > .sp-l { border-right: 1px solid var(--line); overflow-y: auto; min-height: 0; background: var(--surface); }
.split > .sp-r { overflow-y: auto; min-height: 0; }
.list-row {
  display: flex; gap: var(--s-5); padding: var(--s-6) var(--s-7);
  border-bottom: 1px solid var(--line-soft); cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
}
.list-row:hover { background: var(--surface-2); }
.list-row.sel { background: var(--brand-wash); box-shadow: inset 3px 0 0 var(--brand); }

/* ============================ RESPONSIVE ================================= */
@media (max-width: 1180px) {
  .rail { width: var(--rail-w-collapsed); }
  .rail .lbl-txt, .rail .nav-group-title, .rail .nav-badge, .rail .brand-txt, .rail .who { display: none; }
  .rail .nav-item { justify-content: center; padding-inline: 0; }
  .split { grid-template-columns: 280px 1fr; }
}
@media (max-width: 820px) {
  #app { grid-template-columns: 1fr; }
  .rail { position: fixed; left: 0; top: 0; transform: translateX(-100%); }
  body.rail-open .rail { transform: none; box-shadow: var(--shadow-xl); width: var(--rail-w); }
  body.rail-open .rail .lbl-txt, body.rail-open .rail .nav-group-title,
  body.rail-open .rail .nav-badge, body.rail-open .rail .brand-txt { display: block; }
  body.rail-open .rail .nav-item { justify-content: flex-start; padding-inline: var(--s-5); }
  .omnibox { width: auto; }
  .omnibox .om-txt, .omnibox .kbd { display: none; }
  .split { grid-template-columns: 1fr; }
  .split > .sp-l { display: none; }
  .view-pad { padding: var(--s-6); }
}
