:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel2: #172033;
  --line: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #2563eb;
  --accent2: #1d4ed8;
  --ok: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --info: #0891b2;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: #7dd3fc; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ------------------------------------------------------------ header */
.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 26px;
  color: #fff;
  background:
    linear-gradient(115deg, var(--accent2), var(--accent) 48%, var(--accent2) 100%);
  background-size: 180% 180%;
  border-bottom: 1px solid rgba(255, 255, 255, .14);
  box-shadow: 0 8px 30px rgba(2, 8, 23, .38), inset 0 -1px 0 rgba(255, 255, 255, .06);
  overflow: hidden;
  animation: he-shift 16s ease-in-out infinite;
}
.topbar::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(680px 150px at 12% -30%, rgba(255, 255, 255, .30), transparent 62%),
    radial-gradient(520px 150px at 92% 130%, rgba(255, 255, 255, .14), transparent 60%),
    radial-gradient(340px 200px at 60% 160%, rgba(0, 0, 0, .20), transparent 70%);
}
.topbar::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0; left: 0; width: 45%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .18), transparent);
  transform: translateX(-140%) skewX(-18deg);
  animation: he-sheen 8s ease-in-out infinite;
  pointer-events: none;
}
.topbar > * { position: relative; z-index: 1; }
.brand { display: flex; align-items: center; gap: 15px; }
.brand h1 { font-size: 18px; margin: 0; }
.brand p { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; }
.topbar .brand h1, .portal-head .brand h1 { color: #fff; letter-spacing: .2px; text-shadow: 0 1px 2px rgba(0, 0, 0, .22); }
.topbar .brand p, .portal-head .brand p { color: #fff; }
.logo {
  width: 46px; height: 46px; border-radius: 13px;
  display: grid; place-items: center;
  background: linear-gradient(160deg, rgba(255, 255, 255, .34), rgba(255, 255, 255, .10));
  border: 1px solid rgba(255, 255, 255, .45);
  color: #fff; font-weight: 700; font-size: 21px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .28), inset 0 1px 0 rgba(255, 255, 255, .5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.logo-img { object-fit: contain; background: #fff; padding: 4px; }
.topmeta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.chip {
  background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .30);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 12px; color: #fff;
  text-decoration: none;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: background .18s ease, border-color .18s ease, transform .18s ease;
}
a.chip:hover { background: rgba(255, 255, 255, .26); border-color: rgba(255, 255, 255, .5); text-decoration: none; transform: translateY(-1px); }
.chip.warn-chip { border-color: rgba(252, 211, 77, .8); color: #fde68a; }
.topbar .btn.ghost { border-color: rgba(255, 255, 255, .45); color: #fff; background: rgba(255, 255, 255, .08); }
.topbar .btn.ghost:hover { background: rgba(255, 255, 255, .2); }

@keyframes he-shift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}
@keyframes he-sheen {
  0%, 62% { transform: translateX(-140%) skewX(-18deg); }
  100% { transform: translateX(340%) skewX(-18deg); }
}
@media (prefers-reduced-motion: reduce) {
  .topbar { animation: none; }
  .topbar::after { animation: none; opacity: 0; }
}

.tabs {
  display: flex; gap: 4px; padding: 0 18px;
  background: #0c1526; border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.tab {
  background: none; border: none; color: var(--muted);
  padding: 13px 16px; font-size: 13.5px; cursor: pointer;
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: #fff; border-bottom-color: var(--accent); }

main { padding: 22px 24px 60px; max-width: 1240px; margin: 0 auto; }
.panel { display: none; }
.panel.active { display: block; }
.loading { color: var(--muted); padding: 40px; text-align: center; }

h2 { font-size: 17px; margin: 0 0 14px; }
h3 { font-size: 14.5px; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.center { text-align: center; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.grow { flex: 1; }

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }

/* KPI cards */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
}
.kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 24px; font-weight: 650; margin-top: 6px; }
.kpi .value.bad { color: #fca5a5; }
.kpi .value.ok { color: #86efac; }

/* Cards */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin-bottom: 18px;
}
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
tbody tr:hover { background: var(--panel2); }
td.actions { text-align: right; white-space: nowrap; }
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.tbl-wrap table td, .tbl-wrap table th { border-bottom: 1px solid #24324a; }
.tbl-wrap table tr:last-child td { border-bottom: none; }

/* Badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.badge.active, .badge.paid, .badge.completed { background: rgba(22,163,74,.16); color: #86efac; }
.badge.suspended, .badge.overdue, .badge.failed { background: rgba(220,38,38,.16); color: #fca5a5; }
.badge.unpaid, .badge.partial, .badge.pending { background: rgba(217,119,6,.16); color: #fcd34d; }
.badge.cancelled, .badge.void { background: rgba(148,163,184,.16); color: #cbd5e1; }
.badge.refunded { background: rgba(8,145,178,.16); color: #67e8f9; }
.badge.trial, .badge.expiring, .badge.grace { background: rgba(217,119,6,.16); color: #fcd34d; }
.badge.vendor { background: rgba(124,58,237,.18); color: #c4b5fd; }
.badge.unverified, .badge.expired, .badge.revoked, .badge.grace_expired, .badge.inactive, .badge.trial_expired { background: rgba(220,38,38,.16); color: #fca5a5; }

/* License banner */
.license-banner {
  display: flex; align-items: center; gap: 12px; margin: 0 0 14px;
  padding: 11px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font-size: 13px;
}
.license-banner .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex: none; }
.license-banner > div { flex: 1; min-width: 0; }
.license-banner.warn { border-color: rgba(217,119,6,.45); background: rgba(217,119,6,.09); }
.license-banner.warn .dot { background: #f59e0b; }
.license-banner.bad { border-color: rgba(220,38,38,.5); background: rgba(220,38,38,.09); }
.license-banner.bad .dot { background: #ef4444; }
.key-box {
  background: #0b1220; border: 1px dashed var(--line); border-radius: 8px;
  padding: 14px 16px; font-size: 17px; letter-spacing: .06em; text-align: center;
  color: #d1fae5; word-break: break-all; margin: 12px 0;
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--accent); color: #fff; border: 1px solid transparent;
  border-radius: 8px; padding: 8px 14px; font-size: 13px; cursor: pointer;
  text-decoration: none; font-family: inherit;
}
.btn:hover { background: var(--accent2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn.ghost:hover { background: var(--panel2); }
.btn.danger { background: var(--bad); }
.btn.danger:hover { background: #b91c1c; }
.btn.ok { background: var(--ok); }
.btn.ok:hover { background: #15803d; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn-row { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

/* Forms */
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 5px; }
input, select, textarea {
  width: 100%; background: #0b1220; border: 1px solid var(--line);
  color: var(--text); border-radius: 8px; padding: 9px 11px; font: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { min-height: 84px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 14px; }
.captcha { margin: 10px 0 14px; min-height: 0; }
@media (max-width: 640px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.check { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.check input { width: auto; }
.filters { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.filters input, .filters select { width: auto; min-width: 160px; }
.fieldset-title { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; margin: 20px 0 10px; border-top: 1px solid var(--line); padding-top: 16px; }
.fieldset-title:first-child { margin-top: 0; border-top: none; padding-top: 0; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(3,7,18,.72); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal[hidden] { display: none; }
.modal .sheet {
  background: #131f36; border: 1px solid var(--line); border-radius: 14px;
  width: 100%; max-width: 720px; max-height: 90vh; overflow: auto; padding: 22px;
}
.modal .sheet.wide { max-width: 940px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-head h2 { margin: 0; }
.x { background: none; border: none; color: var(--muted); font-size: 22px; cursor: pointer; line-height: 1; }
.x:hover { color: #fff; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #14532d; border: 1px solid var(--ok); color: #dcfce7;
  padding: 12px 20px; border-radius: 10px; z-index: 100; max-width: 90vw;
  box-shadow: 0 8px 30px rgba(0,0,0,.4);
}
.toast.err { background: #7f1d1d; border-color: var(--bad); color: #fee2e2; }
.toast[hidden] { display: none; }

.empty { text-align: center; color: var(--muted); padding: 34px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 6px; }
.section { margin-bottom: 26px; }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 6px 16px; }
.kv dt { color: var(--muted); font-size: 12.5px; }
.kv dd { margin: 0; }
.inline-note { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; color: var(--muted); }

/* Portal */
body.portal { background: #0b1220; }
.portal-wrap { max-width: 980px; margin: 0 auto; padding: 26px 20px 70px; }
.portal-head {
  position: relative;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 20px 24px; border-radius: 16px; margin-bottom: 22px; color: #fff;
  background: linear-gradient(115deg, var(--accent2), var(--accent) 48%, var(--accent2) 100%);
  background-size: 180% 180%;
  border: 1px solid rgba(255, 255, 255, .16);
  box-shadow: 0 12px 34px rgba(2, 8, 23, .32);
  overflow: hidden;
  animation: he-shift 16s ease-in-out infinite;
}
.portal-head::before {
  content: "";
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(560px 130px at 10% -30%, rgba(255, 255, 255, .28), transparent 62%),
    radial-gradient(420px 150px at 95% 140%, rgba(255, 255, 255, .14), transparent 60%);
}
.portal-head > * { position: relative; z-index: 1; }
.portal-head .brand h1 { font-size: 17px; margin: 0; color: #fff; text-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
.portal-head .brand p { color: #fff; }
.portal-head .chip { background: rgba(255, 255, 255, .16); border-color: rgba(255, 255, 255, .32); color: #fff; }
.portal-head .logo {
  background: linear-gradient(160deg, rgba(255, 255, 255, .34), rgba(255, 255, 255, .10));
  border: 1px solid rgba(255, 255, 255, .45); color: #fff;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .28), inset 0 1px 0 rgba(255, 255, 255, .5);
}
.portal-head .logo-img { background: #fff; padding: 4px; }

.login-card {
  position: relative; overflow: hidden;
  max-width: 420px; margin: 8vh auto 0;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 30px;
  box-shadow: 0 18px 50px rgba(2, 8, 23, .35);
}
.login-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 5px;
  background: linear-gradient(90deg, var(--accent2), var(--accent), var(--accent2));
}
.login-card .logo {
  background: linear-gradient(150deg, var(--accent), var(--accent2));
  border: none; color: #fff; box-shadow: 0 8px 20px rgba(2, 8, 23, .3);
}
.login-card .logo-img { background: #fff; padding: 4px; }
.invoice-box { background: #fff; color: #111827; border-radius: 12px; padding: 30px; }
.invoice-box h2, .invoice-box h3 { color: #111827; }
.invoice-box table td, .invoice-box table th { border-color: #e5e7eb; color: #111827; }
.invoice-box .muted { color: #6b7280; }
.inv-total { font-size: 20px; font-weight: 700; }
@media print {
  body.portal { background: #fff; }
  .no-print { display: none !important; }
  .portal-wrap { padding: 0; }
}

/* Auth layout (portal sign-in / register) */
.auth-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 760px) { .auth-grid { grid-template-columns: 1fr; } }
.invoice-box.no-print-title { margin-bottom: 8px; }

/* ---------------------------------------------------------------- light theme */
body.theme-light {
  --bg: #eef2f7;
  --panel: #ffffff;
  --panel2: #f8fafc;
  --line: #d8e0ea;
  --text: #0f172a;
  --muted: #5b6b80;
}
body.theme-light,
body.portal.theme-light { background: #eef2f7; }
body.theme-light .tabs { background: #ffffff; }
body.theme-light .tab.active { color: #0f172a; }
body.theme-light .muted { color: var(--muted); }
body.theme-light input,
body.theme-light select,
body.theme-light textarea { background: #ffffff; color: var(--text); }
body.theme-light .tbl-wrap table td,
body.theme-light .tbl-wrap table th { border-color: #e6ecf3; }
body.theme-light .modal .sheet { background: #ffffff; }
body.theme-light .inline-note { background: #f1f5f9; }
body.theme-light .kpi,
body.theme-light .card,
body.theme-light .tbl-wrap,
body.theme-light .login-card,
body.theme-light .portal-head { box-shadow: 0 1px 2px rgba(15,23,42,.05); }
body.theme-light .badge.active, body.theme-light .badge.paid, body.theme-light .badge.completed { background: #dcfce7; color: #166534; }
body.theme-light .badge.suspended, body.theme-light .badge.overdue, body.theme-light .badge.failed { background: #fee2e2; color: #991b1b; }
body.theme-light .badge.unpaid, body.theme-light .badge.partial, body.theme-light .badge.pending { background: #fef3c7; color: #92400e; }
body.theme-light .badge.cancelled, body.theme-light .badge.void { background: #e2e8f0; color: #475569; }
body.theme-light .badge.refunded { background: #cffafe; color: #155e75; }
body.theme-light .badge.vendor { background: #ede9fe; color: #5b21b6; }
body.theme-light .badge.trial, body.theme-light .badge.expiring, body.theme-light .badge.grace { background: #fef3c7; color: #92400e; }
body.theme-light .badge.unverified, body.theme-light .badge.expired, body.theme-light .badge.revoked, body.theme-light .badge.grace_expired, body.theme-light .badge.inactive, body.theme-light .badge.trial_expired { background: #fee2e2; color: #991b1b; }
body.theme-light .toast { background: #14532d; }
body.theme-light .toast.err { background: #7f1d1d; }
body.theme-light .btn.ghost { color: var(--text); }
body.theme-light a { color: #1d4ed8; }
/* Header/portal banner keeps its coloured look in the light theme. */
body.theme-light .topbar a.chip,
body.theme-light .portal-head a.chip,
.topbar a.chip,
.portal-head a.chip { color: #fff; }

/* Colour swatches (appearance settings) */
.swatch { width: 30px; height: 30px; border-radius: 8px; border: 2px solid var(--line); cursor: pointer; padding: 0; }
.swatch:hover { border-color: var(--text); }

/* Header tagline is always white on the coloured banner (both themes). */
.topbar .brand p,
.portal-head .brand p,
body.theme-light .topbar .brand p,
body.theme-light .portal-head .brand p {
  color: #ffffff;
}

/* ------------------------------------------------------------ mobile */
@media (max-width: 760px) {
  .topbar { padding: 10px 12px; gap: 8px; flex-wrap: wrap; }
  .brand { gap: 10px; }
  .brand h1 { font-size: 15px; }
  .brand p { display: none; }
  .logo { width: 34px; height: 34px; border-radius: 9px; font-size: 16px; }
  .topmeta { width: 100%; gap: 5px; }
  .topmeta .chip { padding: 4px 9px; font-size: 11px; }
  .topbar .btn.ghost { padding: 5px 9px; font-size: 11.5px; }
  .tabs { padding: 0 6px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { padding: 11px 12px; font-size: 13px; }
  main { padding: 14px 12px 48px; }
  .card { padding: 14px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .portal .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { padding: 12px; }
  .kpi .value { font-size: 20px; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dt { margin-top: 8px; }
  .kv dd { margin-bottom: 4px; }
  .license-banner { flex-wrap: wrap; padding: 10px 12px; gap: 8px; }
  .license-banner > div { flex: 1 1 100%; }
  .license-banner .btn { width: 100%; justify-content: center; }
  .modal { padding: 8px; align-items: flex-start; }
  .modal .sheet { width: 100%; max-width: 100%; max-height: 92vh; overflow-y: auto; padding: 16px; }
  .modal .sheet.wide { max-width: 100%; }
  .tbl-wrap { -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
  main .tbl-wrap table { min-width: 720px; }
  main .tbl-wrap table th, main .tbl-wrap table td { white-space: nowrap; }
  main .tbl-wrap table td .muted.small { white-space: normal; }
  #panel-license .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #panel-license .kv dd { overflow-wrap: anywhere; }
  #panel-license .grid2,
  #panel-license .grid3 { grid-template-columns: 1fr; }
  #panel-license .field .btn { width: 100%; justify-content: center; }
  #panel-license .btn-row { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  #panel-license .btn-row .btn { width: 100%; justify-content: center; }
  #panel-licenses .row.between > .btn-row { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  #panel-licenses .row.between > .btn-row .btn { width: 100%; justify-content: center; }
  .portal-wrap { padding: 16px 12px 50px; }
  .portal-head { padding: 16px; align-items: flex-start; flex-direction: column; }
  .portal-head .topmeta { width: auto; }
  .key-box { font-size: 15px; }
}
@media (max-width: 420px) {
  .kpis { grid-template-columns: 1fr; }
  #panel-license .kpis, .portal .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Mobile card lists for the Licenses tab */
#panel-licenses .mobile-list { display: none; }
@media (max-width: 760px) {
  #panel-licenses .tbl-wrap { display: none; }
  #panel-licenses .mobile-list { display: block; }
  #panel-licenses .mobile-item {
    border: 1px solid var(--line); border-radius: 10px; background: var(--panel2);
    padding: 12px; margin-bottom: 10px;
  }
  #panel-licenses .mobile-item:last-child { margin-bottom: 0; }
  #panel-licenses .mobile-meta {
    display: flex; flex-wrap: wrap; gap: 4px 14px;
    color: var(--muted); font-size: 12px; margin-top: 6px;
  }
  #panel-licenses .key-small { font-size: 11.5px; overflow-wrap: anywhere; }
  #panel-licenses .mobile-item .btn-row { justify-content: flex-start; }
}

/* Mobile card lists for the customer portal */
.portal .mobile-list { display: none; }
@media (max-width: 760px) {
  .portal .hide-mobile { display: none; }
  .portal .mobile-list { display: block; }
  .portal .mobile-item {
    border: 1px solid var(--line); border-radius: 10px; background: var(--panel2);
    padding: 12px; margin-bottom: 10px;
  }
  .portal .mobile-item:last-child { margin-bottom: 0; }
  .portal .mobile-meta {
    display: flex; flex-wrap: wrap; gap: 4px 14px;
    color: var(--muted); font-size: 12px; margin-top: 6px;
  }
  .portal .mobile-item .btn-row { justify-content: flex-start; }
  .portal .key-small { font-size: 11.5px; overflow-wrap: anywhere; }
}

/* Tickets */
.badge.open { background: rgba(37,99,235,.16); color: #93c5fd; }
.badge.answered { background: rgba(22,163,74,.16); color: #86efac; }
.badge.closed { background: rgba(148,163,184,.18); color: #cbd5e1; }
.badge.urgent { background: rgba(220,38,38,.18); color: #fca5a5; }
.badge.high { background: rgba(217,119,6,.16); color: #fcd34d; }
.badge.normal { background: rgba(8,145,178,.16); color: #67e8f9; }
.badge.low { background: rgba(148,163,184,.16); color: #cbd5e1; }
body.theme-light .badge.open { background: #dbeafe; color: #1d4ed8; }
body.theme-light .badge.answered { background: #dcfce7; color: #166534; }
body.theme-light .badge.closed, body.theme-light .badge.low { background: #e2e8f0; color: #475569; }
body.theme-light .badge.urgent { background: #fee2e2; color: #991b1b; }
body.theme-light .badge.high { background: #fef3c7; color: #92400e; }
body.theme-light .badge.normal { background: #cffafe; color: #155e75; }

.ticket-thread { display: grid; gap: 10px; margin: 14px 0; }
.ticket-msg { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: var(--panel2); }
.ticket-msg.admin { border-color: rgba(37,99,235,.55); background: rgba(37,99,235,.09); }
.ticket-msg.system { background: transparent; border-style: dashed; color: var(--muted); font-style: italic; }
.ticket-meta { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.ticket-body { white-space: pre-wrap; overflow-wrap: anywhere; }

#panel-tickets .mobile-list { display: none; }
@media (max-width: 760px) {
  #panel-tickets #ticketList { border: 0; background: transparent; overflow: visible; }
  #panel-tickets #ticketList table { display: none; }
  #panel-tickets .mobile-list { display: block; }
  #panel-tickets .mobile-item {
    border: 1px solid var(--line); border-radius: 10px; background: var(--panel2);
    padding: 12px; margin-bottom: 10px;
  }
  #panel-tickets .mobile-item:last-child { margin-bottom: 0; }
  #panel-tickets .mobile-meta {
    display: flex; flex-wrap: wrap; gap: 4px 14px;
    color: var(--muted); font-size: 12px; margin-top: 6px;
  }
  #panel-tickets .mobile-item .btn-row { justify-content: flex-start; }
}

/* Customer portal: main column + optional plugin sidebar */
.portal-wrap { max-width: 1220px; }
.portal-layout { display: block; }
.portal-layout.has-side {
  display: grid; grid-template-columns: minmax(0, 1fr) 320px;
  gap: 22px; align-items: start;
}
.portal-main { min-width: 0; }
.portal-side {
  display: flex; flex-direction: column; gap: 16px;
  position: sticky; top: 16px;
}
.portal-side .card { margin-bottom: 0; }
.client-message-item + .client-message-item {
  border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px;
}
.client-message-body { white-space: pre-wrap; color: var(--muted); margin-top: 4px; overflow-wrap: anywhere; }
@media (max-width: 1000px) {
  .portal-layout.has-side { grid-template-columns: 1fr; }
  .portal-side { position: static; order: -1; }
}

/* Fit the five portal KPIs next to the plugin sidebar on wide screens. */
@media (min-width: 1001px) {
  .portal-layout.has-side .kpis { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
}

/* Guest ordering on the portal sign-in page */
.plan-card {
  display: flex; flex-direction: column; gap: 8px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel2); padding: 14px;
}
.plan-card .btn { align-self: flex-start; margin-top: 2px; }

/* Activity cards on mobile */
#panel-activity .mobile-list { display: none; }
@media (max-width: 760px) {
  #panel-activity #actList { border: 0; background: transparent; overflow: visible; }
  #panel-activity #actList table { display: none; }
  #panel-activity .mobile-list { display: block; }
  #panel-activity .mobile-item {
    border: 1px solid var(--line); border-radius: 10px; background: var(--panel2);
    padding: 12px; margin-bottom: 10px; overflow-wrap: anywhere;
  }
  #panel-activity .mobile-item:last-child { margin-bottom: 0; }
  #panel-activity .mobile-meta {
    display: flex; flex-wrap: wrap; gap: 4px 14px;
    color: var(--muted); font-size: 12px; margin-top: 6px;
  }
}

/* Fraud decisions */
.badge.allow { background: rgba(22,163,74,.16); color: #86efac; }
.badge.review { background: rgba(217,119,6,.16); color: #fcd34d; }
.badge.reject { background: rgba(220,38,38,.16); color: #fca5a5; }
body.theme-light .badge.allow { background: #dcfce7; color: #166534; }
body.theme-light .badge.review { background: #fef3c7; color: #92400e; }
body.theme-light .badge.reject { background: #fee2e2; color: #991b1b; }

/* Guest checkout wizard */
.checkout-stepper { display: flex; align-items: center; margin: 2px 0 22px; }
.checkout-step {
  display: flex; align-items: center; gap: 8px; padding: 0; border: 0; background: none;
  color: var(--muted); font: inherit; font-size: 13px; cursor: pointer;
}
.checkout-step .num {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
  border: 1px solid var(--line); background: var(--panel2);
}
.checkout-step.active { color: var(--text); }
.checkout-step.active .num { background: var(--accent); border-color: var(--accent); color: #fff; }
.checkout-step.done { color: #86efac; }
.checkout-step.done .num { background: rgba(22,163,74,.18); border-color: rgba(22,163,74,.5); color: #86efac; }
.checkout-step:disabled { cursor: default; opacity: .72; }
.checkout-line { flex: 1; height: 1px; background: var(--line); margin: 0 10px; min-width: 18px; }
.checkout-grid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 22px; align-items: start; }
.checkout-main { min-width: 0; }
.checkout-heading h3 { margin: 0 0 4px; font-size: 18px; }
.checkout-heading p { margin: 0 0 16px; }
.checkout-summary {
  border: 1px solid var(--line); border-radius: 12px; background: var(--panel2);
  padding: 16px; position: sticky; top: 0;
}
.checkout-summary h3 { margin: 0 0 12px; }
.checkout-plan-name { font-weight: 650; font-size: 15px; }
.checkout-lines { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; display: grid; gap: 6px; }
.checkout-lines .row { gap: 8px; }
.checkout-total { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; font-size: 16px; font-weight: 700; }
.checkout-secure { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11.5px; }
.checkout-plans { display: grid; gap: 10px; }
.checkout-plan-option {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; color: var(--text); font: inherit; cursor: pointer;
}
.checkout-plan-option:hover { border-color: var(--accent); }
.checkout-plan-option.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.checkout-radio {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 11px; color: #fff;
  border: 1px solid var(--line); background: transparent;
}
.checkout-plan-option.selected .checkout-radio { background: var(--accent); border-color: var(--accent); }
.checkout-plan-copy { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.checkout-plan-price { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 650; white-space: nowrap; text-align: right; }
.checkout-plan-price small { display: block; font-weight: 400; color: var(--muted); font-size: 10.5px; }
.checkout-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 20px; }
.checkout-actions .btn { min-height: 40px; }
/* Cart */
.cart-chip { position: relative; }
.cart-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 19px; height: 19px; padding: 0 5px; margin-left: 5px;
  border-radius: 999px; background: rgba(255, 255, 255, .24);
  font-size: 11px; font-weight: 700; line-height: 1;
}
.cart-chip.has-items .cart-count { background: var(--accent); color: #fff; }
.cart-item {
  border: 1px solid var(--line); border-radius: 12px; background: var(--panel2);
  padding: 14px;
}
.cart-item + .cart-item { margin-top: 10px; }
.cart-item .field { margin-bottom: 10px; }
.cart-x { flex: none; padding: 0 4px; }
.cart-qty {
  display: inline-flex; align-items: center; border: 1px solid var(--line);
  border-radius: 8px; overflow: hidden; background: transparent;
}
.cart-qty button {
  width: 32px; height: 30px; border: 0; background: transparent;
  color: var(--text); font: inherit; font-size: 16px; cursor: pointer;
}
.cart-qty button:hover { background: rgba(127, 127, 127, .12); }
.cart-qty span { min-width: 30px; text-align: center; font-weight: 650; }
.cart-summary-inline {
  margin-top: 16px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--panel2); padding: 14px;
}
.cart-summary-inline .checkout-lines { margin-top: 10px; }
.cart-review-list { display: grid; gap: 8px; }
.cart-review-item {
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel2); padding: 12px;
}

@media (max-width: 760px) {
  .checkout-grid { grid-template-columns: 1fr; }
  .checkout-summary { position: static; order: -1; }
  .checkout-stepper { overflow-x: auto; padding-bottom: 6px; }
  .checkout-step { flex: none; }
  .checkout-step .label { font-size: 11px; }
  .checkout-line { margin: 0 6px; min-width: 12px; }
  .checkout-actions .btn { flex: 1; justify-content: center; }
  .checkout-plan-option { align-items: flex-start; }
  .checkout-plan-price { font-size: 12px; }
}

.checkout-group-title {
  margin: 18px 0 8px; color: var(--muted); font-size: 11.5px;
  text-transform: uppercase; letter-spacing: .05em; font-weight: 650;
}
.checkout-group-title:first-of-type { margin-top: 0; }
