:root {
  --bg: #F5F6F8;
  --surface: #FFFFFF;
  --surface-2: #F0F2F5;
  --border: #E2E5EA;
  --text: #1B1F24;
  --muted: #5E6773;
  --primary: #2B59C3;
  --primary-ink: #FFFFFF;
  --primary-soft: #E8EEFB;
  --danger: #C2362B;
  --ok: #1E7F4F;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0 0 12px; line-height: 1.25; }
h1 { font-size: 22px; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
code { font: 12px/1.4 ui-monospace, Consolas, monospace; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 8px 0; width: 100%; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.error { color: var(--danger); margin: 0; }

/* ---------- layout helpers ---------- */
.row { display: flex; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.gap-s { gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: minmax(320px, 5fr) minmax(360px, 7fr); gap: 20px; align-items: start; }
@media (max-width: 980px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 20px; padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-title { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.chip { font-size: 11.5px; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 2px 8px; }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.tabs button { display: flex; align-items: center; gap: 8px; border: 0; background: none; padding: 8px 12px; border-radius: 8px; font: inherit; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tabs button:hover { background: var(--surface-2); color: var(--text); }
.tabs button[aria-selected="true"] { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.num { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--surface-2); font-size: 11.5px; font-weight: 700; }
.tabs button[aria-selected="true"] .num { background: var(--primary); color: var(--primary-ink); }

main { padding: 24px; max-width: 1440px; margin: 0 auto; }
@media (max-width: 640px) { main { padding: 16px; } .topbar { padding: 10px 16px; flex-wrap: wrap; } }

/* ---------- cards & forms ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; min-width: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span:first-child { font-weight: 600; font-size: 13px; }
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]), select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%; min-width: 0;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
input[type="color"] { width: 44px; height: 34px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
input[type="range"] { width: 100%; accent-color: var(--primary); }
textarea { resize: vertical; }
fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
legend { font-weight: 650; margin-bottom: 8px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px 16px; }
.checks.one { grid-template-columns: 1fr; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input[type="checkbox"] { accent-color: var(--primary); width: 16px; height: 16px; }
.radio-card { flex: 1; display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.radio-card:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }

.btn { font: inherit; font-weight: 600; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 8px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: progress; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); padding: 32px; display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { margin: 0; }
.login-card p { margin: 0; }

/* ---------- logo step ---------- */
.dropzone { display: grid; place-items: center; min-height: 160px; border: 2px dashed var(--border); border-radius: 12px; cursor: pointer; text-align: center; padding: 16px; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.over { border-color: var(--primary); background: var(--primary-soft); }
.dz-empty { display: flex; flex-direction: column; gap: 4px; }
.dz-thumb { max-width: 100%; max-height: 140px; border-radius: 6px; }
.checker { background-color: #fff; background-image: linear-gradient(45deg, #eceef1 25%, transparent 25%), linear-gradient(-45deg, #eceef1 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #eceef1 75%), linear-gradient(-45deg, transparent 75%, #eceef1 75%); background-size: 14px 14px; background-position: 0 0, 0 7px, 7px -7px, -7px 0; }
.analysis { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.swatch { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px 3px 3px; font: 12px ui-monospace, Consolas, monospace; background: var(--surface); cursor: pointer; }
.swatch i { width: 18px; height: 18px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }
.swatch.selected { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }

.proposals { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.proposal { position: relative; display: flex; flex-direction: column; gap: 8px; text-align: left; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); padding: 10px; cursor: pointer; font: inherit; color: inherit; }
.proposal:hover { border-color: #b9c3d3; }
.proposal[aria-pressed="true"] { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.proposal .stage { display: grid; place-items: center; height: 84px; border-radius: 8px; background: var(--surface-2); overflow: hidden; }
.proposal canvas { max-width: 100%; max-height: 72px; }
.proposal strong { font-size: 13.5px; }
.proposal .why { font-size: 12px; color: var(--muted); line-height: 1.35; }
.badge { position: absolute; top: 8px; right: 8px; font-size: 10.5px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; background: var(--primary); color: var(--primary-ink); padding: 2px 7px; border-radius: 999px; }

.theme-previews { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 14px; }
.theme { margin: 0; border-radius: 10px; padding: 18px 14px 10px; display: flex; flex-direction: column; align-items: center; gap: 10px; border: 1px solid var(--border); }
.theme.light { background: #FFFFFF; }
.theme.dark { background: #1F1F1F; border-color: #1F1F1F; }
.theme canvas { max-width: 100%; height: auto; }
.theme figcaption { font-size: 11.5px; color: #6B6B6B; text-align: center; }
.theme.dark figcaption { color: #A8A8A8; }
.gif-result { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 14px; }
.gif-result figure { margin: 0; border-radius: 10px; padding: 14px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.gif-result figcaption { font-size: 12px; }
.gif-result .light { background: #fff; border: 1px solid var(--border); color: var(--muted); }
.gif-result .dark { background: #1F1F1F; color: #A8A8A8; }
.gif-result .warn { color: #B26A00; font-weight: 600; }

.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.empty-state p { margin: 14px 0 0; }

/* ---------- signature step ---------- */
.sig-previews { display: flex; flex-direction: column; gap: 12px; }
.sig-previews figure { margin: 0; }
.sig-previews figcaption { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.sig-previews iframe { width: 100%; height: 210px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.color-pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 8px; font: 12px ui-monospace, Consolas, monospace; }

.result { border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.result.ok { background: #E7F5EE; color: var(--ok); }
.result.fail { background: #FCEBEA; color: var(--danger); }

/* ---------- toast ---------- */
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1B1F24; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.2); z-index: 100; max-width: calc(100vw - 32px); }
.toast.fail { background: var(--danger); }

/* ---------- Microsoft sign-in & session ---------- */
.btn.ms { display: inline-flex; align-items: center; justify-content: center; gap: 10px; background: #fff; border-color: #8C8C8C; color: #5E5E5E; padding: 10px 14px; }
.btn.ms:hover { background: #F3F3F3; }
.user-chip { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
@media (max-width: 900px) { .user-chip { display: none; } }

/* ---------- proposals filter ---------- */
.segmented { display: inline-flex; flex-wrap: wrap; gap: 2px; background: var(--surface-2); border-radius: 9px; padding: 3px; margin-bottom: 12px; }
.segmented button { border: 0; background: transparent; font: inherit; font-size: 12.5px; padding: 5px 10px; border-radius: 7px; color: var(--muted); cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.proposal .cat { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }

/* ---------- Entra & add-in ---------- */
.status { display: flex; flex-direction: column; gap: 4px; border-radius: 10px; padding: 12px 14px; background: var(--surface-2); font-size: 13px; }
.status.ok { background: #E7F5EE; }
.status.warn { background: #FFF4E0; }
.status strong { font-size: 14px; }
.checklist { margin: 0; padding-left: 20px; font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.checklist li::marker { color: var(--ok); }
details.card summary { cursor: pointer; }
details.card[open] summary { margin-bottom: 14px; }
code.url { display: block; padding: 8px 10px; font-size: 13px; overflow-wrap: anywhere; }
.warn-box { margin: 6px 0 0; padding: 10px 12px; border-radius: 8px; background: #FFF4E0; color: #7A4B00; font-size: 12.5px; }
.domain-row { display: flex; align-items: center; gap: 8px; }
.domain-row .tag { font-size: 11px; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 1px 7px; }
.card.stack p { margin: 0; }

/* ---------- signatures list ---------- */
.sig-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.sig-card { display: flex; flex-direction: column; gap: 12px; text-align: left; font: inherit; color: inherit; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.sig-card:hover { border-color: #b9c3d3; box-shadow: 0 4px 14px rgba(16, 24, 40, .08); }
.sig-card .logo-stage { display: grid; place-items: center; height: 96px; border-radius: 10px; background: var(--surface-2); overflow: hidden; }
.sig-card .logo-stage img { max-width: 90%; max-height: 72px; }
.sig-card .logo-stage .placeholder { font-weight: 700; font-size: 22px; color: var(--muted); }
.sig-card h3 { margin: 0; font-size: 15px; }
.sig-card .meta { font-size: 12.5px; color: var(--muted); }
.state { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; }
.state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.state.ok { color: var(--ok); }
.state.pending { color: #B26A00; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-domain { font-size: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 2px 9px; }
.empty-signatures { text-align: center; padding: 40px 20px; }
.empty-signatures p { max-width: 520px; margin: 8px auto 18px; }

/* ---------- editor ---------- */
.editor-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin-bottom: 20px; }
.editor-head h1 { margin: 0; font-size: 20px; flex: 0 1 auto; overflow-wrap: anywhere; }
.steps-nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.steps-nav button { display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); background: var(--surface); padding: 7px 12px; border-radius: 999px; font: inherit; font-size: 13px; color: var(--muted); cursor: pointer; }
.steps-nav button[aria-current="step"] { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.steps-nav button[aria-current="step"] .num { background: var(--primary); color: var(--primary-ink); }
.steps-nav button:disabled { opacity: .45; cursor: not-allowed; }
.btn.small { padding: 5px 10px; font-size: 12.5px; }

/* ---------- domain picker ---------- */
.picker-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.picker-toolbar input[type="search"] { flex: 1 1 220px; }
.picker-toolbar .segmented { margin: 0; }
.domain-picker { border: 1px solid var(--border); border-radius: 10px; max-height: 460px; overflow: auto; }
.domain-group + .domain-group { border-top: 1px solid var(--border); }
.domain-group > .group-head { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--surface-2); font-weight: 600; font-size: 13px; }
.domain-group > .group-head .count { margin-left: auto; font-weight: 400; color: var(--muted); font-size: 12px; }
.domain-item { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 34px; font-size: 13.5px; cursor: pointer; }
.domain-item:hover { background: #F7F8FA; }
.domain-item.locked { cursor: not-allowed; color: var(--muted); }
.domain-item .owner { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45%; }
.domain-item .tag, .group-head .tag { font-size: 11px; color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 0 7px; font-weight: 400; }
.domain-picker .none { padding: 18px; text-align: center; color: var(--muted); font-size: 13px; }
.domain-picker input[type="checkbox"] { accent-color: var(--primary); width: 16px; height: 16px; flex: none; }

/* ---------- ENC Company branding ---------- */
.login-mark { width: 64px; height: 64px; margin-bottom: 6px; }
.topbar-mark { width: 26px; height: 26px; flex: none; }
.made-by { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 10px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.made-by img { height: auto; opacity: .85; }
.made-by.inline { display: inline-flex; margin: 0; padding: 0; border: 0; gap: 6px; }
.app-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; padding: 24px 16px 32px; font-size: 12px; color: var(--muted); }
.app-footer img { height: auto; opacity: .7; vertical-align: middle; }
.notice { margin: 0; padding: 10px 12px; border-radius: 8px; background: #E7F5EE; color: var(--ok); font-size: 13px; }

/* ---------- subscription ---------- */
.price { font-size: 34px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.price .per { font-size: 15px; font-weight: 500; color: var(--muted); }
.benefits { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; }
.tiers { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 13px; }
.tiers th, .tiers td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.tiers th { color: var(--muted); font-weight: 600; }
#billing-approve { align-self: flex-start; }
.warn-box a { color: inherit; font-weight: 600; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- price list editor ---------- */
.tiers.editable input { width: 100%; max-width: 140px; }
.tiers.editable td.from { color: var(--muted); }
.tiers.editable input:disabled { background: var(--surface-2); }
