:root {
  --navy: #0b2638;
  --navy-2: #123a50;
  --aqua: #12a8b6;
  --aqua-dark: #087d8c;
  --aqua-soft: #e2f7f7;
  --gold: #e4a23a;
  --ink: #102332;
  --muted: #637582;
  --line: #dce5e9;
  --surface: #ffffff;
  --canvas: #f3f7f7;
  --danger: #b42318;
  --success: #147d4c;
  --shadow: 0 18px 45px rgba(11, 38, 56, .12);
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--canvas); font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 70% 18%, rgba(18,168,182,.25), transparent 28%), linear-gradient(145deg, var(--navy), #071a27); }
.auth-card { width: min(420px, 100%); background: var(--surface); border-radius: 22px; padding: 36px; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.auth-wordmark { width: 148px; height: auto; margin-bottom: 34px; }
.auth-card h1 { margin: 2px 0 8px; font-size: 30px; letter-spacing: -.035em; }
.eyebrow { margin: 0 0 4px; color: var(--aqua-dark); text-transform: uppercase; letter-spacing: .11em; font-size: 11px; font-weight: 800; }
.muted, .section-head p, .card-head p { color: var(--muted); margin: 4px 0 0; }
label { display: grid; gap: 6px; color: #334957; font-size: 12px; font-weight: 700; }
.auth-card form { display: grid; gap: 16px; margin-top: 24px; }
input, select { width: 100%; min-height: 42px; border: 1px solid var(--line); border-radius: 9px; background: #fff; padding: 9px 11px; color: var(--ink); outline: none; }
input:focus, select:focus { border-color: var(--aqua); box-shadow: 0 0 0 3px rgba(18,168,182,.12); }
input:disabled { color: var(--muted); background: #edf3f4; }
.button { border: 1px solid var(--line); border-radius: 9px; padding: 10px 16px; background: #fff; color: var(--ink); font-weight: 750; }
.button.primary { background: var(--aqua-dark); border-color: var(--aqua-dark); color: #fff; }
.button.primary:hover { background: #056776; }
.button:disabled { opacity: .48; cursor: not-allowed; }
.wide { width: 100%; }
.form-message { min-height: 20px; color: var(--danger); font-size: 13px; }
.security-note { margin: 20px 0 0; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; text-align: center; }

.portal { min-height: 100vh; display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 22px 14px; color: #d9e5eb; background: var(--navy); }
.brand { display: grid; gap: 8px; padding: 2px 12px 24px; color: #8ba3b1; font-size: 11px; text-transform: uppercase; letter-spacing: .13em; }
.brand img { width: 132px; max-height: 42px; object-fit: contain; object-position: left center; }
.sidebar nav { display: grid; gap: 5px; }
.nav-link { display: flex; align-items: center; gap: 8px; width: 100%; border: 0; border-radius: 9px; padding: 11px 12px; color: #c9d8e0; background: transparent; text-align: left; font-weight: 700; }
.nav-link:hover, .nav-link.active { color: #fff; background: rgba(18,168,182,.24); }
.nav-link.active { box-shadow: inset 3px 0 var(--aqua); }
.count { margin-left: auto; min-width: 22px; border-radius: 20px; padding: 1px 6px; color: var(--navy); background: var(--gold); text-align: center; font-size: 11px; }
.sidebar-foot { margin-top: auto; display: grid; gap: 8px; padding: 16px 12px 2px; border-top: 1px solid rgba(255,255,255,.12); font-size: 12px; }
.text-button { width: max-content; border: 0; padding: 0; color: #9fb5c0; background: none; text-decoration: underline; }
.workspace { min-width: 0; }
.topbar { min-height: 82px; display: flex; align-items: center; gap: 18px; padding: 16px clamp(20px,4vw,48px); border-bottom: 1px solid var(--line); background: rgba(255,255,255,.94); position: sticky; top: 0; z-index: 10; backdrop-filter: blur(12px); }
.topbar h1 { margin: 0; font-size: 22px; }
.session-pill { margin-left: auto; border-radius: 40px; padding: 6px 11px; color: var(--aqua-dark); background: var(--aqua-soft); font-size: 11px; font-weight: 800; }
.menu-button { display: none; border: 0; background: none; font-size: 22px; }
.content { max-width: 1260px; padding: 34px clamp(20px,4vw,48px) 70px; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.section-head h2 { margin: 0; font-size: 27px; letter-spacing: -.025em; }
.compact { width: 150px; }
.notice { margin-bottom: 18px; border: 1px solid #f0d3a0; border-radius: 10px; padding: 10px 13px; color: #6e4a10; background: #fff8e8; }
.product-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; }
.card, .product-card { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: 0 5px 18px rgba(11,38,56,.04); }
.product-card { display: grid; gap: 17px; padding: 20px; }
.product-card h3, .card h3 { margin: 0; font-size: 17px; }
.sku { width: max-content; border-radius: 5px; padding: 2px 7px; color: var(--aqua-dark); background: var(--aqua-soft); font: 700 11px ui-monospace, SFMono-Regular, Menlo, monospace; }
.tier-list { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 7px; }

/* Properties (docs/24 R2) — same card language as the catalog so the portal stays one thing. */
.property-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; }
.property-card { display: grid; gap: 10px; align-content: start; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: 0 5px 18px rgba(11,38,56,.04); padding: 20px; }
.property-card h3 { margin: 0; font-size: 17px; }
.property-card .button { justify-self: start; }
/* Deliberately quiet: a Free unit is a live customer, not an error state. */
.free-badge { margin-top: 4px; width: max-content; border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; color: var(--muted); background: #f4f8f8; font-size: 11px; font-weight: 600; }
.tier { border: 1px solid var(--line); border-radius: 8px; padding: 8px; text-align: center; }
.tier.active { border-color: var(--aqua); background: var(--aqua-soft); }
.tier span { display: block; color: var(--muted); font-size: 10px; }
.tier strong { display: block; margin-top: 3px; font-size: 12px; }
.product-actions { display: grid; grid-template-columns: 90px 1fr auto; align-items: end; gap: 10px; }
.band-readout { min-height: 42px; display: flex; align-items: center; border-radius: 9px; padding: 8px 10px; color: var(--muted); background: #f4f8f8; font-size: 12px; }
.quick-qty { display: flex; flex-wrap: wrap; gap: 5px; }
.quick-qty button { border: 1px solid var(--line); border-radius: 6px; padding: 3px 7px; color: var(--muted); background: #fff; font-size: 11px; }

.table-card { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 15px; border-bottom: 1px solid #edf2f3; text-align: left; vertical-align: middle; }
th { color: var(--muted); background: #f8fafa; text-transform: uppercase; letter-spacing: .06em; font-size: 10px; }
tbody tr:last-child td { border-bottom: 0; }
.empty { margin: 0; padding: 30px; color: var(--muted); text-align: center; }
.qty-control { display: flex; align-items: center; gap: 6px; }
.qty-control input { width: 74px; }
.small-button, .icon-button { border: 1px solid var(--line); border-radius: 7px; padding: 6px 9px; color: var(--ink); background: #fff; font-weight: 700; }
.small-button.danger { color: var(--danger); }
.status { display: inline-block; border-radius: 50px; padding: 4px 9px; color: #49606d; background: #e9eff1; text-transform: capitalize; font-size: 11px; font-weight: 800; }
.status.paid, .status.delivered { color: var(--success); background: #e0f4e9; }
.status.shipped, .status.fulfilled { color: #135d84; background: #e1f2fb; }
.status.cancelled, .status.refunded { color: var(--danger); background: #fde8e7; }
/* Referrals (docs/24 R3). 'sent' is the only status that wants the partner's attention, so
   it is the only warm one; the terminal states stay grey on purpose. */
.status.sent { color: #7a4c06; background: #fdf0d8; }
.status.accepted { color: #135d84; background: #e1f2fb; }
.status.completed { color: var(--success); background: #e0f4e9; }
.status.declined, .status.no_response, .status.lost { color: #6b7c85; background: #eceff1; }
/* Partner billing (docs/24 R4). Only the two states that need action are coloured; 'active'
   is deliberately quiet, because a working subscription is not news. */
.status.active { color: var(--success); background: #e0f4e9; }
.status.past_due { color: #7a4c06; background: #fdf0d8; }
.status.suspended { color: var(--danger); background: #fde8e7; }
.status.none { color: #6b7c85; background: #eceff1; }
/* Connection requests (docs/24 R5). 'pending' is warm because it is the one the partner may
   want to follow up on by phone; expired is grey, like every other closed state. */
.status.pending { color: #7a4c06; background: #fdf0d8; }
.status.expired { color: #6b7c85; background: #eceff1; }
#billingHelp { margin: 0; padding-left: 18px; line-height: 1.7; }
#billingStatusRow { margin-top: 10px; }
#billingStatusRow .muted { margin-top: 6px; font-size: 12px; }
.referral-top { display: grid; grid-template-columns: minmax(0,.85fr) minmax(0,1.15fr); gap: 18px; margin-bottom: 18px; align-items: start; }
.rating-card { padding: 20px; }
.rating-card h3 { margin: 0; font-size: 15px; }
.rating-value { margin: 8px 0 2px; font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.rating-comment { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.rating-stars { color: var(--gold); letter-spacing: 2px; font-size: 13px; }
.toggle-row { display: flex; flex-direction: row !important; align-items: center; gap: 10px; }
.toggle-row input { width: auto; margin: 0; flex: 0 0 auto; accent-color: var(--aqua, #00a8cc); }
.toggle-row span { margin: 0; line-height: 1.3; }
.hidden-until-accept { color: var(--muted); font-style: italic; font-size: 12px; }
/* Fleet (docs/24 R1): a dot + label reads faster than a pill in a dense device table. */
.fleet-claim { display: flex; align-items: end; gap: 10px; flex-wrap: wrap; }
.fleet-filters { display: flex; align-items: center; margin: 16px 0; }
.presence-help { max-width: 230px; margin-top: 5px; color: var(--muted); font-size: 12px; }
/* The claim-code preview hint (docs/24 R4 smart default) sits on its own line under the
   form controls rather than squeezing the row it explains. */
.fleet-claim .sku { flex-basis: 100%; margin: 2px 0 0; }
.dot { display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: #c3ced4; vertical-align: middle; }
.dot.on { background: var(--success); }
.dot.heat { background: var(--gold); }
.checkout-grid { display: grid; grid-template-columns: minmax(0,1.45fr) minmax(260px,.55fr); gap: 18px; margin-top: 18px; align-items: start; }
.form-card, .total-card { padding: 20px; }
.card-head { margin-bottom: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
.span-2 { grid-column: span 2; }
.total-card { position: sticky; top: 105px; }
.total-card dl { margin: 16px 0; }
.total-card dl div { display: flex; justify-content: space-between; padding: 8px 0; }
.total-card dt { color: var(--muted); }
.total-card dd { margin: 0; font-weight: 750; }
.total-card .grand { margin-top: 6px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 18px; }
.fine-print { color: var(--muted); font-size: 11px; }
.subheading { margin-top: 8px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 15px; font-weight: 800; }
.form-actions { display: flex; align-items: center; gap: 14px; margin-top: 22px; }

.alert-badge { display:inline-block; border-radius:8px; padding:3px 7px; font-weight:600; }
.alert-badge.critical { background:#fee2e2; color:#991b1b; }
.alert-badge.warning { background:#fef3c7; color:#92400e; }
.alert-badge.info { background:#dbeafe; color:#1e40af; }

dialog { width: min(720px, calc(100% - 28px)); max-height: calc(100vh - 44px); border: 0; border-radius: 17px; padding: 0; color: var(--ink); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(5,22,32,.58); backdrop-filter: blur(3px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; }
.icon-button { border: 0; font-size: 25px; }
#orderDetail { padding: 22px 24px 28px; }
.detail-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.detail-block { border-radius: 10px; padding: 13px; background: #f5f8f8; }
.detail-block span { display: block; color: var(--muted); font-size: 11px; }
.detail-block strong { display: block; margin-top: 3px; }
.detail-lines { margin-top: 18px; }
.detail-actions { display: flex; gap: 10px; margin-top: 18px; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 80; max-width: min(380px,calc(100% - 44px)); transform: translateY(120px); opacity: 0; border-radius: 10px; padding: 12px 15px; color: #fff; background: var(--navy); box-shadow: var(--shadow); transition: .2s ease; }
.toast.show { transform: none; opacity: 1; }
.toast.error { background: var(--danger); }

@media (max-width: 900px) {
  .portal { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -250px; z-index: 30; width: 232px; transition: left .2s ease; box-shadow: var(--shadow); }
  .sidebar.open { left: 0; }
  .menu-button { display: block; }
  .product-grid, .checkout-grid, .property-grid { grid-template-columns: 1fr; }
  .total-card { position: static; }
}
@media (max-width: 620px) {
  .auth-card { padding: 28px 22px; }
  .content { padding-top: 24px; }
  .section-head { align-items: stretch; flex-direction: column; }
  .compact { width: 100%; }
  .product-grid, .property-grid { grid-template-columns: 1fr; }
  .tier-list { grid-template-columns: repeat(2,1fr); }
  .product-actions, .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .session-pill { display: none; }
  th, td { padding: 11px 10px; }
}

.fleet-seasonal { display: flex; gap: 10px; margin: 12px 0; }
.fleet-seasonal[hidden] { display: none; }
input[data-seasonal-device] { margin-right: 8px; }

.incoming-requests { margin-bottom: 1rem; }
.incoming-requests h3, .incoming-requests > p { margin: 1rem; }
