:root {
  --bg: #fafafa;
  --fg: #1d1d1d;
  --muted: #666;
  --accent: #2c5aa0;
  --border: #d4d4d4;
  --error-bg: #fee;
  --error-fg: #800;
  --error-border: #c33;
  --max-width: 26rem;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.5;
}
.site-header {
  background: var(--accent);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.site-brand {
  display: flex; align-items: center; gap: 0.75rem;
  color: #fff; text-decoration: none; font-weight: 600; font-size: 1.15rem;
}
.site-brand:hover { text-decoration: none; opacity: 0.92; }
.site-logo { display: block; height: 2.5rem; width: auto; border-radius: 50%; background: #fff; }
.site-name {
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 1.25rem;
}

/* Header nav (logged-in user pill + odkazy + odhlásit), stejný styl jako vodaci. */
.site-auth {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
}
.site-auth .user-name {
  color: rgba(255, 255, 255, 0.92);
  padding-right: 0.75rem;
  border-right: 1px solid rgba(255, 255, 255, 0.3);
  text-decoration: none;
}
.site-auth a.user-name:hover { color: #fff; text-decoration: underline; }
.auth-link {
  color: #fff;
  text-decoration: none;
  opacity: 0.92;
}
.auth-link:hover { opacity: 1; text-decoration: underline; }
.auth-admin,
.auth-button {
  display: inline-block;
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.5);
  color: #fff;
  padding: 0.3rem 0.75rem;
  border-radius: 3px;
  font: inherit;
  font-size: 0.9rem;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
}
.auth-admin:hover,
.auth-button:hover {
  background: rgba(255, 255, 255, 0.15);
  text-decoration: none;
}
.auth-form { margin: 0; display: inline; }
.site-main {
  max-width: var(--max-width);
  margin: 4rem auto;
  padding: 2rem;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.875rem;
  padding: 2rem 1rem;
}
a { color: var(--accent); }
a:hover { text-decoration: underline; }

h1 { margin-top: 0; }
.muted { color: var(--muted); }

.alert {
  background: var(--error-bg);
  border-left: 3px solid var(--error-border);
  color: var(--error-fg);
  padding: 0.75rem 1rem;
  border-radius: 4px;
  margin-bottom: 1rem;
  white-space: pre-line;   /* Honoruj \n v textu jako line breaks. */
}
.alert.alert-success {
  background: #e8f5e8;
  border-left-color: #4a9d4a;
  color: #1f5e1f;
}

/* Profile form (auth tenant /me) — vertikální stack labelů s hinty. */
.profile-form-stack { display: flex; flex-direction: column; gap: 0.75rem; max-width: 28rem; }
.profile-form-stack .field { display: flex; flex-direction: column; gap: 0.2rem; }
.profile-form-stack .field-label { font-weight: 600; }
.profile-form-stack input[type="text"],
.profile-form-stack input[type="email"] {
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font: inherit;
}
.profile-form-stack .hint { color: var(--muted); font-size: 0.85rem; }

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.login-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.9rem;
  color: var(--muted);
}
.login-form input {
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--fg);
  background: #fff;
}
.login-form input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.login-form button,
.btn,
.logout-form button {
  padding: 0.6rem 1rem;
  background: var(--accent);
  color: white;
  text-decoration: none;
  border: none;
  border-radius: 4px;
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
  display: inline-block;
}
.login-form button:hover,
.btn:hover,
.logout-form button:hover { opacity: 0.9; }

.logout-form button { background: #888; }
.logout-form { margin-top: 1.5rem; }

/* TOTP enrollment wizard. */
.totp-qr {
  margin: 1rem 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 12rem;
  padding: 0.5rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
}
.totp-qr svg {
  display: block;
  max-width: 100%;
  height: auto;
}
.totp-qr-fallback { margin: 0; padding: 1rem; text-align: center; }

.totp-secret,
.totp-url {
  background: #f4f4f4;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.5rem 0.75rem;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.95em;
  word-break: break-all;
  white-space: pre-wrap;
  margin: 0.5rem 0;
}
.totp-secret { font-size: 1.1em; letter-spacing: 0.05em; }

details summary { cursor: pointer; padding: 0.3rem 0; color: var(--accent); }
details[open] summary { font-weight: 600; }

/* Security / Passkeys. */
.security-section {
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}
.security-section > h2 { margin-top: 0; }

.cred-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0 1.25rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: #fafafa;
}
.cred-list li {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
}
.cred-list li:last-child { border-bottom: none; }
.cred-list li:nth-child(odd) { background: #fff; }

.cred-info {
  flex: 1;
  min-width: 0;          /* aby long-name nepřetékal a daly se přerušit slova */
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.cred-name {
  font-weight: 600;
  word-break: break-word;
}
.cred-meta {
  font-size: 0.85rem;
  color: var(--muted);
}
.cred-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}
.cred-actions form { margin: 0; display: inline; }

.btn-mini {
  display: inline-block;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 0.3rem 0.7rem;
  border-radius: 4px;
  font: inherit;
  font-size: 0.85rem;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
}
.btn-mini:hover {
  background: #f0f0f0;
  text-decoration: none;
}
.btn-mini.btn-danger {
  color: #c33;
  border-color: #e0b4b4;
}
.btn-mini.btn-danger:hover {
  background: #fdf3f3;
  border-color: #c33;
}

.cred-empty {
  margin: 1rem 0 1.25rem;
  padding: 1rem;
  background: #fafafa;
  border: 1px dashed var(--border);
  border-radius: 6px;
  color: var(--muted);
  text-align: center;
  font-size: 0.95rem;
}

/* Backwards-compat shim — staré .passkey-* selektory v jiných šablonách. */
.btn-link {
  background: none;
  border: none;
  color: #c33;
  cursor: pointer;
  padding: 0;
  font: inherit;
  text-decoration: underline;
}
.btn-link:hover { opacity: 0.8; }

.passkey-status {
  margin: 0.75rem 0 0;
  padding: 0.5rem 0.75rem;
  background: #f4f4f4;
  border-radius: 4px;
  font-size: 0.9rem;
}
.passkey-status.err { background: var(--error-bg); color: var(--error-fg); border-left: 3px solid var(--error-border); }
.passkey-status.ok  { background: #e7f5e9; color: #1f5a2c; border-left: 3px solid #4a8c4a; }

/* DB browser a docs stránky potřebují víc místa než login (26rem max-width).
   :has() expanduje .site-main jen na adminských stránkách, login zůstane úzký. */
.site-main:has(.db-rows-wrapper),
.site-main:has(.db-table-list),
.site-main:has(.docs-content),
.site-main:has(.users-table),
.site-main:has(.audit-table-wrapper) {
  max-width: 80rem;
}
.site-main:has(.security-section),
.site-main:has(.profile-card) {
  max-width: 46rem;
}

/* Docs subnav — řádka s odkazy na sekce dokumentace, pod modrým site-header. */
.docs-subnav {
  margin: -2rem -2rem 1.5rem;          /* záporný margin negate site-main padding */
  padding: 0.6rem 1.5rem;
  background: #f8f8f8;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}
.docs-subnav a {
  color: var(--accent);
  text-decoration: none;
}
.docs-subnav a:hover { text-decoration: underline; }
.docs-subnav a.active { font-weight: 600; }

/* Docs content wrapper — žádné dodatečné styly, /docs/styles.css se načítá
   z docs.php template a obsluhuje typografii (h2 border, code, pre, .note,
   .toc, table). */
.docs-content { /* placeholder — selektor pro :has() match nahoře */ }

/* DB browser. */
.db-table-list {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.95rem;
}
.db-table-list th,
.db-table-list td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.db-table-list th { background: #fafafa; font-weight: 600; }
.db-table-list .num { text-align: right; font-variant-numeric: tabular-nums; }
.db-table-list a { color: var(--accent); text-decoration: none; }
.db-table-list a:hover { text-decoration: underline; }

.db-rows-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
  margin: 1rem 0;
  background: #fff;
}
.db-rows {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  font-family: "SF Mono", Menlo, Consolas, monospace;
}
.db-rows th,
.db-rows td {
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  vertical-align: top;
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 28rem;
}
.db-rows th:last-child,
.db-rows td:last-child { border-right: none; }
.db-rows th {
  background: #f4f4f4;
  font-weight: 600;
  font-family: system-ui, sans-serif;
  position: sticky;
  top: 0;
  text-align: left;
}
.db-rows tr:hover td { background: rgba(0, 0, 0, 0.02); }
.db-rows .col-pk { font-size: 0.8em; opacity: 0.7; margin-left: 0.2em; }
.db-rows .db-null { color: var(--muted); font-style: italic; }
.db-rows .db-blob { font-size: 0.8em; color: #666; word-break: break-all; }
.db-rows .cell-blob { background: #fafafa; }

.db-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 1rem 0;
  padding: 0.5rem 0.75rem;
  background: #fafafa;
  border-radius: 4px;
}
.db-pager a { color: var(--accent); text-decoration: none; }
.db-pager a:hover { text-decoration: underline; }

.db-schema { margin-top: 2rem; }
.profile-card {
  display: flex;
  gap: 1.25rem;
  align-items: center;
  padding: 1.5rem;
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 1rem 0 0.5rem;
}
.profile-avatar {
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  flex-shrink: 0;
  overflow: hidden;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.profile-summary { min-width: 0; flex: 1; }
.profile-name { margin: 0 0 0.15rem; font-size: 1.4rem; word-break: break-word; }
.profile-email { margin: 0 0 0.6rem; color: var(--muted); word-break: break-all; font-size: 0.95rem; }

.profile-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.profile-tag {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
}
.profile-tag-super { background: var(--accent); border-color: var(--accent); color: #fff; }

.profile-meta-line { margin: 0 0 1.5rem; color: var(--muted); font-size: 0.9rem; }

.profile-section { margin: 1.75rem 0; }
.profile-section h2 { margin-bottom: 0.4rem; font-size: 1.15rem; }
.profile-section p { margin: 0.5rem 0; }
.profile-form { margin-top: 0.75rem; }

/* Danger button — destruktivní akce (logout, smaž). Auth theme dosud
   používalo jen mini variantu, ale na /me chceme plnohodnotné tlačítko.
   :not(.btn-mini) zabraňuje, aby toto pravidlo přebíjelo padding/font
   u <button class="btn-mini btn-danger"> v /security seznamu. */
.btn-danger:not(.btn-mini) {
  display: inline-block;
  padding: 0.55rem 1rem;
  background: #fff;
  color: #c33;
  border: 1px solid #c33;
  border-radius: 4px;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}
.btn-danger:not(.btn-mini):hover { background: #c33; color: #fff; text-decoration: none; }

/* User menu (avatar trigger + dropdown). Generický blok — používá CSS
   proměnné, takže se v každém tématu naplní svojí --accent / --border. */
.user-menu { position: relative; display: inline-block; }
.user-menu-trigger {
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  border-radius: 50%;
  line-height: 0;
}
.user-menu-trigger:focus { outline: none; }
.user-menu-trigger:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}
.user-menu-avatar {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.5);
  box-sizing: border-box;
}
.user-menu-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.user-menu-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  min-width: 14rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
  padding: 0.4rem 0;
  z-index: 100;
  font-size: 0.9rem;
  color: var(--fg);
}
.user-menu-dropdown[hidden] { display: none; }

.user-menu-header {
  padding: 0.5rem 1rem 0.4rem;
}
.user-menu-name {
  font-weight: 600;
  word-break: break-word;
}
.user-menu-email {
  color: var(--muted);
  font-size: 0.8rem;
  word-break: break-all;
}
.user-menu-dropdown hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 0.3rem 0;
}
.user-menu-dropdown a,
.user-menu-dropdown button {
  display: block;
  width: 100%;
  padding: 0.45rem 1rem;
  color: var(--fg);
  text-decoration: none;
  background: none;
  border: 0;
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-sizing: border-box;
}
.user-menu-dropdown a:hover,
.user-menu-dropdown button:hover {
  background: rgba(0, 0, 0, 0.05);
  text-decoration: none;
}
.user-menu-dropdown form { margin: 0; padding: 0; }

/* Users admin table (/users na auth tenantu, super-admin). */
.users-table-wrapper {
  margin: 1rem 0;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}
.users-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.9rem;
}
.users-table th,
.users-table td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
.users-table th:last-child,
.users-table td:last-child { border-right: none; }
.users-table tr:last-child td { border-bottom: none; }
.users-table thead th {
  background: #f4f4f4;
  font-weight: 600;
  color: var(--fg);
  border-bottom: 1px solid var(--border);
}
.users-table tbody tr:nth-child(odd) { background: #fafafa; }
.users-table tbody tr:hover { background: #eef3f9; }

.users-id {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  color: var(--muted);
  width: 3rem;
}
.users-avatar-cell {
  width: 2.5rem;
  padding: 0.4rem !important;
}
.users-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  overflow: hidden;
}
.users-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.users-name { font-weight: 600; }
.users-email { color: var(--muted); font-size: 0.85rem; word-break: break-all; }
.users-flag { color: #c33; font-size: 0.78rem; margin-top: 0.15rem; }

.users-roles { max-width: 18rem; }
.users-roles .profile-tag { margin: 0.1rem 0.15rem 0.1rem 0; }

.users-2fa { white-space: nowrap; }
.users-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  margin: 0.1rem 0.15rem 0.1rem 0;
  border-radius: 4px;
  background: #e9efff;
  border: 1px solid #c7d4f0;
  color: #2c5aa0;
  font-size: 0.78rem;
}

.users-mail { text-align: right; }
.users-time {
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
}

/* Klikací řádky tabulky uživatelů. */
.users-row { cursor: pointer; }
.users-row:hover { background: #eef3f9 !important; }
.users-id a { color: var(--muted); text-decoration: none; }
.users-id a:hover { color: var(--accent); }

/* Role matrix v /users/{id} detailu. */
.role-matrix {
  border-collapse: collapse;
  width: 100%;
  margin: 0.75rem 0;
  font-size: 0.9rem;
}
.role-matrix th,
.role-matrix td {
  padding: 0.55rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.role-matrix thead th {
  background: #f4f4f4;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.role-matrix tbody tr:hover { background: #fafafa; }
.role-matrix-host {
  display: block;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.78rem;
  margin-top: 0.1rem;
}
.role-matrix-actions {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}
.role-matrix-form { display: inline; margin: 0; }
.role-matrix-actions .btn-mini[disabled] {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  cursor: default;
  opacity: 1;
}

/* Alternativní login tlačítka (Google, passkey) — visuálně paritní:
   bílé pozadí + šedý border + černý text + ikona vlevo. Odlišují se od
   primárního "Přihlásit" submitu, který je solid modrý.
   Google brand guideline vyžaduje white-on-gray look pro Google button,
   takže passkey to dědí (uniformity). */
.login-alt {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.btn-alt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.6rem 1rem;
  background: #fff;
  color: #1f1f1f;
  border: 1px solid #d4d4d4;
  border-radius: 4px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.3;
  box-sizing: border-box;
}
.btn-alt:hover {
  background: #f4f4f4;
  text-decoration: none;
}
.btn-alt-icon {
  width: 1.05rem;
  height: 1.05rem;
  display: block;
  flex-shrink: 0;
}
.login-or {
  text-align: center;
  margin: 0.5rem 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Čekající Google signups (admin /users sekce). */
.pending-section {
  margin: 1rem 0 2rem;
  padding: 1rem 1.25rem;
  background: #fff8e6;
  border: 1px solid #f0d27a;
  border-radius: 6px;
}
.pending-section > h2 {
  margin: 0 0 0.4rem;
  font-size: 1.1rem;
}
.pending-list {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 0;
}
.pending-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 0;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}
.pending-item:first-child { border-top: 0; }

.pending-avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #fff;
}
.pending-avatar-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #d4d4d4;
  color: #fff;
  font-weight: 600;
}

.pending-info {
  flex: 1;
  min-width: 0;
}
.pending-name { font-weight: 600; word-break: break-word; }
.pending-email { color: var(--muted); font-size: 0.85rem; word-break: break-all; }
.pending-meta { font-size: 0.78rem; margin-top: 0.15rem; }

.pending-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
  flex-wrap: wrap;
  align-items: center;
}
.pending-actions form { margin: 0; }
.pending-link-form {
  display: inline-flex;
  gap: 0.3rem;
  align-items: center;
}
.pending-link-form select {
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font: inherit;
  max-width: 18rem;
}

/* User detail — profile edit form (super-admin). */
.profile-edit-form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-width: 36rem;
  margin-top: 0.5rem;
}
.profile-edit-row {
  display: grid;
  grid-template-columns: 10rem 1fr;
  align-items: center;
  gap: 0.6rem;
}
.profile-edit-row > span {
  color: var(--muted);
  font-size: 0.9rem;
  text-align: right;
}
.profile-edit-row input,
.profile-edit-row select {
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.95rem;
  font-family: inherit;
  background: #fff;
}
.profile-edit-actions { padding-left: 10.6rem; margin-top: 0.3rem; }
.profile-edit-fieldset {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.6rem 0.8rem 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.2rem 0;
}
.profile-edit-fieldset > legend { padding: 0 0.4rem; color: var(--muted); font-size: 0.9rem; }

.user-create-section { margin: 1rem 0 1.5rem; }
.user-create-section > details > summary {
  cursor: pointer;
  padding: 0.5rem 0.8rem;
  background: #f6f8fb;
  border: 1px solid var(--border);
  border-radius: 4px;
  list-style: none;
}
.user-create-section > details[open] > summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.user-create-form {
  display: flex; flex-direction: column; gap: 0.5rem;
  padding: 0.8rem;
  border: 1px solid var(--border);
  border-top: none;
  border-bottom-left-radius: 4px;
  border-bottom-right-radius: 4px;
}
.profile-flash {
  padding: 0.5rem 0.8rem;
  border-radius: 4px;
  margin-bottom: 0.7rem;
  font-size: 0.95rem;
}
.profile-flash-ok  { background: #ecfdf3; border: 1px solid #a7e3c0; color: #115e2b; }
.profile-flash-err { background: #fff4f4; border: 1px solid #f0c2c2; color: #8a1f1f; }

/* User menu — sekce "Přepnout na" v dropdownu (multi-tenant switcher). */
.user-menu-section-title {
  padding: 0.55rem 0.9rem 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.user-menu-dropdown a.user-menu-tenant-link {
  font-size: 0.95rem;
  color: var(--accent);
}

/* Externí link icon v user-menu (Související sekce). */
.user-menu-ext-icon {
  font-size: 0.85em;
  opacity: 0.6;
  margin-left: 0.2rem;
}

/* Audit log — toolbar + denser table layout. */
.audit-filterbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin: 1rem 0 1.25rem;
  padding: 0.6rem 0.75rem;
  background: #f6f8fa;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
}
.audit-filterbar input,
.audit-filterbar select {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  font-size: 0.9rem;
  background: #fff;
}
.audit-filterbar input[type="search"],
.audit-filterbar input[type="text"] { min-width: 12rem; flex: 1 1 12rem; }
.audit-filterbar input[type="number"] { width: 7.5rem; }
.audit-filterbar select { min-width: 9rem; }
.audit-filterbar button {
  padding: 0.45rem 1.1rem;
  font-weight: 600;
}
.audit-filter-clear {
  font-size: 0.85rem;
  color: var(--muted);
  text-decoration: none;
  padding: 0.25rem 0.5rem;
}
.audit-filter-clear:hover { color: #c1121f; }

.audit-table-wrapper {
  margin: 1rem 0;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: #fff;
}
.audit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.audit-table th,
.audit-table td {
  padding: 0.55rem 0.75rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}
.audit-table tr:last-child td { border-bottom: none; }
.audit-table thead th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: #fafbfc;
  font-weight: 600;
  white-space: nowrap;
}
.audit-table tbody tr:nth-child(even) { background: #fafafa; }
.audit-table tbody tr:hover { background: #f0f6ff; }

/* Severity strip on the left + bg tint pro warning/critical řádky. */
.audit-row.sev-warning  td:first-child { box-shadow: inset 3px 0 0 #f0b400; }
.audit-row.sev-critical td:first-child { box-shadow: inset 3px 0 0 #c1121f; }

/* Time column. */
.audit-col-time { white-space: nowrap; font-variant-numeric: tabular-nums; min-width: 8rem; }
.audit-col-time time { font-weight: 500; }
.audit-time-abs { display: block; color: var(--muted); font-size: 0.78rem; margin-top: 2px; }

/* Action pill + category color. */
.audit-action {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 0.82rem;
  padding: 0.15rem 0.5rem;
  border-radius: 0.3rem;
  background: rgba(0,0,0,0.05);
  white-space: nowrap;
}
.audit-cat-auth    { background: #e3edff; color: #1f4ea8; }
.audit-cat-access  { background: #ffe9d6; color: #a04d00; }
.audit-cat-user    { background: #e6f4d9; color: #3a6b1c; }
.audit-cat-2fa     { background: #f3e6ff; color: #6a2d96; }
.audit-cat-content { background: #fff5cc; color: #87650a; }
.audit-cat-other   { background: #ececec; color: #555; }

/* Severity pill (small uppercase letter). */
.audit-sev-pill {
  display: inline-block;
  margin-left: 0.35rem;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 0.85rem;
  vertical-align: middle;
}
.audit-sev-info     { background: #eef0f2; color: #4a5460; }
.audit-sev-warning  { background: #fde8b4; color: #8a5800; }
.audit-sev-critical { background: #fad4d6; color: #9a0a14; }

/* Actor cell. */
.audit-col-actor a { font-weight: 500; }
.audit-ip {
  display: block;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 2px;
}

/* Target / tenant cell. */
.audit-target-type {
  display: inline-block;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--muted);
  margin-right: 0.3rem;
}
.audit-target-id { font-size: 0.85rem; }
.audit-tenant {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 2px;
}

/* Metadata cell — inline key:value pairs. */
.audit-col-meta {
  font-size: 0.85rem;
  max-width: 28rem;
  word-break: break-word;
}
.audit-meta-kv { white-space: nowrap; }
.audit-meta-kv b { color: var(--muted); font-weight: 500; }

.audit-empty {
  text-align: center;
  padding: 3rem 1rem !important;
  color: var(--muted);
}

.audit-pagination {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin: 1.5rem 0;
  align-items: center;
  font-size: 0.9rem;
}
.audit-pagination a { font-weight: 500; }
.audit-page-disabled { color: var(--border); cursor: not-allowed; }

/* Mobil: schovat absolutní čas + IP řádek pod 720px. */
@media (max-width: 720px) {
  .audit-table { font-size: 0.82rem; }
  .audit-table th,
  .audit-table td { padding: 0.4rem 0.55rem; }
  .audit-time-abs { display: none; }
  .audit-col-meta { max-width: 14rem; }
}

/* Media — alba a items grid. */
.media-page-header { margin-bottom: 1.5rem; }
.media-page-header h1 { margin: 0.5rem 0 0.25rem; }
.media-album-desc { color: var(--muted); margin: 0.25rem 0 0.75rem; }

.media-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--muted);
  font-size: 1.1rem;
}

/* New album panel + edit panel — collapsible details. */
.media-new-album, .media-share-panel, .media-album-edit-panel, .media-upload-form {
  margin: 1rem 0;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: #fafbfc;
}
.media-new-album summary,
.media-share-panel summary,
.media-album-edit-panel summary {
  padding: 0.7rem 1rem;
  cursor: pointer;
  user-select: none;
  font-weight: 500;
}
.media-new-album form,
.media-share-panel,
.media-album-edit-panel form {
  padding: 0 1rem 1rem;
}
.media-new-album label,
.media-album-edit-panel label {
  display: block;
  margin: 0.5rem 0;
}
.media-new-album input[type="text"],
.media-new-album textarea,
.media-album-edit-panel input[type="text"],
.media-album-edit-panel textarea {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.3rem;
  font: inherit;
  box-sizing: border-box;
}
.media-album-edit-panel form { padding-top: 1rem; }

/* Album grid (rozcestník + shared). */
.media-album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}
.media-album-card {
  display: block;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  overflow: hidden;
  background: #fff;
  transition: transform 0.1s, box-shadow 0.1s;
}
.media-album-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.media-album-cover {
  aspect-ratio: 4 / 3;
  background: #f0f2f5;
  overflow: hidden;
}
.media-album-card .media-album-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.media-album-cover-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 3rem;
  color: var(--border);
}
.media-album-info { padding: 0.6rem 0.85rem; }
.media-album-info h3 { margin: 0; font-size: 1rem; font-weight: 600; }
.media-album-info p  { margin: 0.2rem 0 0; font-size: 0.85rem; }

/* Item grid (uvnitř alba). */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.5rem;
  margin: 1rem 0;
}
.media-thumb {
  position: relative;
  margin: 0;
  aspect-ratio: 1;
  background: #f0f2f5;
  border-radius: 0.4rem;
  overflow: hidden;
}
.media-grid .media-thumb-link {
  position: absolute;
  inset: 0;
  display: block;
}
/* Specificita 0,0,2,1 — porazí responsive.css `.site-main img { height: auto }`
   (0,0,1,1), který jinak v kaskádě vyhrává a nechá fotku jen "na šířku". */
.media-grid .media-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.media-video-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 3rem;
  color: #fff;
  background: linear-gradient(135deg, #2b2b2b, #4a4a4a);
}
/* Video poster + centered play button overlay. */
.media-video-poster {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.media-video-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  text-indent: 0.2em;     /* opticky vystředit ▶ uvnitř kruhu */
}

/* Protected indicator (zámeček v rohu vlastníkova thumbu). */
.media-thumb.is-protected::before {
  content: '🔒';
  position: absolute;
  top: 0.4rem;
  left: 0.4rem;
  font-size: 1rem;
  background: rgba(0,0,0,0.55);
  color: #fff;
  width: 1.6rem;
  height: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  z-index: 2;
}

/* Action buttons na thumbu — zobraz na hover. */
.media-thumb-actions {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: flex-end;
  gap: 0.25rem;
  padding: 0.4rem;
  background: linear-gradient(to top, rgba(0,0,0,0.6), transparent);
  opacity: 0;
  transition: opacity 0.15s;
}
.media-thumb:hover .media-thumb-actions { opacity: 1; }
.media-thumb-actions form { margin: 0; }
.media-thumb-btn {
  background: rgba(255,255,255,0.85);
  border: none;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.media-thumb-btn:hover { background: #fff; }
.media-thumb-btn.is-active { background: #ffd966; }

/* Share list — uživatelé jako toggle button. */
.media-share-list {
  list-style: none;
  padding: 0 1rem 1rem;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.media-share-list li { margin: 0; }
.media-share-list form { margin: 0; }
.media-share-toggle {
  background: #fff;
  border: 1px solid var(--border);
  padding: 0.35rem 0.8rem 0.35rem 0.4rem;
  border-radius: 1.5rem;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  line-height: 1.2;
}
.media-share-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  overflow: hidden;
}
.media-share-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-share-info {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
}
.media-share-toggle small {
  font-size: 0.75rem;
  color: var(--muted);
}
.media-share-toggle.is-shared {
  background: #e8f5e8;
  border-color: #4a9d4a;
  color: #1f5e1f;
}
.media-share-toggle.is-shared small { color: #4a9d4a; }
.media-share-toggle:hover { box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

/* Sort toggle (newest/oldest) v hlavičce alba. */
.media-sort {
  display: inline-flex;
  gap: 0.5rem;
  align-items: baseline;
  font-size: 0.9rem;
  margin-top: 0.25rem;
}
.media-sort a {
  padding: 0.15rem 0.5rem;
  border: 1px solid #d0d0d0;
  border-radius: 0.25rem;
  text-decoration: none;
  color: #555;
  background: #fafafa;
}
.media-sort a:hover { background: #f0f0f0; }
.media-sort a.is-active {
  background: #2c5b8c;
  color: #fff;
  border-color: #2c5b8c;
}

/* Upload form. */
.media-upload-form { padding: 0.85rem 1rem; }
.media-upload-label {
  display: block;
  cursor: pointer;
  text-align: center;
  padding: 1.25rem;
  border: 2px dashed var(--border);
  border-radius: 0.4rem;
  background: #fff;
  transition: border-color 0.15s, background 0.15s;
}
.media-upload-label:hover {
  border-color: #4a9d4a;
  background: #f3faf3;
}
.media-upload-label input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}
.media-upload-cta { font-weight: 500; font-size: 1rem; }
.media-upload-form small { display: block; margin-top: 0.5rem; text-align: center; }
.media-upload-errors {
  margin: 0.5rem 0;
  padding-left: 1.25rem;
  color: #c1121f;
  font-size: 0.85rem;
}
#media-upload-status p { margin: 0.5rem 0; }
#media-upload-status .error { color: #c1121f; }

/* Toolbar — zarovnání všech tří panelů. */
.media-toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 1rem 0;
}

/* :not(.btn-mini) — bez toho by toto pravidlo přebíjelo padding/border
   u <button class="btn-mini btn-danger"> v /security a /user-detail
   (× delete buttons) a buttony by tam vyšly dvakrát větší. */
.btn-danger:not(.btn-mini) {
  background: #c1121f;
  color: #fff;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 0.3rem;
  cursor: pointer;
  font-size: 0.9rem;
}
.btn-danger:not(.btn-mini):hover { background: #9a0a14; }

/* Site-main expanze pro media stránky. */
.site-main:has(.media-grid),
.site-main:has(.media-album-grid),
.site-main:has(.media-page-header) {
  max-width: 80rem;
}
