/* MyMeister design system — mobile-first, single theme, no build step. */
:root {
  /* Neutral scale */
  --n-0: #ffffff;
  --n-25: #f8fafc;
  --n-50: #f1f5f9;
  --n-100: #e8edf3;
  --n-200: #dbe3ec;
  --n-300: #c3cfdd;
  --n-400: #93a3b8;
  --n-500: #64748b;
  --n-600: #475467;
  --n-700: #334155;
  --n-800: #1e293b;
  --n-900: #0f1b2d;

  /* Brand */
  --brand: #14375e;
  --brand-2: #1c4c7d;
  --brand-3: #2f6aa8;
  --brand-ink: #0d2743;
  --accent: #1c4c7d;
  --accent-hover: #14375e;
  --accent-soft: #e8f0fb;

  /* Semantic */
  --ok: #157347;
  --ok-bg: #e6f5ec;
  --ok-line: #b9e2c8;
  --warn: #a5670a;
  --warn-bg: #fdf3e2;
  --warn-line: #f2ddb2;
  --err: #b42318;
  --err-bg: #fdecec;
  --err-line: #f4c7c3;
  --info: #1d5fb5;
  --info-bg: #e8f0fb;
  --info-line: #c3d9f5;

  /* Roles */
  --bg: var(--n-50);
  --bg-elev: var(--n-0);
  --ink: var(--n-900);
  --muted: var(--n-500);
  --line: var(--n-200);
  --focus: #2b6cb0;

  /* Type scale */
  --fs-xs: 0.75rem;
  --fs-sm: 0.85rem;
  --fs-md: 0.95rem;
  --fs-lg: 1.1rem;
  --fs-xl: 1.35rem;
  --fs-2xl: 1.7rem;
  --fs-3xl: 2.1rem;

  /* Spacing */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;

  /* Radius & elevation */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;
  --shadow-xs: 0 1px 2px rgba(15, 27, 45, 0.06);
  --shadow-sm: 0 2px 6px rgba(15, 27, 45, 0.06);
  --shadow: 0 8px 24px rgba(15, 27, 45, 0.08);
  --shadow-lg: 0 18px 48px rgba(15, 27, 45, 0.14);

  --touch: 44px;
  --header-h: 60px;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; height: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

img, svg, canvas { max-width: 100%; }
svg { display: inline-block; vertical-align: middle; }
a { color: var(--brand-3); text-decoration: none; }
a:hover { text-decoration: underline; }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--s-5) 0; }

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 var(--s-3); font-weight: 700; color: var(--ink); }
h1 { font-size: var(--fs-2xl); letter-spacing: -0.01em; }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
p { margin: 0 0 var(--s-3); }
small { font-size: var(--fs-sm); }
.muted { color: var(--muted); }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.strong { font-weight: 700; }
.mono { font-family: ui-monospace, "SFMono-Regular", "Cascadia Code", Consolas, monospace; }

/* ---------- Icons ---------- */
.icon { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 24px; height: 24px; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-3);
  padding: 0 var(--s-4);
  min-height: var(--header-h);
  background: linear-gradient(180deg, var(--brand-2), var(--brand));
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: var(--shadow-sm);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.01em;
  text-decoration: none;
  white-space: nowrap;
}
.brand:hover { color: #fff; text-decoration: none; }
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-weight: 800;
  font-size: 0.95rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
  object-fit: contain;
  padding: 0;
}
img.brand-mark,
.brand-mark-img {
  background: #fff;
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, 0.35);
}
.brand-sub { font-size: var(--fs-xs); font-weight: 600; opacity: 0.75; text-transform: uppercase; letter-spacing: 0.08em; }
.topbar-actions { display: flex; gap: var(--s-2); align-items: center; }
.topbar select, .locale-form select {
  width: auto;
  min-width: 92px;
  min-height: 38px;
  height: 38px;
  padding: 4px 30px 4px 10px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background-color: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-radius: var(--radius-sm);
}
.topbar select option { color: var(--ink); }
.locale-form { margin: 0; }
.topbar .btn-ghost {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.28);
  background: transparent;
  min-height: 38px;
  padding: 6px 12px;
}
.topbar .btn-ghost:hover { background: rgba(255, 255, 255, 0.12); }
.user-chip { display: flex; align-items: center; gap: var(--s-2); color: #fff; }
.user-chip .avatar { border: 1px solid rgba(255, 255, 255, 0.35); }
.user-chip-name { display: none; font-weight: 600; font-size: var(--fs-sm); }

/* ---------- Guest shell ---------- */
.shell {
  width: min(1120px, calc(100% - 24px));
  margin: 0 auto;
  padding: var(--s-6) 0 var(--s-10);
}

/* ---------- App layout ---------- */
.layout { display: block; }
.sidenav { display: none; }
.content { padding: var(--s-4) var(--s-4) 88px; max-width: 1180px; margin: 0 auto; width: 100%; }

.nav-group { margin-top: var(--s-4); }
.nav-group:first-child { margin-top: 0; }
.nav-group-title {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--n-400);
  padding: 0 12px var(--s-1);
  font-weight: 700;
}
.sidenav a, .bottomnav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  min-height: var(--touch);
  text-decoration: none;
  color: var(--n-700);
  border-radius: 10px;
  font-weight: 600;
  font-size: var(--fs-md);
}
.sidenav a .icon { color: var(--n-400); }
.sidenav a:hover { background: var(--n-50); text-decoration: none; }
.sidenav a.active { background: var(--brand); color: #fff; }
.sidenav a.active .icon { color: #fff; }

.bottomnav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  z-index: 30;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav a {
  flex-direction: column;
  gap: 3px;
  font-size: 10.5px;
  text-align: center;
  line-height: 1.15;
  padding: 8px 4px;
  min-height: 58px;
  color: var(--muted);
  font-weight: 600;
  border-radius: 0;
}
.bottomnav a .icon { width: 22px; height: 22px; }
.bottomnav a.active { color: var(--brand); background: none; }

/* ---------- Page header ---------- */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-5);
}
.page-header h1 { margin: 0; }
.page-header .subtitle { color: var(--muted); margin: 4px 0 0; }
.page-header-actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.breadcrumb { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: var(--fs-sm); color: var(--muted); margin-bottom: 6px; }
.breadcrumb a { color: var(--muted); }
.breadcrumb .sep { color: var(--n-300); }

/* ---------- Cards ---------- */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--s-5);
  margin: 0 0 var(--s-4);
  box-shadow: var(--shadow-xs);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  margin: calc(var(--s-5) * -1) calc(var(--s-5) * -1) var(--s-4);
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--line);
}
.card-head h2, .card-head h3 { margin: 0; font-size: var(--fs-lg); }
.card-link { display: block; color: inherit; text-decoration: none; transition: border-color .15s, box-shadow .15s, transform .15s; }
.card-link:hover { border-color: var(--brand-3); box-shadow: var(--shadow-sm); text-decoration: none; transform: translateY(-1px); }
.cards, .grid-2, .grid-3 { display: grid; gap: var(--s-4); margin-bottom: var(--s-4); }

/* ---------- Stat / KPI ---------- */
.stats { display: grid; gap: var(--s-3); grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: var(--s-5); }
.stat {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--s-4);
  box-shadow: var(--shadow-xs);
  display: flex;
  gap: var(--s-3);
  align-items: center;
}
.stat-icon {
  width: 42px; height: 42px;
  border-radius: 11px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--info-bg); color: var(--brand-3);
  flex-shrink: 0;
}
.stat-body { min-width: 0; }
.stat-value { display: block; font-size: var(--fs-2xl); font-weight: 800; color: var(--brand); line-height: 1.1; }
.stat-label { display: block; font-size: var(--fs-sm); color: var(--muted); }
.stat.tone-ok .stat-icon { background: var(--ok-bg); color: var(--ok); }
.stat.tone-warn .stat-icon { background: var(--warn-bg); color: var(--warn); }
.stat.tone-accent .stat-icon { background: var(--accent-soft); color: var(--accent); }

/* legacy .stats .card compatibility */
.stats .card { margin: 0; }
.stats strong { display: block; font-size: var(--fs-2xl); color: var(--brand); }

/* ---------- Definition list ---------- */
.data-list { display: grid; gap: var(--s-3); grid-template-columns: 1fr; }
.data-list .row { display: grid; gap: 2px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.data-list .row:last-child { border-bottom: 0; }
.data-list dt { font-size: var(--fs-sm); color: var(--muted); font-weight: 600; margin: 0; }
.data-list dd { margin: 0; font-weight: 600; word-break: break-word; }

/* ---------- Forms ---------- */
.stack { display: grid; gap: var(--s-4); }
.stack > label, .field {
  display: grid;
  gap: 6px;
  font-weight: 600;
  color: var(--ink);
  font-size: var(--fs-sm);
}
.field .help { font-weight: 500; color: var(--muted); font-size: var(--fs-xs); }
.field .error { font-weight: 600; color: var(--err); font-size: var(--fs-xs); }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--err); }
.req { color: var(--err); margin-left: 2px; }
.form-grid { display: grid; gap: var(--s-4); }
.form-grid .full, .stack > fieldset, .stack > button, .stack > .actions { grid-column: 1 / -1; }

fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--s-4);
  margin: 0;
  background: var(--n-25);
  display: grid;
  gap: var(--s-3);
}
legend { font-weight: 700; padding: 0 6px; color: var(--brand); font-size: var(--fs-md); }

input, select, textarea, button { font: inherit; color: var(--ink); }
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]),
select, textarea {
  width: 100%;
  max-width: 100%;
  min-height: var(--touch);
  padding: 10px 12px;
  border: 1px solid var(--n-300);
  border-radius: var(--radius-sm);
  background: #fff;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--n-400); }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2364748b' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
select[multiple] { min-height: 148px; background-image: none; padding-right: 12px; appearance: auto; }
textarea { min-height: 110px; resize: vertical; }
input[type="file"] {
  width: 100%;
  padding: 10px;
  border: 1px dashed var(--n-300);
  border-radius: var(--radius-sm);
  background: var(--n-25);
  min-height: var(--touch);
}
input[type="checkbox"], input[type="radio"] {
  width: 18px; height: 18px; min-width: 18px; min-height: 18px;
  margin: 0; padding: 0; flex-shrink: 0;
  accent-color: var(--brand);
  appearance: auto; -webkit-appearance: auto;
}
.inline {
  display: flex !important;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  font-weight: 500;
  width: auto;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-3);
  box-shadow: 0 0 0 3px rgba(43, 108, 176, 0.18);
}
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.input-affix { position: relative; display: flex; align-items: center; }
.input-affix .suffix { position: absolute; right: 12px; color: var(--muted); font-weight: 600; pointer-events: none; }
.input-affix input { padding-right: 40px; }

/* Choice grid (checkbox/radio pills) */
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.choice {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--n-300);
  border-radius: var(--radius-sm);
  background: #fff;
  font-weight: 500;
  cursor: pointer;
  font-size: var(--fs-sm);
}
.choice:hover { border-color: var(--brand-3); }
.choice:has(input:checked) { border-color: var(--brand); background: var(--info-bg); }
.choice-inline {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px; min-height: var(--touch);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg-elev); cursor: pointer; font-weight: 600; font-size: var(--fs-sm);
  white-space: nowrap;
}
.choice-inline:has(input:checked) { border-color: var(--brand); background: var(--info-bg); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--touch);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--n-300);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
  width: auto;
  max-width: 100%;
  transition: background .15s, border-color .15s, filter .15s, box-shadow .15s;
}
.btn:hover { background: var(--n-25); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: var(--shadow-xs); }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-secondary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-secondary:hover { background: var(--brand-2); color: #fff; }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--n-50); }
.btn-danger { background: var(--err); color: #fff; border-color: var(--err); }
.btn-danger:hover { filter: brightness(0.94); color: #fff; }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: var(--fs-sm); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
a.btn { color: inherit; }
a.btn:hover { text-decoration: none; }
a.btn-primary,
a.btn-secondary,
a.btn-danger,
.btn-primary,
.btn-secondary,
.btn-danger { color: #fff; }
a.btn-primary:hover,
a.btn-secondary:hover,
a.btn-danger:hover { color: #fff; }
.btn-primary .icon,
.btn-secondary .icon,
.btn-danger .icon,
a.btn-primary .icon,
a.btn-secondary .icon,
a.btn-danger .icon { stroke: currentColor; color: #fff; }

.actions, .inline-form { display: flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; }
.inline-form { margin-bottom: var(--s-4); }
.inline-form input, .inline-form select { width: auto; min-width: 160px; }
.toolbar { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; justify-content: space-between; margin-bottom: var(--s-4); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: var(--s-5); overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tabs button, .tabs a {
  appearance: none;
  border: 0;
  background: none;
  padding: 10px 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  font-size: var(--fs-md);
}
.tabs button:hover, .tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs button.active, .tabs a.active { color: var(--brand); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Tables ---------- */
.table-wrap {
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: var(--s-4);
  box-shadow: var(--shadow-xs);
}
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
thead th {
  position: sticky; top: 0;
  background: var(--n-25);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  z-index: 1;
}
tbody tr:nth-child(even) { background: var(--n-25); }
tbody tr:hover { background: var(--info-bg); }
tbody tr:last-child td { border-bottom: 0; }
.table-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: var(--n-100);
  color: var(--n-700);
  font-size: var(--fs-xs);
  font-weight: 700;
  line-height: 1.5;
  border: 1px solid transparent;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-ok, .badge-approved, .badge-abschluss_erfolgt, .badge-provision_faellig, .badge-paid { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.badge-warn, .badge-pending, .badge-neu, .badge-in_pruefung, .badge-offen { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.badge-err, .badge-rejected, .badge-abgelehnt, .badge-storniert { background: var(--err-bg); color: var(--err); border-color: var(--err-line); }
.badge-info, .badge-kontaktiert, .badge-angebot, .badge-termin { background: var(--info-bg); color: var(--info); border-color: var(--info-line); }

/* ---------- Avatar ---------- */
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand-2);
  color: #fff;
  font-weight: 700;
  font-size: var(--fs-sm);
  flex-shrink: 0;
  overflow: hidden;
  background-size: cover;
  background-position: center;
}
.avatar-lg { width: 56px; height: 56px; font-size: var(--fs-lg); }
.avatar-xl { width: 76px; height: 76px; font-size: var(--fs-xl); border-radius: var(--radius); }

/* ---------- Flash / toast ---------- */
.flash {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: var(--s-4);
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow-xs);
  font-weight: 500;
}
.flash ul { margin: 0; padding-left: 18px; }
.flash-ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.flash-err { background: var(--err-bg); color: var(--err); border-color: var(--err-line); }
.flash-warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.flash-info { background: var(--info-bg); color: var(--info); border-color: var(--info-line); }
.flash .mono { word-break: break-all; margin: 0 0 4px; }

/* ---------- Chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--n-100);
  color: var(--n-700);
  font-size: var(--fs-sm);
  font-weight: 600;
}
.chip .icon { width: 14px; height: 14px; }
.chip-muted { background: transparent; color: var(--n-400); border: 1px dashed var(--n-300); }
.chip-warn { background: var(--warn-bg); color: var(--warn); }

/* ---------- Filter bar ---------- */
.filter-bar { display: flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; margin-bottom: var(--s-4); }
.filter-bar input[type="search"] { flex: 1 1 220px; min-width: 0; }
.filter-bar select { flex: 0 1 auto; min-width: 140px; width: auto; }

/* ---------- Template grid ---------- */
.tpl-grid { display: grid; grid-template-columns: 1fr; gap: var(--s-3); }
@media (min-width: 640px) { .tpl-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1080px) { .tpl-grid { grid-template-columns: repeat(3, 1fr); } }
.tpl-card {
  display: flex; flex-direction: column; gap: 10px;
  padding: var(--s-4);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  text-decoration: none; color: inherit;
  transition: border-color .15s, box-shadow .15s, transform .05s;
}
.tpl-card:hover { border-color: var(--brand-3); box-shadow: var(--shadow-sm); }
.tpl-card:active { transform: translateY(1px); }
.tpl-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tpl-card-key { display: flex; align-items: center; gap: 8px; font-weight: 700; word-break: break-word; }
.tpl-card-key .icon { color: var(--muted); }
.tpl-card-foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: var(--fs-sm); }
.tpl-card-edit { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; color: var(--brand-3); font-weight: 700; }

.nowrap { white-space: nowrap; }
.mt-2 { margin-top: var(--s-2); }
.mt-6 { margin-top: var(--s-6); }
.stack-sm { display: grid; gap: var(--s-1); margin: 0; padding-left: var(--s-4); }

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: var(--s-8) var(--s-4);
  color: var(--muted);
  background: var(--bg-elev);
  border: 1px dashed var(--n-300);
  border-radius: var(--radius);
}
.empty-state .icon { width: 40px; height: 40px; color: var(--n-300); margin-bottom: var(--s-2); }
.empty-state h3 { color: var(--ink); }

/* ---------- Hero (guest) ---------- */
.hero {
  padding: var(--s-8) 0 var(--s-4);
}
.hero h1 { font-size: var(--fs-3xl); max-width: 22ch; }
.hero p { font-size: var(--fs-lg); max-width: 46ch; color: var(--muted); }

/* ---------- Misc ---------- */
.sig {
  width: 100%; max-width: 420px; height: 140px;
  border: 1px dashed var(--n-300);
  background: #fff; touch-action: none;
  border-radius: var(--radius-sm);
}
.preview-frame { width: 100%; min-height: 360px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.picked { outline: 2px solid var(--accent); }
.auth-card { max-width: 440px; margin: var(--s-8) auto; }
.auth-logo { text-align: center; margin-bottom: var(--s-5); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 var(--s-4) var(--s-5); border-left: 2px solid var(--line); }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 3px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand-3); border: 2px solid #fff; }
.timeline .t-time { font-size: var(--fs-xs); color: var(--muted); }
.divider-label { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: var(--fs-sm); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; margin: var(--s-4) 0; }
.divider-label::before, .divider-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.split { display: grid; gap: var(--s-4); }

/* ---------- Disclosure ---------- */
details.disclosure { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-xs); margin-bottom: var(--s-4); }
details.disclosure > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: var(--s-4) var(--s-5);
  font-weight: 700;
  color: var(--brand);
}
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary .chev { margin-left: auto; transition: transform .15s; }
details.disclosure[open] > summary .chev { transform: rotate(90deg); }
details.disclosure > .disclosure-body { padding: 0 var(--s-5) var(--s-5); border-top: 1px solid var(--line); }
details.disclosure > .disclosure-body { padding-top: var(--s-4); }

/* ---------- Rich text editor ---------- */
.rte { border: 1px solid var(--n-300); border-radius: var(--radius-sm); overflow: hidden; background: #fff; }
.rte-toolbar { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px; background: var(--n-25); border-bottom: 1px solid var(--line); }
.rte-toolbar button {
  min-height: 32px; min-width: 34px;
  padding: 4px 8px; border: 1px solid transparent; border-radius: 6px;
  background: transparent; cursor: pointer; font-weight: 700; color: var(--n-700);
}
.rte-toolbar button:hover { background: var(--n-100); }
.rte-area { min-height: 200px; padding: 12px 14px; outline: none; font-size: var(--fs-md); }
.rte-area:focus { box-shadow: inset 0 0 0 2px rgba(43,108,176,0.15); }
.rte-area p { color: var(--ink); margin: 0 0 8px; }
.rte-area a { color: var(--brand-3); }

/* ---------- i18n editor ---------- */
.i18n-hint { display: flex; align-items: center; gap: 6px; margin: 0 0 var(--s-3); }
.i18n-list { display: grid; gap: var(--s-3); }
.i18n-row {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--s-3) var(--s-4);
  box-shadow: var(--shadow-xs);
}
.i18n-row.is-missing { border-color: var(--warn-line); }
.i18n-row.is-dirty { border-color: var(--brand-3); }
.i18n-row.is-saved { border-color: var(--ok-line); }
.i18n-row-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: var(--s-3);
}
.i18n-row-meta { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.i18n-key {
  font-size: var(--fs-sm); font-weight: 700; color: var(--brand);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%;
}
.i18n-row-status { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.i18n-save-state { font-size: var(--fs-xs); font-weight: 700; min-height: 1.2em; }
.i18n-save-state.is-saving { color: var(--info); }
.i18n-save-state.is-ok { color: var(--ok); }
.i18n-save-state.is-err { color: var(--err); }
.i18n-langs {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s-3);
}
@media (min-width: 720px) {
  .i18n-langs { grid-template-columns: repeat(var(--i18n-cols, 2), minmax(0, 1fr)); }
}
.i18n-row-actions { display: flex; justify-content: flex-end; margin-top: var(--s-3); }
.i18n-row textarea { min-height: 64px; resize: vertical; }

/* ---------- Responsive ---------- */
@media (min-width: 560px) {
  .user-chip-name { display: inline; }
  .data-list { grid-template-columns: 1fr 1fr; }
}

@media (min-width: 720px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .split { grid-template-columns: 2fr 1fr; align-items: start; }
}

@media (min-width: 900px) {
  .layout {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    min-height: calc(100vh - var(--header-h));
  }
  .sidenav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: #fff;
    border-right: 1px solid var(--line);
    padding: var(--s-5) var(--s-3);
    position: sticky;
    top: var(--header-h);
    height: calc(100vh - var(--header-h));
    overflow-y: auto;
  }
  .content { padding: var(--s-6) var(--s-8) var(--s-10); }
  .bottomnav { display: none; }
  .cards { grid-template-columns: repeat(3, 1fr); }
  body.panel-partner { padding-bottom: 0; }
}

@media (max-width: 899px) {
  body.panel-partner { padding-bottom: 66px; }
  .layout { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- Wizard ---------- */
.wizard { padding: var(--s-5); }
.wizard-steps {
  display: flex; flex-wrap: wrap; gap: 8px;
  list-style: none; margin: 0 0 var(--s-5); padding: 0;
}
.wizard-step {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg-elev);
  font-size: var(--fs-sm); color: var(--muted); font-weight: 600;
}
.wizard-step.is-active { border-color: var(--brand); color: var(--brand); background: var(--info-bg); }
.wizard-step.is-done { border-color: var(--ok-line); color: var(--ok); }
.wizard-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--n-100); font-size: 12px;
}
.wizard-step.is-active .wizard-num { background: var(--brand); color: #fff; }
.wizard-panel { display: none; }
.wizard-panel.is-active { display: block; }
.wizard-panel h2 { margin: 0 0 8px; font-size: 1.15rem; color: var(--brand); }
.wizard-nav { margin-top: var(--s-5); justify-content: space-between; }
.choice-block { align-items: flex-start; min-height: 64px; }
.choice-block.picked, .choice.picked { border-color: var(--brand); background: var(--info-bg); }
.html-toolbar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.html-toolbar .btn { min-height: 32px; padding: 4px 10px; }
textarea.html-input { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 0.92rem; }
.prose { line-height: 1.6; }
.prose p { margin: 0 0 0.75em; }
.prose ul, .prose ol { margin: 0 0 0.75em; padding-left: 1.25em; }
.prose h2, .prose h3, .prose h4 { margin: 1em 0 0.5em; color: var(--brand-ink, var(--brand)); }
.prose a { text-decoration: underline; }
.prose table { width: 100%; border-collapse: collapse; margin: 0 0 0.75em; }
.prose td, .prose th { border: 1px solid var(--line); padding: 6px 8px; text-align: left; }
@media (max-width: 720px) {
  .wizard-label { display: none; }
  .wizard-step.is-active .wizard-label { display: inline; }
}
