/* ==========================================================
   ScoutBase - shared layout primitives
   ==========================================================
   Building blocks used by BOTH the feedback pages and the
   calendar pages: reset, page shell, header/nav, generic
   buttons/forms, the ".panel" card, and the theme toggle
   switch (ported from scout_calendar's app.css .toggle/.switch).
   Feedback-only styling lives in feedback.css; calendar-only
   styling lives in calendar.css.
   ========================================================== */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  color: var(--text);
  background: var(--bg);
}

/* Brand top bar, echoing ppoe.at's maroon strip above the header. */
html {
  border-top: 4px solid var(--accent);
}

body {
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4,
.panel-title,
.title-month {
  font-family: var(--font-heading);
  font-weight: 800;
  letter-spacing: 0.1px;
}

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px 32px;
}

/* Full-width layout toggle (static/js/width.js) - centered (default,
   the 1180px cap above) vs. edge-to-edge on large screens, kept as an
   opt-in per-visitor preference rather than a global change since the
   centered width is still the better default on typical screens. */
:root[data-width="full"] .wrap {
  max-width: none;
}

a {
  color: var(--accent-strong);
  text-decoration: none;
}
a:hover { opacity: .9; }

/* Keyboard focus must stay obvious in both the light and dark token sets.
   Use :focus-visible so pointer interactions retain the calm visual design. */
:focus-visible {
  outline: 3px solid var(--accent-strong);
  outline-offset: 3px;
}

/* The search field intentionally removes its browser outline because its
   enclosing search box supplies the visible boundary. Restore an equally
   strong keyboard affordance on that enclosing control. */
.directory-search:focus-within {
  outline: 3px solid var(--accent-strong);
  outline-offset: 3px;
}

.nowrap { white-space: nowrap; }
.muted { color: var(--muted); }
.error { color: var(--danger-strong); }

/* Gloria Hallelujah, per the brand guide: "Schrift für den Slogan
   und manche Hervorhebungen" - the slogan and occasional
   highlights, not body copy or headings. Use sparingly. */
.font-hand {
  font-family: var(--font-hand);
  font-weight: 400;
}

/* Colored group badge (mirrors the PDF's PWA/Biber/WiWö/GuSp/CaEx/
   RaRo rectangles) - background comes from each group's own
   `color` config, falling back to the brand red. */
.group-badge {
  display: inline-flex;
  align-items: center;
  padding: 14px 18px;
  border-radius: 12px;
  color: #fff;
  font-family: var(--font-heading);
  font-weight: 800;
  text-decoration: none;
  box-shadow: var(--shadow);
}
.group-badge:hover { opacity: .92; }

/* --- Header --- */
.header {
  padding: 12px 0 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.header-context {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 12px;
}

.header-navigation {
  display: flex;
  justify-content: center;
  border-top: 1px solid var(--border);
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.brand-logo {
  height: 56px;
  width: auto;
  display: block;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Tenant context is deliberately separate from primary navigation.
   The chevron belongs to a real <details> switcher, not to a homepage
   link that merely looks like a dropdown. */
.tenant-switcher,
.account-menu {
  position: relative;
}

.tenant-switcher-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 6px;
  border-radius: 10px;
  background: var(--button-bg);
  border: 1px solid var(--button-border);
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  list-style: none;
}
.tenant-switcher-trigger::-webkit-details-marker { display: none; }
.tenant-switcher-trigger:hover,
.tenant-switcher[open] .tenant-switcher-trigger {
  background: var(--button-bg-hover);
}

.tenant-initials {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
}

.tenant-switcher-label {
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tenant-switcher-caret,
.account-menu-caret { font-size: 11px; }

.tenant-switcher-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: min(320px, calc(100vw - 40px));
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  box-shadow: var(--shadow);
  z-index: 30;
}

.tenant-switcher-title {
  margin: 4px 8px 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.tenant-switcher-item,
.tenant-switcher-all {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 8px;
  color: var(--text);
  font-weight: 600;
}

.tenant-switcher-item:hover,
.tenant-switcher-item.is-current { background: var(--button-bg-hover); }
.tenant-check { margin-left: auto; color: var(--accent-strong); }
.tenant-switcher-divider { height: 1px; margin: 8px 0; background: var(--border); }
.tenant-switcher-all { color: var(--accent-strong); }
.tenant-switcher-all span { margin-left: auto; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.header-login, .header-subscribe { font-weight: 600; }
.header-subscribe { color: var(--accent-strong); }

/* --- Navigation --- */
.nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 10px 0;
}

.nav a {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 18px;
  transition: color 0.2s;
}

.nav a:hover { color: var(--accent); }

/* Account menu (Manage/Platform/Logout) - collapsed behind a single
   dropdown instead of three always-visible links, so the nav doesn't
   keep growing every time a new module/action is added. Plain
   <details>/<summary> - no JS needed to open/close, just a little to
   close it on an outside click (static/js/nav.js). */
.account-menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  list-style: none;
  vertical-align: middle;
  transition: color 0.2s;
}

.account-menu-trigger::-webkit-details-marker { display: none; }
.account-menu-trigger:hover { color: var(--accent); }

.account-menu-label {
  display: inline-block;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

.account-menu-caret {
  font-size: 10px;
}

.account-menu-items {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  box-shadow: var(--shadow);
  min-width: 160px;
  z-index: 20;
}

.account-menu-items a {
  padding: 6px 10px;
  border-radius: 8px;
  white-space: nowrap;
}

.account-menu-items a:hover { background: var(--button-bg-hover); }

/* Mobile nav toggle */
.menu-toggle {
  display: none;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

/* --- Content wrapper --- */
.content {
  padding-top: 10px;
}

/* --- Footer --- */
.footer {
  border-top: 1px solid var(--border);
  padding: 16px 0 32px;
  color: var(--muted);
}

.footer-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.footer-preferences {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.footer-preferences-divider {
  width: 1px;
  height: 28px;
  margin: 0 4px;
  background: var(--border);
}

/* --- Generic panel/card --- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.panel-title {
  margin: 0;
}

/* Small neutral tag distinguishing a calendar's public/leader
   collection (Milestone 6+) - shown next to the panel title, its text
   customizable per connection via Integrations (falls back to
   "Public"/"Leader"). Deliberately not accent-colored (that's already
   used for the unit's own brand color on this same heading). */
.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  margin-left: 6px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  vertical-align: middle;
  color: var(--muted);
  background: var(--button-bg);
  border: 1px solid var(--button-border);
}

/* Unit-filter pills on the tenant homepage (spec §63) - plain
   .role-badge links, with the currently-selected one outlined so it's
   distinguishable even when the unit has no brand color of its own. */
.unit-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

.unit-filter .role-badge {
  margin-left: 0;
  text-decoration: none;
}

.role-badge--active {
  box-shadow: 0 0 0 2px var(--accent);
}

.announcement-priority-high {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  margin-left: 6px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  vertical-align: middle;
  color: #fff;
  background: var(--accent);
}

/* Tenant portal overview: a scannable module dashboard rather than a
   vertical stack of unrelated panels. Data remains module/access filtered
   by portal/routers.py. */
.portal-content { padding-top: 18px; }
.portal-hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(180px, .45fr); align-items: stretch; overflow: hidden; margin-bottom: 18px; border: 1px solid var(--border); border-radius: 16px; background: var(--panel); box-shadow: var(--shadow); }
.portal-hero > div:first-child { padding: 24px; }
.portal-kicker { margin: 0 0 4px; color: var(--accent-strong); font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.portal-hero h1 { margin: 0; font-size: clamp(26px, 4vw, 40px); }
.portal-subtitle { margin: 6px 0 14px; color: var(--muted); font-size: 17px; }
.portal-hero .unit-filter { margin-bottom: 0; }
.portal-hero-art { display: flex; align-items: end; justify-content: end; min-height: 180px; padding: 0 12px 0 0; }
.portal-hero-art img { display: block; width: min(100%, 390px); height: auto; max-height: 220px; }
.portal-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.portal-card { min-width: 0; }
.portal-card .panel-head { margin-bottom: 8px; }
.portal-card .panel-head > a { font-size: 14px; font-weight: 700; white-space: nowrap; }
.portal-section-icon { display: inline-grid; place-items: center; width: 32px; height: 32px; margin-right: 8px; border-radius: 50%; background: var(--button-bg); color: var(--accent-strong); font-size: 16px; vertical-align: middle; }
.portal-list { margin: 0; padding: 0; list-style: none; }
.portal-list li { padding: 9px 0; border-top: 1px solid var(--border); line-height: 1.35; }
.portal-list a { font-weight: 700; }
.portal-list small { display: block; margin-top: 3px; color: var(--muted); }
.portal-event-list li { display: flex; align-items: center; gap: 12px; }
.portal-event-list time { display: flex; flex: 0 0 38px; flex-direction: column; align-items: center; color: var(--accent-strong); font-size: 11px; font-weight: 800; line-height: 1.1; text-transform: uppercase; }
.portal-event-list time strong { font-size: 21px; }

/* Public ScoutBase directory: intentionally only the cross-tenant Board
   appears alongside the group chooser. Tenant-specific modules stay on
   the group portal where their scope is clear. */
.tenant-directory-content { padding-top: 18px; }
.directory-hero { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, .52fr); align-items: stretch; margin-bottom: 18px; border: 1px solid var(--border); border-radius: 16px; background: var(--panel); box-shadow: var(--shadow); }
.directory-hero > div:first-child { position: relative; z-index: 1; padding: 28px; }
.directory-kicker { margin: 0 0 4px; color: var(--accent-strong); font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.directory-hero h1 { margin: 0; font-size: clamp(28px, 4vw, 42px); }
.directory-hero p:not(.directory-kicker) { max-width: 560px; margin: 7px 0 18px; color: var(--muted); font-size: 17px; }
.directory-hero-art { display: flex; align-items: end; justify-content: end; min-height: 190px; padding: 0 14px 0 0; }
.directory-hero-art img { display: block; width: min(100%, 430px); height: auto; max-height: 238px; }
.directory-search { position: relative; display: flex; align-items: center; width: min(100%, 380px); height: 50px; gap: 9px; padding: 0 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--muted); }
.directory-search input { display: block; flex: 1 1 0; width: 0; min-width: 0; height: 48px; padding: 0; border: 0; outline: 0; color: var(--text); background: transparent; font-size: 16px; line-height: 24px; white-space: nowrap; }

/* Keep form labels available to assistive technology without rendering a
   second copy beside a field whose placeholder already conveys the prompt. */
.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;
}
.tenant-search-results { position: absolute; z-index: 5; top: calc(100% + 6px); left: 0; width: 100%; overflow: hidden; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); box-shadow: var(--shadow); }
.tenant-search-results a { display: block; padding: 10px 12px; color: var(--text); font-weight: 700; text-decoration: none; }
.tenant-search-results a + a { border-top: 1px solid var(--border); }
.tenant-search-results a:hover, .tenant-search-results a.is-active { background: var(--button-bg); color: var(--accent-strong); opacity: 1; }
.search-form > div { display: flex; max-width: 620px; gap: 8px; margin-top: 6px; }
.search-form input { flex: 1; min-width: 0; }
.search-results { margin: 12px 0 0; padding: 0; list-style: none; }
.search-results li { padding: 11px 0; border-top: 1px solid var(--border); }
.search-results .role-badge { margin-right: 8px; font-size: 11px; }
.search-results small { display: block; margin: 3px 0 0 0; color: var(--muted); }
.email-health { font-weight: 700; }
.email-health--green { color: var(--success-strong); }
.email-health--amber { color: #9a6800; }
.email-health--red { color: var(--danger-strong); }
.shared-overview { margin-bottom: 26px; }
.shared-board-heading { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.shared-board-icon { display: grid; flex: 0 0 auto; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: var(--button-bg); color: var(--accent-strong); font-size: 25px; font-weight: 800; }
.shared-board-heading > div { min-width: 0; }
.shared-board-heading .panel-title { margin: 0; }
.shared-board-heading .muted { margin: 1px 0 0; }
.shared-board-heading > a { margin-left: auto; font-weight: 700; white-space: nowrap; }
.shared-board-list { margin: 0; padding: 0; list-style: none; }
.shared-board-list li { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 10px 0; border-top: 1px solid var(--border); }
.shared-board-list li > div { min-width: 0; }
.shared-board-list a { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shared-board-description { display: block; margin-top: 2px; overflow: hidden; color: var(--muted); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.shared-board-meta { flex: 0 0 auto; color: var(--muted); font-size: 13px; text-align: right; }
.shared-empty { margin: 0; color: var(--muted); }
.tenant-directory { padding-bottom: 8px; }
.directory-section-head { display: flex; justify-content: space-between; align-items: end; margin-bottom: 10px; }
.directory-section-head h2 { margin: 0; font-size: 24px; }
.directory-section-head p { margin: 2px 0 0; }
.tenant-directory-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.tenant-directory-card { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 12px; min-width: 0; padding: 18px; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); box-shadow: var(--shadow); color: var(--text); text-decoration: none; }
.tenant-directory-card:hover { border-color: var(--accent); opacity: 1; transform: translateY(-1px); }
.tenant-directory-card[hidden] { display: none; }
.tenant-directory-initials { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 50%; color: var(--accent-strong); background: var(--button-bg); font-size: 16px; font-weight: 800; }
.tenant-directory-details { min-width: 0; }
.tenant-directory-name { overflow: hidden; font-family: var(--font-heading); font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.tenant-directory-description { display: block; overflow: hidden; margin-top: 2px; color: var(--muted); font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.tenant-directory-action { grid-column: 1 / -1; padding: 10px 14px; border-radius: 9px; background: var(--accent); color: #fff; font-weight: 800; text-align: center; }
.tenant-search-empty { margin: 14px 0 0; color: var(--muted); }

@media (max-width: 720px) {
  .portal-hero { grid-template-columns: 1fr; }
  .portal-hero-art { display: none; }
  .portal-hero > div:first-child { padding: 18px; }
  .portal-grid { grid-template-columns: 1fr; gap: 12px; }
  .directory-hero { display: block; min-height: 220px; }
  .directory-hero-art { position: absolute; right: 0; bottom: 0; display: flex; width: 54%; min-height: 0; padding: 0; opacity: .42; pointer-events: none; }
  .directory-hero-art img { width: 100%; max-height: none; }
  .directory-hero > div:first-child { padding: 20px; }
  .directory-search { max-width: 340px; }
  .tenant-directory-grid { grid-template-columns: 1fr; }
  /* Keep the shared-board title, explanatory copy, and action in separate
     rows.  The earlier inline action competed with the title at phone widths. */
  .shared-board-heading { align-items: start; flex-wrap: wrap; }
  .shared-board-heading > div { flex: 1 1 180px; }
  .shared-board-heading > a { flex: 0 0 calc(100% - 54px); margin: 0 0 0 54px; white-space: normal; }
  .shared-board-list li { align-items: start; flex-direction: column; gap: 2px; }
  .shared-board-meta { text-align: left; }
}

.actions {
  margin-left: auto;
}

/* ==========================================================
   Forms & Inputs (generic)
   ========================================================== */
input,
select,
textarea,
button {
  font-family: inherit;
  font-size: 15px;
}

input,
select,
textarea {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
}

textarea {
  resize: vertical;
}

label {
  color: var(--text);
}

button,
.btn {
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

button:hover,
.btn:hover {
  background: var(--accent-strong);
}

.btn-danger { background: var(--danger); }
.btn-danger:hover { background: var(--danger-strong); }

.btn-success { background: var(--success); }
.btn-success:hover { background: var(--success-strong); }

.btn-small {
  padding: 6px 12px;
  font-size: 14px;
  border-radius: 999px;
}

/* Rich text toolbar (Announcement body, Poll description - see
   static/js/richtext.js) - the toolbar row above the contenteditable
   editor box that replaces a plain textarea. */
.richtext-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.richtext-editor {
  min-height: 120px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  overflow-y: auto;
}

.richtext-editor:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

/* Read-only rendering of sanitized rich text (see app/core/richtext.py) -
   resets default browser margins on the first/last block child so it
   sits flush inside a .panel like plain text used to. */
.rich-text > :first-child { margin-top: 0; }
.rich-text > :last-child { margin-bottom: 0; }
.rich-text ul { padding-left: 1.4em; }

.btn-add {
  background: var(--accent);
  color: white;
  padding: 10px 18px;
  border-radius: 12px;
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow);
}
.btn-add:hover {
  background: var(--accent-strong);
}

.form-spaced > * {
  margin-bottom: 18px;
}
.form-spaced > *:last-child {
  margin-bottom: 0;
}

.account-request-panel { max-width: 680px; }
.account-request-form { max-width: 460px; }
.account-request-form .form-field { display: grid; gap: 6px; }
.account-request-form input,
.account-request-form select { width: 100%; }
.subscription-panel { max-width: 720px; }
.subscription-form { max-width: 560px; }
.subscription-form .form-field { display: grid; gap: 6px; }
.subscription-form input[type="email"],
.subscription-form select { width: 100%; }
.subscription-units { border: 0; padding: 0; margin: 0; min-width: 0; }
.subscription-units legend { padding: 0; color: var(--text); }
#subscriptionUnitOptions { display: grid; gap: 6px; margin-top: 4px; }

/* --- Rounded icon button (if used anywhere) --- */
.iconbtn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: background 0.2s, transform 0.1s;
}
.iconbtn:hover { background: var(--accent-strong); }
.iconbtn:active { transform: scale(0.96); }

/* ==========================================================
   Theme toggle switch (ported from scout_calendar's app.css)
   ========================================================== */
.btn--sm { padding: 6px 10px; border-radius: 10px; font-size: 12px; }

.theme-toggle {
  background: var(--button-bg);
  color: var(--button-fg);
  border: 1px solid var(--button-border);
}
.theme-toggle:hover { background: var(--button-bg-hover); }

.toggle { display: inline-flex; align-items: center; gap: 8px; user-select: none; }
.switch {
  width: 54px; height: 22px; border-radius: 999px; position: relative;
  background: var(--panel); border: 1px solid var(--button-border);
}
#widthBtn .switch { width: 40px; }
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 999px;
  background: var(--accent); transition: transform .2s ease;
}
/* Theme has three visible positions: light (left), automatic (centre), and
   dark (right). The width control retains its original binary movement. */
:root[data-theme-preference="auto"] #themeBtn .switch::after { transform: translateX(17px); }
:root[data-theme-preference="dark"] #themeBtn .switch::after { transform: translateX(34px); }
:root[data-width="full"] #widthBtn .switch::after { transform: translateX(18px); }

/* ==========================================================
   Responsive tweaks (shared)
   ========================================================== */
@media (max-width: 900px) {
  .header {
    padding-top: 10px;
  }

  .header-context {
    padding-bottom: 10px;
  }

  .menu-toggle {
    display: inline-block;
  }

  .nav[data-collapsible] {
    display: none;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    padding: 12px 0;
  }

  .nav[data-collapsible].is-open {
    display: flex;
  }

  .nav a {
    font-size: 16px;
    padding: 4px 0;
  }

  .footer-content {
    align-items: flex-start;
    flex-direction: column;
  }

  .footer-preferences { justify-content: flex-start; }

  /* Platform health/audit and management listings are legitimately wider than
     a tablet once they contain several operational columns. Keep the document
     itself within the viewport; the table remains reachable by horizontal
     touch/trackpad scrolling. */
  table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 720px) {
  .panel {
    padding: 12px;
    border-radius: 12px;
  }

  .panel-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .panel-head .actions {
    width: 100%;
  }
}

/* ==========================================================
   Management shell (Milestone 4 - templates/manage/base.html)
   ========================================================== */
.manage-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}
.manage-nav {
  flex: 0 0 200px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.manage-nav .manage-nav-group {
  margin: 14px 0 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
.manage-nav .manage-nav-group:first-child {
  margin-top: 0;
}
.manage-nav a {
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
}
.manage-nav a:hover {
  background: var(--card);
}
.manage-nav a.active {
  background: var(--accent);
  color: #fff;
}
.manage-content {
  flex: 1;
  min-width: 0;
}
.stat-tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 12px 0 20px;
}
.stat-tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 18px;
  min-width: 120px;
}
.stat-tile .stat-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}
.stat-tile .stat-label {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

/* Tenant management dashboard: an operational overview rather than a
   growing pile of equally weighted cards. */
.tenant-dashboard { display: grid; gap: 20px; }
.tenant-dashboard__header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 4px 2px 0; }
.tenant-dashboard__header h2, .dashboard-card h3 { margin: 0; }
.tenant-dashboard__header .muted { margin: 5px 0 0; }
.tenant-dashboard__eyebrow { margin: 0 0 4px; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.tenant-dashboard__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.btn--secondary { background: var(--card); color: var(--accent); border: 1px solid var(--accent); }
.btn--secondary:hover { background: var(--button-bg-hover); }
.dashboard-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; background: var(--panel); }
.dashboard-summary__item { display: grid; gap: 3px; min-height: 92px; align-content: center; padding: 14px 18px; color: var(--text); text-decoration: none; border-right: 1px solid var(--border); }
.dashboard-summary__item:last-child { border-right: 0; }
.dashboard-summary__item:hover { background: var(--card); }
.dashboard-summary__item strong { font-size: 28px; line-height: 1; }
.dashboard-summary__item span { color: var(--muted); font-size: 13px; }
.dashboard-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.dashboard-card { padding: 20px; border: 1px solid var(--border); border-radius: 14px; background: var(--panel); }
.dashboard-card__heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.dashboard-card__heading > a { font-size: 14px; font-weight: 600; }
.dashboard-badge { display: inline-grid; place-items: center; min-width: 25px; height: 25px; padding: 0 7px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 13px; font-weight: 700; }
.dashboard-attention__items { display: grid; gap: 8px; }
.dashboard-attention__items a { display: flex; justify-content: space-between; padding: 12px 14px; border-radius: 9px; background: var(--card); color: var(--text); font-weight: 600; text-decoration: none; }
.dashboard-attention__items a:hover { color: var(--accent); }
.dashboard-empty { margin: 0; color: var(--muted); }
.dashboard-empty > span { color: #278554; font-weight: 700; }
.dashboard-calendar-list { list-style: none; margin: 0; padding: 0; }
.dashboard-calendar-list li { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--border); }
.dashboard-calendar-list li:first-child { padding-top: 0; border-top: 0; }
.dashboard-calendar-list a { font-size: 14px; font-weight: 600; white-space: nowrap; }
.dashboard-tools { padding-bottom: 16px; }
.dashboard-tool-links { display: flex; flex-wrap: wrap; gap: 8px; }
.dashboard-tool-links a { padding: 8px 11px; border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 14px; font-weight: 600; text-decoration: none; }
.dashboard-tool-links a:hover { border-color: var(--accent); color: var(--accent); }

.footer-language { color: var(--text); font-size: 14px; font-weight: 600; text-decoration: none; }
.footer-language:hover { color: var(--accent); }

@media (max-width: 720px) {
  .manage-layout {
    flex-direction: column;
  }
  /* A column flex container with align-items:flex-start otherwise lets the
     management content grow to its widest table on a phone. Keep that width
     in the table's local scroller instead of widening the whole document. */
  .manage-content {
    width: 100%;
  }
  .manage-nav {
    flex: none;
    flex-direction: row;
    flex-wrap: wrap;
    width: 100%;
  }
  .manage-nav .manage-nav-group {
    display: none;
  }
  .tenant-dashboard__header { flex-direction: column; }
  .dashboard-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-summary__item:nth-child(2) { border-right: 0; }
  .dashboard-summary__item:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .header-context { align-items: flex-start; flex-wrap: wrap; gap: 8px; }
  /* The logo and current-group selector are one visual unit.  Do not give
     this inner row a forced full basis: that made the selector wrap beneath
     the logo on the root page while it happened to fit on tenant pages. */
  .header-left { flex: 1 1 auto; flex-wrap: nowrap; gap: 8px; min-width: 0; }
  .brand-logo { height: 48px; }
  .tenant-switcher-label { max-width: 100px; }
  /* Keep the menu control on the left, but keep the account links together
     on the right instead of stretching them across the full header row. */
  .header-actions { width: 100%; gap: 8px; }
  /* Logged-in account controls share the row with the menu button. Anchor
     the trigger (and its right-positioned popover) to the far edge. */
  .header-actions > .account-menu { margin-left: auto; }
  .header-login, .header-subscribe { font-size: 14px; white-space: nowrap; }
  .header-subscribe { margin-left: auto; }
  .header-login { margin-left: 0; }
  .tenant-switcher-label { max-width: 130px; }
  .nav { justify-content: flex-start; gap: 4px; overflow-x: auto; scrollbar-width: none; }
  .nav a { flex: 0 0 auto; font-size: 16px; padding: 8px 10px; }
  .footer-content, .footer-preferences { align-items: flex-start; flex-direction: column; }
  .footer-preferences-divider { display: none; }
  table { white-space: nowrap; }
  .mobile-table-scroll { position: relative; overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }
  .mobile-table-scroll::after { content: "↔"; position: sticky; right: 8px; float: right; margin-top: -28px; padding: 2px 7px; border-radius: 999px; background: var(--panel); color: var(--muted); pointer-events: none; }
  .mobile-table-scroll table { margin-bottom: 28px; }
  .question-review-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .question-review-actions form { min-width: 0; }
  .question-review-actions button { width: 100%; min-height: 44px; padding: 8px 6px; font-size: 13px; }
  input, select, textarea { max-width: 100%; }

  /* Phone controls need a dependable touch target even where a feature
     template uses a compact link-action or button variant. */
  button,
  .btn,
  .btn-small,
  .btn-add,
  .link-action,
  .manage-nav a {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
  .manage-nav a { padding-block: 8px; }
}

@media (max-width: 480px) {
  /* Review actions carry meaningful, sometimes long labels in German. A
     full-width stack is clearer and easier to activate than three cramped
     columns on a narrow phone. */
  .question-review-actions {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================
   Platform Admin support mode banner (Milestone 5, spec §16)
   ========================================================== */
.support-mode-banner {
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  margin-bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
}
.support-mode-banner a {
  color: #fff;
  text-decoration: underline;
}
