:root {
  --bg: #020617;
  --card: #0f172a;
  --card2: rgba(2, 6, 23, .6);
  --border: #1e293b;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --dim: #64748b;
  --blue: #3b82f6;
  --green: #10b981;
  --red: #f87171;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  justify-content: center;
  padding: 40px 16px;
  min-height: 100vh;
}
::selection { background: #2563eb; color: #fff; }

.page { width: 100%; max-width: 42rem; display: flex; flex-direction: column; gap: 24px; }

/* Header */
.header { text-align: center; }
.header-row { display: flex; justify-content: center; align-items: center; gap: 12px; }
h1 { font-size: 1.875rem; font-weight: 800; letter-spacing: -.025em; margin: 8px 0; color: #fff; }
.subtitle { color: var(--muted); font-size: .875rem; max-width: 32rem; margin: 0 auto; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 9999px;
  font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  border: 1px solid; background: transparent; font-family: inherit; cursor: default;
  transition: background .15s;
}
.pill-blue { color: #60a5fa; background: rgba(59, 130, 246, .1); border-color: rgba(59, 130, 246, .2); }
.pill-green { color: #34d399; background: rgba(16, 185, 129, .1); border-color: rgba(16, 185, 129, .2); cursor: pointer; }
.pill-green:hover { background: rgba(16, 185, 129, .2); }
.pill:disabled { opacity: .5; cursor: not-allowed; }

.sync-card {
  text-align: left; background: var(--card);
  border: 1px solid rgba(16, 185, 129, .3); border-radius: 12px;
  padding: 16px; margin-top: 12px; box-shadow: 0 10px 15px -3px rgba(0, 0, 0, .3);
}
.sync-head { display: flex; justify-content: space-between; align-items: center; font-size: .75rem; font-weight: 500; color: #cbd5e1; margin-bottom: 6px; }
#syncStatusText { color: #34d399; font-weight: 600; }
#syncPctText { color: var(--muted); }
.bar { width: 100%; background: var(--border); border-radius: 9999px; height: 8px; overflow: hidden; }
.bar-fill { background: var(--green); height: 8px; border-radius: 9999px; transition: width .3s; }

/* Cards */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px;
  padding: 24px; box-shadow: 0 20px 25px -5px rgba(0, 0, 0, .3);
  display: flex; flex-direction: column; gap: 16px;
}
.card.result { gap: 24px; }
label { font-size: .875rem; font-weight: 600; color: #e2e8f0; }

.input-row { display: flex; gap: 8px; }
.input {
  flex: 1; min-width: 0; background: var(--bg); border: 1px solid #334155; border-radius: 12px;
  padding: 12px 16px; font-size: 1rem; color: var(--text); outline: none; font-family: inherit;
}
.input::placeholder { color: var(--dim); }
.input:focus { box-shadow: 0 0 0 2px var(--blue); }

.btn { border: none; border-radius: 12px; font-weight: 600; cursor: pointer; font-family: inherit; transition: background .15s; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: #2563eb; color: #fff; padding: 12px 24px; font-size: 1rem; }
.btn-primary:hover:not(:disabled) { background: var(--blue); }
.btn-small { background: var(--border); color: #cbd5e1; padding: 6px 12px; font-size: .75rem; border-radius: 6px; }
.btn-small:hover { background: #334155; }
.btn-small.copied { background: #059669; color: #fff; }

.samples { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: .75rem; color: var(--muted); padding-top: 4px; }
.chip {
  padding: 4px 10px; border-radius: 8px; background: var(--border); color: #cbd5e1;
  border: 1px solid transparent; cursor: pointer; font-family: inherit; font-size: .75rem; transition: background .15s;
}
.chip:hover { background: #334155; }
.chip-purple { background: rgba(59, 7, 100, .8); color: #d8b4fe; border-color: rgba(107, 33, 168, .4); }
.chip-purple:hover { background: #581c87; }
.chip-green { background: rgba(2, 44, 34, .8); color: #6ee7b7; border-color: rgba(6, 95, 70, .4); }
.chip-green:hover { background: #064e3b; }

/* Loading + error */
.loading { text-align: center; padding: 32px 0; color: var(--muted); font-size: .875rem; }
.loading p { margin: 8px 0 0; }
.spinner {
  display: inline-block; width: 32px; height: 32px;
  border: 4px solid var(--blue); border-top-color: transparent; border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.alert-error {
  background: rgba(69, 10, 10, .5); border: 1px solid rgba(153, 27, 27, .8);
  border-radius: 16px; padding: 20px; color: #fecaca; font-size: .875rem;
}
.alert-error strong { display: block; margin-bottom: 4px; }
.alert-error p { margin: 0; }

/* Result */
.result-head { display: flex; justify-content: space-between; align-items: center; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.eyebrow { font-size: .75rem; font-weight: 500; color: var(--dim); text-transform: uppercase; letter-spacing: .05em; }
#resNumber { font-size: 1.5rem; font-weight: 700; letter-spacing: -.025em; color: #fff; }
.badges { display: flex; align-items: center; gap: 8px; }
.badge { padding: 4px 10px; border-radius: 8px; font-size: .75rem; font-weight: 600; border: 1px solid; }
.badge-green { background: rgba(16, 185, 129, .1); color: #34d399; border-color: rgba(16, 185, 129, .2); }
.badge-blue { background: rgba(59, 130, 246, .2); color: #93c5fd; border-color: rgba(59, 130, 246, .3); }
.badge-purple { background: rgba(168, 85, 247, .2); color: #d8b4fe; border-color: rgba(168, 85, 247, .3); }
.badge-gray { background: rgba(100, 116, 139, .2); color: #cbd5e1; border-color: rgba(100, 116, 139, .3); }

.grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 768px) {
  .grid { grid-template-columns: 1fr 1fr; }
  .cell-wide { grid-column: span 2; }
}
.cell {
  background: var(--card2); padding: 16px; border-radius: 12px;
  border: 1px solid rgba(30, 41, 59, .8); display: flex; flex-direction: column; gap: 4px;
}
.cell .eyebrow { text-transform: none; letter-spacing: 0; }
#resBrand { font-size: 1.125rem; font-weight: 700; color: #60a5fa; }
#resLineType { font-size: 1rem; font-weight: 600; color: #e2e8f0; }
#resLegal { font-size: .875rem; color: #cbd5e1; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
#resLocation { font-size: .875rem; font-weight: 500; color: #e2e8f0; }
#resEngine { font-size: .75rem; font-weight: 500; color: #34d399; }

.gateways {
  background: rgba(2, 6, 23, .9); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; display: flex; flex-direction: column; gap: 12px;
}
.gateways > .eyebrow { color: var(--muted); font-weight: 700; }
.gw-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px; border-radius: 8px; background: var(--card); border: 1px solid rgba(30, 41, 59, .6); gap: 12px;
}
.gw-row > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.gw-row .eyebrow { text-transform: none; letter-spacing: 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .875rem; color: #e2e8f0; word-break: break-all; }

.footer { text-align: center; font-size: .75rem; color: var(--dim); padding-top: 16px; }
.footer p { margin: 0; }

.hidden { display: none !important; }

/* Login */
.login-card { max-width: 26rem; margin: 0 auto; width: 100%; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card label { margin-top: 4px; }
.login-error { margin: 0; color: #fecaca; font-size: .875rem; }
.pill-gray { color: #cbd5e1; background: rgba(100, 116, 139, .15); border-color: rgba(100, 116, 139, .3); cursor: pointer; }
.pill-gray:hover { background: rgba(100, 116, 139, .3); }
.inline { display: inline; margin: 0; }

/* Settings / tokens */
.section-title { font-size: 1.125rem; font-weight: 700; margin: 0; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
.table th { color: var(--dim); font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; }
.table td.name { white-space: normal; font-weight: 600; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.btn-danger { background: rgba(153, 27, 27, .6); color: #fecaca; }
.btn-danger:hover { background: #991b1b; }
.reveal { border-color: rgba(16, 185, 129, .4); }
.reveal code { display: block; padding: 12px; background: var(--bg); border-radius: 8px; word-break: break-all; font-size: .875rem; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.reveal-row { display: flex; gap: 8px; align-items: center; }
.reveal-row code { flex: 1; }
.note { color: var(--muted); font-size: .8rem; margin: 0; }
.input-narrow { flex: 0 0 8rem; }
.muted { color: var(--dim); }
a.pill { text-decoration: none; }
