:root {
  --red: #b91c1c;
  --red-dark: #7f1d1d;
  --rose: #fff1f2;
  --ink: #172033;
  --muted: #667085;
  --line: #d9dee8;
  --soft: #f6f8fb;
  --green: #047857;
  --amber: #b45309;
  --blue: #1d4ed8;
  --white: #ffffff;
  --shadow: 0 12px 30px rgba(23, 32, 51, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  background: #eef2f7;
}

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

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 24px;
  color: white;
  background: var(--red-dark);
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
  font-weight: 800;
  letter-spacing: 0;
}

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

.nav {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
}

.nav button,
.ghost-button {
  min-height: 38px;
  padding: 0 12px;
  border-radius: 7px;
  color: white;
  background: rgba(255,255,255,0.11);
  white-space: nowrap;
}

.nav button.active,
.nav button:hover,
.ghost-button:hover {
  background: white;
  color: var(--red-dark);
}

.page {
  width: min(1280px, calc(100vw - 32px));
  margin: 22px auto 36px;
}

.hero-band {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 18px;
  align-items: stretch;
  margin-bottom: 18px;
}

.search-panel,
.panel,
.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
}

.search-panel {
  padding: 22px;
}

.blood-visual {
  min-height: 250px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(127, 29, 29, 0.18);
  background:
    linear-gradient(rgba(127, 29, 29, 0.40), rgba(127, 29, 29, 0.68)),
    url("https://images.unsplash.com/photo-1615461066841-6116e61058f4?auto=format&fit=crop&w=1200&q=80");
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: end;
  padding: 22px;
  color: white;
}

.blood-visual h1,
.search-panel h1 {
  margin: 0 0 8px;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.04;
  letter-spacing: 0;
}

.blood-visual p,
.search-panel p {
  margin: 0;
  max-width: 680px;
  line-height: 1.5;
  color: rgba(255,255,255,0.88);
}

.search-panel p { color: var(--muted); }

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

.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.search-strip {
  margin: -22px calc(50% - 50vw) 18px;
  padding: 16px max(16px, calc(50vw - 640px));
  background: #e5e5e5;
}

.search-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr)) 120px 96px;
  gap: 10px;
  align-items: end;
}

.search-action .primary,
.search-action .secondary {
  width: 100%;
  min-height: 42px;
}

.search-action .primary {
  background: #980014;
}

.clear-search {
  color: #7f1d1d;
  background: #fff;
  border: 1px solid #cbd5e1;
}

.admin-search-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr)) 110px 96px;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9fc;
}

.admin-blood-search-grid {
  display: grid;
  grid-template-columns: 1.15fr repeat(4, minmax(0, 1fr)) 130px 90px;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff8f8;
}

.import-panel {
  display: grid;
  grid-template-columns: 260px 1fr 180px;
  gap: 12px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9fc;
}

.import-textarea {
  grid-row: span 2;
}

.import-actions {
  display: grid;
  gap: 8px;
}

.import-note {
  grid-column: 1 / -1;
  margin: 0;
}

.admin-hero {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
  padding: 20px;
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  color: #111827;
  background: linear-gradient(135deg, #ffffff 0%, #f9fbff 100%);
  box-shadow: var(--shadow);
}

.admin-hero h1 {
  margin: 4px 0 6px;
  font-size: 30px;
  line-height: 1.12;
  letter-spacing: 0;
}

.admin-hero p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.eyebrow {
  color: var(--red);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.admin-quick {
  min-width: 170px;
  padding: 14px;
  border: 1px solid #e1e7f0;
  border-radius: 8px;
  background: white;
  text-align: right;
}

.admin-quick strong {
  display: block;
  font-size: 34px;
  line-height: 1;
  color: var(--red);
}

.admin-quick span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.admin-panel {
  border-color: #dbe3ef;
}

.admin-panel .panel-header {
  padding-bottom: 12px;
  border-bottom: 1px solid #edf1f6;
}

.admin-panel table th {
  background: #eef2f7;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

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

.field label {
  color: #394258;
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid #cfd6e3;
  border-radius: 7px;
  color: var(--ink);
  background: white;
}

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

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

.primary,
.secondary,
.danger,
.small {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 7px;
  font-weight: 800;
}

.primary { color: white; background: var(--red); }
.secondary { color: var(--ink); background: #e8edf5; }
.danger { color: white; background: #991b1b; }
.small {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.status.approved { color: #065f46; background: #d1fae5; }
.status.pending { color: #92400e; background: #fef3c7; }
.status.rejected { color: #991b1b; background: #fee2e2; }
.status.info { color: #1e3a8a; background: #dbeafe; }

.panel {
  padding: 18px;
  margin-bottom: 18px;
}

.panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.panel-header h2,
.panel h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.panel-header p,
.panel > p {
  margin: 5px 0 0;
  color: var(--muted);
}

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

.stat {
  min-height: 96px;
  padding: 15px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: white;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

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

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

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

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

th {
  color: #394258;
  background: #f3f6fb;
  font-size: 13px;
}

.search-table {
  min-width: 1180px;
}

.search-table th {
  color: #111827;
  background: #efe4e6;
}

.center-detail {
  margin-top: 7px;
  color: #5f6b7a;
  line-height: 1.55;
}

.mobile-result-head,
.mobile-result-grid {
  display: none;
}

.desktop-center-name {
  display: inline;
}

.availability {
  color: #008000;
  font-weight: 800;
  line-height: 1.65;
}

.category-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 12px;
  border: 1px solid #9bc2f9;
  border-radius: 999px;
  color: #1d4ed8;
  background: #f8fbff;
  font-size: 12px;
  font-weight: 800;
}

.stock-row td {
  padding: 6px;
  background: #e5f1df;
  text-align: center;
}

.stock-link {
  width: 100%;
  min-height: 30px;
  color: #111827;
  background: transparent;
  font-weight: 800;
}

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

.login-box {
  max-width: 460px;
  margin: 52px auto;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.tabs button {
  min-height: 38px;
  padding: 0 12px;
  border-radius: 999px;
  color: var(--ink);
  background: #e8edf5;
  font-weight: 800;
}

.tabs button.active {
  color: white;
  background: var(--red);
}

.notice {
  padding: 11px 12px;
  border-radius: 8px;
  color: #334155;
  background: #e0f2fe;
  border: 1px solid #bae6fd;
  margin-bottom: 14px;
}

.muted { color: var(--muted); }
.right { text-align: right; }

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  color: white;
  background: #172033;
  box-shadow: var(--shadow);
}

@media (max-width: 920px) {
  .topbar {
    height: auto;
    min-height: 64px;
    padding: 12px 16px;
    align-items: start;
    flex-direction: column;
  }

  .hero-band,
  .grid.cols-2,
  .grid.cols-3,
  .grid.cols-4,
  .search-grid,
  .admin-search-grid,
  .admin-blood-search-grid,
  .import-panel,
  .stats {
    grid-template-columns: 1fr;
  }

  .import-textarea,
  .import-note {
    grid-column: auto;
  }

  .blood-visual {
    min-height: 210px;
  }

  .admin-hero {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-quick {
    min-width: 0;
    text-align: left;
  }
}

@media (max-width: 560px) {
  body {
    background: #f4f6fa;
  }

  .page {
    width: 100%;
    margin-top: 0;
  }

  .search-strip {
    margin: 0;
    padding: 12px 10px;
  }

  .search-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 10px;
    border: 1px solid #d7dce5;
    border-radius: 8px;
    background: #eef0f3;
  }

  .field label {
    font-size: 13px;
    line-height: 1.2;
  }

  .field input,
  .field select,
  .search-action .primary,
  .search-action .secondary {
    min-height: 44px;
    font-size: 15px;
  }

  .search-grid .field:nth-child(4),
  .search-grid .search-action {
    min-width: 0;
  }

  .search-grid .search-action {
    grid-column: span 1;
  }

  .search-panel, .panel {
    margin: 10px;
    padding: 12px;
    border-radius: 8px;
  }

  .panel-header { flex-direction: column; }

  .admin-hero {
    margin: 10px;
    padding: 14px;
  }

  .admin-hero h1 {
    font-size: 24px;
  }

  .search-table {
    min-width: 0;
  }

  .search-table thead {
    display: none;
  }

  .search-table,
  .search-table tbody,
  .search-table tr,
  .search-table td {
    display: block;
    width: 100%;
  }

  .search-table tr {
    border-bottom: 1px solid var(--line);
  }

  .search-table tbody tr:not(.stock-row) {
    padding: 10px 0;
  }

  .search-table td {
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 10px;
    padding: 7px 10px;
    border-bottom: 0;
  }

  .search-table td::before {
    content: attr(data-label);
    color: #5f6b7a;
    font-size: 12px;
    font-weight: 800;
  }

  .search-table td[data-label="Blood Center"] {
    display: block;
    padding: 14px;
  }

  .search-table td[data-label="Blood Center"]::before {
    display: none;
  }

  .search-table td:not([data-label="Blood Center"]) {
    display: none;
  }

  .search-table tbody tr:not(.stock-row) {
    margin: 0 0 12px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 8px 20px rgba(23, 32, 51, 0.06);
    overflow: hidden;
  }

  .mobile-result-head {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    color: #0f172a;
    font-size: 16px;
    line-height: 1.35;
  }

  .mobile-result-index {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    color: #7f1d1d;
    background: #fff1f2;
    font-size: 13px;
    font-weight: 900;
  }

  .desktop-center-name {
    display: none;
  }

  .center-detail {
    margin: 10px 0 0;
    padding-left: 40px;
    font-size: 14px;
    line-height: 1.55;
    word-break: break-word;
  }

  .availability {
    font-size: 14px;
  }

  .mobile-result-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 12px;
    padding-left: 40px;
  }

  .mobile-result-grid div {
    min-width: 0;
    padding: 8px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #f8fafc;
  }

  .mobile-result-grid span {
    display: block;
    margin-bottom: 3px;
    color: #64748b;
    font-size: 11px;
    font-weight: 800;
  }

  .mobile-result-grid strong {
    color: #0f172a;
    font-size: 13px;
    line-height: 1.25;
    overflow-wrap: anywhere;
  }

  .mobile-result-grid .availability {
    color: #047857;
  }

  .stock-row td {
    display: block;
    padding: 6px;
  }

  .stock-row td::before {
    content: "";
    display: none;
  }
}
