:root {
  --bg: #34383f;
  --panel: #40454e;
  --panel-raised: #4a4f58;
  --input: #3a3f47;
  --border: rgba(255, 255, 255, 0.14);
  --text: #eceef1;
  --muted: rgba(236, 238, 241, 0.68);
  --accent: #c47a3a;
  --accent-hover: #d48c4f;
  --accent-soft: rgba(196, 122, 58, 0.22);
  --accent-text: #f3d5b5;
  --danger: #e07a7a;
  --sidebar: #3c4048;
  --font: "Segoe UI", system-ui, sans-serif;
  --control-width: 92%;
  --content-bg: #d7dce3;
  --content-panel: #e9edf2;
  --content-text: #1c2026;
  --content-muted: #5a6270;
  --content-border: #c2c8d2;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px; /* ~1pt smaller than default 16px */
}

/*
 * Tablet webapp only (~iPad 11" class): +2–3pt.
 * Excludes phones (<768) and large desktop (>1280).
 * Prefer standalone PWA; also applies when body has .is-pwa-tablet.
 */
@media (display-mode: standalone) and (min-width: 768px) and (max-width: 1280px) {
  html {
    font-size: 18px;
  }
}

html.is-pwa-tablet {
  font-size: 18px;
}

/* Sidebar / tab groups: extra bump on tablet PWA */
@media (display-mode: standalone) and (min-width: 768px) and (max-width: 1280px) {
  .dash-sidebar .nav-link {
    font-size: 1.05rem;
    padding: 0.45rem 0.65rem;
  }

  .dash-sidebar .nav-group > summary {
    font-size: 0.98rem;
    padding: 0.4rem 0.35rem;
  }

  .dash-sidebar .nav-group__links .nav-link {
    font-size: 1.02rem;
  }
}

html.is-pwa-tablet .dash-sidebar .nav-link {
  font-size: 1.05rem;
  padding: 0.45rem 0.65rem;
}

html.is-pwa-tablet .dash-sidebar .nav-group > summary {
  font-size: 0.98rem;
  padding: 0.4rem 0.35rem;
}

html.is-pwa-tablet .dash-sidebar .nav-group__links .nav-link {
  font-size: 1.02rem;
}

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

.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 0.85rem; }

/* Auth */
.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(196, 122, 58, 0.18), transparent 60%),
    var(--bg);
  padding: 1.5rem;
  position: relative;
}

.auth-lang {
  position: absolute;
  right: 1rem;
  top: 1rem;
}

.auth-card {
  width: min(100%, 400px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.75rem;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}

.auth-card--wide { width: min(100%, 480px); }

.auth-brand {
  margin: 0 0 0.85rem;
  text-align: center;
}

.celosys-logo-wrap {
  align-items: center;
  display: inline-flex;
  flex-shrink: 0;
  height: 32px;
  min-height: 32px;
  width: 120px;
}

.celosys-logo {
  display: block;
  height: 28px;
  width: 105px;
  object-fit: contain;
  object-position: left center;
}

.dash-brand .celosys-logo-wrap {
  width: 140px;
  height: 40px;
}

.dash-brand .celosys-logo {
  height: 36px;
  width: 130px;
}

.auth-brand .celosys-logo-wrap {
  width: 160px;
  height: 44px;
}

.auth-brand .celosys-logo {
  height: 40px;
  width: 150px;
  margin: 0 auto;
}

.auth-card__title {
  font-size: 1.25rem;
  margin: 0 0 0.25rem;
}

.auth-card__sub {
  color: var(--muted);
  margin: 0 0 0.85rem;
  font-size: 0.9rem;
}

.auth-form {
  display: grid;
  gap: 0.35rem;
}

.auth-form label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.auth-form input {
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.55rem 0.7rem;
  font-size: 0.95rem;
  width: 100%;
  max-width: none;
}

.auth-btn {
  margin-top: 0.45rem;
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  color: #1f1510;
  cursor: pointer;
  font-weight: 650;
  padding: 0.65rem 0.9rem;
  font-size: 0.95rem;
}

.auth-btn:hover { background: var(--accent-hover); }

.auth-alert {
  background: rgba(224, 122, 122, 0.14);
  border: 1px solid rgba(224, 122, 122, 0.4);
  border-radius: 8px;
  color: #f0b4b4;
  margin-bottom: 0.75rem;
  padding: 0.55rem 0.75rem;
  font-size: 0.9rem;
}

.auth-error { color: var(--danger); font-size: 0.8rem; margin: 0; }

.auth-steps {
  color: var(--muted);
  margin: 0 0 1rem;
  padding-left: 1.2rem;
  font-size: 0.9rem;
}

.auth-qr {
  text-align: center;
  margin-bottom: 1rem;
}

.auth-qr img {
  background: #f5f5f5;
  border-radius: 8px;
  padding: 0.5rem;
}

.auth-manual {
  color: var(--muted);
  font-size: 0.85rem;
  word-break: break-all;
}

/* Shell */
.dash-body {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
  min-height: 100dvh;
}

.dash-sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  position: sticky;
  top: 0;
  max-height: 100vh;
  max-height: 100dvh;
  z-index: 40;
}

.dash-sidebar__top {
  align-items: center;
  display: flex;
  gap: 0.5rem;
  justify-content: space-between;
  padding-right: 0.5rem;
}

.dash-nav-close,
.dash-nav-toggle {
  display: none;
}

.dash-nav-backdrop {
  display: none;
}

.dash-brand {
  padding: 0.85rem 1rem 0.65rem;
}

.dash-brand img {
  display: block;
  height: 28px;
  width: auto;
  max-width: 100%;
}

.dash-nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  overflow: auto;
  padding: 0 0.65rem 1rem;
  flex: 1;
}

.nav-group {
  margin: 0.35rem 0 0.15rem;
}

.nav-group > summary {
  align-items: center;
  color: var(--text);
  cursor: pointer;
  display: flex;
  font-size: 0.84rem;
  font-weight: 700;
  gap: 0.4rem;
  letter-spacing: 0.04em;
  list-style: none;
  margin: 0.4rem 0 0.25rem 0;
  padding: 0.3rem 0.35rem;
  text-transform: uppercase;
  user-select: none;
}

.nav-group > summary::-webkit-details-marker { display: none; }

.nav-group > summary::before {
  color: var(--accent);
  content: "▸";
  flex: 0 0 auto;
  font-size: 0.7rem;
  width: 0.7rem;
}

.nav-group[open] > summary::before {
  content: "▾";
}

.nav-group__icon {
  align-items: center;
  color: var(--accent-text);
  display: inline-flex;
  flex: 0 0 auto;
  opacity: 0.9;
}

.nav-group__links {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding-left: 1.35rem;
}

.nav-group__links .nav-link {
  font-size: 0.86rem;
  font-weight: 400;
}

.dash-nav__group {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  margin: 0.85rem 0 0.25rem 0.45rem;
  text-transform: uppercase;
}

.nav-link {
  border-radius: 8px;
  color: var(--text);
  padding: 0.4rem 0.6rem;
  text-decoration: none;
  font-size: 0.9rem;
}

.nav-link:hover { background: rgba(255, 255, 255, 0.06); text-decoration: none; }
.nav-link.active {
  background: var(--accent-soft);
  color: var(--accent-text);
}
.nav-link--soon { color: var(--muted); opacity: 0.55; pointer-events: none; }

.dash-sidebar__footer {
  border-top: 1px solid var(--border);
  padding: 0.85rem 1rem 1rem;
}

.dash-user {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.45rem;
}

.dash-logout {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  padding: 0.4rem 0.7rem;
  width: 100%;
}

.dash-logout:hover {
  border-color: var(--accent);
  color: var(--accent-text);
}

.dash-main {
  background: var(--content-bg);
  color: var(--content-text);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.dash-top {
  align-items: center;
  background: #e4e8ee;
  border-bottom: 1px solid var(--content-border);
  color: var(--content-text);
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
  padding: 0.75rem 1.1rem;
  position: sticky;
  top: 0;
  z-index: 20;
}

.dash-top__left {
  align-items: center;
  display: flex;
  gap: 0.65rem;
  min-width: 0;
}

.dash-top__title {
  font-size: 1.1rem;
  margin: 0;
  color: var(--content-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dash-top__meta {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  justify-content: flex-end;
}

.dash-top__user {
  color: var(--content-text);
  font-size: 0.9rem;
  font-weight: 600;
}

.dash-top__role {
  background: var(--accent-soft);
  border-radius: 999px;
  color: #7a4a22;
  font-size: 0.8rem;
  padding: 0.25rem 0.7rem;
}

.dash-top__logout-form { margin: 0; }

.dash-main .dash-logout {
  background: #fff;
  border: 1px solid var(--content-border);
  border-radius: 8px;
  color: var(--content-text);
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
  padding: 0.3rem 0.7rem;
}

.dash-main .dash-logout:hover {
  border-color: var(--accent);
  color: #7a4a22;
}

.dash-content { padding: 1rem 1.15rem 1.75rem; }

.dash-panel {
  background: var(--content-panel);
  border: 1px solid var(--content-border);
  border-radius: 12px;
  color: var(--content-text);
  padding: 1rem 1.1rem;
  position: relative;
}

.dash-main .muted { color: var(--content-muted); }

.dash-form {
  color-scheme: light;
}

.dash-form label {
  align-content: start;
  color: var(--content-muted);
  display: grid;
  font-size: 0.8rem;
  gap: 0.25rem;
}

.dash-form input,
.dash-form textarea,
.dash-form select {
  background: #fff;
  border: 1px solid var(--content-border);
  border-radius: 8px;
  color: var(--content-text);
  font: inherit;
  padding: 0.4rem 0.5rem;
  width: var(--control-width);
  max-width: 18rem;
  min-width: 8rem;
}

.dash-form .form-grid__full input,
.dash-form .form-grid__full textarea,
.dash-form .form-grid__full select {
  width: 100%;
  max-width: 36rem;
}

.form-grid {
  align-items: start;
  display: grid;
  column-gap: 0.4rem;
  row-gap: 0.55rem;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.form-grid.is-hidden,
label.is-hidden,
.is-hidden {
  display: none !important;
}

.form-grid > .form-check--align {
  align-self: end;
  min-height: 2.35rem;
  padding-bottom: 0.2rem;
}

.dash-form textarea.textarea-compact {
  max-width: 22rem;
  min-height: 2.6rem;
}

@media (max-width: 1280px) {
  .form-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
}

.dash-form input[type="date"],
.dash-form input[type="datetime-local"],
.dash-form input.input-datetime {
  color-scheme: light;
  min-height: 2.2rem;
}

.dash-form input[type="date"]::-webkit-calendar-picker-indicator,
.dash-form input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  filter: none;
  opacity: 1;
}

.input-with-btn {
  align-items: center;
  display: flex;
  gap: 0.35rem;
  max-width: 22rem;
}

.input-with-btn input {
  flex: 1;
  max-width: none;
  min-width: 0;
  width: auto;
}

.check-list {
  background: #fff;
  border: 1px solid var(--content-border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 0;
  list-style: none;
  margin: 0;
  max-height: 14rem;
  max-width: 36rem;
  overflow: auto;
  padding: 0.35rem 0.55rem;
  width: 100%;
}

.check-list > li {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
}

.dash-form .check-list label.form-check,
.check-list .form-check {
  align-items: center;
  color: var(--content-text);
  display: flex !important;
  flex-direction: row;
  font-size: 0.85rem;
  gap: 0.55rem;
  grid-template-columns: none !important;
  line-height: 1.3;
  margin: 0;
  padding: 0.35rem 0.15rem;
  width: 100%;
}

.dash-form .check-list .form-check input[type="checkbox"],
.check-list .form-check input[type="checkbox"] {
  flex: 0 0 auto;
  height: 1rem;
  margin: 0;
  max-width: none;
  min-width: 0;
  width: 1rem;
}

.dash-table th,
.dash-table td {
  border-bottom: 1px solid var(--content-border);
  color: var(--content-text);
}

.dash-table th {
  color: var(--content-muted);
}

.dash-main .flash-ok {
  background: rgba(70, 150, 90, 0.12);
  border-color: rgba(70, 150, 90, 0.35);
  color: #1f5c30;
}

.dash-main .auth-alert {
  color: #8a3030;
}

.dash-main code {
  background: rgba(0, 0, 0, 0.06);
  color: #333;
}

.dash-checklist { color: var(--content-muted); line-height: 1.5; }

.dash-toolbar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: flex-start;
  margin-bottom: 1rem;
}

.dash-toolbar > .auth-btn,
.dash-toolbar > .page-help-wrap {
  margin-left: auto;
}

.dash-toolbar > .btn-link + .page-help-wrap {
  margin-left: auto;
}

.dash-toolbar .auth-btn {
  display: inline-block;
  margin-top: 0;
  margin-bottom: 0;
  margin-right: 0;
  padding: 0.55rem 0.9rem;
  text-decoration: none;
  width: auto;
}

.flash-ok {
  background: rgba(74, 166, 110, 0.16);
  border: 1px solid rgba(74, 166, 110, 0.4);
  border-radius: 8px;
  color: #1f5c30;
  margin-bottom: 1rem;
  padding: 0.7rem 0.85rem;
}

.validation-summary-valid { display: none; }
.validation-summary-errors {
  background: rgba(224, 122, 122, 0.14);
  border: 1px solid rgba(224, 122, 122, 0.4);
  border-radius: 8px;
  color: #8a3030;
  margin-bottom: 1rem;
  padding: 0.7rem 0.85rem;
}

.validation-summary-errors ul {
  margin: 0;
  padding-left: 1.1rem;
}

.row-actions { white-space: nowrap; }

.row-actions a,
.btn-danger-link,
.btn-link {
  color: #a35a20;
  font-size: 0.9rem;
  margin-right: 0.65rem;
}

.btn-danger-link {
  background: none;
  border: 0;
  color: var(--danger);
  cursor: pointer;
  font: inherit;
  padding: 0;
}

.inline-form { display: inline; }

.dash-form .multi-select {
  width: 100%;
  max-width: 36rem;
  min-height: 7rem;
}

.config-panel {
  border-top: 1px solid var(--content-border);
  margin-top: 1rem;
  padding-top: 0.85rem;
}

.config-panel__title {
  color: #7a4a22;
  font-size: 0.95rem;
  font-weight: 650;
  margin: 0 0 0.65rem;
}

.dash-form input:focus,
.dash-form textarea:focus,
.dash-form select:focus,
.auth-form input:focus {
  border-color: rgba(196, 122, 58, 0.55);
  outline: none;
}

.dash-form input[readonly] { opacity: 0.8; }

.form-grid__full { grid-column: 1 / -1; }

.form-check {
  align-items: center;
  display: flex !important;
  gap: 0.5rem;
  grid-template-columns: none !important;
}

.form-check input { width: auto; max-width: none; min-width: 0; }

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.btn-secondary {
  align-items: center;
  background: #fff;
  border: 1px solid var(--content-border);
  border-radius: 8px;
  color: var(--content-text);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  padding: 0.4rem 0.7rem;
  text-decoration: none;
  white-space: nowrap;
}

.btn-secondary:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.table-wrap { overflow: auto; }

/* Loyalty Programs: same column grid across Bonus / Aktionen / Stempelkarte */
.loyalty-program-table {
  table-layout: fixed;
  width: 100%;
}

.loyalty-program-table .lp-col-id { width: 4.5rem; }
.loyalty-program-table .lp-col-name { width: 34%; }
.loyalty-program-table .lp-col-typ { width: 9rem; }
.loyalty-program-table .lp-col-shop { width: 8.5rem; }
.loyalty-program-table .lp-col-aktiv { width: 4.5rem; }
.loyalty-program-table .lp-col-actions { width: 11rem; }

.loyalty-program-table th,
.loyalty-program-table td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.loyalty-program-table td.row-actions {
  overflow: visible;
  white-space: nowrap;
}

.dash-table {
  border-collapse: collapse;
  width: 100%;
}

.dash-table th,
.dash-table td {
  border-bottom: 1px solid var(--content-border);
  padding: 0.55rem 0.45rem;
  text-align: left;
}

.dash-table th {
  color: var(--content-muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
}

.dash-table tr:hover td {
  background: rgba(0, 0, 0, 0.03);
}

/* Phone + tablet (incl. 11"): off-canvas nav drawer */
@media (max-width: 1180px) {
  .dash-body {
    grid-template-columns: 1fr;
  }

  .dash-nav-toggle {
    align-items: center;
    background: #fff;
    border: 1px solid var(--content-border);
    border-radius: 10px;
    color: var(--content-text);
    cursor: pointer;
    display: inline-flex;
    flex: 0 0 auto;
    height: 2.35rem;
    justify-content: center;
    padding: 0;
    width: 2.35rem;
  }

  .dash-nav-toggle__bars,
  .dash-nav-toggle__bars::before,
  .dash-nav-toggle__bars::after {
    background: currentColor;
    border-radius: 2px;
    content: "";
    display: block;
    height: 2px;
    position: relative;
    width: 1.05rem;
  }

  .dash-nav-toggle__bars::before {
    position: absolute;
    top: -6px;
  }

  .dash-nav-toggle__bars::after {
    position: absolute;
    top: 6px;
  }

  .dash-nav-close {
    align-items: center;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    cursor: pointer;
    display: inline-flex;
    flex: 0 0 auto;
    font-size: 1.35rem;
    height: 2.1rem;
    justify-content: center;
    line-height: 1;
    margin: 0.65rem 0.35rem 0 0;
    width: 2.1rem;
  }

  .dash-nav-backdrop {
    background: rgba(0, 0, 0, 0.45);
    display: block;
    inset: 0;
    position: fixed;
    z-index: 45;
  }

  .dash-nav-backdrop[hidden] {
    display: none !important;
  }

  .dash-sidebar {
    border-right: 1px solid var(--border);
    bottom: 0;
    box-shadow: 8px 0 28px rgba(0, 0, 0, 0.28);
    left: 0;
    max-height: none;
    min-height: 0;
    position: fixed;
    top: 0;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    width: min(18.5rem, 86vw);
    z-index: 50;
  }

  .dash-body.nav-open .dash-sidebar {
    transform: translateX(0);
  }

  .dash-main {
    min-width: 0;
    width: 100%;
  }

  .dash-top {
    padding: 0.65rem 0.85rem;
  }

  .dash-top__meta {
    gap: 0.4rem;
  }

  .dash-top__role {
    display: none;
  }

  .dash-content {
    padding: 0.85rem;
  }

  .dash-panel {
    padding: 0.9rem;
  }

  .table-wrap {
    -webkit-overflow-scrolling: touch;
    margin: 0 -0.25rem;
    overflow-x: auto;
  }

  .dash-table {
    min-width: 40rem;
  }

  .form-actions {
    flex-wrap: wrap;
  }

  .media-modal__dialog {
    max-height: 92dvh;
  }
}

@media (max-width: 720px) {
  .dash-top__user {
    max-width: 6.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .dash-lang {
    margin-right: 0.15rem;
  }

  .dash-main .dash-logout {
    padding: 0.35rem 0.55rem;
  }

  .row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
  }
}

/* Standalone PWA: safe areas */
@supports (padding: env(safe-area-inset-top)) {
  .dash-top {
    padding-top: max(0.65rem, env(safe-area-inset-top));
  }

  .dash-sidebar {
    padding-bottom: env(safe-area-inset-bottom);
  }

  @media (max-width: 1180px) {
    .dash-sidebar {
      padding-left: env(safe-area-inset-left);
    }
  }
}

.dash-lang {
  align-items: center;
  display: inline-flex;
  font-size: 0.78rem;
  gap: 0.25rem;
  margin-right: 0.5rem;
}

.dash-top .dash-lang__link {
  color: #1c2026;
  font-weight: 600;
  padding: 0.15rem 0.35rem;
  text-decoration: none;
}

.dash-top .dash-lang__link.active,
.dash-top .dash-lang__link:hover {
  color: #7a4a22;
  text-decoration: underline;
}

.dash-top .dash-lang__sep {
  color: #5a6270;
}

.dash-lang__link {
  color: var(--muted);
  font-weight: 600;
  padding: 0.15rem 0.35rem;
  text-decoration: none;
}

.dash-lang__link.active,
.dash-lang__link:hover {
  color: var(--accent-text);
  text-decoration: none;
}

.dash-lang__sep {
  color: rgba(255, 255, 255, 0.35);
}

.media-preview-btn {
  background: none;
  border: 0;
  color: #a35a20;
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  margin-right: 0.65rem;
  padding: 0;
}

.media-preview-btn:hover {
  text-decoration: underline;
}

.media-modal {
  align-items: center;
  background: rgba(0, 0, 0, 0.55);
  display: none;
  inset: 0;
  justify-content: center;
  padding: 1.25rem;
  position: fixed;
  z-index: 1000;
}

.media-modal.is-open {
  display: flex;
}

.media-modal__dialog {
  background: #fff;
  border-radius: 12px;
  max-height: 90vh;
  max-width: min(960px, 100%);
  overflow: auto;
  padding: 0.85rem 1rem 1rem;
  width: 100%;
}

.media-modal__header {
  align-items: center;
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
  margin-bottom: 0.65rem;
}

.media-modal__title {
  color: #1c2026;
  font-size: 0.95rem;
  font-weight: 650;
  margin: 0;
  word-break: break-all;
}

.media-modal__close {
  background: none;
  border: 1px solid #c2c8d2;
  border-radius: 8px;
  color: #1c2026;
  cursor: pointer;
  font: inherit;
  padding: 0.25rem 0.55rem;
}

.media-modal__body {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 12rem;
}

.media-modal__body img,
.media-modal__body video {
  background: #111;
  border-radius: 8px;
  max-height: 75vh;
  max-width: 100%;
}

.media-modal__error {
  color: #8a1f1f;
  font-size: 0.9rem;
  margin: 0;
  padding: 1rem;
  text-align: center;
}

.media-modal__dialog--help {
  max-width: min(520px, 100%);
}

.media-modal__body--help {
  align-items: stretch;
  display: block;
  justify-content: flex-start;
  min-height: 0;
  text-align: left;
}

.page-help-wrap {
  position: relative;
  z-index: 2;
}

.page-help {
  align-items: center;
  background: #fff;
  border: 1px solid var(--content-border);
  border-radius: 50%;
  color: var(--content-muted);
  cursor: pointer;
  display: inline-flex;
  font-size: 0.82rem;
  font-style: italic;
  font-weight: 700;
  height: 1.7rem;
  justify-content: center;
  line-height: 1;
  padding: 0;
  width: 1.7rem;
}

.page-help:hover,
.page-help[aria-expanded="true"] {
  border-color: var(--accent);
  color: #7a4a22;
}

.page-help-list {
  margin: 0;
  width: 100%;
}

.page-help-list dt {
  color: var(--content-text);
  font-size: 0.82rem;
  font-weight: 600;
  margin-top: 0.45rem;
}

.page-help-list dd {
  color: var(--content-muted);
  font-size: 0.82rem;
  margin: 0.15rem 0 0;
}

.dash-user-menu {
  position: relative;
}

.dash-user-menu__btn {
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  padding: 0;
}

.dash-user-menu__btn:hover {
  text-decoration: underline;
}

.dash-user-menu__panel {
  background: #fff;
  border: 1px solid var(--content-border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  min-width: 11rem;
  padding: 0.35rem;
  position: absolute;
  right: 0;
  top: calc(100% + 0.4rem);
  z-index: 40;
}

.dash-user-menu__link {
  border-radius: 8px;
  color: var(--content-text);
  display: block;
  font-size: 0.88rem;
  padding: 0.45rem 0.65rem;
  text-decoration: none;
}

.dash-user-menu__link:hover {
  background: #eef1f5;
}

.pwa-install-btn {
  background: #fff;
  border: 1px solid var(--content-border);
  border-radius: 8px;
  color: #7a4a22;
  cursor: pointer;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 650;
  padding: 0.35rem 0.65rem;
  white-space: nowrap;
}

.pwa-install-btn:hover {
  border-color: var(--accent);
}

.pwa-install-tip {
  background: #fff8ee;
  border: 1px solid #e0c49a;
  border-radius: 10px;
  color: #1c2026;
  font-size: 0.88rem;
  line-height: 1.45;
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
}

.pwa-install-tip p { margin: 0.45rem 0; }
.pwa-install-tip ul { margin: 0.4rem 0 0; padding-left: 1.1rem; }
.pwa-install-tip code {
  background: #f0e6d6;
  border-radius: 4px;
  font-size: 0.82rem;
  padding: 0.05rem 0.3rem;
}

.dash-section-title {
  color: var(--content-text);
  font-size: 1rem;
  margin: 0 0 0.75rem;
}

.users-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.users-create {
  margin-bottom: 1.75rem;
}

.users-card {
  background: #fff;
  border: 1px solid var(--content-border);
  border-radius: 12px;
  padding: 1rem 1.15rem 1.1rem;
}

.users-card--inactive {
  opacity: 0.78;
}

.users-card__head {
  align-items: flex-start;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  justify-content: space-between;
  margin-bottom: 0.9rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid rgba(60, 64, 72, 0.12);
}

.users-card__username {
  color: var(--content-text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  margin: 0 0 0.35rem;
  word-break: break-all;
}

.users-card__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.users-card__badge {
  background: rgba(40, 90, 160, 0.1);
  border-radius: 999px;
  color: #1e3a5f;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.55rem;
}

.users-card__badge--muted {
  background: rgba(60, 64, 72, 0.1);
  color: #5a5f66;
}

.users-card__badge--warn {
  background: rgba(180, 90, 20, 0.14);
  color: #8a4500;
}

.users-card__actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.85rem;
}

.users-card__actions form {
  margin: 0;
}

.users-card__form {
  display: grid;
  gap: 0.75rem 1rem;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  align-items: end;
}

.users-card__form label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.85rem;
}

.users-card__save {
  align-items: end;
  display: flex;
}

.users-list__item {
  background: #fff;
  border: 1px solid var(--content-border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
}

.users-list__head {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-bottom: 0.65rem;
}

.users-list__meta {
  color: var(--content-muted);
  font-size: 0.82rem;
}

.user-admin-row {
  display: grid;
  gap: 0.65rem 0.85rem;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
}

.user-admin-row__actions {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.auth-btn--small {
  padding: 0.35rem 0.7rem;
  width: auto;
}

.form-check--inline {
  align-items: center;
  display: flex;
  gap: 0.4rem;
  margin-top: 1.4rem;
}

.clone-layout {
  background: #fff;
  border: 1px solid var(--content-border);
  border-radius: 12px;
  margin-top: 1.5rem;
  padding: 1rem 1.1rem 1.15rem;
}

.clone-layout__title {
  color: var(--content-text);
  font-size: 1rem;
  font-weight: 650;
  margin: 0 0 0.35rem;
}

.clone-layout__intro {
  color: var(--content-muted);
  font-size: 0.88rem;
  margin: 0 0 0.9rem;
}

.clone-layout__fields {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: minmax(0, 1fr);
  max-width: 28rem;
}

.clone-layout__fields label {
  display: grid;
  gap: 0.25rem;
}

.clone-layout__checks {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin: 0.85rem 0 0;
}

.clone-layout__checks .form-check {
  align-items: flex-start;
  max-width: 36rem;
}

.clone-layout__checks .form-check input {
  margin-top: 0.2rem;
}

.clone-layout .form-actions {
  margin-top: 1rem;
}

.zone-map-editor {
  margin-top: 1.25rem;
}

.zone-map-editor__toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.zone-map-editor__toolbar .auth-btn.is-active {
  outline: 2px solid rgba(40, 90, 160, 0.85);
  outline-offset: 1px;
}

.zone-map-editor__frame {
  position: relative;
  width: 100%;
  max-width: 52rem;
  border-radius: 0.5rem;
  overflow: hidden;
  border: 1px solid rgba(60, 64, 72, 0.25);
  background: #f3f4f6;
  user-select: none;
  touch-action: none;
  cursor: crosshair;
}

.zone-map-editor__img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
}

.zone-map-editor__box {
  position: absolute;
  box-sizing: border-box;
  border: 2px solid rgba(40, 90, 160, 0.9);
  background: rgba(40, 90, 160, 0.28);
  cursor: move;
  min-width: 1.5%;
  min-height: 1.5%;
}

.zone-map-editor__label {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.75rem;
  font-weight: 600;
  color: #10243a;
  text-align: center;
  pointer-events: none;
  padding: 0.15rem 0.35rem;
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.zone-map-editor__handle {
  position: absolute;
  width: 0.55rem;
  height: 0.55rem;
  background: #fff;
  border: 1px solid rgba(40, 90, 160, 0.95);
  box-sizing: border-box;
  border-radius: 1px;
}

.zone-map-editor__handle[data-h="nw"] { left: -0.3rem; top: -0.3rem; cursor: nwse-resize; }
.zone-map-editor__handle[data-h="n"]  { left: 50%; top: -0.3rem; transform: translateX(-50%); cursor: ns-resize; }
.zone-map-editor__handle[data-h="ne"] { right: -0.3rem; top: -0.3rem; cursor: nesw-resize; }
.zone-map-editor__handle[data-h="e"]  { right: -0.3rem; top: 50%; transform: translateY(-50%); cursor: ew-resize; }
.zone-map-editor__handle[data-h="se"] { right: -0.3rem; bottom: -0.3rem; cursor: nwse-resize; }
.zone-map-editor__handle[data-h="s"]  { left: 50%; bottom: -0.3rem; transform: translateX(-50%); cursor: ns-resize; }
.zone-map-editor__handle[data-h="sw"] { left: -0.3rem; bottom: -0.3rem; cursor: nesw-resize; }
.zone-map-editor__handle[data-h="w"]  { left: -0.3rem; top: 50%; transform: translateY(-50%); cursor: ew-resize; }

.perm-matrix th.perm-role {
  text-align: center;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
}

.perm-matrix th.perm-flag,
.perm-matrix td.perm-flag {
  text-align: center;
  width: 2.2rem;
  padding-left: 0.25rem;
  padding-right: 0.25rem;
}

.perm-matrix input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
}

.dash-table tr.row-error td {
  background: rgba(180, 40, 40, 0.08);
}

.log-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: flex-end;
  margin-bottom: 1rem;
}

.log-filters label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.85rem;
  min-width: 8rem;
}

.log-filters select,
.log-filters input[type="month"] {
  min-height: 2.1rem;
  padding: 0.25rem 0.45rem;
}

/* —— System monitor (Admin) —— */
.sys-monitor__toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.65rem;
  align-items: center;
  margin: 0.75rem 0 0.85rem;
}

.sys-monitor__toolbar .auth-btn,
.sys-monitor__toolbar .dash-logout {
  min-height: 2.15rem;
  padding: 0.35rem 0.85rem;
}

.sys-monitor__toolbar .dash-logout:disabled,
.sys-monitor__toolbar .auth-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.sys-monitor__status {
  font-size: 0.85rem;
  margin-left: 0.25rem;
}

.sys-monitor__meta {
  margin-top: -0.35rem;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  word-break: break-word;
}

.sys-monitor__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

@media (max-width: 1100px) {
  .sys-monitor__grid { grid-template-columns: 1fr; }
}

.sys-card {
  background: #f4f6f9;
  border: 1px solid var(--content-border, #d8dee8);
  border-radius: 10px;
  padding: 0.9rem 1rem 1rem;
  min-width: 0;
}

.sys-card--wide {
  grid-column: 1 / -1;
}

.sys-card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.55rem;
}

.sys-card__title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--content-text, #1f2430);
}

.sys-card__value {
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--content-text, #1f2430);
}

.sys-card__detail {
  margin: 0.45rem 0 0.35rem;
  font-size: 0.82rem;
}

.sys-bar {
  height: 0.55rem;
  border-radius: 999px;
  background: #dde3ec;
  overflow: hidden;
}

.sys-bar--thin {
  height: 0.35rem;
  margin-top: 0.25rem;
}

.sys-bar__fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: #3b82f6;
  transition: width 0.4s ease, background 0.3s ease;
}

.sys-bar__fill.is-warn { background: #d97706 !important; }
.sys-bar__fill.is-crit { background: #dc2626 !important; }

#sys-ram-bar:not(.is-warn):not(.is-crit) { background: #16a34a; }
#sys-disk-bar:not(.is-warn):not(.is-crit) { background: #d97706; }
#sys-pg-bar:not(.is-warn):not(.is-crit) { background: #7c3aed; }

.sys-chart {
  display: block;
  width: 100%;
  height: 140px;
  margin-top: 0.75rem;
  border-radius: 6px;
  background: #eef2f7;
}

.sys-db-list {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.75rem;
}

.sys-db__row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--content-text, #1f2430);
}

.sys-db__name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sys-db__size {
  font-variant-numeric: tabular-nums;
  color: var(--content-muted, #5a6270);
  flex-shrink: 0;
}

