/* Mimir / Fonn Group identity: Manrope, teal for the primary action and the
   selected state, plum for chrome. Text in ink, never in teal. */
:root {
  --teal: #159AB2;
  --teal-text: #0C485C;
  --teal-fill: #DEF1F4;
  --plum: #474056;
  --plum-light: #6A5F81;
  --page: #F7F0F0;
  --surface: #FFFFFF;
  --ink: #071627;
  --muted: #5F5E5A;
  --border: rgba(10, 12, 8, 0.12);
  --border-strong: rgba(10, 12, 8, 0.24);
  --strong: #1E7F4F;  --strong-fill: #E3F6EA;
  --possible: #8A6A12; --possible-fill: #FBF1D6;
  --weak: #5F5E5A;    --weak-fill: #EFEDE7;
  --none: #8B8A85;    --none-fill: #F4F3EF;
  --danger: #A63A2B;
  color-scheme: light;
}
/* Dark: chosen in the top bar (html[data-theme="dark"]), or "system" on a
   device set to dark. "light" stays light whatever the device says. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --teal: #3DB5CB;
    --teal-text: #9ADCE8;
    --teal-fill: #11343D;
    --plum: #2A2533;
    --plum-light: #9A8FB3;
    --page: #121316;
    --surface: #1B1C20;
    --ink: #ECEAE6;
    --muted: #A8A6A0;
    --border: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.22);
    --strong: #6FD99C;  --strong-fill: #173527;
    --possible: #E6C266; --possible-fill: #3A3017;
    --weak: #B9B7B0;    --weak-fill: #2A2A2C;
    --none: #85837E;    --none-fill: #222225;
    --danger: #F08C7C;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --teal: #3DB5CB;
  --teal-text: #9ADCE8;
  --teal-fill: #11343D;
  --plum: #2A2533;
  --plum-light: #9A8FB3;
  --page: #121316;
  --surface: #1B1C20;
  --ink: #ECEAE6;
  --muted: #A8A6A0;
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.22);
  --strong: #6FD99C;  --strong-fill: #173527;
  --possible: #E6C266; --possible-fill: #3A3017;
  --weak: #B9B7B0;    --weak-fill: #2A2A2C;
  --none: #85837E;    --none-fill: #222225;
  --danger: #F08C7C;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Manrope", system-ui, -apple-system, "Segoe UI", "Noto Sans", "Noto Sans CJK JP", "Noto Sans Arabic", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--page);
}
[hidden] { display: none !important; }
a { color: var(--teal-text); }
button, input, select { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--danger); min-height: 1.5em; margin: 0; }

button { cursor: pointer; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); padding: 6px 12px; }
button.primary { background: var(--teal); border-color: var(--teal); color: #fff; font-weight: 600; padding: 10px 16px; }
button.ghost { background: transparent; }
.button-link { display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
button.small { padding: 4px 10px; font-size: 13px; }
button:disabled { opacity: .5; cursor: default; }
input, select { border: 1px solid var(--border-strong); border-radius: 8px; padding: 7px 10px; background: var(--surface); width: 100%; }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--teal); margin: 0 6px 0 0; }

textarea { font: inherit; color: inherit; border: 1px solid var(--border-strong); border-radius: 8px; padding: 7px 10px; background: var(--surface); width: 100%; resize: vertical; }
h1, h2, h3 { line-height: 1.25; }

/* ---------------------------------------------------------------- sign-in */
.signin { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
.signin-hero { background: var(--plum); color: #F7F0F0; padding: 56px 48px; display: flex; flex-direction: column; justify-content: center; gap: 16px; }
.signin-logo { height: 44px; width: auto; align-self: flex-start; }
.signin-emblem { width: min(320px, 70vw); height: auto; border-radius: 16px; box-shadow: 0 12px 40px rgba(0,0,0,.35); margin-top: 8px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.home-hero { display: flex; gap: 20px; align-items: center; margin-bottom: 24px; }
.home-hero img { width: 88px; height: 88px; border-radius: 12px; flex: none; }
.home-hero h1 { font-size: 28px; font-weight: 800; margin: 0 0 4px; }
.home-hero .lead { margin: 0; }
.signin-hero h1 { font-size: 44px; font-weight: 800; margin: 12px 0 0; letter-spacing: -.01em; }
.signin-hero p { font-size: 18px; margin: 0; max-width: 28em; color: #E4E0EA; }
.signin-products { --logo-h: 26px; display: flex; gap: 24px; align-items: flex-start; margin-top: 24px; flex-wrap: wrap; }
.signin-products img { height: var(--logo-h); width: auto; opacity: .9; }
/* The three logos share an x-height, but Saga's baseline sits 20 of 72 px above
   the image bottom (the g descends) where Mimir's and TEIKNA's sit at the
   bottom: shift Saga down so all three stand on one line. */
.signin-products img[alt="Saga"] { margin-top: calc(var(--logo-h) * 20 / 72); }
.signin-panel { display: grid; place-items: center; padding: 32px 16px; }
.signin-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 28px; display: grid; gap: 14px; }
.signin-card h2 { margin: 0; }
.signin-card p { margin: 0; }
.google-btn {
  display: flex; align-items: center; justify-content: center; gap: 12px; text-decoration: none; color: var(--ink);
  border: 1px solid var(--border-strong); border-radius: 8px; padding: 11px 16px; font-weight: 600; background: var(--surface);
}
.google-btn:hover { border-color: var(--teal); }
.notice { background: var(--possible-fill); color: var(--ink); border-radius: 8px; padding: 10px 12px; margin: 0; font-size: 14px; }
@media (max-width: 760px) {
  .signin { grid-template-columns: 1fr; }
  .signin-hero { padding: 32px 20px; }
  .signin-hero h1 { font-size: 34px; }
  .signin-emblem { width: min(220px, 60vw); }
}

/* ----------------------------------------------------------------- topbar */
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: var(--plum); color: #F7F0F0;
  position: sticky; top: 0; z-index: 5;
}
.topbar .muted { color: #CFCAD9; }
.topbar button { color: #F7F0F0; border-color: rgba(255,255,255,.3); }
.brand { font-weight: 800; display: flex; align-items: center; gap: 12px; color: #F7F0F0; text-decoration: none; }
.brand .logo { height: 32px; width: auto; display: block; }
.brand span { padding-left: 12px; border-left: 1px solid rgba(255,255,255,.3); line-height: 1.2; font-size: 17px; }
.top-right { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.avatar { width: 28px; height: 28px; border-radius: 50%; }
.theme-pick { width: auto; padding: 4px 8px; font-size: 13px; }
.topbar .theme-pick { color: #F7F0F0; background: transparent; border-color: rgba(255,255,255,.3); }
.topbar .theme-pick option { color: var(--ink); background: var(--surface); }
.nav-toggle { display: none; }

/* ------------------------------------------------------------------ shell */
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: calc(100vh - 52px); }
.nav { border-right: 1px solid var(--border); padding: 20px 12px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 52px; align-self: start; max-height: calc(100vh - 52px); overflow-y: auto; }
.nav h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 16px 12px 6px; display: flex; align-items: center; gap: 8px; }
.nav h3 img { height: 16px; width: auto; }
.nav h3.nav-product { margin-top: 20px; }
.nav h3.nav-product img { height: 20px; }
.nav h3.nav-section { margin-top: 20px; font-size: 15px; text-transform: none; letter-spacing: 0; font-weight: 700; color: var(--ink); }
.nav h3.nav-section svg { color: var(--teal); flex: none; }
/* Saga's g descends below the line (see .signin-products): line it up with the others. */
.nav h3.nav-product img[alt="Saga"] { margin-bottom: calc(-20px * 20 / 72); }
.nav a { color: var(--ink); text-decoration: none; padding: 7px 12px; border-radius: 8px; border-left: 3px solid transparent; font-size: 14px; }
.nav a:hover { background: var(--surface); }
.nav a[aria-current=page] { background: var(--surface); border-left-color: var(--teal); font-weight: 600; }
.nav .soon { font-size: 11px; color: var(--muted); margin-left: 6px; }
.view { padding: 28px 32px 56px; min-width: 0; max-width: 1180px; }
.view > h1 { font-size: 28px; font-weight: 800; margin: 0 0 4px; }
.lead { color: var(--muted); margin: 0 0 24px; max-width: 46em; }
@media (max-width: 860px) {
  .nav-toggle { display: inline-block; }
  .top-right #who { display: none; }
  .shell { grid-template-columns: 1fr; }
  .nav { position: static; max-height: none; border-right: 0; border-bottom: 1px solid var(--border); }
  .nav:not(.open) { display: none; }
  .view { padding: 20px 16px 48px; }
}

/* ------------------------------------------------------------------ cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px 24px; margin-bottom: 20px; min-width: 0; }
.card h2 { font-size: 18px; margin: 0 0 12px; }
.tiles { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 16px; margin-bottom: 24px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; display: grid; gap: 10px; align-content: start; }
.tile img { height: 26px; width: auto; justify-self: start; }
.tile p { margin: 0; color: var(--muted); font-size: 14px; }
.tile .links { display: flex; gap: 12px; flex-wrap: wrap; font-size: 14px; }
/* All product tiles on one row; 2 x 2 on narrower screens, stacked on phones. */
@media (max-width: 1100px) { .tiles { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) { .tiles { grid-template-columns: 1fr; } }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; background: transparent; padding: 5px 12px; }
.seg button[aria-pressed=true] { background: var(--teal); color: #fff; }
.pill { display: inline-block; font-size: 12px; font-weight: 600; border-radius: 6px; padding: 1px 8px; background: var(--teal-fill); color: var(--teal-text); }
.pill.warn { background: var(--possible-fill); color: var(--possible); }
.empty { color: var(--muted); padding: 24px; text-align: center; border: 1px dashed var(--border-strong); border-radius: 12px; }

/* ------------------------------------------------------------ price lists */
.table-wrap { overflow-x: auto; }
table.prices, table.plain { width: 100%; border-collapse: collapse; font-size: 14px; }
table.prices th, table.plain th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border-strong); white-space: nowrap; }
table.prices td, table.plain td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.prices td.num, table.prices th.num, table.plain td.num, table.plain th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.prices .name { font-weight: 600; min-width: 160px; }
table.prices .desc { color: var(--muted); max-width: 46em; }
table.prices .comment { font-size: 13px; color: var(--possible); margin-top: 4px; }
table.prices input, table.prices textarea { font-size: 13px; padding: 5px 7px; }
table.prices input.num { text-align: right; width: 96px; }
.edit-actions { position: sticky; bottom: 0; background: var(--page); padding: 12px 0; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; border-top: 1px solid var(--border); }

/* ------------------------------------------------------------- calculator */
.calc { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 1100px) { .calc { grid-template-columns: 1fr; } }
.fields { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; align-items: center; }
.fields label { font-size: 14px; }
.fields .hint { display: block; font-size: 12px; color: var(--muted); }
.fields input { text-align: right; width: 110px; }
.result { position: sticky; top: 72px; }
.result td.group { font-weight: 700; padding-top: 16px; border-bottom: 0; }
.result .detail { display: block; font-size: 12px; color: var(--muted); }
.totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 16px; }
.total { border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.total .label { font-size: 12px; color: var(--muted); }
.total .value { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.warnings { margin: 12px 0 0; padding-left: 18px; color: var(--possible); font-size: 13px; }

/* ------------------------------------------------------------------ admin */
.row-form { display: grid; grid-template-columns: minmax(0, 2fr) 140px auto; gap: 10px; align-items: center; }
@media (max-width: 640px) { .row-form { grid-template-columns: 1fr; } }
table.plain td.num select { width: auto; }
table.plain td.num { white-space: nowrap; }
.check-row { display: flex; gap: 10px; align-items: flex-start; margin: 12px 0 4px; font-size: 14px; cursor: pointer; }
.check-row input { margin-top: 3px; }
.check-row .hint { display: block; font-size: 12px; color: var(--muted); }
.fields select { width: min(260px, 52vw); }
table.plain.inputs input { width: 100px; text-align: right; }
table.plain.inputs td { vertical-align: middle; }
.notice-card { border-color: var(--possible); background: var(--possible-fill); }
.notice-card h2 { color: var(--ink); }
.aws-ok { margin: 0 0 12px; }
.product-picker { display: inline-flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.product-check { display: inline-flex; gap: 4px; align-items: center; cursor: pointer; }
.product-check img { height: 16px; width: auto; }
.product-check input:not(:checked) + img { opacity: .35; filter: grayscale(1); }
.picker-row { display: flex; gap: 12px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.discount-row { display: grid; grid-template-columns: minmax(0, 1fr) 110px 120px auto; gap: 8px; align-items: center; margin: 8px 0; font-size: 14px; }
.discount-row .hint { display: block; font-size: 12px; color: var(--muted); }
.discount-row input { text-align: right; }
.discount-row select:first-child { grid-column: 1 / 4; }
.detail.discount { color: var(--strong); }
@media (max-width: 640px) { .discount-row { grid-template-columns: 1fr 1fr; } .discount-row select:first-child { grid-column: 1 / -1; } }
table.plain.terms { margin-top: 12px; }
table.plain.terms td.num, table.plain.terms th.num { min-width: 110px; }
table.plain.terms tr.discount-row-total td { color: var(--strong); }
table.plain.terms tr.net-row td { font-weight: 800; font-size: 16px; border-bottom: 0; }

/* Deals (HubSpot) */
a.button { display: inline-block; text-decoration: none; border-radius: 8px; border: 1px solid var(--border-strong); padding: 6px 12px; }
a.button.primary { background: var(--teal); border-color: var(--teal); color: #fff; font-weight: 600; padding: 10px 16px; }
.deal-search { flex: 1 1 260px; }
label.check { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; white-space: nowrap; }
label.check input { width: auto; }
.deal-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.deal-facts > div { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; }
.deal-facts .label { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.deal-facts .value { font-size: 20px; font-weight: 800; }
ul.plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.card > .notice:first-child { margin-bottom: 14px; }
table.plain.routing select { width: auto; min-width: 180px; }
table.plain.routing td.name { font-weight: 600; white-space: nowrap; }

/* Quotes ------------------------------------------------------------------ */
.block-label { display: block; font-size: 14px; margin: 12px 0 4px; }
.template-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin: 8px 0 14px; }
.template-tile { display: grid; gap: 6px; text-align: left; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border-strong); background: var(--surface); }
.template-tile img { height: 22px; width: auto; justify-self: start; }
.template-tile.chosen { border-color: var(--teal); box-shadow: 0 0 0 2px var(--teal); }
/* The Fonn logo is white (for the dark top bar): dark on light surfaces. */
img.brand-fonn { filter: brightness(0); }
:root[data-theme="dark"] .template-tile img.brand-fonn { filter: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .template-tile img.brand-fonn { filter: none; } }


/* ------------------------------------------------------------ Skipan */
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--weak-fill); color: var(--weak); white-space: nowrap; }
.badge.create, .badge.done, .badge.ok, .badge.test { background: var(--strong-fill); color: var(--strong); }
.badge.update, .badge.running, .badge.queued, .badge.previewing, .badge.staging { background: var(--teal-fill); color: var(--teal-text); }
.badge.manual, .badge.awaiting-approval, .badge.previewed, .badge.warn, .badge.stale { background: var(--possible-fill); color: var(--possible); }
.badge.delete, .badge.failed, .badge.production { background: #F9E1DC; color: var(--danger); }
:root[data-theme="dark"] .badge.delete, :root[data-theme="dark"] .badge.failed, :root[data-theme="dark"] .badge.production { background: #3A1E19; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .badge.delete, :root:not([data-theme="light"]) .badge.failed, :root:not([data-theme="light"]) .badge.production { background: #3A1E19; } }
.steps { counter-reset: step; display: grid; gap: 16px; }
.step { position: relative; padding-left: 52px; }
.step::before { counter-increment: step; content: counter(step); position: absolute; left: 0; top: 18px; width: 34px; height: 34px; border-radius: 50%; background: var(--plum); color: #fff; display: grid; place-items: center; font-weight: 800; }
.summary-panel { border: 2px solid var(--teal); background: var(--teal-fill); }
.summary-panel .one-line { font-size: 17px; font-weight: 600; margin: 0 0 12px; }
.log { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; background: var(--page); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; max-height: 280px; overflow: auto; white-space: pre-wrap; }
.log .warn { color: var(--possible); } .log .error { color: var(--danger); }
.plan-group h3 { margin: 18px 0 6px; font-size: 15px; }
.plan-row { display: grid; grid-template-columns: 90px 1fr; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); }
.plan-row ul { margin: 4px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
.plan-row .conflict { color: var(--possible); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.editor-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0; }
.editor-tabs button[aria-pressed=true] { background: var(--teal); color: #fff; border-color: var(--teal); }
textarea.code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; width: 100%; min-height: 260px; }
.field-grid { width: 100%; border-collapse: collapse; }
.field-grid td, .field-grid th { padding: 4px; border-top: 1px solid var(--border); vertical-align: top; text-align: left; font-size: 13px; }
.field-grid input, .field-grid select, .field-grid textarea { width: 100%; }
.form-block { border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin: 10px 0; background: var(--surface); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px 16px; }
.grid2 label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.help-layout { display: grid; grid-template-columns: 220px 1fr; gap: 24px; align-items: start; }
.help-nav { position: sticky; top: 72px; display: grid; gap: 2px; }
.help-nav a { padding: 6px 10px; border-radius: 6px; text-decoration: none; color: var(--ink); }
.help-nav a.current { background: var(--teal-fill); color: var(--teal-text); font-weight: 600; }
.help-body section { scroll-margin-top: 72px; }
@media (max-width: 860px) { .help-layout { grid-template-columns: 1fr; } .help-nav { position: static; } .plan-row { grid-template-columns: 1fr; } }
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 50; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--plum); color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.25); font-size: 14px; }
.toast.error { background: var(--danger); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.muted-row td { color: var(--muted); }
/* The Skipan mark (skipan-icon.svg): a template (ring) following an ordered path to an applied setup (mint). */
.skipan-emblem { width: 120px; height: 120px; border-radius: 28px; box-shadow: 0 12px 40px rgba(0,0,0,.35); margin-top: 8px; }
.brand .brand-name { display: flex; align-items: center; gap: 10px; }
.brand-icon { width: 28px; height: 28px; border-radius: 7px; box-shadow: 0 0 0 1px rgba(255,255,255,.18); }
