/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

:root {
  --bg:       #f5f6fa;
  --surface:  #ffffff;
  --border:   #dde1ea;
  --text:     #1e2432;
  --muted:    #6b7280;
  --primary:  #2563eb;
  --primary-h:#1d4ed8;
  --danger:   #dc2626;
  --danger-h: #b91c1c;
  --ok:       #16a34a;
  --warn:     #d97706;
  --radius:   6px;
  --shadow:   0 1px 3px rgba(0,0,0,.08);
}

html {
  font-size: 15px;
  scrollbar-gutter: stable;
  scrollbar-width: none;
}

html::-webkit-scrollbar {
  width: 0;
  height: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

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

h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.2rem; font-weight: 600; margin: 1.5rem 0 .75rem; }
h3 { font-size: 1rem;   font-weight: 600; margin: 1rem 0 .5rem; }
h4 { font-size: .9rem;  font-weight: 600; margin: .75rem 0 .25rem; color: var(--muted); }

/* ── Nav ──────────────────────────────────────────────────────────────────── */
.topnav {
  background: #1e293b;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .6rem 1.5rem;
  flex-wrap: wrap;
}
.topnav .brand {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  margin-right: auto;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
}
.topnav .brand i {
  width: 18px;
  height: 18px;
}
.nav-toggle {
  display: none;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid #475569;
  border-radius: var(--radius);
  background: #0f172a;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-direction: column;
}
.nav-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: #e2e8f0;
  border-radius: 999px;
  transition: transform .2s ease, opacity .2s ease;
}
.topnav.is-open .nav-toggle span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}
.topnav.is-open .nav-toggle span:nth-child(2) {
  opacity: 0;
}
.topnav.is-open .nav-toggle span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}
.topnav ul {
  list-style: none;
  display: flex;
  align-items: center;
  gap: .25rem;
  flex-wrap: wrap;
}
.topnav li {
  display: flex;
  align-items: center;
}
.topnav ul a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #cbd5e1;
  padding: .3rem .65rem;
  border-radius: var(--radius);
  font-size: .9rem;
  white-space: nowrap;
}
.topnav ul a.nav-icon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
}
.topnav ul a.nav-icon-link i {
  width: 14px;
  height: 14px;
}
.topnav ul a:hover { background: #334155; color: #fff; text-decoration: none; }
.topnav ul a.btn-nav,
.topnav button.btn-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  padding: .3rem .65rem;
  min-height: 32px;
  border: none;
  border-radius: var(--radius);
  font-size: .9rem;
  line-height: 1;
  font-family: inherit;
  white-space: nowrap;
  cursor: pointer;
}
.topnav button.btn-nav-secondary {
  background: #0f172a;
  border: 1px solid #475569;
  color: #e2e8f0;
}
.topnav button.btn-nav-secondary:hover {
  background: #334155;
}
.topnav ul a.btn-nav:hover,
.topnav button.btn-nav:hover { background: var(--primary-h); }
.topnav .pwa-install-slot {
  display: flex;
}
.topnav form {
  margin: 0;
  display: inline-flex;
  align-items: center;
}
.topnav select {
  border: 1px solid #475569;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: var(--radius);
  padding: .35rem .55rem;
  font-size: .9rem;
}
.topnav .btn-link {
  color: #cbd5e1;
  padding: .3rem .65rem;
}
.topnav .btn-link:hover {
  background: #334155;
  color: #fff;
  text-decoration: none;
}

.pwa-ios-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .65rem 1rem;
  background: #dbeafe;
  border-bottom: 1px solid #bfdbfe;
  color: #1e3a8a;
  font-size: .92rem;
}

.pwa-ios-hint .btn-link {
  padding: 0;
  color: #1d4ed8;
  font-weight: 600;
}

/* ── Container ────────────────────────────────────────────────────────────── */
.container { max-width: 1200px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }

/* ── Page header ──────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.page-header h1 { flex: 1; }
.page-header small { font-size: 1rem; color: var(--muted); font-weight: 400; }

.page-header-actions {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  flex-wrap: wrap;
}

/* ── KPI ──────────────────────────────────────────────────────────────────── */
.kpi-box {
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius);
  padding: .5rem 1.2rem;
  text-align: center;
  min-width: 90px;
}
.kpi-number { font-size: 2rem; font-weight: 800; display: block; }
.kpi-label  { font-size: .75rem; opacity: .85; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn, button[type=submit] {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: .45rem 1rem;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.4;
}
.btn:hover, button[type=submit]:hover { background: var(--primary-h); text-decoration: none; color: #fff; }

.btn-sec { background: #e2e8f0; color: var(--text); }
.btn-sec:hover { background: #cbd5e1; color: var(--text); }

.btn-danger { background: var(--danger); }
.btn-danger:hover { background: var(--danger-h); }

.btn-sm { padding: .25rem .6rem; font-size: .82rem; }

.disabled { opacity: .55; pointer-events: none; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  margin-top: 1rem;
  flex-wrap: wrap;
  width: 100%;
  text-align: center;
}

.pagination-status {
  font-size: .95rem;
  color: var(--muted);
  text-align: center;
}

.btn-link {
  color: var(--primary);
  background: none;
  border: none;
  cursor: pointer;
  font-size: .9rem;
  text-decoration: none;
  padding: .25rem .4rem;
  display: inline-block;
}
.btn-link:hover { text-decoration: underline; }

.action-nowrap {
  white-space: nowrap;
}

.user-actions {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  white-space: nowrap;
}

.user-actions form {
  margin: 0;
  display: inline-flex;
}

.user-actions .btn-link.btn-icon {
  min-width: 50px;
  padding: .2rem .4rem;
  justify-content: center;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
}

.btn-icon i {
  width: 15px;
  height: 15px;
}

.role-chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .2rem .55rem;
  font-weight: 600;
}

.role-chip:hover {
  text-decoration: none;
  border-color: var(--primary);
  background: #eff6ff;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .2rem .55rem;
  font-size: .82rem;
  font-weight: 600;
}

.role-owner {
  border-color: #b45309;
  background: #fffbeb;
  color: #92400e;
}

.role-admin {
  border-color: #1d4ed8;
  background: #eff6ff;
  color: #1e40af;
}

.role-staff {
  border-color: #0f766e;
  background: #f0fdfa;
  color: #115e59;
}

.role-platform-admin {
  border-color: #6d28d9;
  background: #f5f3ff;
  color: #5b21b6;
}

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.alert {
  border-radius: var(--radius);
  padding: .85rem 1rem;
  margin-bottom: 1rem;
  font-size: .9rem;
}
.alert ul { margin: .4rem 0 0 1.2rem; }
.alert-ok  { background: #dcfce7; border-left: 4px solid var(--ok);   color: #14532d; }
.alert-err { background: #fee2e2; border-left: 4px solid var(--danger); color: #7f1d1d; }
.alert-info { background: #dbeafe; border-left: 4px solid #3b82f6; color: #1e3a8a; }

/* ── Search form ──────────────────────────────────────────────────────────── */
.search-form {
  display: flex;
  gap: .5rem;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.search-form input[type=text] {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .4rem .75rem;
  font-size: .9rem;
  min-width: 240px;
  max-width: 400px;
  flex: 1;
}
.search-form select {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .4rem .75rem;
  font-size: .9rem;
}

/* ── Table ────────────────────────────────────────────────────────────────── */
.table-wrap {
  margin-bottom: 1.25rem;
}
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: .9rem;
  table-layout: fixed;
}
th, td {
  padding: .4rem .6rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
th { background: #f1f5f9; font-weight: 600; font-size: .82rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }
tr.row-active td { background: #fffbeb; }
td.empty { color: var(--muted); font-style: italic; padding: 1.5rem; text-align: center; }

/* Table column widths for consistent appearance */
.users-table th:nth-child(1),
.pending-table th:nth-child(1),
.recent-table th:nth-child(1) { width: 30%; }

.users-table th:nth-child(2),
.pending-table th:nth-child(2),
.recent-table th:nth-child(2) { width: 25%; }

.users-table th:nth-child(3),
.pending-table th:nth-child(3),
.recent-table th:nth-child(3) { width: 20%; }

.users-table th:nth-child(4),
.pending-table th:nth-child(4),
.recent-table th:nth-child(4) { width: 15%; }

.users-table th:nth-child(5),
.pending-table th:nth-child(5),
.recent-table th:nth-child(5) { width: 10%; }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 1rem;
}
.form-group label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  margin-bottom: .3rem;
  color: var(--text);
}
.form-group input[type=text],
.form-group input[type=email],
.form-group input[type=password],
.form-group input[type=date],
.form-group input[type=number],
.form-group select,
.form-group textarea {
  width: 100%;
  max-width: 480px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .45rem .75rem;
  font-size: .9rem;
  font-family: inherit;
  background: var(--surface);
}
.form-group textarea { min-height: 80px; resize: vertical; }
.form-actions { margin-top: 1.5rem; display: flex; gap: .75rem; align-items: center; }
.req { color: var(--danger); }

.radio-group { display: flex; flex-direction: column; gap: .35rem; }
.radio-group label { font-weight: 400; display: flex; align-items: center; gap: .4rem; cursor: pointer; }

.inline-form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.inline-form input, .inline-form select { padding: .35rem .65rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: .9rem; }

.surface-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}

.receipt-card {
  max-width: 760px;
  margin: 0 auto 1rem;
}

.receipt-grid {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: .75rem 1rem;
  margin: 1rem 0;
}

.receipt-grid dt {
  color: var(--muted);
  font-weight: 600;
}

.receipt-grid dd {
  margin: 0;
  font-weight: 500;
}

.receipt-actions {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.receipt-meta {
  font-size: .85rem;
  color: var(--muted);
  margin-top: .5rem;
}

.dashboard-table td:last-child form {
  margin: 0;
}

.loan-panel.active {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
}

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
  background: #e2e8f0;
  color: var(--text);
}
.badge-ok   { background: #dcfce7; color: #15803d; }
.badge-warn { background: #fef3c7; color: #92400e; }
.badge-err  { background: #fee2e2; color: #b91c1c; }

/* ── Info grid ────────────────────────────────────────────────────────────── */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .5rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  font-size: .9rem;
}

/* ── Two-column layout ────────────────────────────────────────────────────── */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}
@media (max-width: 768px) { .two-col { grid-template-columns: 1fr; } }

/* ── Quick actions ────────────────────────────────────────────────────────── */
.quick-actions { display: flex; gap: .75rem; margin-top: 1.5rem; flex-wrap: wrap; }

/* ── Section header ───────────────────────────────────────────────────────── */
.section-header { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.section-header h2 { flex: 1; }

/* ── Hier list ────────────────────────────────────────────────────────────── */
.hier-list { list-style: none; font-size: .9rem; }
.hier-list li { padding: .3rem 0; border-bottom: 1px solid var(--border); }

/* ── Import grid ──────────────────────────────────────────────────────────── */
.import-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.import-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}
.import-card h3 { margin-top: 0; }
.import-card input[type=file] { margin-top: .75rem; }

/* ── Code block ───────────────────────────────────────────────────────────── */
pre.code-block {
  background: #1e293b;
  color: #e2e8f0;
  padding: .85rem 1rem;
  border-radius: var(--radius);
  font-size: .82rem;
  overflow-x: auto;
  margin-bottom: 1rem;
  white-space: pre;
}
code { font-family: 'Cascadia Code', 'Fira Code', monospace; font-size: .85em; background: #f1f5f9; padding: .1em .35em; border-radius: 3px; }

/* ── Hint ─────────────────────────────────────────────────────────────────── */
.hint { font-size: .82rem; color: var(--muted); margin: .25rem 0; }

/* ── Text helpers ─────────────────────────────────────────────────────────── */
.text-warn { color: var(--warn); }

/* ── Error page ───────────────────────────────────────────────────────────── */
.error-page { text-align: center; padding: 4rem 1rem; }
.error-page h1 { font-size: 2.5rem; margin-bottom: 1rem; }

/* ── Footer ───────────────────────────────────────────────────────────────── */
.footer {
  text-align: center;
  padding: 1rem;
  font-size: .8rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

body.modal-open {
  overflow: hidden;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(30, 36, 50, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1000;
}

.modal-backdrop[hidden] {
  display: none !important;
}

.modal {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.25rem;
}

.modal h3,
.modal h2 {
  margin-top: 0;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .75rem;
  gap: .6rem;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
  margin-top: 1rem;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #f8fafc;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.modal-close:hover {
  background: #eef2f7;
  color: var(--text);
}

.modal-role {
  max-width: 560px;
}

.role-card-list {
  display: flex;
  flex-direction: column;
  gap: .55rem;
}

.role-card {
  position: relative;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  display: flex;
  align-items: flex-start;
  gap: .65rem;
  text-align: left;
  padding: .75rem .8rem;
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease, box-shadow .12s ease;
}

.role-card:hover {
  border-color: var(--primary);
  background: #f8fbff;
}

.role-card:focus-visible {
  outline: 2px solid rgba(37, 99, 235, .55);
  outline-offset: 1px;
}

.role-card.is-selected {
  border-color: var(--primary);
  background: #eff6ff;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, .15);
}

.role-card.is-selected::after {
  content: 'Valgt';
  position: absolute;
  right: .7rem;
  top: .65rem;
  font-size: .72rem;
  font-weight: 700;
  color: var(--primary-h);
}

.role-card-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid currentColor;
}

.role-card-icon i {
  width: 16px;
  height: 16px;
}

.role-card small {
  display: block;
  color: var(--muted);
  font-size: .8rem;
  margin-top: .1rem;
  line-height: 1.35;
}

.role-card strong {
  display: inline-block;
  margin-bottom: .05rem;
}

/* ── Autocomplete Suggestions ─────────────────────────────────────────────── */
.form-group {
  position: relative;
}

.suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 200px;
  overflow-y: auto;
  z-index: 1000;
  width: 100%;
  display: none;
}

.suggestions div {
  padding: .5rem .75rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}

.suggestions div:hover {
  background: var(--bg);
}

.suggestions div:last-child {
  border-bottom: none;
}

/* ── Login page ───────────────────────────────────────────────────────────── */
.login-wrapper {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 6vh;
  min-height: 72vh;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 4px 28px rgba(0, 0, 0, .1), 0 1px 4px rgba(0, 0, 0, .06);
  padding: 2.75rem 3rem;
  width: 100%;
  max-width: 420px;
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.login-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  margin-bottom: .4rem;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .12));
}

.login-icon i {
  width: 40px;
  height: 40px;
}

.login-title {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -.025em;
  color: var(--text);
}

.login-subtitle {
  color: var(--muted);
  font-size: .9rem;
  margin-top: .25rem;
}

.login-form .form-group input {
  max-width: 100%;
  padding: .6rem .9rem;
  font-size: 1rem;
}

.login-form .form-group label {
  font-size: .88rem;
}

.login-meta-link {
  margin-top: .45rem;
  text-align: right;
}

.login-meta-link a {
  font-size: .85rem;
}

.login-btn {
  width: 100%;
  padding: .7rem 1rem;
  font-size: 1rem;
  margin-top: .25rem;
  border-radius: 8px;
  letter-spacing: .01em;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .container { padding: 1.1rem .9rem 2rem; }

  .page-header {
    align-items: stretch;
    gap: .75rem;
  }

  .page-header h1 {
    flex: 1 1 100%;
  }

  .kpi-box {
    min-width: 0;
  }

  .search-form input[type=text],
  .search-form select,
  .search-form button,
  .search-form .btn-link,
  .inline-form input,
  .inline-form select,
  .inline-form button,
  .inline-form .btn,
  .inline-form .btn-link {
    width: 100%;
    max-width: none;
  }

  .form-group input[type=text],
  .form-group input[type=email],
  .form-group input[type=password],
  .form-group input[type=date],
  .form-group input[type=number],
  .form-group select,
  .form-group textarea {
    max-width: none;
  }
}

@media (max-width: 600px) {
  .topnav { padding: .5rem .75rem; }
  h1 { font-size: 1.3rem; }
  .login-card { padding: 2rem 1.5rem; margin: 0 .5rem; }

  #modal-role.modal-backdrop {
    padding: 0;
  }

  .modal-role {
    max-width: none;
    width: 100%;
    height: 100%;
    border-radius: 0;
    border: 0;
    padding: 1rem;
    display: flex;
    flex-direction: column;
  }

  .modal-role .modal-body {
    flex: 1;
    overflow: auto;
    padding-bottom: .5rem;
  }
}

@media (max-width: 768px) {
  html {
    font-size: 16px;
  }

  .topnav {
    padding: .65rem .8rem;
    gap: .75rem;
    align-items: flex-start;
  }

  .topnav .brand {
    width: auto;
    margin-right: 0;
    flex: 1;
  }

  .nav-toggle {
    display: inline-flex;
    flex-shrink: 0;
  }

  .topnav ul.topnav-links {
    display: none;
    width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .45rem;
    padding-top: .35rem;
    border-top: 1px solid #334155;
  }

  .topnav.is-open ul.topnav-links {
    display: grid;
  }

  .topnav ul {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .45rem;
  }

  .topnav li {
    min-width: 0;
  }

  .topnav ul a,
  .topnav ul .btn-link,
  .topnav ul select,
  .topnav ul form,
  .topnav ul button {
    width: 100%;
  }

  .topnav ul a,
  .topnav ul .btn-link,
  .topnav ul button {
    display: block;
    text-align: center;
  }

  .topnav .pwa-install-slot {
    grid-column: 1 / -1;
  }

  .container {
    padding: .9rem .75rem 1.5rem;
  }

  .pwa-ios-hint {
    align-items: flex-start;
    padding: .65rem .75rem;
  }

  .page-header > .btn,
  .page-header > .btn-sec,
  .page-header > .btn-link,
  .page-header > div,
  .page-header > a,
  .page-header > button {
    width: 100%;
  }

  .page-header > div {
    display: flex;
    flex-direction: column;
    gap: .5rem;
  }

  .desktop-only {
    display: none !important;
  }

  .kpi-box {
    width: 100%;
    padding: .8rem 1rem;
  }

  .search-form,
  .inline-form,
  .form-actions,
  .quick-actions,
  .key-mode-toggle {
    flex-direction: column;
    align-items: stretch;
  }

  .pagination {
    justify-content: center;
    align-items: center;
  }

  .pagination-status {
    width: 100%;
    order: -1;
  }

  .form-actions .btn,
  .form-actions .btn-link,
  .form-actions button,
  .quick-actions .btn,
  .quick-actions .btn-link {
    width: 100%;
    text-align: center;
  }

  .loan-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .5rem;
    border-bottom: none;
  }

  .loan-tab {
    width: 100%;
    padding: .75rem .8rem;
    margin-bottom: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }

  .loan-tab.active {
    background: #eef4ff;
  }

  .key-mode-toggle label {
    width: 100%;
    padding: .65rem .8rem;
  }

  .info-grid {
    grid-template-columns: 1fr;
    padding: .85rem 1rem;
  }

  .receipt-grid {
    grid-template-columns: 1fr;
    gap: .25rem;
  }

  .receipt-actions {
    flex-direction: column;
  }

  .receipt-actions .btn,
  .receipt-actions .btn-link,
  .receipt-actions button {
    width: 100%;
    text-align: center;
  }

  .mobile-cards thead {
    display: none;
  }

  .mobile-cards,
  .mobile-cards tbody,
  .mobile-cards tr,
  .mobile-cards td {
    display: block;
    width: 100%;
  }

  .mobile-cards {
    background: transparent;
    box-shadow: none;
  }

  .mobile-cards tr {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: .85rem;
    overflow: hidden;
  }

  .mobile-cards td {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    padding: .7rem .85rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
  }

  .mobile-cards td::before {
    content: attr(data-label);
    font-size: .76rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .04em;
  }

  .mobile-cards td:last-child {
    border-bottom: none;
  }

  .mobile-cards td.actions form,
  .mobile-cards td.actions button,
  .mobile-cards td.actions .btn,
  .mobile-cards td.actions .btn-danger {
    width: 100%;
  }

  .dashboard-table.mobile-cards thead .mobile-hide,
  .dashboard-table.mobile-cards tbody .mobile-hide {
    display: none;
  }

  .key-types-table .mobile-hide {
    display: none;
  }

  .dashboard-table.mobile-cards tr {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0;
    align-items: center;
  }

  .dashboard-table.mobile-cards td {
    padding: .65rem .8rem;
  }

  .dashboard-table.mobile-cards td::before {
    display: none;
  }

  .dashboard-table.mobile-cards td.col-person,
  .dashboard-table.mobile-cards td.col-key {
    border-bottom: none;
  }

  .dashboard-table.mobile-cards td.col-person {
    font-weight: 600;
    padding-bottom: .2rem;
  }

  .dashboard-table.mobile-cards td.col-key {
    color: var(--muted);
    padding-top: .1rem;
    padding-bottom: .7rem;
  }

  .dashboard-table.mobile-cards td.col-action {
    grid-column: 2;
    grid-row: 1 / span 2;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 92px;
    border-left: 1px solid var(--border);
    border-bottom: none;
    padding: .75rem;
  }

  .dashboard-table.mobile-cards td.col-action form,
  .dashboard-table.mobile-cards td.col-action button {
    width: 100%;
  }

  .suggestions {
    max-height: 240px;
  }
}

@media print {
  body {
    background: #fff;
  }

  .no-print,
  .topnav,
  .footer,
  .nav-toggle,
  .btn,
  .btn-link,
  .receipt-actions,
  .alert,
  .modal-backdrop {
    display: none !important;
  }

  .container {
    max-width: none;
    padding: 0;
  }

  .surface-card,
  .receipt-card {
    box-shadow: none;
    border: 1px solid #d1d5db;
    margin: 0;
  }
}
