:root {
  color-scheme: light;
  --ink: #1d1d1f;
  --muted: #48484d;
  --dim: #6e6e73;
  --line: rgba(0, 0, 0, .12);
  --line-soft: rgba(0, 0, 0, .07);
  --surface: #ffffff;
  --surface-2: #f1f2f4;
  --canvas: #f5f5f7;
  --nav: #f9f9fb;
  --green: #0071e3;
  --green-dark: #005bb8;
  --green-soft: rgba(0, 113, 227, .10);
  --success: #1d7d34;
  --success-soft: rgba(29, 125, 52, .10);
  --amber: #bf5b04;
  --amber-soft: rgba(191, 91, 4, .11);
  --red: #d70015;
  --red-soft: rgba(215, 0, 21, .09);
  --focus: #0071e3;
  font-family: "Golos Text", "Segoe UI", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--canvas); color: var(--ink); }

body { margin: 0; min-width: 320px; background: var(--canvas); }

button, input, select, textarea { font: inherit; letter-spacing: 0; }

a { color: var(--green-dark); text-underline-offset: 3px; }
a:hover { color: #c4e0ff; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  overflow-wrap: anywhere;
}

.topbar { position: sticky; z-index: 20; top: 0; background: rgba(255, 255, 255, .82); color: var(--ink); border-bottom: 1px solid var(--line-soft); backdrop-filter: saturate(180%) blur(22px); }

.topbar-inner {
  width: min(1180px, calc(100% - 40px));
  min-height: 64px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; font-weight: 760; font-size: 19px; }
.brand img { width: 34px; height: 34px; }
.brand span { color: var(--green-dark); font-weight: 560; }

.page-shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 42px 0 70px; }

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 7px; font-size: 36px; line-height: 1.1; letter-spacing: -0.035em; }
h2 { margin-bottom: 12px; font-size: 20px; line-height: 1.25; letter-spacing: 0; }
.muted { margin-bottom: 0; color: var(--muted); line-height: 1.55; }
.eyebrow { margin-bottom: 8px; color: var(--green-dark); font-size: 11px; font-weight: 800; letter-spacing: 0.1em; }

.status-indicator { color: var(--muted); font-size: 13px; white-space: nowrap; }
.status-indicator span { display: inline-block; width: 9px; height: 9px; margin-right: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px var(--success-soft); }

.metrics { display: grid; grid-template-columns: 180px 200px minmax(280px, 1fr); border: 1px solid var(--line); background: var(--surface); margin-bottom: 24px; }
.metric { min-height: 88px; padding: 18px 20px; border-right: 1px solid var(--line); display: flex; flex-direction: column; justify-content: space-between; gap: 8px; }
.metric:last-child { border-right: 0; }
.metric span { color: var(--muted); font-size: 12px; }
.metric strong { font-size: 26px; line-height: 1; }
.metric .technical-value { font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.workspace-main, .setup-panel, .audit-section { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; overflow: hidden; box-shadow: 0 24px 70px -58px rgba(0,0,0,.62); }
.workspace-main { min-width: 0; }
.setup-panel { padding: 22px; }
.section-heading { min-height: 76px; padding: 18px 20px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--line); }
.section-heading h2, .section-heading p { margin-bottom: 0; }
.count-label { color: var(--muted); font-size: 12px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 15px 20px; text-align: left; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
th { color: var(--muted); background: var(--nav); font-size: 11px; font-weight: 750; text-transform: uppercase; }
tbody tr { transition: background .16s ease; }
tbody tr:hover { background: rgba(90, 167, 255, 0.035); }
tbody tr:last-child td { border-bottom: 0; }
.status-badge { display: inline-flex; padding: 5px 9px; background: var(--success-soft); color: #68d5ad; border: 1px solid rgba(53, 185, 138, 0.24); border-radius: 999px; font-size: 11px; font-weight: 750; }
.empty-state { color: var(--muted); text-align: center; padding: 28px; }

.form-stack { display: grid; gap: 16px; }
label { display: grid; gap: 7px; color: var(--ink); font-size: 13px; font-weight: 680; }
input, select, textarea { width: 100%; height: 46px; padding: 0 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--nav); color: var(--ink); }
textarea { min-height: 88px; padding: 12px 13px; resize: vertical; }
input::placeholder { color: var(--dim); }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(90, 167, 255, 0.16); border-color: var(--focus); }
input[type="checkbox"] { width: 18px; height: 18px; padding: 0; accent-color: var(--green); }
fieldset { min-width: 0; margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 8px; }
legend { padding: 0 5px; color: var(--ink); font-size: 13px; font-weight: 680; }
.check-row { display: flex; grid-template-columns: none; align-items: center; gap: 9px; padding: 6px 2px; cursor: pointer; }
.check-row span { min-width: 0; }

.button { min-height: 42px; padding: 0 18px; border: 1px solid transparent; border-radius: 999px; cursor: pointer; font-weight: 720; transition: border-color .16s, background .16s, transform .16s; }
.button:hover { transform: translateY(-1px); }
.button-primary { background: var(--green); color: #fff; }
.button-primary:hover { background: #087eea; }
.button-secondary { display: inline-flex; align-items: center; justify-content: center; background: transparent; color: var(--green-dark); border-color: var(--line); text-decoration: none; }
.button-secondary:hover { background: var(--green-soft); border-color: var(--green); }
.button-quiet { background: transparent; color: var(--muted); border-color: var(--line); }
.button-quiet:hover { background: var(--surface-2); color: var(--ink); }
.button-danger { background: var(--red); color: #fff; }
.button-danger:hover { background: #b90012; }
.archive-control { margin-top: 8px; color: var(--red); font-size: 12px; }
.archive-control summary { cursor: pointer; font-weight: 700; }
.archive-form { width: 260px; margin-top: 10px; padding: 12px; border: 1px solid rgba(215, 0, 21, .2); border-radius: 12px; background: var(--red-soft); display: grid; gap: 10px; }
.archive-form label { font-size: 11px; }
.archive-form input { height: 38px; background: var(--surface); }
.archive-form .button { width: 100%; }

.template-tool { margin: -2px 0 22px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.template-tool h2 { margin-bottom: 7px; }
.template-tool > p:not(.eyebrow) { margin-bottom: 15px; color: var(--muted); font-size: 12px; line-height: 1.55; }

.setup-steps { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); display: grid; grid-template-columns: 26px 1fr; gap: 11px 10px; }
.setup-steps span { color: var(--green-dark); font-size: 11px; font-weight: 850; }
.setup-steps p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.manual-sheet-form { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.manual-sheet-form summary { color: var(--green-dark); cursor: pointer; font-size: 12px; font-weight: 720; }
.manual-sheet-form form { margin-top: 14px; }

.alert { padding: 13px 15px; margin-bottom: 20px; border: 1px solid; border-radius: 12px; font-size: 13px; line-height: 1.45; }
.alert-error { color: var(--red); background: var(--red-soft); border-color: rgba(232, 93, 78, 0.34); }
.alert-success { color: #68d5ad; background: var(--success-soft); border-color: rgba(53, 185, 138, 0.3); }

.connection-result { margin-bottom: 24px; padding: 20px; border: 1px solid var(--green); border-radius: 12px; background: var(--green-soft); display: flex; align-items: center; justify-content: space-between; gap: 22px; }
.connection-result h2 { margin-bottom: 6px; }
.connection-result p:not(.eyebrow) { margin: 0; color: var(--muted); font-size: 13px; }
.connection-result code { flex: 0 0 auto; padding: 13px 15px; border: 1px solid var(--line); border-radius: 8px; background: var(--nav); color: var(--ink); font-size: 15px; font-weight: 750; user-select: all; }

.integration-card { margin-bottom: 24px; padding: 20px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); display: flex; align-items: center; justify-content: space-between; gap: 24px; box-shadow: 0 24px 70px -58px rgba(0,0,0,.62); }
.integration-card h2 { margin-bottom: 6px; }
.integration-card p:not(.eyebrow) { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.integration-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; }
.integration-actions form { margin: 0; }

.audit-section { margin-top: 24px; }
.tester-request-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tester-request-actions form { margin: 0; }
.tester-request-actions .button { min-height: 38px; padding-inline: 14px; font-size: 12px; }
.tester-status { display: inline-flex; padding: 5px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 11px; font-weight: 750; }
.tester-status.is-approved { color: #68d5ad; background: var(--success-soft); border-color: rgba(53, 185, 138, .24); }
.tester-status.is-rejected { color: var(--red); background: var(--red-soft); border-color: rgba(232, 93, 78, .24); }
.audit-list { display: grid; }
.audit-row { display: grid; grid-template-columns: 180px minmax(0, 1fr) 170px; gap: 20px; padding: 13px 20px; border-bottom: 1px solid var(--line-soft); font-size: 12px; }
.audit-row:last-child { border-bottom: 0; }
.audit-row span, .audit-row time { color: var(--muted); }
.audit-row time { text-align: right; }
.usage-heading { align-items: flex-end; }
.month-form { display: flex; align-items: flex-end; gap: 9px; }
.month-form label { font-size: 11px; }
.month-form input { height: 40px; }
.usage-totals { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--line); }
.usage-totals > div { padding: 16px 20px; display: grid; gap: 6px; border-right: 1px solid var(--line-soft); }
.usage-totals > div:last-child { border-right: 0; }
.usage-totals span { color: var(--muted); font-size: 11px; }
.usage-totals strong { font-size: 20px; }
.usage-note { margin: 0; padding: 14px 20px; border-top: 1px solid var(--line-soft); color: var(--muted); font-size: 11px; line-height: 1.5; }
.archived-list { display: grid; }
.archived-list > div { padding: 14px 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line-soft); }
.archived-list > div:last-child { border-bottom: 0; }
.archived-list span { display: grid; gap: 4px; }
.archived-list small { color: var(--muted); }

.login-shell { min-height: 100vh; padding: 32px 18px; display: grid; place-items: center; background: radial-gradient(circle at 50% -20%, rgba(0, 113, 227, .12), transparent 38%), var(--canvas); }
.login-panel { width: min(100%, 420px); padding: 36px; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; box-shadow: 0 36px 100px -36px rgba(0, 0, 0, .38); }
.brand-mark { width: 46px; height: 46px; margin-bottom: 24px; display: block; }
.login-panel h1 { font-size: 26px; }
.login-panel .muted { margin-bottom: 24px; }
.security-note { margin: 20px 0 0; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; line-height: 1.55; }
.join-shell { align-items: start; }
.join-panel { width: min(100%, 560px); }
.invite-summary { padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.totp-setup { margin: 0 0 20px; padding: 16px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; }
.totp-setup p:not(.eyebrow) { margin-bottom: 10px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.totp-setup code { display: block; margin-bottom: 12px; padding: 11px; background: var(--nav); border: 1px solid var(--line); border-radius: 7px; font-size: 15px; font-weight: 750; user-select: all; }
.totp-setup img { display: block; width: min(220px, 100%); height: auto; margin: 12px auto; padding: 8px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.totp-setup details { margin: 12px 0; }
.totp-setup summary { cursor: pointer; font-weight: 750; }
.mfa-choice { display: grid; gap: 10px; }
.mfa-choice label { display: flex; align-items: flex-start; gap: 9px; font-weight: 650; }
.mfa-choice input { width: auto; margin-top: 2px; }
.field-hint { color: var(--muted); font-size: 11px; font-weight: 500; line-height: 1.45; }
.mfa-choice:has(input[value="none"]:checked) + .totp-setup,
.mfa-choice:has(input[value="email"]:checked) + .totp-setup { display: none; }
.account-bar { display: flex; align-items: center; gap: 18px; }
.account-bar > div { display: grid; gap: 3px; text-align: right; }
.account-bar small { color: var(--muted); }
.role-chip { padding: 8px 11px; color: var(--green-dark); background: var(--green-soft); border: 1px solid rgba(0, 113, 227, .24); border-radius: 999px; font-size: 12px; font-weight: 780; }
.dashboard-columns { display: grid; grid-template-columns: minmax(0, 1fr) 350px; gap: 24px; align-items: start; }
.form-intro { margin-bottom: 18px; font-size: 13px; }
.status-off { color: var(--red); background: var(--red-soft); border-color: rgba(232, 93, 78, 0.3); }
.store-name-form { display: flex; align-items: center; gap: 8px; min-width: 260px; }
.store-name-form input { min-width: 140px; height: 38px; font-weight: 700; }
.store-name-form .button { flex: none; }
.owner-setup-grid { display: grid; grid-template-columns: minmax(300px, 440px) minmax(0, 1fr); gap: 30px; padding: 22px; }
.organization-list { display: grid; margin-top: 18px; border: 1px solid var(--line); }
.organization-list > div { display: flex; justify-content: space-between; gap: 16px; padding: 13px; border-bottom: 1px solid var(--line); }
.organization-list > div:last-child { border-bottom: 0; }
.organization-list span { color: var(--muted); font-size: 12px; }
.button:disabled { cursor: not-allowed; opacity: .5; }

@media (max-width: 860px) {
  .page-shell, .topbar-inner { width: min(100% - 24px, 1180px); }
  .page-shell { padding-top: 28px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric:nth-child(2) { border-right: 0; }
  .metric-wide { grid-column: 1 / -1; border-top: 1px solid var(--line); }
  .workspace-grid { grid-template-columns: 1fr; }
  .dashboard-columns, .owner-setup-grid { grid-template-columns: 1fr; }
  .usage-heading, .month-form { align-items: stretch; }
  .usage-heading { flex-direction: column; }
  .setup-panel { grid-row: 1; }
  .connection-result { align-items: stretch; flex-direction: column; }
  .connection-result code { width: 100%; }
  .integration-card { align-items: stretch; flex-direction: column; }
  .integration-actions { flex-wrap: wrap; }
}

@media (max-width: 560px) {
  h1 { font-size: 28px; }
  .metrics { grid-template-columns: 1fr; }
  .metric { border-right: 0; border-bottom: 1px solid var(--line); }
  .metric:last-child { border-bottom: 0; }
  .metric-wide { grid-column: auto; border-top: 0; }
  .audit-row { grid-template-columns: 1fr; gap: 5px; }
  .audit-row time { text-align: left; }
  .login-panel { padding: 26px 22px; }
  .topbar-inner { align-items: flex-start; padding: 12px 0; }
  .account-bar { align-items: flex-end; flex-direction: column; gap: 8px; }
  .table-wrap { overflow: visible; }
  table, tbody, tr, td { display: block; width: 100%; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  tbody tr { padding: 8px 0; border-bottom: 1px solid var(--line); }
  tbody tr:last-child { border-bottom: 0; }
  td { min-height: 43px; padding: 10px 18px; border-bottom: 0; display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 12px; align-items: start; }
  td::before { content: attr(data-label); color: var(--muted); font-size: 10px; font-weight: 780; text-transform: uppercase; }
  td.empty-state { display: block; }
  td code { overflow-wrap: anywhere; }
  .store-name-form { min-width: 0; align-items: stretch; flex-direction: column; }
  .usage-totals { grid-template-columns: 1fr; }
  .usage-totals > div { border-right: 0; border-bottom: 1px solid var(--line-soft); }
  .usage-totals > div:last-child { border-bottom: 0; }
  .archived-list > div { align-items: stretch; flex-direction: column; }
  .archive-form { width: 100%; }
}
.sync-mode-form,
.member-access-form {
  display: grid;
  gap: 0.55rem;
  min-width: 190px;
}

.sync-mode-form select,
.member-access-form select {
  min-width: 180px;
}

.member-store-list {
  display: grid;
  gap: 0.25rem;
  max-height: 140px;
  overflow: auto;
  padding: 0.35rem 0;
}

.member-status-form {
  margin-top: 0.45rem;
}
