:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #111827;
  --muted: #667085;
  --primary: #111827;
  --action-blue: #1e408f;
  --action-blue-dark: #17336f;
  --acg-gray: #a3a5a7;
  --save-green: #176b55;
  --save-green-dark: #125844;
  --border: #dfe5ef;
  --border-soft: #edf1f6;
  --soft: #f8fafc;
  --blue-soft: #eef3ff;
  --warn-soft: #fff7ed;
  --ok-soft: #eaf8ee;
  --danger-soft: #fff1f1;
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 9px;
  --shadow-card: 0 14px 38px rgba(15, 23, 42, .055);
  --shadow-modal: 0 24px 80px rgba(15, 23, 42, .22);
  --font-main: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  overflow: hidden;
}

body {
  position: relative;
  margin: 0;
  height: 100%;
  overflow: hidden;
  background:
    linear-gradient(180deg, #f8fafc 0%, var(--bg) 420px);
  color: var(--text);
  font-family: var(--font-main);
  font-size: 14px;
}

.layout {
  position: relative;
  z-index: 1;
  height: 100vh;
  overflow: hidden;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2,
h3 {
  line-height: 1.1;
}

h1 {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -.05em;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

h2,
h3 {
  letter-spacing: -.04em;
}

h2 {
  font-size: 18px;
  font-weight: 900;
}

h3 {
  font-size: 16px;
  font-weight: 900;
}

button {
  min-height: 38px;
  border: 0;
  border-radius: 13px;
  padding: 9px 14px;
  background: var(--primary);
  color: #fff;
  font: inherit;
  font-weight: 850;
  line-height: 1.1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  transition: transform .14s ease, box-shadow .14s ease, opacity .14s ease, background .14s ease;
}

button:hover {
  transform: translateY(-1px);
  opacity: .95;
}

button.secondary {
  background: #fff;
  color: var(--primary);
  border: 1px solid var(--border);
}

button.new-moc-button {
  background: linear-gradient(135deg, var(--action-blue) 0%, #526da7 100%);
  color: #fff;
  box-shadow: inset 4px 0 0 var(--acg-gray), inset 0 -1px 0 rgba(0, 0, 0, .08);
}

button.new-moc-button:hover {
  background: var(--action-blue-dark);
}

.refresh-button {
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  border-radius: 10px;
  background: #fff;
  color: var(--primary);
  border: 1px solid var(--border);
  font-size: 18px;
  line-height: 1;
}

label {
  display: block;
  color: var(--text);
  font-size: 12px;
  font-weight: 850;
  line-height: 1.2;
}

input,
select,
textarea {
  width: 100%;
  height: 40px;
  min-height: 40px;
  margin-top: 6px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #fff;
  padding: 8px 11px;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 760;
  line-height: 1.2;
}

select {
  appearance: auto;
}

input:disabled {
  color: var(--text);
  background: #fff;
  opacity: 1;
}

textarea {
  height: auto;
  min-height: 88px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #dbeafe;
  border-color: #93c5fd;
}

.layout {
  display: grid;
  grid-template-columns: 210px 1fr;
}

.sidebar {
  background: #fff;
  border-right: 1px solid var(--border);
  padding: 18px 12px;
  min-height: 0;
  overflow-y: auto;
}

.brand-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 20px;
}

.brand-row .brand {
  margin-bottom: 0;
}

.brand strong {
  display: block;
  font-size: 28px;
  font-weight: 950;
  letter-spacing: -.06em;
  line-height: 1;
}

.brand span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-weight: 700;
  font-size: 14px;
}

.sidebar-toggle {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  font-size: 20px;
  font-weight: 850;
  line-height: 1;
}

.sidebar nav {
  display: grid;
  gap: 5px;
}

#yearNav {
  display: grid;
  gap: 6px;
}

.sidebar a {
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
  font-size: 14px;
  line-height: 1.2;
}

.sidebar a:hover {
  background: var(--soft);
}

.sidebar a.active {
  background: #111827;
  color: #fff;
  box-shadow: inset 4px 0 0 #f2b800;
}

.sidebar a.active:hover {
  background: #111827;
  color: #fff;
}

.sidebar hr {
  width: 100%;
  border: 0;
  border-top: 1px solid var(--border);
  margin: 12px 0;
}

.main {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 18px 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.main::after {
  content: none;
}

.topbar,
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  position: relative;
  flex: 0 0 auto;
  margin-bottom: 16px;
  overflow: visible;
}

.topbar::before {
  content: none;
}

.topbar,
.card,
footer {
  position: relative;
  z-index: 1;
}

.subline {
  margin-top: 6px;
  color: var(--muted);
  font-weight: 750;
}

.topbar-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar-tools input[type="search"] {
  width: min(420px, 32vw);
  height: 44px;
  border-radius: 16px;
  padding: 0 16px;
  font-weight: 750;
}

.card {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
}

.card + .card {
  margin-top: 14px;
}

.stats {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.stat {
  min-height: 70px;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 12px 14px;
  background: var(--card);
  box-shadow: var(--shadow-card);
}

.stat span {
  display: block;
  min-height: 22px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
  line-height: 1.15;
  text-transform: uppercase;
}

.stat strong {
  display: block;
  margin-top: 4px;
  font-size: 25px;
  line-height: 1;
  letter-spacing: -.05em;
}

.sidebar-stats {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
  margin: 16px 0 0;
}

.sidebar-stats .stat {
  min-height: 0;
  padding: 8px 10px;
  border-radius: 10px;
  box-shadow: none;
}

.sidebar-stats .stat span {
  min-height: 0;
  font-size: 9px;
  letter-spacing: .05em;
}

.sidebar-stats .stat strong {
  font-size: 19px;
}

.sidebar .nav-export {
  color: #0f2b56;
  background: #eef4ff;
  border-color: #cfe0ff;
}

.sidebar-version {
  margin-top: 14px;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  line-height: 1.2;
}

.quick-grid,
.edit-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
  align-items: end;
  margin-top: 10px;
}

.quick-grid .full,
.edit-grid .full {
  grid-column: 1 / -1;
}

.quick-actions,
.edit-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.quick-actions {
  margin-top: 8px;
}

.edit-actions {
  margin-top: 18px;
}

.form-error {
  margin-bottom: 14px;
  padding: 11px 13px;
  border: 1px solid #fdba74;
  border-radius: 12px;
  background: #fff7ed;
  color: #9a3412;
  font-size: 13px;
  font-weight: 850;
}

.edit-actions button[type="submit"],
.quick-actions button[type="submit"],
.warn-actions button:not(.secondary):not(.warning) {
  background: var(--save-green);
}

.edit-actions button[type="submit"]:hover,
.quick-actions button[type="submit"]:hover,
.warn-actions button:not(.secondary):not(.warning):hover {
  background: var(--save-green-dark);
}

.inline-message {
  color: #9a3412;
  font-size: 12px;
  font-weight: 850;
}

.table-shell {
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 0;
  max-height: none;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
}

.moc-table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 11px;
}

th,
td {
  border-bottom: 1px solid var(--border-soft);
  padding: 7px 8px;
  text-align: left;
  vertical-align: middle;
  line-height: 1.25;
  overflow-wrap: break-word;
}

th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--soft);
  color: var(--text);
  padding: 8px 9px;
  font-size: 12px;
  font-weight: 950;
  white-space: nowrap;
  line-height: 1.12;
}

tbody tr:nth-child(even) {
  background: #fbfcfe;
}

tbody tr:hover {
  background: var(--blue-soft);
}

.overview-row {
  cursor: pointer;
}

.overview-row.is-completed {
  opacity: .58;
  background: #f8fafc;
}

.overview-row.is-completed:hover {
  opacity: .78;
  background: #f1f5f9;
}

.overview-row.is-completed td {
  color: #64748b;
}

.moc-table th:nth-child(1) { width: 118px; }
.moc-table th:nth-child(2) { width: auto; }
.moc-table th:nth-child(3) { width: 100px; }
.moc-table th:nth-child(4) { width: 112px; }
.moc-table th:nth-child(5) { width: 88px; }
.moc-table th:nth-child(6),
.moc-table th:nth-child(7),
.moc-table th:nth-child(8),
.moc-table th:nth-child(9) { width: 72px; }
.moc-table th:nth-child(10) { width: 76px; }
.moc-table th:nth-child(11) { width: 48px; }

.moc-id,
.moc-table th:nth-child(1) {
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: keep-all;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 96px;
  min-height: 22px;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--soft);
  font-size: 10px;
  font-weight: 900;
  line-height: 1.1;
}

.badge.pce-level-1,
.badge.anpassung-offen {
  background: #fff1e6;
  color: #c2410c;
  border-color: #fed7aa;
}

.badge.pce-level-2,
.badge.abgeschlossen,
.badge.erledigt {
  background: #eaf8ee;
  color: #137333;
  border-color: #bce7c8;
}

.badge.info,
.badge.news {
  background: #eef3ff;
  color: #0b4db3;
  border-color: #bcd2ff;
}

.traffic-chip,
.status-chip {
  min-height: 24px;
  width: 100%;
  padding: 3px 7px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
  color: var(--muted);
  box-shadow: none;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  gap: 5px;
}

.traffic-chip:hover,
.status-chip:hover {
  transform: none;
  opacity: 1;
  background: var(--soft);
}

.traffic-chip.locked,
.status-chip.locked,
.traffic-chip:disabled,
.status-chip:disabled {
  cursor: default;
  opacity: .72;
  filter: grayscale(.15);
}

.traffic-chip.selected,
.status-chip.selected {
  transform: none;
  box-shadow: 0 0 0 3px rgba(17, 24, 39, .12);
}

.edit-toggle .traffic-chip:not(.selected),
.edit-toggle .status-chip:not(.selected) {
  opacity: .48;
  background: #fff;
  color: #94a3b8;
}

.edit-toggle .traffic-chip.selected,
.edit-toggle .status-chip.selected {
  border-width: 2px;
  font-weight: 950;
}

.edit-toggle .traffic-chip.selected.erforderlich,
.edit-toggle .status-chip.selected.in-arbeit {
  background: #ffedd5;
  color: #9a3412;
  border-color: #f97316;
}

.edit-toggle .traffic-chip.selected.erledigt {
  background: #dcfce7;
  color: #166534;
  border-color: #16a34a;
}

.edit-toggle .traffic-chip.selected.nr,
.edit-toggle .status-chip.selected.abgeschlossen {
  background: #e2e8f0;
  color: #334155;
  border-color: #64748b;
}

.traffic-chip span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
  flex: 0 0 auto;
}

.traffic-chip.erforderlich {
  background: #fff7ed;
  color: #9a3412;
  border-color: #fed7aa;
}

.traffic-chip.erforderlich span {
  background: #f97316;
}

.traffic-chip.erledigt {
  background: #eaf8ee;
  color: #137333;
  border-color: #bce7c8;
}

.traffic-chip.erledigt span {
  background: #16a34a;
}

.traffic-chip.nr {
  background: #f8fafc;
  color: #64748b;
}

.traffic-chip.nr span {
  background: #94a3b8;
}

.status-chip.in-arbeit {
  background: #fff7ed;
  color: #9a3412;
  border-color: #fed7aa;
}

.status-chip.abgeschlossen {
  background: #f1f5f9;
  color: #64748b;
  border-color: #cbd5e1;
}

.quick-grid input,
.quick-grid select {
  height: 44px;
  min-height: 44px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 850;
}

.quick-traffic {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--soft);
}

.upload-line input[type="file"],
.upload-form input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-line {
  position: relative;
}

.file-picker-ui {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  margin-top: 6px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
}

.quick-drop-zone .file-picker-ui,
.upload-line .file-picker-ui {
  transition: border-color .16s ease, background .16s ease, box-shadow .16s ease;
}

.quick-drop-zone.is-dragging .file-picker-ui,
.upload-line.is-dragging .file-picker-ui {
  border-color: var(--action-blue);
  background: #f4f7ff;
  box-shadow: inset 0 0 0 2px rgba(30, 64, 143, .12);
}

.file-picker-button {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 12px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}

.file-picker-label {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.static-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 44px;
  min-height: 44px;
  margin-top: 6px;
  font-size: 15px;
}

.active-filter {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.detail-section,
.edit-box {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--soft);
  padding: 10px;
}

.detail-section h3 {
  margin-bottom: 10px;
}

.detail-section .muted {
  display: block;
  margin-bottom: 14px;
}

.detail-section button {
  margin-top: 10px;
}

.detail-section button + button {
  margin-left: 8px;
}

.edit-box {
  background: #fff;
}

.edit-top-grid {
  display: flex !important;
  gap: 10px;
  align-items: stretch !important;
}

.edit-section {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-width: 0;
  min-height: 265px;
  align-self: stretch;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #f8fafc;
}

.edit-section + .edit-section {
  margin-top: 0;
}

.edit-section h3 {
  margin-bottom: 7px;
  color: var(--text);
  font-size: 14px;
}

.edit-grid.compact {
  grid-template-columns: 1fr 1fr;
  align-content: start;
}

.edit-grid.status-grid {
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: stretch;
}

.status-section {
  padding: 10px;
  display: flex;
  flex-direction: column;
}

.status-section .status-grid {
  flex: 1;
  align-content: start;
}

.status-bottom {
  margin-top: auto;
  padding-top: 7px;
  border-top: 1px solid var(--border);
}

.status-section .edit-toggle .traffic-chip,
.status-section .edit-toggle .status-chip {
  height: 28px;
  min-height: 28px;
  font-size: 10px;
}

.field-block label {
  margin-bottom: 4px;
}

.edit-toggle {
  min-height: 34px;
}

.traffic-group,
.status-toggle {
  display: grid;
  gap: 6px;
}

.traffic-group {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.status-toggle {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.edit-toggle .traffic-chip,
.edit-toggle .status-chip {
  height: 40px;
  min-height: 40px;
  font-size: 11px;
}

.field-block {
  flex: 0 0 auto;
}

.title-compact {
  min-height: 40px;
  max-height: none;
  padding-right: 46px;
  font-size: 13px;
  resize: none;
  overflow: hidden;
}

.edit-grid.compact label {
  margin-bottom: 4px;
}

.edit-grid.compact input,
.edit-grid.compact select,
.edit-grid.compact textarea,
.edit-grid.compact .date-picker-button {
  height: 34px;
  min-height: 34px;
  margin-top: 4px;
  padding: 6px 10px;
  font-size: 12px;
}

.doc-link {
  min-height: 24px;
  width: 100%;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
  color: var(--primary);
  font-size: 10px;
  font-weight: 900;
}

.upload-form {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.related-select {
  height: 40px;
  min-height: 40px;
  margin-top: 0;
  padding: 8px;
  font-size: 12px;
  font-weight: 760;
}

.related-field {
  display: grid;
  grid-template-rows: 30px 40px;
  gap: 8px;
  align-self: start;
  min-height: 78px;
  margin-top: 0;
}

.compact-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  margin-top: 0;
  font-size: 12px;
  font-weight: 900;
}

.compact-check input {
  width: 17px;
  height: 17px;
  min-height: 17px;
  margin: 0;
  accent-color: var(--save-green);
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 14px;
}

.copy-field {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  align-items: stretch;
  gap: 8px;
}

.copy-field input,
.copy-field textarea {
  padding-right: 10px;
  margin-top: 0;
  height: 46px;
  min-height: 46px;
}

.copy-field textarea.title-compact {
  line-height: 24px;
  padding-top: 11px;
  padding-bottom: 11px;
}

.copy-field input[readonly] {
  background: var(--soft);
}

.copy-button {
  position: static;
  width: 44px;
  min-width: 44px;
  height: 46px;
  min-height: 46px;
  margin: 0;
  padding: 0;
  border: 1px solid #c7d2e4;
  border-radius: 9px;
  background: #f4f7fb;
  color: #475467;
  font-size: 15px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .65);
}

.copy-button:hover {
  background: #eaf0f8;
  border-color: #b8c5d8;
  color: var(--action-blue);
}

.copy-button:hover {
  transform: none;
}

.category-field select {
  font-size: 13px;
}

.date-field {
  position: relative;
}

.date-picker-button {
  width: 100%;
  height: 40px;
  min-height: 40px;
  margin-top: 6px;
  padding: 8px 11px;
  justify-content: space-between;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(180deg, #fff 0%, #f8fafc 100%);
  color: var(--text);
  font-size: 13px;
  font-weight: 850;
}

.date-picker-button strong {
  color: var(--muted);
  font-size: 12px;
}

.date-picker-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 1800;
  width: 286px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow-modal);
}

.date-picker-head,
.date-picker-weekdays,
.date-picker-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  align-items: center;
}

.date-picker-head {
  grid-template-columns: 34px 1fr 34px;
  margin-bottom: 10px;
}

.date-picker-head strong {
  text-align: center;
  font-size: 14px;
  font-weight: 900;
}

.date-picker-head button,
.date-picker-days button {
  min-height: 30px;
  padding: 0;
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  font-size: 12px;
}

.date-picker-head button {
  border: 1px solid var(--border);
  color: var(--muted);
}

.date-picker-weekdays {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  text-align: center;
}

.date-picker-days button {
  border: 0;
  font-weight: 800;
}

.date-picker-days button:hover {
  background: var(--blue-soft);
}

.date-picker-days .muted-day {
  color: #cbd5e1;
}

.date-picker-days .selected-day {
  background: var(--primary);
  color: #fff;
}

.date-picker-today {
  width: 100%;
  min-height: 32px;
  margin-top: 10px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--blue-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
}

.date-picker-today:hover {
  background: #e0e8ff;
}

.itat-entry {
  display: grid;
  grid-template-columns: 1fr 1fr 100px 86px;
  gap: 12px;
  align-items: start;
  margin: 12px 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
}

.itat-delete {
  min-height: 40px;
  margin-top: 19px;
  padding: 7px 10px;
  border: 1px solid #fecdca;
  background: #fff;
  color: #b42318;
  font-size: 12px;
}

.itat-entry.done {
  opacity: .55;
  background: #f8fafc;
}

.itat-entry.done textarea {
  color: #64748b;
  background: #f1f5f9;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  margin-top: 19px;
}

.checkbox-line input {
  width: 18px;
  min-height: 18px;
  margin: 0;
}

.document-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}

.document-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.document-section-head h3 {
  margin: 0;
}

.document-drop-zone {
  transition: border-color .16s ease, background .16s ease, box-shadow .16s ease;
}

.document-drop-zone.is-dragging {
  border-color: var(--action-blue);
  background: #f4f7ff;
  box-shadow: inset 0 0 0 2px rgba(30, 64, 143, .14);
}

.document-name {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
}

.document-name strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-name span {
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
}

.document-actions {
  display: grid;
  grid-template-columns: repeat(3, 36px);
  gap: 6px;
}

.doc-action {
  box-sizing: border-box;
  justify-content: center;
  height: 34px;
  min-height: 34px;
  width: 36px;
  min-width: 36px;
  margin: 0 !important;
  padding: 0;
  border-radius: 9px;
  font-size: 17px;
  font-weight: 850;
  line-height: 1;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--border);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  appearance: none;
  transform: none;
}

.doc-action:hover {
  transform: none;
}

.rename-modal-box {
  max-width: 680px;
}

.rename-form {
  display: grid;
  gap: 20px;
}

.rename-form input {
  width: 100%;
}

.doc-action:hover {
  color: var(--ink);
  border-color: #c8d2e2;
}

.doc-action.danger {
  color: #991b1b;
  border-color: #fecaca;
  background: #fff7f7;
}

.muted {
  color: var(--muted);
  font-weight: 750;
}

.warn-text {
  color: #b45309;
  font-weight: 850;
}

.ok-text {
  color: #15803d;
  font-weight: 850;
}

.hidden {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 52px 24px 24px;
  background: rgba(15, 23, 42, .45);
}

.modal.open {
  display: flex;
}

.modal-box {
  width: min(760px, 100%);
  max-height: calc(100vh - 76px);
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: #fff;
  box-shadow: var(--shadow-modal);
  padding: 24px;
}

.detail-modal {
  align-items: flex-start;
  justify-content: center;
  padding: 28px 28px 22px;
}

.detail-modal-box {
  width: min(1180px, calc(100vw - 96px));
  max-height: calc(100vh - 56px);
  padding: 0 14px 14px;
  position: relative;
}

.detail-modal .card-header {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: 0 -14px 10px;
  padding: 14px 18px 14px 18px;
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  background: #fff;
  box-shadow: 0 10px 18px rgba(255, 255, 255, .98), 0 1px 0 var(--border-soft);
  backdrop-filter: blur(10px);
}

.detail-modal .card-header h2 {
  line-height: 1.2;
}

.detail-modal.is-dirty .detail-modal-box {
  box-shadow: var(--shadow-modal), 0 0 0 3px rgba(249, 115, 22, .22);
}

.icon-close {
  width: 40px;
  min-width: 40px;
  padding: 0;
  font-size: 18px;
}

.detail-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.save-header-button {
  height: 36px;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid #b7e4cf;
  background: #eaf8f1;
  color: #176b55;
}

.save-header-button:hover {
  background: #ddf3e8;
  color: #125844;
}

.detail-floating-close {
  width: 36px;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .18);
}

.warn-modal {
  z-index: 1500;
  align-items: center;
  padding-top: 24px;
  background: rgba(15, 23, 42, .34);
}

.warn-box {
  width: min(560px, calc(100vw - 32px));
  border-color: #fed7aa;
  background: #fffbf5;
  box-shadow: var(--shadow-modal), 0 0 0 3px rgba(249, 115, 22, .16);
}

.warn-box h2 {
  color: #9a3412;
}

.warn-box p {
  margin-top: 10px;
  color: #7c2d12;
  font-size: 15px;
  font-weight: 720;
  line-height: 1.4;
}

.warn-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
  flex-wrap: wrap;
}

button.warning {
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #fdba74;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 1600;
  display: none;
  min-width: 280px;
  max-width: min(560px, calc(100vw - 28px));
  padding: 13px 16px;
  transform: translateX(-50%);
  border: 1px solid #abefc6;
  border-radius: var(--radius-md);
  background: #ecfdf3;
  color: #067647;
  box-shadow: var(--shadow-modal);
  text-align: center;
  font-weight: 780;
}

.toast.show {
  display: block;
}

.toast.error {
  border-color: #fecdca;
  background: var(--danger-soft);
  color: #b42318;
}

footer {
  padding: 16px 4px 0;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.layout.sidebar-collapsed {
  grid-template-columns: 58px 1fr;
}

.layout.sidebar-collapsed .sidebar {
  padding: 14px 8px;
}

.layout.sidebar-collapsed .brand span,
.layout.sidebar-collapsed .sidebar nav a,
.layout.sidebar-collapsed .sidebar hr {
  display: none;
}

.layout.sidebar-collapsed .sidebar-stats {
  display: none;
}

.layout.sidebar-collapsed .sidebar-version {
  display: none;
}

.layout.sidebar-collapsed .brand strong {
  font-size: 18px;
  letter-spacing: 0;
}

.layout.sidebar-collapsed .brand-row {
  display: grid;
  gap: 8px;
  justify-items: center;
}

.layout.sidebar-collapsed .sidebar-toggle {
  transform: rotate(180deg);
}

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

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .main {
    padding: 16px;
  }

  .topbar,
  .card-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-tools,
  .topbar-tools input[type="search"] {
    width: 100%;
  }

  .edit-top-grid {
    flex-direction: column;
  }

  .quick-grid,
  .quick-traffic,
  .edit-grid,
  .edit-grid.compact,
  .edit-grid.status-grid,
  .detail-grid,
  .itat-entry {
    grid-template-columns: 1fr;
  }
}

/* Detail-form alignment overrides kept last to win over older compact rules. */
.related-field {
  display: grid !important;
  grid-template-rows: 30px 40px !important;
  gap: 8px !important;
  min-height: 78px !important;
}

.related-field .compact-check {
  position: static !important;
  grid-row: 1 !important;
  align-self: center !important;
}

.related-field .related-select {
  position: static !important;
  grid-row: 2 !important;
  align-self: end !important;
  margin-top: 0 !important;
}

.copy-field {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) 44px !important;
  align-items: stretch !important;
  gap: 8px !important;
}

.copy-field input,
.copy-field textarea,
.copy-field textarea.title-compact {
  height: 46px !important;
  min-height: 46px !important;
  margin-top: 0 !important;
  padding-top: 11px !important;
  padding-bottom: 11px !important;
  line-height: 24px !important;
}

.copy-button {
  position: static !important;
  width: 44px !important;
  min-width: 44px !important;
  height: 46px !important;
  min-height: 46px !important;
  margin: 0 !important;
  transform: none !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.copy-button:hover {
  transform: none !important;
}
