/* 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; }
.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; }
.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); }
.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 span { display: none; }
  .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; }
