/* Itolia MailBridge – Oberfläche. Farbwerte in /static/brand/tokens.css. */
/* tokens.css is linked separately in the templates (versioned) */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-strong); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-small); }

h1 { font-size: 28px; line-height: 1.2; font-weight: 650; letter-spacing: -0.01em; margin: 0 0 8px; }
h2 { font-size: 19px; font-weight: 600; margin: 0 0 12px; }
p { margin: 0 0 16px; }
.lead { color: var(--text-muted); font-size: 17px; margin-bottom: 32px; }
.muted { color: var(--text-muted); }
.small { font-size: 14px; }
code, .mono { font-family: var(--font-mono); font-size: 0.92em; }

.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 16px; top: 16px; background: var(--bg); padding: 8px 16px; z-index: 10; }

/* --- header --- */
.topbar {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 24px;
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand img { height: 30px; width: auto; display: block; }
.brand-product { font-weight: 600; font-size: 15px; padding-left: 12px; border-left: 1px solid var(--border); }
.brand-tenant { color: var(--text-muted); font-size: 14px; }

.nav { display: flex; flex-wrap: wrap; gap: 4px; margin-left: auto; align-items: center; }
.nav a {
  color: var(--text);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 15px;
}
.nav a:hover { background: var(--surface-alt); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--brand-tint); color: var(--brand-strong); font-weight: 600; }
.nav form { margin: 0; }

/* --- layout --- */
main { max-width: 1040px; margin: 0 auto; padding: 40px 24px 64px; }
.narrow { max-width: 640px; }

.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
}
.card > :last-child { margin-bottom: 0; }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-bottom: 32px; }
.grid > .card { margin-bottom: 0; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px; margin-bottom: 24px; }
.page-head > div { flex: 1 1 auto; }
.page-head .lead { margin-bottom: 0; }

/* --- auth pages --- */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-card);
  padding: 40px 32px 32px;
}
.auth-logo { display: block; height: 44px; width: auto; margin: 0 auto 24px; }
.auth-card h1 { text-align: center; font-size: 24px; }
.auth-card .lead { text-align: center; font-size: 15px; margin-bottom: 24px; }
.auth-foot { text-align: center; margin-top: 24px; font-size: 14px; }

/* --- forms --- */
.field { margin-bottom: 20px; }
.label-row { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
label { font-weight: 550; font-size: 15px; }
input[type="text"], input[type="email"], input[type="password"], select {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  padding: 11px 14px;
  min-height: 46px;
}
input:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus-ring); }
input.code { font-family: var(--font-mono); font-size: 22px; letter-spacing: 0.25em; text-align: center; }
.help { color: var(--text-muted); font-size: 14px; margin-top: 6px; }

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; font-size: 15px;
  border: 1px solid transparent; border-radius: 999px;
  padding: 10px 20px; min-height: 44px;
  cursor: pointer; text-decoration: none;
  background: var(--brand-strong); color: var(--on-brand, #fff);
}
.button:hover { filter: brightness(1.06); text-decoration: none; }
.button.block { width: 100%; }
.button.secondary { background: var(--bg); color: var(--text); border-color: var(--border); }
.button.secondary:hover { background: var(--surface-alt); filter: none; }
.button.danger { background: var(--bg); color: var(--danger); border-color: var(--border); }
.button.link { background: none; color: var(--text); padding: 6px 12px; min-height: 0; font-weight: 400; }
.button.link:hover { background: var(--surface-alt); }
.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.actions form { margin: 0; }

/* --- messages --- */
.notice, .error {
  border-radius: var(--radius-small);
  padding: 12px 16px;
  margin-bottom: 20px;
  font-size: 15px;
}
.notice { background: var(--brand-tint); }
.error { background: color-mix(in srgb, var(--danger) 10%, var(--bg)); color: var(--danger); }
.ok { color: var(--success); }

/* --- "?" explanations --- */
details.hint { display: inline-block; position: relative; }
details.hint > summary {
  list-style: none;
  cursor: pointer;
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
}
details.hint > summary::-webkit-details-marker { display: none; }
details.hint[open] > summary { border-color: var(--brand); color: var(--brand-strong); }
details.hint .hint-body {
  position: absolute; z-index: 5; left: 0; top: 26px;
  width: min(320px, 80vw);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  box-shadow: var(--shadow-card);
  padding: 12px 14px;
  font-size: 14px; font-weight: 400; line-height: 1.45;
  color: var(--text);
}

/* --- tables / lists --- */
.list { width: 100%; border-collapse: collapse; }
.list th { text-align: left; font-size: 13px; font-weight: 600; color: var(--text-muted); padding: 0 12px 10px; }
.list td { padding: 14px 12px; border-top: 1px solid var(--border); vertical-align: middle; }
.list tr.clickable:hover td { background: var(--surface); }
.list .right { text-align: right; }

.badge {
  display: inline-block; font-size: 13px; font-weight: 550;
  padding: 2px 10px; border-radius: 999px;
  background: var(--surface-alt); color: var(--text-muted);
}
.badge.good { background: color-mix(in srgb, var(--success) 14%, var(--bg)); color: var(--success); }
.badge.warn { background: color-mix(in srgb, var(--warning) 16%, var(--bg)); color: var(--warning); }
.badge.bad { background: color-mix(in srgb, var(--danger) 12%, var(--bg)); color: var(--danger); }

/* --- overview --- */
.stat .stat-label { color: var(--text-muted); font-size: 14px; }
.stat .stat-value { font-size: 32px; font-weight: 650; letter-spacing: -0.02em; }
.steps { list-style: none; padding: 0; margin: 0; counter-reset: step; }
.steps li {
  counter-increment: step;
  display: flex; gap: 16px; align-items: flex-start;
  padding: 16px 0; border-top: 1px solid var(--border);
}
.steps li:first-child { border-top: 0; padding-top: 0; }
.steps li::before {
  content: counter(step);
  flex: 0 0 32px; height: 32px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-alt); font-weight: 600;
}
.steps li.done::before { content: "✓"; background: color-mix(in srgb, var(--success) 15%, var(--bg)); color: var(--success); }
.steps li > div { flex: 1; }
.steps .step-title { font-weight: 600; }

/* --- 2FA setup / codes / links --- */
.qr { display: flex; justify-content: center; margin: 8px 0 16px; }
.qr svg { border-radius: var(--radius-small); border: 1px solid var(--border); padding: 8px; background: #fff; }
.secret { font-family: var(--font-mono); text-align: center; font-size: 15px; letter-spacing: 0.05em; word-break: break-all; }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 24px; padding: 16px 20px; background: var(--surface); border-radius: var(--radius-small); margin-bottom: 20px; font-family: var(--font-mono); font-size: 16px; }
.copy-field { font-family: var(--font-mono); font-size: 14px; }

ol.howto { padding-left: 20px; margin: 0 0 20px; }
ol.howto li { margin-bottom: 8px; }

/* --- help --- */
.help-toc { columns: 2 220px; padding-left: 18px; }
.help-section { scroll-margin-top: 24px; }
.help-section h2 { margin-top: 8px; }
.faq dt { font-weight: 600; margin-top: 16px; }
.faq dd { margin: 4px 0 0; color: var(--text); }

footer.site { max-width: 1040px; margin: 0 auto; padding: 0 24px 40px; color: var(--text-muted); font-size: 13px; }

@media (max-width: 640px) {
  main { padding: 24px 16px 48px; }
  .topbar-inner { padding: 12px 16px; }
  .nav { margin-left: 0; width: 100%; }
  .brand-tenant { display: none; }
  h1 { font-size: 24px; }
  .card { padding: 20px; }
  .auth-card { padding: 32px 20px 24px; }
  .list .hide-mobile { display: none; }
  .codes { grid-template-columns: 1fr; }
  .nav a { padding: 6px 10px; font-size: 14px; }
  .nav .button.link { font-size: 14px; padding: 6px 10px; }
  .grid { grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 24px; }
  .grid > .card { padding: 12px; }
  .stat .stat-label { font-size: 12px; line-height: 1.3; }
  .stat .stat-value { font-size: 24px; }
}

/* --- utilities --- */
.center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-20 { margin-bottom: 20px; }
input.code-inline { width: 180px; flex: 0 0 auto; font-family: var(--font-mono); letter-spacing: 0.1em; }

/* --- mail accounts --- */
.choice-list { display: grid; gap: 12px; }
.choice { display: flex; flex-direction: column; gap: 4px; margin-bottom: 0; color: var(--text); }
.choice:hover { text-decoration: none; border-color: var(--brand); }
.choice-title { font-weight: 600; font-size: 17px; }
.field.has-error input, .field.has-error select { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 14px; margin-top: 6px; }
.ok-box { background: color-mix(in srgb, var(--success) 12%, var(--bg)); color: var(--success); }
details.advanced { margin-top: 8px; }
details.advanced > summary { cursor: pointer; color: var(--text-muted); font-size: 15px; margin-bottom: 12px; }
.radio-list { display: grid; gap: 10px; margin-bottom: 16px; }
label.radio, label.checkbox { font-weight: 400; display: flex; gap: 10px; align-items: center; cursor: pointer; }
label.checkbox { margin-bottom: 16px; }
input[type="radio"], input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--brand-strong); }
input[type="number"] { width: 120px; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-small); padding: 11px 14px; min-height: 46px; }
.inbox-imap { display: none; }
.mail-form:has(input[name="inbox_kind"][value="imap"]:checked) .inbox-imap { display: block; }
.mail-form:has(input[name="inbox_same_credential"]:checked) .inbox-own-credential { display: none; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 30%, var(--border)); }
pre.code-block { background: var(--surface-alt); border-radius: var(--radius-small); padding: 12px 14px; overflow-x: auto; font-family: var(--font-mono); font-size: 13px; line-height: 1.5; white-space: pre; margin: 10px 0; }
