:root {
  color-scheme: light;
  --ink: #111827;
  --muted: #64748b;
  --faint: #f8fafc;
  --line: #e2e8f0;
  --brand: #2563eb;
  --brand-soft: #eff6ff;
  --green: #15803d;
  --amber: #a16207;
  --danger: #b91c1c;
  --success-soft: #f0fdf4;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
  --card-gap: var(--space-5);
  --card-padding: var(--space-6);
  --section-gap: var(--space-4);
  --element-gap: var(--space-3);
  --control-height: 42px;
  --radius-card: 18px;
  --radius-control: 10px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body { margin: 0; background: #f1f5f9; color: var(--ink); }
a { color: inherit; }

.shell { min-height: 100vh; display: grid; grid-template-rows: 70px minmax(0, 1fr); }
.topbar { height: 70px; padding: 0 clamp(var(--space-6), 4vw, 56px); display: flex; align-items: center; justify-content: space-between; background: rgba(255, 255, 255, .96); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 3; backdrop-filter: blur(12px); }
.brand { text-decoration: none; display: inline-flex; align-items: center; gap: var(--element-gap); font-weight: 760; letter-spacing: -.02em; font-size: 17px; }
.brand em { color: var(--brand); font-style: normal; }
.brand-mark { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #2563eb, #7c3aed); box-shadow: 0 5px 16px rgba(37, 99, 235, .25); }
.session-actions { display: flex; align-items: center; gap: var(--element-gap); }
.avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; }
.session-signout, .product-action, .button-quiet { display: inline-flex; align-items: center; gap: var(--space-2); }
button svg, .button svg { width: 16px; height: 16px; flex: none; }

.workspace { min-width: 0; display: block; }
.sidebar { min-width: 0; position: fixed; left: 0; top: 70px; bottom: 0; width: 248px; height: auto; z-index: 2; overflow-y: auto; padding: var(--space-7) var(--element-gap); background: #f8fafc; border-right: 1px solid var(--line); }
.sidebar.is-hidden { visibility: hidden; }
.sidebar-label { padding: 0 var(--element-gap) var(--element-gap); color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.sidebar-nav { display: grid; gap: var(--space-1); }
.sidebar-link { display: flex; align-items: center; gap: var(--element-gap); min-height: 42px; padding: var(--space-2) var(--element-gap); border-radius: var(--radius-control); color: var(--muted); font-size: 13px; font-weight: 650; text-decoration: none; }
.sidebar-link:hover { color: var(--ink); background: #fff; }
.sidebar-link.active { color: var(--brand); background: var(--brand-soft); font-weight: 750; }
.sidebar-icon { width: 18px; height: 18px; flex: none; color: currentColor; }
.sidebar-context { margin: var(--space-6) var(--space-2) 0; padding: var(--element-gap); border: 1px solid var(--line); border-radius: var(--space-3); background: #fff; color: var(--muted); font-size: 11px; line-height: 1.5; }

.content { width: calc(100% - 248px); max-width: none; min-width: 0; margin: 0 0 0 248px; padding: var(--space-7) clamp(22px, 4vw, 64px) 56px; }
.workspace.sidebar-hidden .content { width: 100%; margin-left: 0; }
.context { display: flex; align-items: center; gap: var(--element-gap); padding: var(--element-gap); border-radius: var(--space-3); background: var(--faint); border: 1px solid var(--line); color: var(--muted); font-size: 13px; margin-bottom: var(--card-gap); }
.context strong { color: var(--ink); }
.button-inline { margin-left: auto; padding: var(--space-2) var(--element-gap); white-space: nowrap; }

.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--card-gap); margin-bottom: var(--card-gap); }
.hero-copy { min-width: 0; }
.hero-actions { margin-top: 0; align-items: center; }
.page-heading { margin-bottom: var(--card-gap); }
.eyebrow { color: var(--brand); font-size: 12px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; margin: 0 0 var(--space-2); }
h1 { font-size: clamp(28px, 4vw, 42px); letter-spacing: -.045em; margin: 0 0 var(--space-2); }
h2 { letter-spacing: -.025em; margin: 0 0 var(--space-2); font-size: 20px; }
h3 { letter-spacing: -.015em; }
p { color: var(--muted); line-height: 1.55; }
.hero p, .page-heading > p { margin: 0; max-width: 660px; }

.grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--card-gap); }
.overview-grid { grid-template-columns: minmax(0, 1.5fr) minmax(220px, .5fr); align-items: stretch; }
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-card); padding: var(--card-padding); box-shadow: 0 9px 24px rgba(15, 23, 42, .04); }
.content > .card + .card { margin-top: var(--card-gap); }
.span-4, .span-8, .span-12 { grid-column: 1; }
.metric { min-height: 118px; display: flex; flex-direction: column; justify-content: space-between; }
.metric-label { color: var(--muted); font-size: 13px; }
.metric-value { font-size: 30px; font-weight: 760; letter-spacing: -.04em; }
.identity-card { display: flex; align-items: center; gap: var(--section-gap); min-height: 140px; }
.identity-avatar { width: 64px; height: 64px; font-size: 23px; flex: none; color: #fff; background: linear-gradient(135deg, #2563eb, #7c3aed); box-shadow: 0 8px 18px rgba(37, 99, 235, .2); }
.identity-copy { min-width: 0; }
.identity-kicker, .section-kicker { display: block; margin-bottom: var(--space-2); color: var(--brand); font-size: 11px; font-weight: 750; letter-spacing: .09em; text-transform: uppercase; }
.identity-card h2 { margin-bottom: var(--space-1); }
.identity-card p { margin: 0; font-size: 14px; }
.metric-card { min-height: 140px; flex-direction: row; align-items: center; justify-content: flex-start; gap: var(--section-gap); }
.metric-icon { width: 44px; height: 44px; display: grid; place-items: center; flex: none; color: var(--brand); background: var(--brand-soft); border-radius: 14px; }
.metric-icon svg { width: 21px; height: 21px; }
.metric-card > div:last-child { display: grid; gap: var(--space-1); min-width: 0; }
.metric-label, .metric-value, .metric-card .hint { display: block; }
.overview-products-card { grid-column: 1 / -1; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--section-gap); }
.section-head p { margin: 0; font-size: 12px; }
.section-head-actions { display: flex; align-items: center; gap: var(--element-gap); flex-wrap: wrap; }

.product-logo { width: 38px; height: 38px; border-radius: var(--space-3); display: grid; place-items: center; color: #fff; font-size: 14px; font-weight: 800; flex: none; }
.product-logo img { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; display: block; }
.product-logo.small { width: 30px; height: 30px; font-size: 12px; flex: 0 0 30px; }
.product-logo.tone-blue { background: #2563eb; }
.product-logo.tone-violet { background: #7c3aed; }
.product-logo.tone-cyan { background: #0891b2; }
.product-logo.tone-green { background: #16a34a; }
.product-logo.tone-orange { background: #ea580c; }
.product-logo.tone-pink { background: #db2777; }

.products, .billing-list, .addresses, .source-list { display: grid; gap: var(--card-gap); }
.products { grid-template-columns: minmax(0, 1fr); grid-auto-rows: minmax(84px, auto); margin-top: var(--section-gap); }
.product { min-width: 0; min-height: 84px; height: 100%; border: 1px solid var(--line); border-radius: 15px; padding: var(--section-gap); display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--section-gap); align-items: center; }
.product h3 { margin: var(--space-1) 0 var(--space-1); font-size: 15px; }
.product p { margin: 0; font-size: 12px; }
.product .meta { min-width: 0; }
.product .meta > p { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.registered-at { margin-top: var(--space-2) !important; }
.product-meta { display: flex; align-items: center; gap: var(--element-gap); flex-wrap: wrap; }
.product-meta .status { margin-top: 0; }
.detail-label { color: var(--muted); margin-right: var(--space-1); }
.detail-list { display: grid; gap: 0; margin-top: var(--section-gap); border-top: 1px solid var(--line); }
.detail-row { display: flex; align-items: center; justify-content: space-between; gap: var(--section-gap); min-height: 52px; padding: var(--space-2) 0; border-bottom: 1px solid var(--line); }
.detail-row > span:first-child { color: var(--muted); font-size: 13px; }
.detail-row strong { font-size: 14px; text-align: right; overflow-wrap: anywhere; }
.detail-row .status { margin-top: 0; }
.product-summary-row { min-height: 56px; padding: var(--space-3) var(--section-gap); }
.summary-product { display: flex; align-items: center; gap: var(--element-gap); min-width: 0; }
.summary-name { font-weight: 700; }

.billing-list { grid-auto-rows: minmax(64px, auto); }
.billing-row { display: flex; align-items: center; gap: var(--section-gap); flex-wrap: wrap; border: 1px solid var(--line); border-radius: var(--space-3); padding: var(--section-gap); }
.billing-row > div { flex: 1 1 260px; min-width: 0; }
.billing-row p { margin: var(--space-1) 0 0; }
.billing-message { flex: 1 1 100%; }
.billing-copy { flex: 1 1 260px; min-width: 0; }

.address-card { border: 1px solid var(--line); border-radius: 15px; padding: var(--section-gap); background: #fff; }
.address-card.is-default { border-color: #93c5fd; box-shadow: 0 0 0 3px var(--brand-soft); }
.address-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--section-gap); }
.address-card-head h3 { margin: 0; font-size: 16px; }
.address-card p { margin: var(--space-2) 0 0; }
.address-card .address-detail { margin: var(--section-gap) 0 0; color: var(--ink); line-height: 1.6; white-space: pre-line; }
.address-actions { margin-top: var(--section-gap); }
.address-form { display: grid; gap: var(--space-2); margin-top: var(--space-2); }
.form-section + .form-section { margin-top: var(--card-gap); padding-top: var(--card-gap); border-top: 1px solid var(--line); }
.form-section-heading { display: flex; align-items: flex-start; gap: var(--element-gap); margin-bottom: var(--section-gap); color: var(--brand); }
.form-section-heading svg { width: 20px; height: 20px; flex: none; margin-top: 2px; }
.form-section-heading h3 { margin: 0 0 var(--space-1); color: var(--ink); font-size: 15px; }
.form-section-heading p { margin: 0; font-size: 12px; }
.form-section > .field:first-of-type { margin-top: 0; }
.checkbox-field { margin-top: var(--card-gap); padding-top: var(--section-gap); border-top: 1px solid var(--line); }
.address-empty { margin: 0; padding: var(--section-gap); border-radius: var(--space-3); background: var(--faint); }

.status { display: inline-flex; align-items: center; gap: var(--space-1); border-radius: 999px; padding: var(--space-1) var(--space-2); font-size: 11px; font-weight: 700; margin-top: var(--space-2); }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.active { color: var(--green); background: var(--success-soft); }
.status.pending { color: var(--amber); background: #fffbeb; }
.status.none { color: var(--muted); background: var(--faint); }

.actions { display: flex; gap: var(--element-gap); flex-wrap: wrap; margin-top: var(--section-gap); }
.auth-actions { justify-content: center; }
button, .button { min-height: var(--control-height); border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: var(--radius-control); padding: var(--space-2) var(--element-gap); cursor: pointer; font: inherit; font-size: 13px; font-weight: 650; text-decoration: none; }
button:hover, .button:hover { border-color: #93c5fd; background: var(--brand-soft); }
button.primary, .button.primary { color: #fff; border-color: var(--brand); background: var(--brand); }
button.primary:hover, .button.primary:hover { background: #1d4ed8; }
button:disabled { cursor: wait; opacity: .65; }

.field { display: grid; gap: var(--space-2); margin-top: var(--section-gap); }
.field label { font-size: 13px; font-weight: 700; }
.field input, .field select { width: 100%; min-height: var(--control-height); border: 1px solid var(--line); border-radius: var(--radius-control); padding: var(--space-2) var(--element-gap); font: inherit; color: var(--ink); background: #fff; }
.field input[type="checkbox"] { width: auto; min-height: auto; margin: 0 var(--space-2) 0 0; accent-color: var(--brand); }
.field input:focus, .field select:focus { outline: 3px solid #dbeafe; border-color: #60a5fa; }
.hint { font-size: 12px; color: var(--muted); }
.hint.is-success { color: var(--green); }
.hint.is-error, .is-error { color: var(--danger); }
.source-list { margin-top: var(--section-gap); }
.source { display: flex; justify-content: space-between; align-items: center; gap: var(--section-gap); padding: var(--element-gap); border-radius: var(--radius-control); background: var(--faint); font-size: 12px; }
.source .ok { color: var(--green); font-weight: 700; }
.source .bad { color: var(--amber); font-weight: 700; }

.loading-card, .error-card, .signin-card { background: #fff; border: 1px solid var(--line); border-radius: 20px; min-height: 340px; display: grid; place-items: center; align-content: center; text-align: center; padding: var(--space-8); }
.spinner { width: 26px; height: 26px; border: 3px solid #dbeafe; border-top-color: var(--brand); border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-card h2, .signin-card h2 { margin-top: var(--section-gap); }
.error-card p, .signin-card p { max-width: 460px; }

@media (max-width: 760px) {
  .shell { grid-template-rows: 64px auto; }
  .topbar { height: 64px; }
  .workspace { display: block; }
  .sidebar { position: static; width: auto; height: auto; overflow: visible; border-right: 0; border-bottom: 1px solid var(--line); padding: var(--section-gap) var(--element-gap); }
  .sidebar-label, .sidebar-context { display: none; }
  .sidebar-nav { display: flex; overflow-x: auto; gap: var(--space-1); }
  .sidebar-link { white-space: nowrap; }
  .content, .workspace.sidebar-hidden .content { width: 100%; margin-left: 0; padding: var(--space-6) var(--element-gap) var(--space-8); }
  .hero { display: block; }
  .hero-actions { margin-top: var(--section-gap); }
  .overview-grid { grid-template-columns: minmax(0, 1fr); }
  .metric-card { align-items: flex-start; }
  .section-head { align-items: flex-start; flex-direction: column; }
  .section-head-actions { width: 100%; justify-content: space-between; }
  .context { align-items: flex-start; flex-wrap: wrap; }
  .button-inline { margin-left: 0; }
  .product { grid-template-columns: auto minmax(0, 1fr); }
  .product > .button { grid-column: 2; justify-self: start; }
}
