:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #18212f;
  --muted: #687386;
  --line: #dfe5ec;
  --primary: #0f766e;
  --primary-dark: #0b5f59;
  --accent: #c47d22;
  --soft: #e8f4f2;
  --warn: #fff1d6;
  --danger: #b42318;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
}

a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px clamp(16px, 4vw, 42px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
}

.brand:hover { text-decoration: none; }

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  color: white;
  background: var(--primary);
  font-weight: 800;
}

.brand small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}

nav {
  display: flex;
  align-items: center;
  gap: 14px;
  white-space: nowrap;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 28px auto 56px;
}

.page-head,
.section-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.page-head { margin-bottom: 20px; }
.section-title { margin-bottom: 14px; }

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(2rem, 5vw, 3.2rem); }
h2 { margin-bottom: 0; font-size: 1.1rem; }

.button,
button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 15px;
  color: var(--ink);
  background: white;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.button:hover,
button:hover {
  text-decoration: none;
  border-color: #b7c2cf;
}

.button.primary,
button.primary {
  border-color: var(--primary);
  color: white;
  background: var(--primary);
}

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

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

.stats-grid article,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 16px 45px rgba(15, 32, 48, 0.06);
}

.stats-grid article { padding: 18px; }
.stats-grid span,
.section-title span,
label span {
  color: var(--muted);
  font-size: 0.86rem;
}

.stats-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 1.8rem;
}

.panel { padding: 18px; }

.filters {
  display: grid;
  grid-template-columns: 1.2fr repeat(3, 1fr) auto auto;
  gap: 12px;
  align-items: end;
}

label {
  display: grid;
  gap: 7px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  background: white;
  font: inherit;
}

textarea { resize: vertical; }

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(15, 118, 110, 0.18);
  border-color: var(--primary);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  gap: 16px;
  margin-top: 16px;
}

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 930px;
}

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
  background: #fbfcfd;
}

tr:last-child td { border-bottom: 0; }

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 3px 10px;
  color: var(--primary-dark);
  background: var(--soft);
  font-size: 0.82rem;
  font-weight: 800;
}

.pill.warn {
  color: #8a5200;
  background: var(--warn);
}

.pill.ok {
  color: var(--primary-dark);
  background: var(--soft);
}

.bars { display: grid; gap: 14px; }

.bar-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

.bar-row div {
  grid-column: 1 / -1;
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1f5;
}

.bar-row i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.card-list { display: none; }

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

.card-photo {
  display: block;
  width: 100%;
  max-width: 230px;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f1f4f7;
}

.asset-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.asset-card > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.asset-card p { margin: 12px 0; }

dl {
  display: grid;
  grid-template-columns: 95px 1fr;
  gap: 7px 10px;
  margin: 0 0 14px;
}

dt { color: var(--muted); }
dd { margin: 0; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.form-grid .wide,
.form-actions { grid-column: 1 / -1; }

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.photo-preview {
  display: grid;
  gap: 10px;
}

.photo-preview img {
  width: min(100%, 360px);
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

.legacy-ref {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.delete-form {
  margin-top: 18px;
}

.delete-form button {
  border-color: #f0b6b0;
  color: var(--danger);
  background: #fff7f6;
}

.flash,
.empty {
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--soft);
  color: var(--primary-dark);
}

.flash { margin-bottom: 16px; }
.empty { text-align: center; }

@media (max-width: 860px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  nav {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .desktop-action { display: none; }

  .stats-grid,
  .content-grid,
  .filters,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .asset-panel { padding: 14px; }
}

@media (max-width: 520px) {
  .shell {
    width: min(100% - 22px, 1180px);
    margin-top: 18px;
  }

  .brand small { display: none; }
  .stats-grid article,
  .panel { padding: 14px; }
  h1 { font-size: 2rem; }
}

/* Select2 */
.select2-container--default .select2-selection--single {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: 40px;
  padding-left: 12px;
  color: var(--ink);
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 40px;
  right: 8px;
}

.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single {
  outline: 3px solid rgba(15, 118, 110, 0.18);
  border-color: var(--primary);
}

.select2-dropdown {
  border-color: var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
  background: var(--primary);
}

.select2-container--default .select2-search--dropdown .select2-search__field {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
}

/* DataTables */
.dataTables_wrapper {
  font: inherit;
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
  color: var(--muted);
  font-size: 0.86rem;
  margin: 10px 0;
}

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  font: inherit;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
  border-radius: 6px;
  padding: 5px 10px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
  border-color: var(--primary);
  color: white !important;
  background: var(--primary) !important;
}

table.dataTable thead th {
  position: relative;
}
