@font-face {
  font-family: "Outfit";
  src: url("/static/fonts/OutfitVariable.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --brand: #10b981;
  --brand-soft: #e8f8f1;
  --brand-muted: #0f9f73;
  --success: #10b981;
  --success-hover: #0b956c;
  --danger: #d9534f;
  --text: #344054;
  --text-soft: #667085;
  --text-strong: #1f2937;
  --border: #e2e8f0;
  --surface: #fff;
  --surface-soft: #f8fafc;
  --row-hover: #fbfefd;
  --page: #f8fafc;
  --shadow: 0 6px 18px rgba(15, 23, 42, .06);
}

body {
  margin: 0;
  font-family: Outfit, "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  background: var(--page);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

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

.topbar {
  min-height: 60px;
  padding: 0 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  color: var(--text-strong);
  border-bottom: 1px solid var(--border);
  box-shadow: none;
}

.brand { display: flex; align-items: center; text-decoration: none; }
.brand img { width: 126px; height: auto; display: block; filter: drop-shadow(0 1px 0 rgba(0, 0, 0, .04)); }
.topbar-left { display: flex; align-items: center; gap: 30px; min-width: 0; }
.main-nav { display: flex; align-items: stretch; gap: 6px; }
.nav-item { position: relative; display: flex; align-items: center; }
.main-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 8px;
  color: #53627a;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.main-nav a:hover { background: var(--surface-soft); color: var(--text-strong); }
.main-nav a.active { background: var(--brand-soft); color: #065f46; }
.nav-menu {
  position: absolute;
  left: 0;
  top: 100%;
  z-index: 30;
  display: none;
  min-width: 240px;
  max-width: min(360px, calc(100vw - 24px));
  padding: 6px;
  border: 1px solid #88bdd6;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 45px rgba(16, 24, 40, .16);
}
.nav-item:hover .nav-menu, .nav-item:focus-within .nav-menu { display: grid; gap: 0; }
.nav-menu a {
  min-height: 28px;
  justify-content: flex-start;
  padding: 3px 10px;
  color: #1f4b5f;
  font-size: 13px;
  white-space: normal;
}
.userbar { display: flex; align-items: center; gap: 12px; color: var(--text-strong); font-weight: 600; }
.avatar {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #e8eef7;
  color: #52627a;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}
.user-name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page { max-width: 1480px; margin: 0 auto; padding: 30px 42px; }

.page-title, .panel h1, .login-panel h1 {
  margin: 0 0 4px;
  color: #0f172a;
  font-size: 28px;
  font-weight: 750;
  letter-spacing: 0;
}

.toolbar, .meta, .pagination, .title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.meta { margin-top: -6px; color: var(--text-soft); font-size: 13px; }
.pagination { justify-content: flex-start; margin: 0; }
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 0;
  padding: 12px 22px;
  border-top: 1px solid #edf2f7;
}
.per-page { display: flex; align-items: center; gap: 8px; color: var(--text-soft); font-size: 13px; font-weight: 600; }
.per-page label { margin: 0; color: var(--text-soft); }
.per-page select {
  min-height: 34px;
  padding: 5px 30px 5px 10px;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  background: #fff;
  color: var(--text-strong);
  font: inherit;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
}
.page-counter { display: inline-flex; align-items: center; min-height: 34px; color: var(--text-soft); font-size: 13px; font-weight: 600; }
.button.disabled { pointer-events: none; opacity: .48; }
.search { display: flex; align-items: center; gap: 14px; width: 100%; }
.search input { flex: 1; }
.quick-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -4px 0 18px;
}
.quick-filters a {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 5px 11px;
  border: 1px solid #d8e1ee;
  border-radius: 999px;
  background: #fff;
  color: #53627a;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}
.quick-filters a:hover { background: var(--surface-soft); color: var(--text-strong); }
.quick-filters a.active { border-color: transparent; background: var(--brand-soft); color: #065f46; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 22px;
  max-width: 980px;
}

.panel.narrow { max-width: 420px; margin: 48px auto; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 22px; }

label { display: block; margin: 10px 0 6px; color: var(--text-strong); font-size: 14px; font-weight: 600; }

input {
  width: 100%;
  box-sizing: border-box;
  min-height: 42px;
  padding: 8px 13px;
  border: 1px solid #d8e1ee;
  border-radius: 12px;
  background: #fff;
  color: var(--text-strong);
  font: inherit;
  box-shadow: none;
}

input:focus {
  border-color: var(--brand-muted);
  outline: 0;
  box-shadow: 0 0 0 4px rgba(0, 112, 0, .10);
}

small { display: block; min-height: 18px; color: var(--danger); font-size: 13px; }

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--success);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 10px 18px rgba(16, 185, 129, .18);
}

button:hover, .button:hover { background: var(--success-hover); color: #fff; }
button.ghost { min-height: 38px; background: #fff; border-color: transparent; color: #53627a; box-shadow: none; }
button.ghost:hover { background: #f9fafb; }
.button.secondary { background: #fff; border-color: #d8e1ee; color: #334155; box-shadow: none; }
.button.secondary:hover { background: #f9fafb; color: var(--text-strong); }

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

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 0;
  border-radius: 0;
  overflow: hidden;
  box-shadow: none;
}

th, td { padding: 12px 20px; border-bottom: 1px solid #edf2f7; text-align: left; vertical-align: middle; }
th.numeric, td.numeric { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td { overflow-wrap: break-word; }
td strong { display: block; color: #0f172a; font-weight: 750; }
th { background: #fff; color: #334155; font-size: 13px; font-weight: 750; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--row-hover); }
.clickable-row { cursor: pointer; }
.clickable-row:focus-within, .clickable-row:hover { background: var(--row-hover); }
.table-link {
  color: var(--brand-muted);
  font-weight: 700;
  text-decoration: none;
}
.table-link:hover { color: #06704f; text-decoration: underline; text-underline-offset: 3px; }
.table-link strong { color: inherit; }
.related-link { display: inline-flex; align-items: baseline; gap: 6px; max-width: 100%; }
.related-link strong, .related-link span {
  display: inline;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.related-link span { color: #0f9f73; font-size: 12px; font-weight: 700; }
.subtext { display: block; margin-top: 2px; color: #526a8a; }
.muted-id { color: #8092b0; font-size: 13px; font-weight: 700; white-space: nowrap; }

.orders-table { table-layout: fixed; }
.orders-table .col-order-id { width: 94px; }
.orders-table .col-order-customer { width: 22%; }
.orders-table .col-order-merchant { width: 26%; }
.orders-table .col-order-status { width: 126px; }
.orders-table .col-order-postcode { width: 132px; }
.orders-table .col-order-total { width: 106px; }
.orders-table .col-order-created { width: 170px; }

.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.actions form { display: inline-flex; }
.actions button { box-sizing: border-box; min-width: 112px; height: 34px; min-height: 34px; padding: 6px 11px; font-size: 13px; border-radius: 8px; box-shadow: none; }
.actions .action-link { box-sizing: border-box; min-width: 112px; height: 34px; min-height: 34px; padding: 6px 11px; font-size: 13px; border-radius: 8px; box-shadow: none; }
.order-create { display: flex; align-items: center; gap: 8px; }
.order-create input { width: 92px; min-height: 34px; padding: 6px 10px; font-size: 13px; border-radius: 8px; }

.flash { padding: 12px 14px; margin-bottom: 16px; border-radius: 8px; font-size: 14px; }
.flash.success { background: var(--brand-soft); border: 1px solid #cce8cc; color: #245b27; }
.flash.error { background: #fef3f2; border: 1px solid #fecdca; color: #b42318; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, .38);
}

.modal {
  width: min(420px, 100%);
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(15, 23, 42, .22);
  padding: 24px;
}

.modal h2 {
  margin: 0 0 8px;
  color: var(--text-strong);
  font-size: 24px;
  font-weight: 600;
}

.modal p {
  margin: 0 0 18px;
  color: var(--text-soft);
  white-space: normal;
  overflow-wrap: anywhere;
}

.modal-id {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--brand-soft);
}

.modal-id span {
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.modal-id strong {
  color: var(--brand);
  font-size: 28px;
}

.modal-warning { border-top: 5px solid var(--brand); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.is-hidden { display: none; }

.pill { display: inline-flex; align-items: center; min-height: 22px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; background: #eef2f7; color: #475569; }
.pill.ok { background: #dff7ec; color: #065f46; }
.pill.muted { background: #eef2f7; color: #475569; }
.pill.danger { background: #fee4e2; color: #b42318; }
.pill-button {
  min-height: 28px;
  padding: 2px 9px;
  border: 0;
  box-shadow: none;
  cursor: pointer;
}
.pill-button.ok:hover { background: #d7efd7; }
.pill-button.muted:hover { background: #e4e7ec; color: var(--text-strong); }

.check { display: flex; gap: 8px; align-items: center; }
.check input { width: auto; min-height: auto; box-shadow: none; }

.login-panel {
  max-width: 420px;
  margin: 64px auto;
  padding: 28px;
  border: 1px solid rgba(35, 120, 158, .14);
  border-radius: 12px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 24px 70px rgba(22, 67, 86, .16);
  color: var(--text);
}
.login-panel label, .login-panel h1 { color: var(--text-strong); }
.login-panel input { color: var(--text-strong); }
.login-panel button { width: 100%; margin-top: 12px; }
.login-logo { max-width: 240px; display: block; margin: 0 auto 28px; }
body:has(.login-panel) {
  background:
    radial-gradient(circle at top left, rgba(195, 230, 248, .68), transparent 34%),
    linear-gradient(180deg, #f7fbfd 0%, #e8f4f8 100%);
}
body:has(.login-panel) .topbar { display: none; }

.lead { margin: 6px 0 0; color: var(--text-soft); font-size: 14px; }
.section-title { margin: 0 0 16px; color: var(--text-strong); font-size: 20px; font-weight: 600; }
.module-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.module-card {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text-strong);
  font-weight: 600;
  text-decoration: none;
}
.module-card:hover, .module-card.active { border-color: #88bdd6; background: #f1fbff; color: #1f4b5f; }
.incident { margin-top: 22px; border-top: 1px solid var(--border); }
.incident dl { margin: 0; }
.incident div { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.incident dt { color: var(--text-strong); font-weight: 700; }
.incident dd { margin: 0; }
.help-text { margin: 18px 0 0; color: var(--text-soft); }
.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.detail-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 20px;
}
.detail-card h2, .card-heading h2 {
  margin: 0 0 14px;
  color: var(--text-strong);
  font-size: 16px;
  font-weight: 750;
}
.detail-card-wide { margin-top: 20px; }
.detail-list { margin: 0; }
.detail-list div {
  display: grid;
  grid-template-columns: minmax(120px, 34%) minmax(0, 1fr);
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px solid #edf2f7;
}
.detail-list div:last-child { border-bottom: 0; }
.detail-list dt { color: var(--text-soft); font-size: 12px; font-weight: 750; text-transform: uppercase; }
.detail-list dd { margin: 0; color: var(--text-strong); overflow-wrap: anywhere; }
.detail-list a { color: #0f766e; font-weight: 700; text-decoration: none; }
.detail-list a:hover { text-decoration: underline; }
.detail-table { margin-top: 20px; }
.card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid #edf2f7;
}
.card-heading h2 { margin: 0; }
.card-heading span { color: var(--text-soft); font-size: 13px; font-weight: 600; }

@media (max-width: 760px) {
  .grid, .toolbar, .title-row, .meta { grid-template-columns: 1fr; flex-direction: column; align-items: stretch; }
  .topbar { align-items: flex-start; gap: 14px; padding: 16px 12px; }
  .topbar-left { flex-direction: column; align-items: flex-start; gap: 12px; }
  .main-nav { width: 100%; flex-wrap: wrap; align-items: stretch; }
  .nav-item { flex: 1 1 42%; display: block; }
  .main-nav > .nav-item > a { width: 100%; justify-content: center; box-sizing: border-box; }
  .nav-menu { position: static; margin-top: 6px; min-width: 100%; max-width: none; }
  .userbar { align-self: stretch; justify-content: space-between; }
  .userbar span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .page { padding: 24px 12px; }
  .page-title, .panel h1, .login-panel h1 { font-size: 26px; }
  .brand img { width: 126px; }
  .toolbar .button, .search button, .pagination .button { width: 100%; }
  .pagination-bar, .pagination, .per-page { align-items: stretch; flex-direction: column; }
  .per-page select { width: 100%; }
  .search { flex-direction: column; align-items: stretch; width: 100%; }
  .table-card { border: 0; background: transparent; box-shadow: none; overflow: visible; }
  table { display: block; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
  thead { display: none; }
  tbody { display: grid; gap: 12px; }
  tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
    overflow: hidden;
  }
  td {
    display: grid;
    grid-template-columns: minmax(92px, 34%) minmax(0, 1fr);
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
  }
  td::before {
    content: attr(data-label);
    text-align: left;
    color: var(--text-soft);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
  }
  td:last-child { border-bottom: 0; }
  .pagination-bar { padding: 0; border-top: 0; }
  .actions, .order-create { align-items: stretch; flex-direction: column; }
  .actions { gap: 10px; }
  .order-create input { width: 100%; }
  .actions button, .order-create button { width: 100%; min-height: 40px; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-card { padding: 16px; }
  .detail-list div { grid-template-columns: 1fr; gap: 4px; }
  .card-heading { align-items: flex-start; flex-direction: column; padding: 14px 16px; }
  .modal-backdrop { padding: 16px; align-items: flex-end; }
  .modal { width: 100%; padding: 20px; border-radius: 12px 12px 0 0; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions button, .modal button { width: 100%; }
  .incident div { grid-template-columns: 1fr; gap: 4px; }
}
