:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --green: #059669;
  --green-soft: #ecfdf5;
  --nav: #0f172a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

a {
  color: var(--primary);
}

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

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--nav);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06), 0 8px 24px rgba(15, 23, 42, 0.18);
}

.topbar-inner {
  max-width: 1560px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 28px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #fff;
  font-weight: 800;
  font-size: 18px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.brand-mark-lg {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  font-size: 26px;
  margin: 0 auto 16px;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.main-nav::-webkit-scrollbar {
  display: none;
}

.main-nav a {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 9px;
  color: #cbd5e1;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.main-nav a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.main-nav a.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.13);
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.org-name {
  color: #94a3b8;
  font-size: 12.5px;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-name {
  color: #e2e8f0;
  font-size: 13.5px;
  white-space: nowrap;
}

/* ---------- Page shell ---------- */

.page {
  width: 100%;
  flex: 1;
  max-width: 1560px;
  margin: 0 auto;
  padding: 28px 24px 64px;
}

/* ---------- Footer ---------- */

.site-footer {
  flex-shrink: 0;
  padding: 20px 24px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  background: var(--surface);
  text-align: center;
  font-size: 13px;
}

.site-footer-inner {
  max-width: 1560px;
  margin: 0 auto;
}

.site-footer p {
  margin: 0;
}

.site-footer p + p {
  margin-top: 3px;
}

.site-footer a {
  color: inherit;
  font-weight: 600;
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--primary);
  text-decoration: underline;
}

.auth-body .site-footer {
  border-top-color: rgba(255, 255, 255, 0.1);
  color: #94a3b8;
  background: transparent;
}

.auth-body .site-footer a:hover {
  color: #fff;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.page-head h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.page-subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.page-head-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

/* ---------- Stats ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
  position: relative;
  overflow: hidden;
}

.stat::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, #3b82f6, #93c5fd);
}

.stat-label {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 6px;
}

.stat-value {
  display: block;
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-value-sm {
  font-size: 16px;
  white-space: normal;
}

.import-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}

.import-step {
  position: relative;
  padding-top: 22px;
}

.import-step h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.import-step p {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 16px;
}

.import-step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 800;
  font-size: 15px;
  margin-bottom: 10px;
}

.import-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-start;
}

.import-form input[type="file"] {
  width: 100%;
}

.admin-section {
  margin-top: 28px;
}

.admin-section h2 {
  margin: 0 0 12px;
  font-size: 19px;
  letter-spacing: -0.01em;
}

.meta-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
}

.meta-inline > div {
  min-width: 220px;
}

.meta-inline span {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 3px;
}

.meta-inline strong {
  font-size: 15px;
}

/* ---------- Panels, filters ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

.panel-title {
  margin: 0 0 12px;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.filters {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field > span {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}

.field > span em {
  color: var(--danger);
  font-style: normal;
}

.field-search {
  flex: 1;
  min-width: 240px;
}

.filters .field:not(.field-search) {
  width: 240px;
}

input[type="text"],
input[type="search"],
input[type="password"],
input[type="date"],
input[type="number"],
input[type="file"],
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 14.5px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input[type="file"] {
  padding: 8px 10px;
  font-size: 13.5px;
}

textarea {
  resize: vertical;
  min-height: 90px;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

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

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: #334155;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.chip:hover {
  border-color: #93c5fd;
  color: var(--primary-dark);
  background: var(--primary-soft);
}

.chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.chip-count {
  display: inline-block;
  padding: 0 7px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.07);
  font-size: 11.5px;
  font-weight: 700;
  line-height: 18px;
}

.chip.active .chip-count {
  background: rgba(255, 255, 255, 0.22);
}

.results-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 4px 12px;
  color: var(--muted);
  font-size: 13.5px;
}

.results-line strong {
  color: var(--text);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-ghost {
  background: #fff;
  border-color: var(--border-strong);
  color: #334155;
}

.btn-ghost:hover {
  background: var(--surface-2);
  border-color: #94a3b8;
}

.btn-ghost-light {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.22);
  color: #e2e8f0;
}

.btn-ghost-light:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-sm {
  height: 32px;
  padding: 0 11px;
  font-size: 13px;
  border-radius: 8px;
}

.btn-block {
  width: 100%;
}

/* ---------- Tables ---------- */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table:not(.simple-table) {
  min-width: 900px;
}

.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-2);
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.data-table tbody td {
  padding: 9px 14px;
  border-bottom: 1px solid #eef2f7;
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr:hover {
  background: #f8fafc;
}

.data-table .num {
  text-align: right;
}

.data-table .nowrap {
  white-space: nowrap;
}

.data-table .center {
  text-align: center;
}

.photo-col {
  width: 72px;
}

.thumb-link {
  display: inline-block;
  line-height: 0;
}

.thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #f1f5f9;
  display: block;
}

.thumb-empty {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  line-height: 1.15;
  text-align: center;
  color: #94a3b8;
  font-weight: 600;
}

.inv-link {
  font-family: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
}

.inv-link:hover {
  text-decoration: underline;
}

.name-cell {
  max-width: 560px;
}

.name-link {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}

.name-link:hover {
  color: var(--primary);
}

.note-dot {
  color: var(--primary);
  font-size: 7px;
  vertical-align: middle;
  margin-left: 4px;
}

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-blue {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.badge-green {
  background: var(--green-soft);
  color: #047857;
}

.muted {
  color: var(--muted);
}

.count-link {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

.count-link:hover {
  text-decoration: underline;
}

/* ---------- Pagination ---------- */

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin: 24px 0 0;
  flex-wrap: wrap;
}

.page-link {
  min-width: 36px;
  height: 36px;
  padding: 0 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: #334155;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}

.page-link:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.page-link.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 700;
}

.page-link.disabled {
  opacity: 0.4;
  pointer-events: none;
}

.page-gap {
  color: var(--muted);
  padding: 0 2px;
}

/* ---------- Breadcrumbs ---------- */

.breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--muted);
}

.breadcrumbs a {
  color: var(--muted);
  text-decoration: none;
}

.breadcrumbs a:hover {
  color: var(--primary);
}

.breadcrumbs .sep {
  color: #cbd5e1;
}

/* ---------- Item card ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.item-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 28px;
  border-bottom: 1px solid var(--border);
}

.eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.inv-big {
  font-family: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 27px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
  margin: 2px 0 8px;
  word-break: break-word;
}

.item-title h1 {
  margin: 0 0 12px;
  font-size: 23px;
  line-height: 1.3;
  letter-spacing: -0.01em;
  max-width: 900px;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.item-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.item-card-body {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
}

.photo-hero {
  background: var(--surface-2);
  border-right: 1px solid var(--border);
  padding: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 320px;
}

.photo-hero-link {
  display: block;
  max-width: 100%;
  line-height: 0;
}

.photo-hero img {
  max-width: 100%;
  max-height: 480px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.12);
}

.photo-caption {
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
}

.photo-caption a {
  margin-left: 6px;
}

.photo-empty {
  width: 100%;
  border: 2px dashed var(--border-strong);
  border-radius: 14px;
  background: #fff;
  padding: 36px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13.5px;
}

.photo-empty strong {
  color: var(--text);
  font-size: 16px;
}

.photo-empty-icon {
  font-size: 36px;
  line-height: 1;
  color: #94a3b8;
}

.photo-empty .btn {
  margin-top: 8px;
}

.meta {
  margin: 0;
  padding: 8px 28px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-content: start;
}

.meta > div {
  padding: 14px 0;
  border-bottom: 1px solid #eef2f7;
  min-width: 0;
}

.meta > div:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.meta-wide {
  grid-column: 1 / -1;
}

.meta dt {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.meta dd {
  margin: 5px 0 0;
  font-size: 15px;
  font-weight: 500;
  word-break: break-word;
}

.meta dd p {
  margin: 0 0 6px;
}

/* ---------- Acts timeline ---------- */

.acts-section {
  margin-top: 30px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section-head h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.01em;
}

.counter {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  vertical-align: middle;
}

.timeline {
  position: relative;
  padding-left: 26px;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--border);
}

.act-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 14px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

.act-card:last-child {
  margin-bottom: 0;
}

.act-marker {
  position: absolute;
  left: -25px;
  top: 21px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--border-strong);
  border: 3px solid var(--bg);
  box-sizing: content-box;
}

.act-latest {
  border-color: #bfdbfe;
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.act-latest .act-marker {
  background: var(--primary);
}

.act-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.act-head-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.act-date {
  font-weight: 700;
  font-size: 14.5px;
}

.act-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.act-actions form {
  display: inline;
}

.link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--primary);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.link:hover {
  text-decoration: underline;
}

.link-danger {
  color: var(--danger);
}

.act-route {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin: 10px 0;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid #eef2f7;
}

.route-point {
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-weight: 600;
  font-size: 14px;
}

.route-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.route-arrow {
  color: var(--primary);
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
}

.act-desc {
  color: #334155;
  font-size: 14.5px;
}

.act-desc p {
  margin: 0 0 8px;
}

.act-desc p:last-child {
  margin-bottom: 0;
}

.act-photo {
  display: inline-block;
  margin-top: 10px;
  line-height: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.act-photo img {
  display: block;
  max-width: 360px;
  max-height: 280px;
  width: auto;
  height: auto;
  object-fit: cover;
}

/* ---------- Empty states ---------- */

.empty-state {
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 52px 24px;
  text-align: center;
}

.empty-state h2 {
  margin: 12px 0 6px;
  font-size: 18px;
}

.empty-state p {
  color: var(--muted);
  max-width: 540px;
  margin: 0 auto 18px;
  font-size: 14px;
}

.empty-icon {
  font-size: 34px;
  line-height: 1;
  color: #94a3b8;
}

.empty-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.empty-state-inline {
  padding: 36px 24px;
}

/* ---------- Forms ---------- */

.form-page {
  max-width: 960px;
  margin: 0 auto;
}

.form-page-wide {
  max-width: 1100px;
}

.draft-actions {
  margin-top: 20px;
}

.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.form-card h1 {
  margin: 0 0 4px;
  font-size: 24px;
  letter-spacing: -0.01em;
}

.form-card > .page-subtitle {
  margin-bottom: 22px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.field-wide {
  grid-column: 1 / -1;
}

.field-hint {
  font-size: 12.5px;
  color: var(--muted);
}

.field-hint a {
  color: var(--primary);
  text-decoration: none;
}

.field-hint a:hover {
  text-decoration: underline;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.form-errors {
  background: var(--danger-soft);
  border: 1px solid #fecaca;
  color: #991b1b;
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 20px;
  font-size: 14px;
}

.form-errors ul {
  margin: 8px 0 0 18px;
  padding: 0;
}

.danger-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 32px;
  padding: 16px 18px;
  border: 1px solid #fecaca;
  background: #fff7f7;
  border-radius: 12px;
}

.danger-zone p {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.subject-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 20px;
}

.subject-label {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 2px;
}

.current-photo {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.current-photo img {
  max-width: 240px;
  max-height: 180px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
}

.checkbox input {
  width: 17px;
  height: 17px;
  min-height: auto;
  accent-color: var(--danger);
}

/* ---------- Categories / cabinets ---------- */

.inline-create {
  display: flex;
  align-items: center;
  gap: 10px;
}

.input-create {
  flex: 1;
  max-width: 560px;
}

.inline-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.input-inline {
  flex: 1;
  max-width: 560px;
  min-height: 38px;
  padding: 6px 11px;
}

.simple-table td {
  padding-top: 8px;
  padding-bottom: 8px;
}

.actions-col {
  width: 150px;
  text-align: right;
  white-space: nowrap;
}

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

.staff-form input[type="text"],
.staff-form input[type="password"] {
  flex: 1 1 160px;
  width: auto;
}

.staff-form input[type="submit"] {
  flex: 0 0 auto;
}

.cabinet-edit-form {
  flex-wrap: wrap;
}

.cabinet-edit-form .input-inline {
  max-width: 240px;
}

.hint {
  color: var(--muted);
  font-size: 13px;
  margin-top: 12px;
}

/* ---------- Flash ---------- */

.flash {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
}

.flash-notice {
  background: var(--green-soft);
  border-color: #a7f3d0;
  color: #065f46;
}

.flash-alert {
  background: var(--danger-soft);
  border-color: #fecaca;
  color: #991b1b;
}

/* ---------- Auth ---------- */

.auth-body {
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(37, 99, 235, 0.18), transparent 60%),
    radial-gradient(800px 500px at 100% 110%, rgba(29, 78, 216, 0.16), transparent 60%),
    #0f172a;
}

.auth-page {
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-page .flash {
  width: 100%;
  max-width: 400px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: 20px;
  padding: 36px 32px 28px;
  box-shadow: 0 30px 80px rgba(2, 6, 23, 0.5);
}

.auth-card-wide {
  max-width: 480px;
}

.auth-brand {
  text-align: center;
  margin-bottom: 26px;
}

.auth-brand h1 {
  margin: 0 0 4px;
  font-size: 24px;
  letter-spacing: -0.02em;
}

.auth-brand p {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-hint {
  margin: 20px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
}

/* ---------- Responsive ---------- */

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

  .item-card-body {
    grid-template-columns: 1fr;
  }

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

  .item-card-head {
    flex-direction: column;
  }

  .item-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 820px) {
  .topbar-inner {
    gap: 14px;
    padding: 0 16px;
  }

  .org-name,
  .user-name {
    display: none;
  }

  .page {
    padding: 20px 16px 48px;
  }

  .page-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-head h1 {
    font-size: 24px;
  }

  .filters .field:not(.field-search) {
    width: 100%;
  }

  .filter-actions {
    width: 100%;
  }

  .form-grid,
  .meta,
  .import-grid {
    grid-template-columns: 1fr;
  }

  .meta > div {
    border-bottom: 1px solid #eef2f7 !important;
  }

  .meta > div:last-child {
    border-bottom: 0 !important;
  }

  .form-card {
    padding: 20px;
  }

  .danger-zone {
    flex-direction: column;
    align-items: flex-start;
  }

  .inline-create,
  .inline-form {
    flex-wrap: wrap;
  }

  .input-create,
  .input-inline {
    max-width: none;
    width: 100%;
    flex-basis: 100%;
  }

  .item-card-head {
    padding: 20px;
  }

  .meta {
    padding: 8px 20px;
  }

  .timeline {
    padding-left: 22px;
  }

  .act-marker {
    left: -21px;
  }

  .act-head {
    flex-direction: column;
    align-items: flex-start;
  }
}

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

  .brand-text {
    display: none;
  }

  .topbar-inner {
    height: 58px;
  }

  .main-nav a {
    padding: 7px 10px;
    font-size: 13px;
  }

  .auth-card {
    padding: 28px 20px 22px;
  }

  .act-route {
    gap: 8px;
  }

  .route-arrow {
    font-size: 17px;
  }
}

/* ---------- Print form ---------- */

.print-body {
  background: #fff;
  color: #000;
  font-family: "Times New Roman", Times, serif;
}

.print-toolbar {
  max-width: 210mm;
  margin: 20px auto;
  padding: 0 10mm;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.print-page {
  max-width: 210mm;
  margin: 0 auto 40px;
  padding: 10mm;
  background: #fff;
}

.print-org {
  text-align: center;
  font-size: 13pt;
  margin-bottom: 4mm;
}

.print-page h1 {
  text-align: center;
  font-size: 16pt;
  font-weight: 700;
  margin: 0 0 7mm;
}

.print-meta {
  display: flex;
  justify-content: space-between;
  gap: 10mm;
  font-size: 12pt;
  margin-bottom: 5mm;
}

.print-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11pt;
}

.print-table th,
.print-table td {
  border: 1px solid #000;
  padding: 4px 6px;
  vertical-align: top;
}

.print-table th {
  background: #f0f0f0;
  text-align: left;
  font-weight: 700;
}

.print-table .print-qty {
  width: 25mm;
  text-align: center;
}

.print-table .print-inv {
  width: 45mm;
}

.print-empty {
  text-align: center;
  font-style: italic;
}

.print-reason {
  margin-top: 8mm;
  font-size: 12pt;
  line-height: 1.6;
}

.print-footer {
  margin-top: 14mm;
  display: flex;
  flex-direction: column;
  gap: 9mm;
  font-size: 12pt;
}

.print-line {
  display: inline-block;
  min-width: 70mm;
  min-height: 1.2em;
  border-bottom: 1px solid #000;
}

@media print {
  @page {
    size: A4;
    margin: 12mm;
  }

  .no-print {
    display: none !important;
  }

  .print-body {
    background: #fff;
  }

  .print-page {
    max-width: none;
    margin: 0;
    padding: 0;
  }

  .print-table {
    page-break-inside: auto;
  }

  .print-table tr {
    page-break-inside: avoid;
  }

  .print-table thead {
    display: table-header-group;
  }
}
