:root {
  --bg: #f3f5fa;
  --panel: #ffffff;
  --side: #0f1f3d;
  --side-2: #16294d;
  --side-text: #b7c3dc;
  --text: #1d2433;
  --muted: #6b7489;
  --line: #e4e8f1;
  --primary: #1f6bff;
  --primary-2: #1557d6;
  --primary-soft: #e8f0ff;
  --green: #12a150; --green-soft: #e3f6eb;
  --amber: #c77700; --amber-soft: #fff3dc;
  --red: #d93a3a; --red-soft: #fde8e8;
  --violet: #6d4ce0; --violet-soft: #efeafe;
  --gray-soft: #eef0f5;
  --cyan: #0e8fb3; --cyan-soft: #e1f4fa;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  font-family: Inter, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
code, .mono { font-family: "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace; font-size: 12.5px; }
.hidden { display: none !important; }
a { color: var(--primary); text-decoration: none; }

/* layout */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 232px; background: var(--side); color: var(--side-text); display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 17px; padding: 20px 20px 18px; letter-spacing: .2px; }
.brand-lg { font-size: 22px; padding: 0 0 6px; color: var(--text); }
.logo { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, #3d8bff, #1f6bff 55%, #6d4ce0); display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 800; font-size: 17px; }
#nav { display: flex; flex-direction: column; padding: 4px 10px; gap: 2px; }
#nav a { color: var(--side-text); padding: 9px 12px; border-radius: 8px; display: flex; align-items: center; gap: 10px; font-weight: 500; }
#nav a:hover { background: var(--side-2); color: #fff; }
#nav a.active { background: var(--primary); color: #fff; }
.nav-section { text-transform: uppercase; font-size: 11px; letter-spacing: .08em; color: #6f7fa3; padding: 16px 12px 6px; }
.sidebar-foot { margin-top: auto; padding: 14px 18px; font-size: 12px; border-top: 1px solid var(--side-2); color: #8796b8; word-break: break-all; }
.sidebar-foot b { color: #dfe6f5; font-weight: 600; }
.main { margin-left: 232px; flex: 1; min-width: 0; }
.topbar { height: 62px; background: var(--panel); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 28px; position: sticky; top: 0; z-index: 5; }
.topbar h1 { font-size: 18px; margin: 0; font-weight: 650; }
.topbar-right { display: flex; gap: 8px; }
.content { padding: 24px 28px 48px; }

/* icons (pure CSS masks would need data URIs; use simple glyph boxes) */
.ico { width: 16px; height: 16px; border-radius: 4px; border: 2px solid currentColor; opacity: .85; flex: none; }
.ico-dash { border-radius: 50%; }
.ico-sim { border-radius: 2px 6px 2px 2px; }
.ico-qr { border-style: dashed; }
.ico-bell { border-radius: 8px 8px 3px 3px; }
.ico-link { border-radius: 8px; height: 10px; }
.ico-list { border-width: 2px 0; border-radius: 0; height: 12px; }
.ico-gear { border-style: dotted; border-radius: 50%; }

/* cards & grid */
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.two { grid-template-columns: 2fr 1fr; }
.half { grid-template-columns: 1fr 1fr; }
@media (max-width: 1100px) { .two, .half { grid-template-columns: 1fr; } }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-head h3 { margin: 0; font-size: 14.5px; font-weight: 650; }
.card-body { padding: 16px 18px; }
.card-body.flush { padding: 0; }
.kpi { padding: 16px 18px; }
.kpi .label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.kpi .value { font-size: 26px; font-weight: 700; margin-top: 6px; }
.kpi .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.kpi.accent-blue { border-top: 3px solid var(--primary); }
.kpi.accent-green { border-top: 3px solid var(--green); }
.kpi.accent-amber { border-top: 3px solid var(--amber); }
.kpi.accent-violet { border-top: 3px solid var(--violet); }
.kpi.accent-red { border-top: 3px solid var(--red); }
.kpi.accent-cyan { border-top: 3px solid var(--cyan); }
.mt { margin-top: 16px; }

/* toolbar */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
input, select, textarea { font: inherit; color: inherit; border: 1px solid #d5dbe7; border-radius: 8px; padding: 8px 10px; background: #fff; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.search { min-width: 260px; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 550; font-size: 13px; color: #333c50; }
label .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.btn { font: inherit; font-weight: 600; border: 1px solid #d5dbe7; background: #fff; color: var(--text); padding: 8px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f6f8fc; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-2); }
.btn.danger { color: var(--red); border-color: #f1c1c1; }
.btn.danger:hover { background: var(--red-soft); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--gray-soft); color: var(--text); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { border: 0; background: transparent; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
.seg { display: inline-flex; border: 1px solid #d5dbe7; border-radius: 9px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer; color: var(--muted); }
.seg button + button { border-left: 1px solid #d5dbe7; }
.seg button.on { background: var(--primary-soft); color: var(--primary); }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 10px 14px; background: #f8f9fc; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover td { background: #f7f9ff; }
td.wrap { white-space: normal; word-break: break-word; }
.empty { text-align: center; color: var(--muted); padding: 34px 0; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }

/* pills */
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--gray-soft); color: #4a5368; }
.pill.available, .pill.active, .pill.completed, .pill.ok, .pill.success { background: var(--green-soft); color: var(--green); }
.pill.reserved, .pill.initiated, .pill.authenticated { background: var(--amber-soft); color: var(--amber); }
.pill.downloaded, .pill.bpp_sent { background: var(--cyan-soft); color: var(--cyan); }
.pill.installed, .pill.disabled { background: var(--primary-soft); color: var(--primary); }
.pill.enabled { background: var(--violet-soft); color: var(--violet); }
.pill.deleted, .pill.retired, .pill.revoked, .pill.expired, .pill.cancelled, .pill.exhausted { background: var(--gray-soft); color: #5b6478; }
.pill.failed, .pill.bad { background: var(--red-soft); color: var(--red); }
.flag { display: inline-block; font-size: 11px; background: var(--amber-soft); color: var(--amber); border-radius: 4px; padding: 1px 6px; margin: 1px 2px; font-weight: 600; }

/* detail */
.detail-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.detail-head h2 { margin: 0; font-size: 20px; }
.detail-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.back { color: var(--muted); font-weight: 600; }
.kv { display: grid; grid-template-columns: 150px 1fr; row-gap: 10px; column-gap: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding: 0 12px; }
.tabs button { border: 0; background: transparent; padding: 12px 14px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--primary); border-bottom-color: var(--primary); }
.timeline { list-style: none; margin: 0; padding: 4px 18px 10px; }
.timeline li { position: relative; padding: 10px 0 10px 22px; border-left: 2px solid var(--line); margin-left: 6px; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 15px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid var(--primary); }
.timeline .when { color: var(--muted); font-size: 12px; }
.timeline .what { font-weight: 600; }
.timeline .who { color: var(--muted); font-weight: 400; font-size: 12px; }

/* activation code */
.ac-box { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.qr { width: 220px; height: 220px; border: 1px solid var(--line); border-radius: 10px; padding: 8px; background: #fff; }
.qr img { width: 100%; height: 100%; image-rendering: pixelated; }
.ac-string { font-family: "JetBrains Mono", Menlo, monospace; background: #f6f8fc; border: 1px dashed #c9d3e6; border-radius: 8px; padding: 10px 12px; word-break: break-all; font-size: 13px; }
.ac-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* charts */
.chart { width: 100%; height: 220px; }
.chart text { font-size: 11px; fill: #7a8399; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.stack { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--gray-soft); }
.stack span { display: block; height: 100%; }
.bg-available { background: var(--green); } .bg-reserved { background: var(--amber); } .bg-downloaded { background: var(--cyan); }
.bg-installed { background: var(--primary); } .bg-enabled { background: var(--violet); } .bg-disabled { background: #7ea6ff; }
.bg-deleted { background: #9aa3b5; } .bg-retired { background: #c4cad6; } .bg-failed { background: var(--red); }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { padding: 10px 18px; border-bottom: 1px solid var(--line); }
.feed li:last-child { border-bottom: 0; }
.feed .meta { color: var(--muted); font-size: 12px; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 20; overflow-y: auto; }
.modal-card { background: #fff; border-radius: 14px; width: min(720px, 100%); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 18px 20px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.pick-list { max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.pick-list label { flex-direction: row; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); font-weight: 400; }
.pick-list label:last-child { border-bottom: 0; }
.kind-desc { color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.result-list { list-style: none; padding: 0; margin: 12px 0 0; max-height: 260px; overflow-y: auto; }
.result-list li { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.ok-text { color: var(--green); font-weight: 600; } .error-text { color: var(--red); font-weight: 600; }
pre.hex { white-space: pre-wrap; word-break: break-all; background: #f6f8fc; border-radius: 8px; padding: 12px; max-height: 360px; overflow-y: auto; font-size: 12px; }
.muted { color: var(--muted); }
.grow { flex: 1; min-width: 260px; }

/* login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at 20% 20%, #e3ecff 0, transparent 40%), radial-gradient(circle at 80% 70%, #efe9ff 0, transparent 40%), var(--bg); }
.login-card { width: min(400px, 92vw); background: #fff; padding: 30px; border-radius: 16px; box-shadow: 0 12px 40px rgba(16,24,40,.12); display: flex; flex-direction: column; gap: 16px; }
.login-card p { margin: 0; }

.toast { position: fixed; bottom: 24px; right: 24px; background: #101828; color: #fff; padding: 12px 16px; border-radius: 10px; z-index: 30; max-width: 420px; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.toast.err { background: var(--red); }

/* multi-tenant portal */
.scope-switch { padding: 0 14px 10px; }
.scope-switch select { width: 100%; background: var(--side-2); color: #fff; border-color: #34405e; }
.banner { margin: 18px 28px 0; padding: 12px 16px; border-radius: 10px; background: #fff7e6; border: 1px solid #f3d595; color: #7a5200; font-weight: 550; }
.banner.bad { background: var(--red-soft); border-color: #f1c1c1; color: #8f2020; }
.login-card .links { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 13px; margin-top: 4px; }
.login-card .ok-box { background: #eefaf2; border: 1px solid #bfe8cc; color: #11633a; border-radius: 8px; padding: 10px 12px; }
.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 450; }
.meter { height: 8px; border-radius: 4px; background: var(--gray-soft); overflow: hidden; margin-top: 6px; }
.meter > span { display: block; height: 100%; background: var(--primary); }
.secret { word-break: break-all; background: #f6f8fc; border: 1px dashed #c9d2e3; border-radius: 8px; padding: 10px 12px; }
.tenant-tag { display: inline-block; font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; margin-left: 6px; }
td.nowrap, .nowrap { white-space: nowrap; }
.modal-body h4 { margin: 18px 0 10px; font-size: 14px; }
pre.secret { white-space: pre-wrap; font-size: 12.5px; max-height: 50vh; overflow: auto; }

.small { font-size: 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; border-radius: 999px; background: var(--primary-soft); font-size: 13px; }
.group-tag { display: inline-block; white-space: nowrap; font-size: 11px; background: var(--gray-soft); color: #4a5368; border-radius: 4px; padding: 1px 6px; margin-left: 4px; font-weight: 600; text-decoration: none; }
.group-tag:hover { background: var(--primary-soft); color: var(--primary); }
.result-box { max-height: 280px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; margin-top: 8px; }
textarea.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; white-space: pre; }
.intro { margin: 0 0 12px; }
.banner.ok { background: var(--green-soft, #e7f7ee); border-color: #b5e3c7; color: #145c33; }
#content .banner.ok { margin: 12px 0 16px; }

/* Generate AC */
.req { color: #d93025; font-weight: 600; }
details.more { border: 1px solid #e3e8f2; border-radius: 8px; padding: 8px 12px; }
details.more summary { cursor: pointer; color: #4a5b78; font-size: 13px; }
details.more .form-grid { margin-top: 10px; }
.ac-formats { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.ac-formats > span { font-weight: 500; }
.ac-link { margin-top: 12px; word-break: break-all; font-size: 12px; }
.error-box { margin-top: 12px; }
#ac-result .ac-box { margin-top: 12px; }

/* the signed-out portal's top bar, and the test eSIM page */
.pub-top { position: fixed; inset: 0 0 auto 0; height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 24px; background: var(--panel); border-bottom: 1px solid var(--line); z-index: 6; }
.pub-top .brand { padding: 0; color: var(--text); }
.pub-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.pub-nav a { padding: 8px 12px; border-radius: 8px; font-weight: 600; color: var(--muted); }
.pub-nav a:hover { background: var(--gray-soft); color: var(--text); }
.pub-nav a.active { background: var(--primary-soft); color: var(--primary); }
.login.with-top { padding-top: 62px; }
.public { min-height: 100vh; background: var(--bg); padding-top: 62px; }
.demo-main { max-width: 860px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.public .demo-main { padding: 24px 16px 48px; }
.demo-main > p { margin: 0; }
.demo-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.demo-row { display: flex; gap: 10px; flex-wrap: wrap; }
.demo-grow { flex: 1; min-width: 0; }
.demo-pad { padding: 0 18px 12px; margin: 0; }
.demo-foot { text-align: center; }
.demo-cmd { white-space: pre-wrap; }
.card-sub { border-top: 1px solid var(--line); }
.warn-text { color: var(--amber); font-weight: 600; }
.kv dd.mono { font-family: "JetBrains Mono", Menlo, monospace; }
.kv .tag { margin-left: 8px; }
.demo-main .form-grid p { margin: 0; }
@media (max-width: 640px) {
  .pub-top { padding: 0 12px; }
  .pub-top .brand span:last-child { display: none; }
  .demo-main .form-grid { grid-template-columns: 1fr; }
  .demo-main .kv { grid-template-columns: 90px 1fr; }
  .demo-main .qr { width: 180px; height: 180px; }
}
