:root {
  --bg: #0f141b;
  --panel: #171f2a;
  --panel-2: #223044;
  --text: #f4efe7;
  --muted: #aeb6c2;
  --line: #2c3746;
  --accent: #d28a36;
  --accent-2: #f4d49c;
  --success: #5fd58a;
  --warning: #f4a441;
  --expired: #ff6b6b;
  --mistake: #9fb2cc;
  --danger: #d95d50;
  --page: #f6eddf;
  --page-ink: #28231d;
  --input-bg: #0e141d;
  --sidebar-bg: rgba(9, 13, 19, .92);
  --shadow: 0 18px 60px rgba(0,0,0,.28);
}

body[data-theme="light"] {
  --bg: #edf4fb;
  --panel: rgba(255,255,255,.84);
  --panel-2: #e7f0fb;
  --text: #101827;
  --muted: #58657a;
  --line: #cfdae8;
  --accent: #0876e8;
  --accent-2: #005fc0;
  --success: #15803d;
  --warning: #c56a00;
  --expired: #c62828;
  --mistake: #64748b;
  --danger: #c0392b;
  --input-bg: #ffffff;
  --sidebar-bg: rgba(255,255,255,.82);
  --shadow: 0 18px 50px rgba(31, 59, 96, .14);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(45, 126, 230, .16), transparent 34%),
    radial-gradient(circle at top right, rgba(210, 138, 54, .12), transparent 30%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, sans-serif;
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 250px;
  padding: 22px 18px;
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  overflow-y: auto;
  scrollbar-gutter: stable;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(16px);
}
.brand {
  display: grid;
  gap: 10px;
  justify-items: start;
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 18px;
}
.brand img {
  width: 58px;
  height: 58px;
  object-fit: contain;
  border-radius: 10px;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--line);
  padding: 6px;
}
.sidebar nav { display: grid; gap: 7px; }
.sidebar nav a {
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--muted);
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  align-items: center;
  column-gap: 10px;
  min-width: 0;
  white-space: nowrap;
}
.sidebar nav a .nav-key {
  display: inline-grid;
  place-items: center;
  font-size: 11px;
  color: inherit;
  opacity: .78;
}
.sidebar nav a .nav-label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-badge {
  min-width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 0 6px;
  background: var(--danger);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--panel-2) 75%, transparent);
}
.sidebar nav a.active, .sidebar nav a:hover {
  background: var(--panel-2);
  color: var(--text);
  text-decoration: none;
}
.sidebar-foot {
  margin-top: 16px;
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  padding: 14px 0 18px;
}
.sidebar-foot strong { color: var(--text); font-size: 15px; }
.sidebar-clock {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 10px;
  color: var(--text);
  background: rgba(126, 150, 180, .08);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.gta-countdown {
  display: grid;
  gap: 7px;
  border: 1px solid rgba(210, 138, 54, .42);
  border-radius: 14px;
  padding: 10px;
  background: linear-gradient(135deg, rgba(88, 36, 122, .45), rgba(235, 111, 51, .14));
}
.gta-countdown span { color: var(--muted); font-size: 12px; }
.gta-countdown strong { color: var(--text); font-size: 13px; font-variant-numeric: tabular-nums; }
.gta-logo {
  width: 54px;
  min-height: 48px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: #fff;
  font-weight: 900;
  line-height: .88;
  letter-spacing: .02em;
  text-shadow: 0 2px 0 #1a062c;
  background: linear-gradient(160deg, #4e1a8b 0%, #2367ff 38%, #fa3eb6 68%, #ffd95d 100%);
  box-shadow: inset 0 0 0 3px rgba(255,255,255,.8), 0 0 0 2px rgba(81, 16, 115, .8);
}
.gta-logo strong { font-size: 24px; color: #fff; }
.main {
  margin-left: 250px;
  padding: 28px;
}
.auth-main {
  margin-left: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  align-content: center;
}
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
h1, h2, h3 { margin: 0 0 8px; }
p { color: var(--muted); }
.panel, .card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.metric span { display: block; color: var(--muted); font-size: 13px; }
.metric strong { display: block; font-size: 26px; margin-top: 8px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar form { margin: 0; }
.button, button {
  border: 0;
  border-radius: 12px;
  padding: 10px 13px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.button.primary, button.primary { background: var(--accent); color: #1b1208; font-weight: 700; }
.button.success, button.success { background: var(--success); color: #07150d; font-weight: 800; }
.button.danger, button.danger { background: var(--danger); color: #fff; }
.button.ghost, button.ghost { background: transparent; border: 1px solid var(--line); }
.button:hover, button:hover { filter: brightness(1.08); text-decoration: none; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--input-bg);
  color: var(--text);
  padding: 10px 11px;
  font: inherit;
}
textarea { min-height: 130px; resize: vertical; }
label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 13px; }
.checkline {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  color: var(--text);
}
.checkline input {
  width: auto;
  margin: 0;
  flex: 0 0 auto;
}
.checkline span { line-height: 1.35; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field.full { grid-column: 1 / -1; }
.stack { display: grid; gap: 16px; }
.wide-left { grid-template-columns: minmax(0, 1.1fr) minmax(360px, .9fr); }
.editor-full {
  max-width: 1680px;
  margin: 0 auto;
}
.editor-panel {
  padding: 22px;
}
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.tabs a {
  padding: 9px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.tabs a.active {
  color: var(--text);
  background: var(--panel-2);
}
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 13px; background: rgba(126, 150, 180, .08); }
tr:hover td { background: rgba(255,255,255,.025); }
.flash { padding: 12px 14px; border-radius: 8px; margin-bottom: 14px; background: #1f3326; border: 1px solid #2d6b3d; }
.error { background: #3a1f1f; border-color: #78352e; }
.info { background: rgba(59, 130, 246, .12); border-color: rgba(59, 130, 246, .34); }
.auth-card { width: min(420px, calc(100vw - 28px)); }
.login-stack {
  width: 100%;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 16px;
  transform: translateY(-3vh);
}
.login-logo {
  width: 78px;
  height: 78px;
  object-fit: contain;
  margin: 0 auto;
  display: block;
  border-radius: 16px;
  padding: 8px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.06);
}
.forbidden-card {
  text-align: left;
  border-color: #60422a;
  background: linear-gradient(180deg, #1b222c, #151b23);
}
.forbidden-card h1 { font-size: 28px; }
.pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 7px;
  margin-left: 7px;
  color: var(--accent-2);
  font-size: 12px;
}
.avatar {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--panel-2);
  border: 1px solid var(--line);
}
.avatar-sm {
  width: 32px;
  height: 32px;
  flex-basis: 32px;
  border-radius: 9px;
}
.avatar-xl {
  width: 96px;
  height: 96px;
  flex-basis: 96px;
  border-radius: 20px;
}
.avatar-fallback {
  display: inline-grid;
  place-items: center;
  color: var(--text);
  font-weight: 800;
}
.assigned-user,
.case-owner,
.profile-preview {
  display: flex;
  align-items: center;
  gap: 10px;
}
.assigned-user span { white-space: nowrap; }
.case-owner {
  margin: 10px 0 14px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(126, 150, 180, .07);
}
.case-owner span,
.profile-preview span,
.profile-preview small,
.muted-line {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.profile-preview strong {
  display: block;
  color: var(--text);
  font-size: 18px;
}
.check-mark {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: #071f47;
  color: #fff;
  font-weight: 900;
}
.empty-mark {
  color: var(--muted);
  font-weight: 900;
  font-size: 18px;
}
.employee-table td,
.employee-table th {
  vertical-align: middle;
}
.employee-table tbody tr:nth-child(even) td {
  background: rgba(126, 150, 180, .05);
}
.employee-table strong { color: var(--text); }
.table-actions {
  margin: 12px 0;
  justify-content: flex-end;
}
.users-table thead th:last-child:empty { display: none; }
.links-list { display: grid; gap: 8px; margin-top: 10px; }
.link-row { display: grid; grid-template-columns: 1fr 2fr auto; gap: 8px; }
.file-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}
.file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  background: rgba(126, 150, 180, .08);
}
.file-row-main { display: grid; gap: 3px; min-width: 0; }
.file-row-main strong,
.file-name-link,
.file-name-button {
  overflow-wrap: anywhere;
}
.file-name-link { color: var(--accent-2); font-weight: 800; }
.file-name-button {
  width: fit-content;
  padding: 0;
  border: 0;
  color: var(--accent-2);
  background: transparent;
  box-shadow: none;
  text-align: left;
  font-weight: 800;
  cursor: pointer;
}
.file-name-button:hover { text-decoration: underline; transform: none; }
.file-row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.file-row-actions form { margin: 0; }
.file-row:hover {
  background: var(--panel-2);
  text-decoration: none;
}
.file-row span {
  color: var(--muted);
  font-size: 13px;
}
.image-preview-dialog {
  width: min(1100px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--text);
  background: var(--panel);
  box-shadow: 0 30px 100px rgba(0,0,0,.58);
}
.image-preview-dialog::backdrop { background: rgba(3, 7, 12, .82); backdrop-filter: blur(5px); }
.image-preview-head,
.image-preview-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; }
.image-preview-head { border-bottom: 1px solid var(--line); }
.image-preview-head h2 { margin: 0; overflow-wrap: anywhere; }
.image-preview-actions { justify-content: flex-end; border-top: 1px solid var(--line); }
.image-preview-stage {
  min-height: 260px;
  display: grid;
  place-items: center;
  padding: 18px;
  background: #0a0d12;
}
.image-preview-stage img { display: block; max-width: 100%; max-height: calc(100vh - 190px); object-fit: contain; }
.live-refresh-notice {
  position: fixed;
  z-index: 1000;
  right: 22px;
  bottom: 22px;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100vw - 44px);
  padding: 12px 14px 12px 18px;
  border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--line));
  border-radius: 14px;
  color: var(--text);
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}
@media (max-width: 720px) {
  .file-row { align-items: stretch; flex-direction: column; }
  .file-row-actions { justify-content: flex-start; }
  .live-refresh-notice { right: 12px; bottom: 12px; max-width: calc(100vw - 24px); }
}
.danger-zone {
  border-color: rgba(192, 57, 43, .55);
}
.admin-cleanup-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 12px;
}
.admin-cleanup-grid form,
.admin-cleanup-grid button {
  width: 100%;
}
.doc-shell {
  background: #0b0f14;
  min-height: calc(100vh - 56px);
  padding: 24px;
  border-radius: 8px;
}
.doc-page {
  width: min(880px, 100%);
  min-height: 1120px;
  margin: 0 auto;
  padding: 42px;
  background: var(--page);
  color: var(--page-ink);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
  line-height: 1.55;
}
.doc-page p { color: var(--page-ink); }
.letter-head { text-align: center; margin-bottom: 52px; }
.letter-head img { width: 64px; height: auto; margin-bottom: 12px; }
.letter-head h1 { font-size: 18px; }
.letter-head p { margin: 0; color: #70675c; font-size: 13px; }
.letter-meta { display: flex; justify-content: space-between; gap: 24px; margin: 44px 0; }
.right { text-align: right; }
.az-block { text-align: right; color: #8d571b; letter-spacing: .08em; margin: 24px 0; }
.az-block small { display: block; }
.az-block strong { font-family: Consolas, monospace; }
.subject {
  border-left: 0;
  background: transparent;
  padding: 0;
  margin: 20px 0;
}
.subject small { color: #8d571b; letter-spacing: .14em; }
.subject h2 { font-size: 18px; margin: 3px 0 0; }
.doc-token {
  color: var(--page-ink);
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
}
.doc-box {
  border: 0;
  background: transparent;
  border-radius: 0;
  padding: 0;
  margin: 14px 0;
  min-height: 0;
}
.doc-box:focus, .doc-page [contenteditable="true"]:focus {
  outline: 2px solid #e18b31;
}
.doc-actions {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  margin-bottom: 18px;
  background: rgba(10,14,20,.85);
  backdrop-filter: blur(8px);
  border-radius: 8px;
}
.autosave-status {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(126, 150, 180, .08);
  font-size: 13px;
}
.hint { color: var(--muted); font-size: 13px; }
.read-only-panel {
  opacity: .72;
}
.read-only-panel input,
.read-only-panel select,
.read-only-panel textarea {
  background: #131922;
  color: #9fa9b6;
}
.permission-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  margin: 12px 0;
}
.role-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
}
.role-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #121922;
}
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
}
.template-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #121922;
  display: grid;
  gap: 12px;
}
.template-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.template-card h3 { margin: 7px 0 0; }
.template-meta {
  display: flex;
  gap: 7px;
  align-items: center;
  flex-wrap: wrap;
}
.template-badge,
.template-state {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.template-badge {
  color: var(--accent-2);
  background: #241a10;
  border-color: #60422a;
}
.template-state.active {
  color: #90e1a3;
  border-color: #2d6b3d;
  background: #14261a;
}
.template-preview-label {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.template-preview {
  max-height: 220px;
  overflow: auto;
  background: var(--page);
  color: var(--page-ink);
  border-radius: 6px;
  padding: 16px;
  font-size: 13px;
  border: 1px solid #e6d7bd;
}
.template-preview p { color: var(--page-ink); }
.template-home {
  display: grid;
  gap: 18px;
}
.template-guide {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
}
.template-guide-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 8px;
}
.template-guide-grid span {
  display: inline-flex;
  justify-content: center;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(126, 150, 180, .08);
  color: var(--text);
  font-size: 13px;
}
.template-grid-modern {
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
}
.template-card-modern {
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255,255,255,.035), rgba(255,255,255,.015)), #121922;
}
.template-preview-modern {
  max-height: 260px;
}
.template-studio {
  display: grid;
  grid-template-columns: minmax(230px, 280px) minmax(420px, 1fr) minmax(420px, 1fr);
  gap: 16px;
  align-items: start;
}
.template-toolbox,
.template-preview-panel {
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 36px);
  overflow: auto;
  box-shadow: none;
}
.template-preview-panel {
  resize: horizontal;
  min-width: 420px;
  max-width: 100%;
}
.template-tool-section {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}
.template-tool-section h3 {
  margin: 0;
}
.template-tool-section summary {
  cursor: pointer;
  color: var(--text);
  margin: 8px 0;
}
.template-tool-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.template-tool-list button {
  justify-content: flex-start;
  font-size: 13px;
  padding: 8px 9px;
}
.template-workspace {
  display: grid;
  gap: 14px;
  resize: horizontal;
  overflow: auto;
  min-width: 420px;
  max-width: 100%;
}
.template-meta-panel,
.template-editor-toolbar,
.template-savebar {
  box-shadow: none;
}
.template-editor-toolbar {
  position: sticky;
  top: 12px;
  z-index: 7;
}
.template-page-frame {
  width: min(920px, 100%);
  resize: both;
  overflow: auto;
  min-width: 380px;
  min-height: 560px;
}
.template-editor {
  width: 100%;
  min-height: 620px;
  margin: 0;
  box-shadow: none;
  overflow: auto;
}
.template-editor:empty::before {
  content: "Vorlagentext hier einfügen...";
  color: #9b8f80;
}
.template-editor-page {
  width: min(900px, 100%);
  min-height: 980px;
  margin: 0 auto;
  box-shadow: none;
}
.template-mini-page {
  width: 100%;
  min-height: 0;
  height: 620px;
  max-height: none;
  overflow: auto;
  padding: 24px;
  font-size: 12px;
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px #eadcc8;
}
.template-mini-page .letter-head {
  margin-bottom: 24px;
}
.template-block {
  border-left: 0;
  padding: 0;
  margin: 14px 0;
  background: transparent;
}
.template-field {
  cursor: text;
}
.signature-block {
  margin-top: 36px;
  font-weight: 600;
}
.signature-name {
  font-family: "Segoe Script", "Lucida Handwriting", cursive;
  font-size: 16px;
  font-weight: 500;
}
.signature-role {
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 12px;
  font-weight: 600;
}
.address-picker {
  position: absolute;
  z-index: 50;
  width: 240px;
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.address-picker strong {
  color: var(--text);
  font-size: 13px;
}
.address-picker button {
  justify-content: flex-start;
  padding: 8px 9px;
}
.document-address-book {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0 auto 18px;
  width: min(1040px, 100%);
  box-shadow: none;
}
.document-address-book h3,
.document-address-book p {
  margin-bottom: 4px;
}
.aktenzeichen-preview-card {
  display: inline-grid;
  gap: 4px;
  min-width: min(100%, 360px);
  margin: 8px 0 16px;
  padding: 12px 14px;
  border: 1px solid rgba(210, 138, 54, .38);
  border-radius: 14px;
  background: rgba(210, 138, 54, .10);
}
.aktenzeichen-preview-card span {
  color: var(--muted);
  font-size: 12px;
}
.aktenzeichen-preview-card strong {
  color: var(--text);
  font-size: 24px;
}
.connection-panel h3 {
  margin-top: 18px;
}
.connection-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(126, 150, 180, .07);
}
.connection-row form {
  margin: 0;
}
.connection-row strong,
.connection-row span {
  display: block;
}
.connection-row span {
  color: var(--muted);
  font-size: 13px;
}
.participant-row {
  display: grid;
  grid-template-columns: minmax(150px, 210px) minmax(220px, 1fr) auto;
  gap: 8px;
  align-items: center;
}
.connectable-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  max-height: 320px;
  overflow: auto;
}
.case-chat-panel textarea {
  min-height: 90px;
}
.chat-list {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
  max-height: 360px;
  overflow: auto;
}
.chat-message {
  display: grid;
  gap: 4px;
  max-width: 88%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(126, 150, 180, .08);
}
.chat-message.own {
  justify-self: end;
  background: rgba(210, 138, 54, .14);
  border-color: rgba(210, 138, 54, .34);
}
.chat-message span {
  color: var(--muted);
  font-size: 12px;
}
.chat-message p {
  margin: 0;
  color: var(--text);
}
.chat-message-head,
.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}
.section-head { margin-bottom: 14px; }
.section-head h2,
.section-head p { margin: 0; }
.section-head p { margin-top: 5px; color: var(--muted); }
.chat-message.disposition-message {
  width: min(100%, 860px);
  max-width: 100%;
  padding: 14px;
  border-left: 4px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--panel-2));
}
.chat-message.disposition-eilig { border-left-color: var(--warning); }
.chat-message.disposition-sofort { border-left-color: var(--danger); }
.disposition-kind {
  display: inline-block;
  margin-left: 8px;
  color: var(--accent-2) !important;
  font-weight: 800;
}
.disposition-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 12px;
  align-items: center;
  margin-top: 7px;
  color: var(--muted);
}
.disposition-note {
  margin-top: 6px;
  padding: 9px 10px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 70%, transparent);
}
.disposition-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.disposition-actions input { flex: 1 1 240px; min-width: 180px; }
.chat-compose-grid,
.case-template-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.chat-compose-card,
.case-template-columns > section {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--panel-2) 68%, transparent);
}
.chat-compose-card h3,
.case-template-columns h3 { margin: 0 0 10px; }
.compact-grid { gap: 10px; }
.case-representative {
  margin-top: -8px;
  border-color: color-mix(in srgb, var(--success) 44%, var(--line));
  background: color-mix(in srgb, var(--success) 7%, var(--panel-2));
}
.case-representative small { display: block; margin-top: 3px; color: var(--muted); }
.disposition-task-list { display: grid; gap: 10px; }
.disposition-task {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, auto);
  gap: 14px;
  align-items: center;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--panel-2) 72%, transparent);
}
.disposition-task.disposition-eilig { border-left-color: var(--warning); }
.disposition-task.disposition-sofort { border-left-color: var(--danger); }
.disposition-task p { margin: 8px 0 5px; }
.disposition-task small { color: var(--muted); }
.hearing-imminent td:first-child { color: var(--warning); }
.date-picker {
  position: absolute;
  z-index: 80;
  width: 306px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.date-picker-head {
  display: grid;
  grid-template-columns: 36px 36px 1fr 36px 36px;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}
.date-picker-head strong {
  text-align: center;
  text-transform: capitalize;
}
.date-picker-head button,
.date-day {
  padding: 7px;
  border-radius: 10px;
}
.date-weekdays,
.date-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}
.date-weekdays span {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  padding-bottom: 4px;
}
.date-empty {
  min-height: 34px;
}
.date-day {
  min-height: 34px;
  background: rgba(126, 150, 180, .08);
}
.date-day.today {
  border: 1px solid var(--accent);
}
.date-day.selected {
  background: var(--accent);
  color: #1b1208;
  font-weight: 800;
}
.template-syntax-help {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.template-syntax-help code,
.template-guide code {
  color: var(--accent-2);
  background: rgba(126, 150, 180, .12);
  border-radius: 6px;
  padding: 1px 5px;
}
.editor-toolbar {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  margin: 12px 0;
}
.editor-toolbar button,
.editor-toolbar select,
.editor-toolbar input[type="color"],
.editor-toolbar input[type="number"] {
  width: auto;
}
.editor-toolbar .font-size-custom {
  width: 96px;
}
.editor-toolbar [data-font-size] { min-width: 112px; }
.editor-toolbar input[type="color"] {
  min-width: 46px;
  height: 40px;
  padding: 4px;
}
.placeholder-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 10px 0 14px;
}
.delegation-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}
.address-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: rgba(126, 150, 180, .06);
}
.address-row-form {
  display: grid;
  grid-template-columns: 1.2fr 1.4fr .7fr 1fr auto;
  gap: 8px;
  align-items: center;
}
.address-delete-form {
  margin: 0;
}
.address-card {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: rgba(126, 150, 180, .06);
}
.address-card span { color: var(--muted); }
.dashboard-notification-list {
  display: grid;
  gap: 10px;
}
.dashboard-notification {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  background: rgba(126, 150, 180, .07);
}
.dashboard-notification:hover {
  background: var(--panel-2);
  text-decoration: none;
}
.dashboard-notification strong,
.dashboard-notification small,
.dashboard-notification em {
  display: block;
}
.dashboard-notification small {
  color: var(--muted);
  margin-top: 2px;
  font-style: normal;
}
.dashboard-notification em {
  color: var(--muted);
  margin-top: 5px;
  font-style: normal;
}
.dashboard-notification .notification-dot {
  width: 9px;
  height: 9px;
  margin-top: 6px;
  border-radius: 999px;
  background: var(--line);
}
.dashboard-notification.is-unread {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--line));
  background: color-mix(in srgb, var(--danger) 9%, var(--panel));
}
.dashboard-notification.is-unread .notification-dot {
  background: var(--danger);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 16%, transparent);
}

.request-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.request-card {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(126, 150, 180, .07);
}
.request-card span {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}
.representation-green { color: var(--success); font-weight: 700; }
.representation-red { color: var(--expired); font-weight: 700; }

.row-actions {
  display: flex;
  gap: 7px;
  align-items: center;
  flex-wrap: wrap;
}
.row-actions form { margin: 0; }
.status-text {
  font-weight: 800;
  white-space: nowrap;
}
.status-open { color: var(--text); }
.status-progress { color: var(--warning); }
.status-done { color: var(--success); }
.status-mistake { color: var(--mistake); }
.status-expired { color: var(--expired); }
.status-connected { color: #8b5cf6; }
.limitation-badge {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  border-radius: 999px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  font-weight: 800;
  font-size: 12px;
}
.limitation-safe {
  color: var(--success);
  background: rgba(95, 213, 138, .09);
  border-color: rgba(95, 213, 138, .32);
}
.limitation-warning {
  color: var(--warning);
  background: rgba(244, 164, 65, .10);
  border-color: rgba(244, 164, 65, .36);
}
.limitation-danger,
.limitation-expired {
  color: var(--expired);
  background: rgba(255, 107, 107, .10);
  border-color: rgba(255, 107, 107, .36);
}
.limitation-none {
  color: var(--muted);
  background: rgba(126, 150, 180, .08);
}
.timeline {
  display: grid;
  gap: 10px;
}
.timeline-item {
  border-left: 3px solid var(--accent);
  padding: 8px 0 8px 12px;
}
.timeline-item strong { display: block; }
.timeline-item span {
  color: var(--muted);
  font-size: 12px;
}
.timeline-item p { margin: 6px 0 0; }
.reminder-due td {
  background: rgba(244, 164, 65, .08);
}
.reminder-list .reminder-due {
  border-left-color: var(--warning);
  background: rgba(244, 164, 65, .08);
  border-radius: 8px;
}
.theme-toggle {
  width: 100%;
  justify-content: center;
  gap: 8px;
}
.theme-icon {
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  font-size: 15px;
  line-height: 1;
}
.sun-icon {
  color: #facc15;
  text-shadow: 0 0 12px rgba(250, 204, 21, .9);
}
.moon-icon {
  color: #111827;
  text-shadow: none;
}
.role-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 9px;
  color: #fff;
  background: var(--role-color, #2563eb);
  font-weight: 700;
}
.form-card, .cases-panel {
  background: linear-gradient(180deg, color-mix(in srgb, var(--panel) 94%, var(--accent) 6%), var(--panel));
}
.disabled {
  opacity: .6;
  cursor: not-allowed;
}
.version-panel {
  margin-top: 18px;
  box-shadow: none;
}
body[data-theme="light"] .sidebar nav a.active,
body[data-theme="light"] .sidebar nav a:hover {
  color: #0f172a;
}
body[data-theme="light"] .doc-shell {
  background: #dfeaf6;
}
body[data-theme="light"] .doc-actions {
  background: rgba(240, 246, 253, .9);
}
body[data-theme="light"] .template-card,
body[data-theme="light"] .role-card {
  background: rgba(255,255,255,.7);
}

/* JustizDesk cockpit redesign */
.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 282px minmax(0, 1fr);
}
.app-workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}
.app-sidebar {
  position: sticky;
  inset: auto;
  top: 0;
  width: auto;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  padding: 22px 18px 16px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--sidebar-bg) 88%, #102038 12%), var(--sidebar-bg)),
    var(--sidebar-bg);
}
.brand {
  grid-template-columns: 58px minmax(0, 1fr);
  align-items: center;
  justify-items: start;
  gap: 12px;
  margin-bottom: 24px;
}
.brand span {
  line-height: 1.1;
  overflow-wrap: anywhere;
}
.brand img {
  grid-row: 1;
  width: 56px;
  height: 56px;
}
.app-nav {
  gap: 9px;
}
.app-nav a,
.sidebar nav a {
  display: flex;
  grid-template-columns: none;
  gap: 11px;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid transparent;
  white-space: normal;
}
.app-nav a.active,
.app-nav a:hover {
  border-color: color-mix(in srgb, var(--accent) 28%, var(--line));
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--panel-2) 82%, var(--accent) 18%), var(--panel-2));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}
.nav-icon {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 28px;
  border-radius: 9px;
  color: var(--accent-2);
  background: color-mix(in srgb, var(--panel-2) 78%, transparent);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 900;
}
.app-nav a.active .nav-icon,
.app-nav a:hover .nav-icon {
  color: #1b1208;
  background: var(--accent);
  border-color: transparent;
}
.sidebar nav a .nav-key {
  display: none;
}
.sidebar nav a .nav-label {
  flex: 1 1 auto;
  overflow: visible;
  text-overflow: clip;
  font-weight: 700;
}
.sidebar-foot {
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
.sidebar-foot a {
  display: inline-flex;
  width: fit-content;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(260px, 620px) auto auto;
  align-items: center;
  justify-content: end;
  gap: 12px;
  padding: 16px 28px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 78%, transparent);
  backdrop-filter: blur(18px);
}
.top-search {
  width: 100%;
}
.top-search input {
  min-height: 44px;
  border-radius: 999px;
  padding-left: 18px;
  background: color-mix(in srgb, var(--input-bg) 88%, transparent);
}
.topbar-button,
.topbar-profile {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: color-mix(in srgb, var(--panel) 82%, transparent);
}
.topbar-profile:hover,
.topbar-button:hover {
  text-decoration: none;
  background: var(--panel-2);
}
.topbar-profile span {
  display: grid;
  line-height: 1.1;
}
.topbar-profile small {
  color: var(--muted);
}
.app-workspace .main {
  margin-left: 0;
  padding: 26px 30px 44px;
  width: 100%;
}
.main > .page-head:first-child,
.dashboard-head {
  padding: 8px 0 4px;
}
.page-head {
  align-items: center;
}
.page-head h1 {
  font-size: clamp(30px, 3vw, 44px);
  letter-spacing: -.02em;
}
.page-head h2 {
  font-size: clamp(22px, 2vw, 30px);
}
.page-head p {
  margin: 6px 0 0;
}
.panel,
.card {
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.035), rgba(255,255,255,.012)),
    color-mix(in srgb, var(--panel) 96%, var(--accent) 4%);
  box-shadow: 0 14px 45px rgba(0,0,0,.16);
}
body[data-theme="light"] .panel,
body[data-theme="light"] .card {
  background:
    linear-gradient(180deg, rgba(255,255,255,.86), rgba(255,255,255,.72)),
    var(--panel);
}
.grid {
  grid-template-columns: repeat(4, minmax(190px, 1fr));
}
.metric {
  min-height: 112px;
  display: grid;
  align-content: center;
}
.metric span {
  text-transform: uppercase;
  letter-spacing: .07em;
  font-size: 12px;
}
.metric strong {
  font-size: 34px;
  letter-spacing: -.03em;
}
.tabs {
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 2px;
}
.tabs a {
  white-space: nowrap;
  background: color-mix(in srgb, var(--panel-2) 45%, transparent);
}
.tabs a.active {
  border-color: transparent;
  background: var(--accent);
  color: #1b1208;
  font-weight: 800;
}
.table-wrap {
  border-radius: 16px;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
}
th,
td {
  padding: 14px 15px;
}
th {
  text-transform: uppercase;
  letter-spacing: .05em;
  font-size: 11px;
}
tbody tr:last-child td {
  border-bottom: 0;
}
.row-actions {
  min-width: 220px;
}
.button,
button {
  min-height: 40px;
  border-radius: 12px;
  font-weight: 700;
}
.button.primary,
button.primary {
  box-shadow: 0 8px 18px color-mix(in srgb, var(--accent) 24%, transparent);
}
input,
select,
textarea {
  min-height: 42px;
}
.form-grid {
  gap: 16px;
}
.case-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 280px);
  gap: 16px;
  align-items: stretch;
  margin-bottom: 14px;
}
.case-hero-main,
.case-hero-owner,
.case-hero-actions {
  border: 1px solid var(--line);
  border-radius: 22px;
  background:
    radial-gradient(circle at top right, color-mix(in srgb, var(--accent) 16%, transparent), transparent 42%),
    color-mix(in srgb, var(--panel) 95%, var(--accent) 5%);
  box-shadow: var(--shadow);
}
.case-hero-main {
  min-height: 188px;
  padding: 24px;
  display: grid;
  align-content: center;
}
.case-kicker {
  width: fit-content;
  padding: 5px 10px;
  border-radius: 999px;
  color: var(--accent-2);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--line));
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.case-hero h1 {
  margin: 10px 0 4px;
  font-size: clamp(34px, 4vw, 56px);
  letter-spacing: -.03em;
}
.case-hero p {
  margin: 0;
  font-size: 17px;
}
.case-hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
.case-hero-meta > span,
.case-hero-meta .status-text {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  background: color-mix(in srgb, var(--panel-2) 58%, transparent);
}
.case-hero-owner {
  padding: 18px;
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 8px;
}
.case-hero-owner span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .07em;
}
.case-hero-owner strong {
  font-size: 18px;
}
.case-hero-actions {
  grid-column: 1 / -1;
  padding: 12px;
  justify-content: flex-end;
  box-shadow: none;
}
.case-tabs {
  position: sticky;
  top: 77px;
  z-index: 19;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 0 14px;
  margin-bottom: 6px;
  background: linear-gradient(180deg, var(--bg), color-mix(in srgb, var(--bg) 86%, transparent));
}
.case-tabs a {
  flex: 0 0 auto;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: color-mix(in srgb, var(--panel) 78%, transparent);
}
.case-tabs a:hover {
  color: var(--text);
  text-decoration: none;
  background: var(--panel-2);
}
.wide-left {
  grid-template-columns: minmax(560px, 1.15fr) minmax(380px, .85fr);
  align-items: start;
}
.case-data-panel {
  position: static;
  max-height: none;
  overflow: visible;
}
.case-link-summary {
  margin-top: 4px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.case-connections-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 12px 0 16px;
  padding: 13px 14px;
  border: 1px solid color-mix(in srgb, #9b5de5 50%, var(--line));
  border-radius: 14px;
  background: color-mix(in srgb, #9b5de5 8%, var(--panel-2));
}
.case-connections-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.case-connections-summary strong { display: block; margin-top: 3px; }
.status-chip-link:hover { text-decoration: none; filter: brightness(1.15); }
.dashboard-notification-list,
.request-grid,
.links-list,
.stack {
  gap: 12px;
}
.dashboard-notification,
.request-card,
.connection-row,
.file-row,
.address-row,
.case-owner {
  border-radius: 16px;
}
.template-studio {
  grid-template-columns: minmax(230px, 280px) minmax(480px, 1fr) minmax(480px, 1fr);
}
.template-workspace,
.template-preview-panel {
  min-width: min(480px, 100%);
}
.template-preview-panel {
  resize: both;
}
.template-page-frame,
.template-mini-page {
  border-radius: 16px;
}
body[data-theme="light"] .case-tabs {
  background: linear-gradient(180deg, var(--bg), color-mix(in srgb, var(--bg) 86%, transparent));
}
body[data-theme="light"] .case-hero-main,
body[data-theme="light"] .case-hero-owner,
body[data-theme="light"] .case-hero-actions {
  background:
    radial-gradient(circle at top right, color-mix(in srgb, var(--accent) 10%, transparent), transparent 42%),
    rgba(255,255,255,.8);
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar, .app-sidebar { position: static; width: auto; height: auto; max-height: none; }
  .topbar { position: static; grid-template-columns: 1fr; padding: 14px 16px; }
  .main, .app-workspace .main { margin-left: 0; padding: 16px; }
  .grid, .split, .form-grid, .permission-grid, .wide-left, .template-studio, .request-grid, .participant-row, .admin-cleanup-grid { grid-template-columns: 1fr; }
  .case-hero { grid-template-columns: 1fr; }
  .case-hero-actions { grid-column: auto; justify-content: flex-start; }
  .case-tabs, .case-data-panel { position: static; }
  .page-head { display: block; }
  .link-row, .address-row, .address-row-form, .connection-row { grid-template-columns: 1fr; }
  .document-address-book { display: grid; }
  .template-toolbox, .template-preview-panel, .template-editor-toolbar { position: static; max-height: none; }
  .template-guide { display: grid; }
  .template-grid-modern { grid-template-columns: 1fr; }
}

@media print {
  @page { size: A4; margin: 0; }
  html, body { background: #fff !important; }
  body * { visibility: hidden !important; }
  .doc-page, .doc-page * { visibility: visible !important; }
  .sidebar,
  .doc-actions,
  .flash,
  .editor-toolbar,
  .document-address-book,
  .address-picker,
  .date-picker,
  .autosave-status,
  .panel:not(.doc-page) {
    display: none !important;
  }
  .main { margin: 0 !important; padding: 0 !important; }
  .doc-shell { background: #fff !important; padding: 0 !important; display: block !important; }
  .doc-page {
    position: static !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    border: 0 !important;
    width: 210mm !important;
    min-height: 297mm !important;
    margin: 0 !important;
    padding: 20mm !important;
    background: #fff !important;
  }
}

/* Navigation, dialogs and workflow refinements */
.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}
.nav-icon svg,
.sidebar-collapse svg,
.topbar-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.app-sidebar .brand {
  position: relative;
  grid-template-columns: 52px minmax(0, 1fr) 34px;
  width: 100%;
}
.app-sidebar .brand img { width: 50px; height: 50px; }
.sidebar-collapse {
  min-height: 34px;
  width: 34px;
  padding: 6px;
  border-radius: 10px;
  color: var(--muted);
}
.app-nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
}
.nav-section-label {
  display: block;
  padding: 16px 11px 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
}
.nav-icon svg { width: 17px; height: 17px; }
.sidebar-foot { flex: 0 0 auto; }
.mobile-menu-button { display: none; }
.topbar { position: sticky; grid-template-columns: minmax(280px, 680px) auto; }
.top-search { position: relative; }
.global-search-results {
  position: absolute;
  z-index: 80;
  inset: calc(100% + 8px) 0 auto 0;
  max-height: min(520px, 65vh);
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: color-mix(in srgb, var(--panel) 96%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.global-search-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px 12px;
  padding: 11px 12px;
  border-radius: 11px;
  color: var(--text);
}
.global-search-result:hover,
.global-search-result.is-active { background: var(--panel-2); text-decoration: none; }
.global-search-result strong { color: var(--accent-2); }
.global-search-result span,
.global-search-result small { color: var(--muted); }
.topbar-profile { cursor: pointer; font: inherit; }
.profile-menu {
  position: fixed;
  z-index: 90;
  top: 70px;
  right: 28px;
  width: min(280px, calc(100vw - 32px));
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.profile-menu:not([hidden]) { display: grid; gap: 9px; }
.profile-menu > span { color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.profile-menu a { padding: 8px 4px; color: var(--text); }
.profile-menu .logout-link { color: var(--expired); border-top: 1px solid var(--line); margin-top: 4px; }
.skip-link {
  position: fixed;
  z-index: 200;
  top: -80px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 14px;
  border-radius: 0 0 10px 10px;
  color: #111;
  background: var(--accent);
}
.skip-link:focus { top: 0; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 75%, white); outline-offset: 3px; }

.app-shell.sidebar-collapsed { grid-template-columns: 86px minmax(0, 1fr); }
.sidebar-collapsed .app-sidebar { padding-inline: 13px; }
.sidebar-collapsed .app-sidebar .brand { grid-template-columns: 1fr; justify-items: center; }
.sidebar-collapsed .app-sidebar .brand img,
.sidebar-collapsed .app-sidebar .brand > span,
.sidebar-collapsed .nav-label,
.sidebar-collapsed .nav-section-label,
.sidebar-collapsed .gta-countdown,
.sidebar-collapsed .sidebar-clock,
.sidebar-collapsed .theme-toggle [data-theme-label] { display: none; }
.sidebar-collapsed .sidebar-collapse { display: inline-grid; }
.sidebar-collapsed .app-nav a { justify-content: center; padding-inline: 7px; }
.sidebar-collapsed .sidebar-foot { justify-items: center; }
.sidebar-collapsed .theme-toggle { width: 44px; padding-inline: 8px; }

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: fit-content;
  min-height: 28px;
  padding: 4px 9px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  background: color-mix(in srgb, currentColor 8%, transparent);
}
thead th { position: sticky; top: 0; z-index: 2; background: var(--panel-2); }
.case-hero h1 { font-size: clamp(30px, 3vw, 42px); }
.case-hero-main { min-height: 150px; }
.case-hero-actions { position: sticky; top: 76px; z-index: 23; backdrop-filter: blur(16px); }
.case-tabs { top: 140px; }
.case-tabs a.active { color: #1b1208; border-color: transparent; background: var(--accent); font-weight: 800; }
.tab-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; margin-left: 4px; padding: 0 5px; border-radius: 999px; color: inherit; background: color-mix(in srgb, currentColor 12%, transparent); font-size: 11px; }
.case-tab-mode { display: block; }
.case-tab-mode > .stack { display: contents; }
.case-tab-mode .panel:not([hidden]) { width: 100%; }
.read-only-panel input:disabled,
.read-only-panel select:disabled,
.read-only-panel textarea:disabled {
  opacity: 1;
  color: var(--text);
  border-color: transparent;
  background: transparent;
  padding-inline: 0;
  resize: none;
  -webkit-text-fill-color: var(--text);
}

.app-dialog {
  width: min(560px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--text);
  background: var(--panel);
  box-shadow: 0 30px 100px rgba(0,0,0,.55);
}
.app-dialog::backdrop { background: rgba(3, 7, 12, .72); backdrop-filter: blur(4px); }
.investigation-import-toolbar { display: flex; gap: 8px; flex-wrap: wrap; }
.investigation-import-toolbar input { flex: 1 1 280px; min-width: 0; }
.investigation-import-toolbar button { flex: 0 0 auto; }
.investigation-import-dialog { width: min(760px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; }
.investigation-import-content { padding: 20px; min-width: 0; }
.import-field { padding: 14px 0; border-top: 1px solid var(--border); }
.import-field textarea { width: 100%; margin-top: 8px; resize: vertical; }
.import-warnings, .import-existing { overflow-wrap: anywhere; }
.import-warnings { padding-left: 20px; }
.import-existing { font-size: 13px; }
.investigation-import-dialog .app-dialog-actions { flex-wrap: wrap; }
.app-dialog-card { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 14px; padding: 22px; }
.app-dialog-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: var(--accent-2);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  font-size: 22px;
  font-weight: 900;
}
.app-dialog-icon.is-danger { color: var(--expired); background: color-mix(in srgb, var(--danger) 14%, transparent); }
.app-dialog-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 9px; margin-top: 4px; }
.sticky-save-bar {
  position: sticky;
  z-index: 12;
  bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line));
  border-radius: 14px;
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}
button.compact { min-height: 34px; padding: 7px 10px; }
.metric-link { color: var(--text); position: relative; overflow: hidden; }
.metric-link:hover { text-decoration: none; transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 48%, var(--line)); }
.metric-link small { color: var(--muted); margin-top: 7px; }
.metric-link::after { content: "›"; position: absolute; right: 16px; top: 16px; color: var(--muted); font-size: 24px; }
.metric-alert { border-color: color-mix(in srgb, var(--warning) 55%, var(--line)); }
.dashboard-cockpit {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(340px, .85fr);
  grid-template-areas:
    "urgent urgent"
    "hearings hearings"
    "dispositions dispositions"
    "requests notices"
    "reminders notices"
    "activities activities"
    "all all";
  gap: 18px;
}
.dashboard-cockpit > section { margin-top: 0 !important; min-width: 0; }
.dashboard-limitations { grid-area: urgent; }
.dashboard-hearings { grid-area: hearings; }
.dashboard-dispositions { grid-area: dispositions; }
.dashboard-requests { grid-area: requests; }
.dashboard-reminders { grid-area: reminders; }
.dashboard-notifications { grid-area: notices; }
.dashboard-activities { grid-area: activities; }
.dashboard-all-limitations { grid-area: all; }
.limitation-table {
  table-layout: fixed;
}
.limitation-table th,
.limitation-table td {
  padding: 11px 10px;
  overflow-wrap: anywhere;
}
.limitation-table th:nth-child(1) { width: 12%; }
.limitation-table th:nth-child(2) { width: 16%; }
.limitation-table th:nth-child(3) { width: 20%; }
.limitation-table th:nth-child(4),
.limitation-table th:nth-child(5) { width: 13%; }
.limitation-table th:nth-child(6) { width: 17%; }
.limitation-table th:nth-child(7) { width: 9%; }
.limitation-table .assigned-user {
  min-width: 0;
}
.limitation-table .assigned-user span {
  min-width: 0;
  white-space: normal;
}
.limitation-table .button {
  min-height: 34px;
  padding: 7px 9px;
}
.activity-list { display: grid; gap: 4px; }
.activity-item { display: grid; grid-template-columns: 12px minmax(0, 1fr); gap: 10px; align-items: start; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.activity-item:last-child { border-bottom: 0; }
.activity-item small { display: block; color: var(--muted); margin-top: 3px; }
.activity-dot { width: 9px; height: 9px; margin-top: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 12%, transparent); }
.filter-chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 12px; }
.filter-chip { display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto; padding: 7px 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--text); background: color-mix(in srgb, var(--panel-2) 48%, transparent); font-size: 13px; }
.filter-chip:hover { text-decoration: none; border-color: var(--accent); }
.filter-chip span { min-width: 20px; height: 20px; display: inline-grid; place-items: center; border-radius: 999px; background: var(--panel-2); font-size: 11px; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 14px; padding-top: 16px; color: var(--muted); }
.cases-panel td:first-child { font-weight: 850; color: var(--accent-2); white-space: nowrap; }

@media (max-width: 1100px) {
  .dashboard-cockpit { grid-template-columns: 1fr; grid-template-areas: "urgent" "hearings" "dispositions" "requests" "notices" "reminders" "activities" "all"; }
}
@media (max-width: 900px) {
  .app-shell { display: block; }
  .app-sidebar {
    position: fixed;
    z-index: 120;
    inset: 0 auto 0 0;
    width: min(310px, 88vw);
    height: 100dvh;
    padding: 18px;
    transform: translateX(-105%);
    transition: transform .2s ease;
  }
  body.sidebar-mobile-open .app-sidebar { transform: translateX(0); }
  .app-sidebar .brand { grid-template-columns: 50px minmax(0, 1fr) 34px; justify-items: start; }
  .app-sidebar .brand img,
  .app-sidebar .brand > span,
  .app-sidebar .nav-label,
  .app-sidebar .nav-section-label,
  .app-sidebar .sidebar-clock,
  .app-sidebar .theme-toggle [data-theme-label] { display: flex; }
  .app-sidebar .app-nav a { justify-content: flex-start; padding-inline: 11px; }
  .app-sidebar .gta-countdown { display: grid; }
  .mobile-menu-button { display: inline-flex; }
  .topbar { position: sticky; grid-template-columns: auto minmax(0, 1fr) auto; padding: 10px 12px; }
  .topbar-profile span { display: none; }
  .app-workspace .main { padding: 16px 12px 34px; }
  .profile-menu { right: 12px; top: 64px; }
  .sticky-save-bar { align-items: stretch; flex-direction: column; }
  .case-connections-summary { align-items: flex-start; flex-direction: column; }
  .chat-compose-grid,
  .case-template-columns,
  .disposition-task { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
