/* Stage panel. Tokens from the approved mockup; no external fonts. */
:root {
  --sidebar: #1b1a4a;
  --sidebar-active: #2e2c72;
  --sidebar-line: #34327a;
  --sidebar-ink: #e6e6f5;
  --sidebar-muted: #a9a8d6;
  --accent: #4f46e5;
  --accent-ink: #3f3ab8;
  --accent-deep: #2a2690;
  --ground: #f6f6fa;
  --surface: #ffffff;
  --ink: #18183a;
  --ink-2: #33334f;
  --muted: #55557a;
  --line: #e3e3ee;
  --line-soft: #efeff6;
  --control-line: #d9d9e6;
  --seg-ground: #ececf4;
  --disabled-ink: #8a8aa6;
  --stage: #d92d34;
  --ok-bg: #e3f3ea;
  --ok-ink: #17663f;
  --queued-bg: #e8e7fb;
  --queued-ink: #2a2690;
  --failed-bg: #fdeceb;
  --failed-ink: #a3221b;
  --hold-bg: #fff6e5;
  --hold-ink: #7a4a00;
  --hold-line: #f0c27a;
  --icon-yellow: #f5c451;
  --radius: 12px;
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ground); color: var(--ink); font: 14px/1.45 var(--font); }
a { color: var(--accent-ink); }
a:hover { color: var(--accent-deep); }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.icon { flex: none; }

/* shell */
.shell { display: flex; flex-wrap: wrap; min-height: 100vh; }
.sidebar { flex: 1 1 232px; max-width: 100%; background: var(--sidebar); color: var(--sidebar-ink);
  padding: 24px 16px; display: flex; flex-direction: column; gap: 28px; }
.main { flex: 999 1 560px; min-width: 0; padding: 40px 48px 56px; display: flex;
  flex-direction: column; gap: 24px; }
.shell-bare { align-items: flex-start; justify-content: center; }
.main-bare { flex: 0 1 440px; padding: 12vh 16px 56px; }

.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.brand-mark { width: 32px; height: 32px; border-radius: 8px; background: var(--accent);
  display: flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; }
.brand-text { display: flex; flex-direction: column; gap: 2px; }
.brand-name { font-weight: 600; font-size: 15px; color: #fff; }
.login-card .brand-name { color: var(--ink); }
.stage-tag { align-self: flex-start; background: var(--stage); color: #fff; font-size: 11px;
  font-weight: 700; padding: 1px 6px; border-radius: 4px; }

.nav-group { display: flex; flex-direction: column; gap: 4px; }
.nav-caption { font-size: 12px; color: var(--sidebar-muted); padding: 0 12px 6px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px;
  color: var(--sidebar-ink); text-decoration: none; }
.nav-link:hover { background: var(--sidebar-active); color: #fff; }
.nav-link[aria-current="page"] { background: var(--sidebar-active); color: #fff; font-weight: 500; }
.nav-link[aria-current="page"] .icon { stroke: var(--icon-yellow); }
.badge { margin-left: auto; background: var(--accent); color: #fff; font-size: 12px;
  font-weight: 600; padding: 1px 8px; border-radius: 10px; }
.user-block { margin-top: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 12px 8px 0; border-top: 1px solid var(--sidebar-line); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--icon-yellow);
  color: var(--sidebar); font-weight: 700; display: flex; align-items: center;
  justify-content: center; font-size: 13px; }
.user-names { display: flex; flex-direction: column; }
.user-name { color: #fff; font-weight: 500; }
.user-login { font-size: 12px; color: var(--sidebar-muted); }
.logout { margin-left: auto; }
.btn-link { background: none; border: 0; padding: 4px 0; color: var(--sidebar-muted);
  text-decoration: underline; cursor: pointer; font-size: 13px; }
.btn-link:hover { color: #fff; }

/* type */
.h1 { margin: 0; font-size: 30px; line-height: 1.2; font-weight: 700; letter-spacing: -0.01em;
  overflow-wrap: anywhere; }
.h2 { margin: 0; font-size: 17px; line-height: 1.3; font-weight: 600; }
.lead { margin: 0; color: var(--muted); font-size: 15px; max-width: 640px; }
.muted { color: var(--muted); }
.sub { display: block; font-size: 12px; color: var(--muted); margin: 0; }
.small { font-size: 13px; color: var(--ink-2); }
.strong { font-weight: 600; }
.note { margin: 0; font-size: 13px; color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); flex-basis: 100%; }
.crumb { font-size: 13px; color: #45456a; text-decoration: none; }
.crumb:hover { text-decoration: underline; }
.links { margin: 0; }
.ok-text { color: var(--ok-ink); font-weight: 500; }
.fail-text { color: var(--failed-ink); font-weight: 500; }

.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-sm { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.stack-xs { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 160px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 16px; }
.title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }

/* controls */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 8px;
  border: 1px solid var(--control-line); background: var(--surface); color: var(--ink);
  font-weight: 500; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #b9b9cf; color: var(--ink); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); color: #fff; }
.btn-sm { padding: 7px 10px; border-radius: 7px; font-size: 13px; }
.btn-icon { width: 32px; justify-content: center; padding-left: 0; padding-right: 0; color: var(--ink-2); }
.btn-hold { border-color: var(--hold-line); background: var(--hold-bg); color: var(--hold-ink);
  font-weight: 600; }
.btn:disabled, .btn:disabled:hover { border-color: #ececf4; background: var(--ground);
  color: var(--disabled-ink); cursor: not-allowed; }
.inline { display: inline-flex; margin: 0; }
.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.page-head .actions { gap: 8px; }

.field { display: flex; flex-direction: column; gap: 6px; font-weight: 500; min-width: 0; }
.field input, .hold-form input { width: 100%; padding: 9px 12px; border: 1px solid var(--control-line);
  border-radius: 8px; background: var(--surface); font-weight: 400; min-width: 0; }
/* invalid only after the user has interacted, never on first load */
.field input:user-invalid { border-color: var(--failed-ink); }
.field input[readonly] { background: var(--ground); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.copy-row { display: flex; gap: 8px; }

/* messages and chips */
.msg { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 10px;
  font-weight: 500; overflow-wrap: anywhere; }
.msg-ok { background: var(--ok-bg); color: var(--ok-ink); }
.msg-queued { background: var(--queued-bg); color: var(--queued-ink); }
.msg-failed { background: var(--failed-bg); color: var(--failed-ink); }
.msg-hold { background: var(--hold-bg); color: var(--hold-ink); }
.chip { justify-self: start; display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px;
  border-radius: 12px; font-size: 13px; font-weight: 500; overflow-wrap: anywhere; }
.chip-ok { background: var(--ok-bg); color: var(--ok-ink); }
.chip-queued { background: var(--queued-bg); color: var(--queued-ink); }
.chip-failed { background: var(--failed-bg); color: var(--failed-ink); }
.chip-hold { background: var(--hold-bg); color: var(--hold-ink); align-self: flex-start; font-size: 12px; }
.chip-none { background: var(--seg-ground); color: var(--muted); }
.warn { display: flex; gap: 10px; padding: 12px; border-radius: 10px; background: var(--hold-bg);
  color: var(--hold-ink); font-size: 13px; line-height: 1.45; }

/* toolbar */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.segments { display: flex; flex-wrap: wrap; gap: 4px; background: var(--seg-ground); padding: 4px;
  border-radius: 10px; }
.seg { padding: 7px 14px; border-radius: 7px; color: #45456a; text-decoration: none; font-weight: 500; }
.seg:hover { color: var(--ink); }
.seg[aria-current="true"] { background: var(--surface); color: var(--ink); font-weight: 600;
  box-shadow: 0 1px 2px rgba(27, 26, 74, 0.12); }
.search { display: flex; gap: 8px; margin: 0; }
.search-box { display: flex; align-items: center; gap: 8px; background: var(--surface);
  border: 1px solid var(--control-line); border-radius: 8px; padding: 8px 12px; min-width: 240px;
  color: var(--muted); }
.search-box input { border: 0; outline: none; background: transparent; flex: 1; min-width: 0; color: var(--ink); }
.search-box:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); gap: 20px; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.list-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 10px 0;
  border-top: 1px solid var(--line-soft); }
.log-row { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 12px; padding: 9px 0;
  border-top: 1px solid var(--line-soft); font-size: 13px; overflow-wrap: anywhere; }
.log-row .sub { font-size: 13px; }
.code-card { border: 1px solid var(--line-soft); border-radius: 10px; padding: 14px; display: flex;
  flex-direction: column; gap: 8px; }
.code-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; overflow-wrap: anywhere; }
.checks { list-style: none; margin: 0; padding: 0; display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px 16px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.check-ok .icon { stroke: var(--ok-ink); }
.check-fail { color: var(--failed-ink); }
.snap-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; }
.snap-form .field { flex: 1 1 200px; }

.hold-box { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 14px 16px;
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); }
.hold-box-mine { background: var(--hold-bg); border-color: var(--hold-line); color: var(--hold-ink); }
.hold-box-other { background: var(--ground); border-color: var(--control-line); color: var(--ink-2); }
.hold-box-other .icon { stroke: var(--hold-ink); }
.hold-text { flex: 1; min-width: 220px; overflow-wrap: anywhere; }
.hold-form { display: flex; flex-wrap: wrap; gap: 8px; flex: 1 1 320px; justify-content: flex-end; }
.hold-form input { flex: 1 1 200px; width: auto; }
.hold-mine { color: #8a4b00; font-weight: 600; overflow-wrap: anywhere; }
.hold-other { color: #8a4b00; overflow-wrap: anywhere; }
.hold-free { color: #6b6b88; }

/* sites table */
.table-wrap { padding: 0; overflow-x: auto; }
.sites { width: 100%; min-width: 1000px; border-collapse: collapse; }
.sites th { text-align: left; font-size: 13px; color: var(--muted); font-weight: 500; padding: 12px 20px 12px 0;
  border-bottom: 1px solid var(--line); }
.sites td { padding: 10px 20px 10px 0; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.sites th:first-child, .sites td:first-child { padding-left: 20px; }
.sites tbody tr:last-child td { border-bottom: 0; }
.sites .right { text-align: right; }
.sites .c-when { white-space: nowrap; }
.sites .c-actions { width: 380px; white-space: nowrap; }
.sites .c-actions .actions { flex-wrap: nowrap; }
.m-label { display: none; }
.sites td:nth-child(3) { max-width: 220px; }
.site-name { font-weight: 600; color: var(--ink); text-decoration: none; }
.site-name:hover { text-decoration: underline; color: var(--ink); }
.empty { text-align: center; color: var(--muted); padding: 32px 20px; }

/* dialogs, confirm and job pages */
.dialog { width: 460px; max-width: calc(100% - 32px); border: 0; border-radius: 14px; padding: 24px;
  box-shadow: 0 20px 50px rgba(27, 26, 74, 0.25); color: var(--ink); }
.dialog[open] { display: flex; flex-direction: column; gap: 16px; }
.dialog::backdrop { background: rgba(27, 26, 74, 0.45); }
.dlg-body { margin: 0; color: var(--ink-2); line-height: 1.5; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin: 0; flex-wrap: wrap; }
.confirm { max-width: 560px; }
.details summary { cursor: pointer; color: var(--accent-ink); }
.details pre { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 12px; font-size: 12px; max-height: 360px;
  overflow: auto; }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 28px; display: flex; flex-direction: column; gap: 16px; }
.login-card .brand { padding: 0; }
.login-card form { gap: 14px; }

/* E-post */
.mail-filter { display: flex; align-items: center; gap: 8px; margin: 0; }
.field-inline { display: flex; align-items: center; gap: 8px; color: #45456a; }
.field-inline select { padding: 8px 10px; border-radius: 8px; border: 1px solid var(--control-line);
  background: var(--surface); font: inherit; color: var(--ink); max-width: 100%; }
.mail-wrap { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.mail-list { flex: 1 1 360px; min-width: 0; padding: 0; gap: 0; overflow: hidden; }
.mail-read { flex: 2 1 480px; min-width: 0; }
.mail-items { list-style: none; margin: 0; padding: 0; }
.mail-item { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft); color: var(--ink); text-decoration: none; min-width: 0; }
.mail-items li:last-child .mail-item { border-bottom: 0; }
.mail-item:hover { background: var(--ground); color: var(--ink); }
.mail-item.is-current { background: #eeedfc; box-shadow: inset 3px 0 0 var(--accent); }
.mail-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.mail-meta .dot { width: 8px; height: 8px; border-radius: 50%; background: transparent; flex: none; }
.mail-item.is-unread .dot { background: var(--accent); }
.mail-site { font-weight: 600; color: var(--ink-2); }
.mail-when { margin-left: auto; white-space: nowrap; }
.mail-subj { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-item.is-unread .mail-subj { font-weight: 700; }
.mail-to { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-count { padding: 12px 16px 0; }
.mail-pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 8px; padding: 0 16px 12px; border-bottom: 1px solid var(--line); }
.mail-pager .mail-count { padding: 12px 0 0; margin: 0; }
.mail-pages { display: flex; gap: 6px; padding-top: 12px; }
.mail-hint { margin: 0; }
.mail-list .empty { margin: 0; }
.mail-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start;
  gap: 12px; }
.mail-head .h2 { overflow-wrap: anywhere; }
.mail-head .sub { overflow-wrap: anywhere; }
.mail-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font: 14px/1.55 var(--font);
  color: var(--ink-2); border-top: 1px solid var(--line-soft); padding-top: 14px; }
.mail-frame { width: 100%; min-height: 520px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; }
.mail-empty { justify-content: center; min-height: 160px; }

/* Veiledning */
.guide p, .guide li { line-height: 1.55; color: var(--ink-2); max-width: 760px; }
.guide p { margin: 0; }
.guide-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.guide code, .case code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px;
  background: var(--line-soft); padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere; }
.guide-cmd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--ground);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.cases { display: flex; flex-direction: column; border: 1px solid var(--line-soft); border-radius: 10px; }
.case { border-top: 1px solid var(--line-soft); }
.case:first-child { border-top: 0; }
.case summary { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; cursor: pointer; font-weight: 600; list-style: none; }
.case summary::-webkit-details-marker { display: none; }
.case summary::before { content: "+"; flex: none; width: 18px; color: var(--accent-ink); font-weight: 700; }
.case[open] summary::before { content: "\2212"; }
.case-title { flex: 1; min-width: 0; }
.case summary .chip { flex: none; font-size: 12px; font-weight: 500; }
.case-body { padding: 0 16px 16px 46px; display: flex; flex-direction: column; gap: 10px; }
.case-body ol, .case-body ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }

@media (max-width: 760px) {
  .sidebar { flex-basis: 100%; padding: 14px 16px; gap: 12px; flex-direction: row; flex-wrap: wrap;
    align-items: center; }
  .nav-group { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .nav-caption { display: none; }
  .nav-link { padding: 8px 10px; }
  .user-block { margin-top: 0; flex-basis: 100%; padding-top: 10px; }
  .main { padding: 24px 16px 40px; gap: 18px; }
  .h1 { font-size: 24px; }
  .search, .search-box { flex: 1 1 auto; min-width: 0; }
  .search { width: 100%; }
  .card { padding: 16px; }
  .log-row { grid-template-columns: 1fr; gap: 2px; }
  .page-head .actions { justify-content: flex-start; }

  /* sites table becomes one card per row */
  .table-wrap { overflow-x: visible; }
  .sites { min-width: 0; }
  .sites thead { display: none; }
  .sites, .sites tbody { display: block; }
  .sites tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px;
    align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line-soft); }
  .sites tbody tr:last-child { border-bottom: 0; }
  .sites td, .sites th:first-child, .sites td:first-child { display: block; padding: 0; border: 0; }
  .sites td:nth-child(3) { max-width: none; }
  .sites .c-name, .sites .c-hold, .sites .c-actions, .sites .empty { grid-column: 1 / -1; }
  .sites .c-status { justify-self: end; }
  .sites .c-when, .sites .c-hold { font-size: 13px; }
  .sites .c-actions { width: auto; white-space: normal; }
  .sites .c-actions .actions { flex-wrap: wrap; justify-content: flex-start; }
  .sites .c-actions .inline { flex: 1 1 auto; }
  .sites .c-actions .inline .btn { width: 100%; justify-content: center; }
  .m-label { display: inline; color: var(--muted); }
  .sites .c-when { white-space: normal; }
  .mail-filter, .field-inline, .field-inline select { width: 100%; }
  .field-inline select { flex: 1; }
  .mail-frame { min-height: 380px; }
  .mail-read { order: -1; }          /* the open message first on a phone */
  .mail-empty { display: none; }
  .case-body { padding-left: 16px; }
}

@media (prefers-reduced-motion: no-preference) {
  .btn, .nav-link, .seg { transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease; }
}
