:root {
  --navy: #08233F;
  --navy-2: #123A62;
  --green: #2E8B57;
  --green-dark: #17613A;
  --green-soft: #E8F5EC;
  --line: #DDE5EC;
  --soft: #F5F7FA;
  --soft-2: #EEF2F6;
  --text: #182536;
  --muted: #5D6B7A;
  --warn: #9A5A00;
  --warn-soft: #FFF1D8;
  --danger: #C9342B;
  --white: #FFFFFF;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--text);
  background: var(--soft);
  line-height: 1.5;
}

button, input, select, textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  background: var(--navy);
  color: var(--white);
  padding: 24px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.logo {
  width: 148px;
  min-height: 58px;
  display: grid;
  place-items: center;
  background: var(--white);
  color: var(--navy);
  border-radius: 8px;
  font-weight: 800;
  border: 1px solid rgba(255, 255, 255, 0.34);
  overflow: hidden;
  padding: 6px;
}

.brand-logo {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}

.brand-fallback {
  font-size: 16px;
  font-weight: 800;
  color: var(--navy);
  letter-spacing: 0;
}

.brand strong { display: block; }
.brand span { color: #DCE8F3; font-size: 13px; }

.sidebar .brand {
  display: grid;
  gap: 10px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav button {
  width: 100%;
  color: #F4F8FC;
  background: transparent;
  border-radius: 8px;
  padding: 12px 13px;
  text-align: left;
  font-weight: 700;
  border: 1px solid transparent;
}

.nav button.active,
.nav button:hover {
  background: var(--green);
  color: var(--white);
  border-color: rgba(255, 255, 255, 0.16);
}

.main {
  min-width: 0;
}

.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--line);
  padding: 18px 26px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0;
  color: var(--navy);
}

.content {
  padding: 26px;
}

.grid {
  display: grid;
  gap: 16px;
}

.stats {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

h1, h2, h3 {
  color: var(--navy);
  letter-spacing: 0;
}

h2 {
  margin: 0 0 14px;
  font-size: 18px;
}

.stat-number {
  font-size: 34px;
  font-weight: 800;
  color: var(--navy);
  line-height: 1;
}

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

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 8px;
  background: var(--green);
  color: var(--white);
  text-decoration: none;
  font-weight: 700;
  border: 1px solid var(--green);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:hover {
  background: var(--green-dark);
  border-color: var(--green-dark);
}

.btn.secondary {
  background: var(--white);
  color: var(--navy);
  border-color: var(--navy);
}

.btn.secondary:hover {
  background: var(--navy);
  border-color: var(--navy);
  color: var(--white);
}

.btn.warn {
  background: var(--danger);
  border-color: var(--danger);
}

.btn.warn:hover {
  background: #A92720;
  border-color: #A92720;
}

.btn.small {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

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

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

th {
  font-size: 12px;
  color: var(--navy);
  text-transform: uppercase;
  background: #F1F5F8;
  letter-spacing: 0.02em;
}

tbody tr:hover {
  background: #FBFDFC;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--soft-2);
  color: var(--navy);
}

.pill.ok { background: var(--green-soft); color: var(--green-dark); }
.pill.inactive { background: #ECEFF3; color: #5B6775; }
.pill.check,
.pill.warn { background: var(--warn-soft); color: var(--warn); }

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

.field {
  display: grid;
  gap: 6px;
}

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

label {
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
}

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

input:focus, select:focus, textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(46, 139, 87, 0.14);
  outline: 0;
}

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

input[readonly] {
  background: var(--soft-2);
  color: var(--muted);
}

.hidden { display: none !important; }

.check-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.check-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--text);
  font-size: 13px;
}

.check-option input {
  width: auto;
  min-height: auto;
}

.preview-grid,
.report-files {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

.preview-grid figure,
.report-files figure {
  width: 118px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--white);
}

.preview-grid img,
.report-files img {
  width: 100%;
  height: 90px;
  object-fit: cover;
  display: block;
}

.preview-grid figcaption,
.report-files figcaption {
  padding: 6px;
  font-size: 11px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.file-chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  max-width: 240px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--navy);
  background: var(--soft);
  text-decoration: none;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.import-summary .table-wrap {
  margin: 10px 0;
}

.import-summary ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(7, 31, 61, 0.42);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 20;
}

.modal {
  width: min(760px, 100%);
  max-height: 92vh;
  overflow: auto;
  background: var(--white);
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 20px;
}

.modal h2 { margin-top: 0; }

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: linear-gradient(135deg, var(--navy), #113957 58%, var(--soft) 58%);
}

.login .card {
  width: min(430px, 100%);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.public-page {
  min-height: 100vh;
  background: var(--soft);
}

.public-header {
  background: var(--navy);
  color: var(--white);
  padding: 22px;
}

.public-header .inner,
.public-content {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

.public-content {
  padding: 24px 0;
}

.split {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 18px;
}

.qr-box {
  text-align: center;
}

.qr-box img {
  width: 220px;
  height: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.report {
  background: var(--white);
  color: var(--text);
  width: min(980px, calc(100% - 24px));
  margin: 24px auto;
  padding: 32px;
  border: 1px solid var(--line);
}

.report-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 2px solid var(--navy);
  padding-bottom: 18px;
}

.report h1 { color: var(--navy); margin: 0 0 8px; }

.report-logo {
  width: 180px;
  min-height: 70px;
  border-color: var(--line);
}

.print-only { display: none; }

@media print {
  body { background: var(--white); }
  .no-print { display: none !important; }
  .print-only { display: block; }
  .report { border: 0; margin: 0; width: 100%; padding: 0; }
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
  }
  .sidebar .brand {
    grid-template-columns: auto 1fr;
    align-items: center;
  }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
  .content { padding: 16px; }
  .stats, .form-grid { grid-template-columns: 1fr; }
  .check-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .actions { width: 100%; }
  .btn { width: 100%; }
  .report { padding: 18px; }
  .report-head { flex-direction: column; }
  .logo {
    width: 132px;
    min-height: 52px;
  }
}
