/* Master System platform pages (/account) */
:root {
  --ui-bg: #f4f6f9; --ui-surface: #fff; --ui-border: #e3e7ee; --ui-border-strong: #cfd6e0;
  --ui-text: #1d2433; --ui-muted: #667085; --ui-brand: #2f6db5; --ui-danger: #c0392b; --ui-ok: #1e7e4f; --ui-warn: #b26b00;
  --ui-radius: 12px; --ui-shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --ui-font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--ui-bg); color: var(--ui-text); font: 15px/1.5 var(--ui-font); -webkit-font-smoothing: antialiased; }
a { color: var(--ui-brand); text-decoration: none; font-weight: 600; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0 0 6px; } h2 { font-size: 17px; margin: 0 0 6px; } h3 { font-size: 15px; margin: 22px 0 8px; }
.muted { color: var(--ui-muted); } .mono { font-family: ui-monospace, Menlo, Consolas, monospace; }

/* Auth pages */
.auth-wrap { max-width: 440px; margin: 0 auto; padding: 56px 16px; }
.auth-brand { font-weight: 800; font-size: 18px; color: var(--ui-brand); text-align: center; margin-bottom: 18px; letter-spacing: -.01em; }
.auth-card { padding: 32px; }
.auth-card .foot { text-align: center; margin: 18px 0 0; color: var(--ui-muted); font-size: 14px; }

/* App shell */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 24px; height: 60px; padding: 0 24px; background: var(--ui-surface); border-bottom: 1px solid var(--ui-border); }
.topbar .brand { font-weight: 800; color: var(--ui-brand); }
.topbar nav { display: flex; gap: 6px; align-items: center; flex: 1; }
.topbar nav a { color: var(--ui-text); padding: 8px 12px; border-radius: 8px; font-weight: 500; }
.topbar nav a:hover { background: var(--ui-bg); text-decoration: none; }
.topbar nav a.active { background: var(--ui-bg); font-weight: 700; }
.topbar nav a.btn { color: #fff; margin-left: auto; }
.topbar .who { display: flex; gap: 12px; align-items: center; color: var(--ui-muted); font-size: 14px; }
.topbar .who form { margin: 0; }
.topbar .who-acct { display: flex; align-items: center; gap: 8px; color: var(--ui-text); font-weight: 500; text-decoration: none; padding: 4px 10px 4px 4px; border-radius: 999px; }
a.who-acct:hover { background: var(--ui-bg); text-decoration: none; }
.topbar .who-acct.active { background: var(--ui-bg); font-weight: 700; }
.topbar .avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--ui-brand); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; letter-spacing: .02em; flex: none; }
.wrap { max-width: 860px; margin: 0 auto; padding: 28px 20px 60px; }
.wrap.wide { max-width: 1180px; }
.page-head { margin: 4px 0 18px; }

/* Cards & notices */
.card { background: var(--ui-surface); border: 1px solid var(--ui-border); border-radius: var(--ui-radius); box-shadow: var(--ui-shadow); padding: 24px; margin-bottom: 18px; }
.notice { border-radius: 10px; padding: 11px 14px; margin: 0 0 14px; font-size: 14px; border: 1px solid; word-break: break-word; }
.notice.ok { background: #ecf8f1; border-color: #bfe5cf; color: #14532d; }
.notice.error { background: #fdecea; border-color: #f5c2bd; color: #7f1d1d; }
.notice.info { background: #eef4fc; border-color: #c8daf3; color: #1e3a5f; }
.notice.small { font-size: 13px; padding: 8px 12px; }

/* Forms */
label { display: block; font-weight: 600; font-size: 14px; margin: 14px 0 0; }
input, select, textarea { display: block; width: 100%; margin-top: 6px; padding: 9px 11px; font: 15px var(--ui-font); color: var(--ui-text); background: #fff; border: 1px solid var(--ui-border-strong); border-radius: 8px; transition: border-color .12s, box-shadow .12s; }
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ui-brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ui-brand) 20%, transparent); }
input:disabled { background: var(--ui-bg); color: var(--ui-muted); }
input[type=checkbox] { display: inline-block; width: auto; margin: 0 8px 0 0; vertical-align: -2px; }
input[type=file] { padding: 8px; }
label.check { font-weight: 500; display: flex; align-items: flex-start; gap: 2px; }
.hint { font-size: 13px; color: var(--ui-muted); margin-top: 5px; font-weight: 400; }
.err { font-size: 13px; color: var(--ui-danger); margin-top: 5px; font-weight: 500; }
.hp { position: absolute; left: -9999px; height: 0; overflow: hidden; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; align-items: center; }
.inline-form { margin-top: 16px; font-size: 14px; }
.topbar form.inline { display: inline; margin: 0; }
.strength { height: 4px; border-radius: 4px; background: var(--ui-border); margin-top: 6px; overflow: hidden; }
.strength span { display: block; height: 100%; width: 0; transition: width .2s, background .2s; }

/* Buttons */
.btn, button.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 18px; border-radius: 8px; border: 1px solid var(--ui-brand); background: var(--ui-brand); color: #fff; font: 600 14px var(--ui-font); cursor: pointer; text-decoration: none; }
.btn:hover { filter: brightness(1.07); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.block { width: 100%; margin-top: 22px; padding: 12px; }
.btn.ghost { background: #fff; color: var(--ui-text); border-color: var(--ui-border-strong); }
.btn.ghost:hover { border-color: var(--ui-brand); color: var(--ui-brand); filter: none; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
button.link { background: none; border: 0; color: var(--ui-brand); font: 600 14px var(--ui-font); cursor: pointer; padding: 0; }

/* Stepper */
.stepper { display: flex; list-style: none; padding: 0; margin: 0 0 18px; gap: 8px; counter-reset: s; }
.stepper li { flex: 1; }
.stepper li a, .stepper li { display: flex; align-items: center; gap: 10px; color: var(--ui-muted); font-weight: 600; font-size: 14px; }
.stepper li a { padding: 10px 12px; border-radius: 10px; width: 100%; }
.stepper li a:hover { background: #fff; text-decoration: none; }
.stepper .dot { width: 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center; border: 2px solid var(--ui-border-strong); font-size: 13px; background: #fff; flex: none; }
.stepper li.done .dot { background: var(--ui-ok); border-color: var(--ui-ok); color: #fff; }
.stepper li.current a { background: #fff; color: var(--ui-text); box-shadow: var(--ui-shadow); }
.stepper li.current .dot { border-color: var(--ui-brand); color: var(--ui-brand); }
.checklist { list-style: none; padding: 0; margin: 14px 0; }
.checklist li { padding: 12px 14px; border: 1px solid var(--ui-border); border-radius: 10px; margin-bottom: 8px; display: flex; gap: 10px; align-items: center; }
.checklist li::before { font-weight: 800; }
.checklist li.ok::before { content: "✓"; color: var(--ui-ok); }
.checklist li.todo::before { content: "!"; color: var(--ui-warn); }
.checklist li a { margin-left: auto; font-size: 13px; }

/* Settings layout */
.settings { display: grid; grid-template-columns: 230px 1fr; gap: 28px; align-items: start; }
.settings-nav { position: sticky; top: 84px; }
.settings-nav input[type=search] { margin: 0 0 12px; }
.settings-nav nav { display: flex; flex-direction: column; gap: 2px; }
.settings-nav nav a { color: var(--ui-text); font-weight: 500; padding: 8px 12px; border-radius: 8px; }
.settings-nav nav a:hover { background: #fff; text-decoration: none; }
.settings-nav nav a.active { background: #fff; font-weight: 700; color: var(--ui-brand); box-shadow: var(--ui-shadow); }
.settings-nav nav a.first { margin-bottom: 10px; }   /* General, a little apart from the rest */
.field { display: grid; grid-template-columns: 240px 1fr; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--ui-border); align-items: start; }
.field:last-of-type { border-bottom: 0; }
.field > label { margin: 9px 0 0; }
.field .control input, .field .control select, .field .control textarea { margin-top: 0; }
.field.has-err input, .field.has-err select, .field.has-err textarea { border-color: var(--ui-danger); }
.field .changed { color: var(--ui-brand); font-size: 18px; line-height: 0; }
.field.hit { background: #fffbea; margin: 0 -12px; padding-left: 12px; padding-right: 12px; border-radius: 8px; }
.actions.sticky { position: sticky; bottom: 0; background: linear-gradient(transparent, #fff 30%); padding-top: 18px; margin: 8px -24px -24px; padding: 18px 24px 20px; border-radius: 0 0 var(--ui-radius) var(--ui-radius); }
.color-row { display: flex; gap: 8px; } .color-row input[type=color] { width: 48px; height: 40px; padding: 3px; flex: none; } .color-row input.mono { max-width: 140px; }
.switch { position: relative; display: inline-block; width: 44px; height: 24px; margin: 6px 0 0; }
.switch input[type=checkbox] { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--ui-border-strong); border-radius: 24px; transition: .15s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--ui-brand); }
.switch input:checked + span::before { transform: translateX(20px); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px color-mix(in srgb, var(--ui-brand) 25%, transparent); }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.tile { background: #fff; border: 1px solid var(--ui-border); border-radius: var(--ui-radius); padding: 16px; box-shadow: var(--ui-shadow); border-top: 3px solid var(--ui-border-strong); }
.tile.ok { border-top-color: var(--ui-ok); } .tile.warn { border-top-color: var(--ui-warn); }
.tile .k { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ui-muted); font-weight: 700; }
.tile .v { font-size: 17px; font-weight: 700; margin: 4px 0 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile a { font-size: 13px; }
.section-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.section-list a { display: flex; flex-direction: column; gap: 2px; padding: 14px; border: 1px solid var(--ui-border); border-radius: 10px; color: var(--ui-text); font-weight: 400; }
.section-list a:hover { border-color: var(--ui-brand); text-decoration: none; }
.section-list a span { font-size: 13px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; margin: 14px 0 18px; }
.kv dt { color: var(--ui-muted); font-size: 14px; } .kv dd { margin: 0; font-weight: 500; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; }
.pill.ok { background: #ecf8f1; color: var(--ui-ok); } .pill.warn { background: #fff4e0; color: var(--ui-warn); }
#search-results .result-group { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ui-muted); font-weight: 700; margin: 16px 0 4px; }
#search-results .result-link { display: block; padding: 8px 10px; border-radius: 8px; }
#search-results .result-link:hover { background: var(--ui-bg); text-decoration: none; }

@media (max-width: 860px) {
  .settings { grid-template-columns: 1fr; } .settings-nav { position: static; }
  .settings-nav nav { flex-direction: row; flex-wrap: wrap; }
  .field { grid-template-columns: 1fr; gap: 6px; } .field > label { margin: 0; }
  .tiles { grid-template-columns: 1fr 1fr; } .section-list, .grid-2 { grid-template-columns: 1fr; }
  .topbar { gap: 10px; padding: 0 12px; } .topbar .who .who-name { display: none; } .topbar .who-acct { padding: 2px; }
  .stepper { flex-wrap: wrap; }
}
.schema-status { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; padding: 12px 14px; border: 1px solid var(--ui-border); border-radius: 10px; margin-bottom: 16px; background: #fafbfc; font-size: 14px; }
.schema-status .ok { color: var(--ui-ok); } .schema-status .warn { color: var(--ui-warn); } .schema-status form { margin: 0 0 0 auto; }
.auth-brand a, a.brand { color: var(--ui-brand); text-decoration: none; }

/* ---------- Phones: account pages ---------- */
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 14px 0; gap: 4px 10px; }
  .topbar .brand { flex: 1; font-size: 16px; line-height: 1.2; }
  .topbar .who { order: 2; }
  .topbar nav { order: 3; flex: 0 0 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 8px 0 10px; gap: 6px; scrollbar-width: none; }
  .topbar nav::-webkit-scrollbar { display: none; }
  .topbar nav a { white-space: nowrap; flex: none; }
  .topbar nav a.btn { margin-left: 0; }
  .wrap, .wrap.wide { padding: 18px 14px 48px; }
  .settings > *, .settings-nav, .settings-body { min-width: 0; }
  .settings-nav nav { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; gap: 4px; padding-bottom: 6px; scrollbar-width: none; margin: 0 -14px; padding-left: 14px; padding-right: 14px; }
  .settings-nav nav::-webkit-scrollbar { display: none; }
  .settings-nav nav a { white-space: nowrap; flex: none; background: #fff; border: 1px solid var(--ui-border); }
  .settings-nav nav a.active { border-color: var(--ui-brand); }
  .actions.sticky { position: static; background: none; margin: 8px 0 0; padding: 12px 0 0; }
  .actions { flex-wrap: wrap; }
  .actions .btn { flex: 1 1 auto; }
  .card { padding: 18px; }
  .auth-wrap { padding: 32px 14px; }
  .auth-card { padding: 22px; }
  .stepper { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
  .stepper li a { padding: 8px 2px; font-size: 12px; gap: 4px; flex-direction: column; text-align: center; }
  .kv { grid-template-columns: 100px 1fr; }
  input, select, textarea { font-size: 16px; }
}

/* Hosted onboarding + admin console */
.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin: 16px 0; }
.choice { border: 1px solid var(--border, #e3e7ee); border-radius: 12px; padding: 16px 18px; background: #fff; }
.choice.selected { border-color: var(--ui-brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ui-brand) 15%, transparent); }
.choice h2 { font-size: 17px; margin: 0 0 8px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.small { font-size: 13px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: #667085; padding: 8px 10px; border-bottom: 1px solid #e3e7ee; }
.admin-table td { padding: 10px; border-bottom: 1px solid #eef0f4; vertical-align: top; }
.admin-table tr:hover td { background: #f8fafc; }
.admin-table a.row-link { font-weight: 600; }
.status { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; }
.status.trial { background: #e8f1fc; color: #1d4f91; }
.status.active { background: #e7f7ee; color: #14532d; }
.status.suspended, .status.expired, .status.trial_ended { background: #fdecea; color: #8a1c12; }
.status.pending { background: #fff4e0; color: #8a4b00; }
.admin-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.admin-stats .tile { background: #fff; border: 1px solid #e3e7ee; border-radius: 12px; padding: 12px 14px; }
.admin-stats .k { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: #667085; font-weight: 700; }
.admin-stats .v { font-size: 26px; font-weight: 800; }
.toolbar-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.toolbar-row input[type=search] { flex: 1 1 240px; }
@media (max-width: 760px) {
  .admin-table thead { display: none; }
  .admin-table tr { display: block; border: 1px solid #e3e7ee; border-radius: 10px; margin-bottom: 10px; padding: 6px 0; }
  .admin-table td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 6px 12px; }
  .admin-table td::before { content: attr(data-label); font-weight: 700; color: #667085; font-size: 12px; text-transform: uppercase; }
}
.btn.danger { color: #b42318; border-color: #f5c2bd; }
.btn.danger:hover { background: #fdecea; }
.topbar .btn-sm { white-space: nowrap; }

.scope-switch { display: inline-flex; gap: 4px; padding: 4px; background: #eef1f6; border-radius: 10px; margin: 0 0 12px; flex-wrap: wrap; }
.scope-switch a { padding: 8px 14px; border-radius: 8px; font-weight: 600; font-size: 14px; color: #475467; text-decoration: none; }
.scope-switch a.active { background: #fff; color: var(--ui-brand); box-shadow: 0 1px 2px rgba(16,24,40,.08); }
.notice.small { font-size: 13px; }

/* Delete-workspace card */
.card.danger-zone { border-color: #f5c2bd; }
.card.danger-zone h2 { color: #b42318; }
.btn.danger:not(.ghost) { background: #b42318; color: #fff; border-color: #b42318; }
.btn.danger:not(.ghost):hover { background: #912018; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.img-field { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; } .img-field img { max-width: 180px; max-height: 44px; border: 1px solid var(--ui-border); border-radius: 6px; padding: 4px; background: #fff; } .img-field input[type=file] { font-size: 13px; }
