@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --navy: #1F2A37;
  --navy-light: #2d3d4f;
  --navy-dark: #151e28;
  --orange: #E2680F;
  --orange-hover: #c45a0d;
  --orange-light: #fff4ec;
  --green: #16a34a;
  --green-light: #f0fdf4;
  --green-border: #bbf7d0;
  --red: #dc2626;
  --red-light: #fef2f2;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-400: #94a3b8;
  --gray-600: #475569;
  --gray-800: #1e293b;
  --white: #ffffff;
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 16px rgba(0,0,0,0.07), 0 1px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 40px rgba(0,0,0,0.10), 0 2px 8px rgba(0,0,0,0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Toppmeny ── */
header {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 0 1.25rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 8px rgba(0,0,0,0.06);
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: 120px;
}

.logo {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--navy);
  text-decoration: none;
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: var(--navy);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--orange);
  font-size: 1rem;
}

.logo span { color: var(--orange); }

nav {
  display: flex;
  gap: 0.1rem;
  margin-left: auto;
  align-items: center;
}

nav a {
  color: var(--gray-600);
  text-decoration: none;
  padding: 0.45rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s;
}

nav a:hover { color: var(--navy); background: var(--gray-100); }
nav a.active { color: var(--navy); background: var(--gray-100); font-weight: 600; }

.nav-logout {
  color: var(--gray-400) !important;
  font-size: 0.82rem !important;
}

/* ── Innhold ── */
main {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

h1 {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--navy);
  letter-spacing: -0.4px;
}

h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 0.75rem;
}

/* ── Stats-rad ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
}

.stat-label { font-size: 0.75rem; font-weight: 600; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 1.75rem; font-weight: 800; color: var(--navy); margin-top: 0.2rem; letter-spacing: -1px; }
.stat-value.green { color: var(--green); }
.stat-value.orange { color: var(--orange); }

/* ── Søk/filter ── */
.filter-bar {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 1.1rem;
  flex-wrap: wrap;
}

.filter-bar input, .filter-bar select {
  flex: 1;
  min-width: 140px;
  padding: 0.6rem 0.9rem;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  background: var(--white);
  color: var(--gray-800);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow-sm);
}

.filter-bar input:focus, .filter-bar select:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(226,104,15,0.12);
}

/* ── Bilkort ── */
.bil-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 1rem;
}

.bil-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1.5px solid var(--gray-200);
  overflow: hidden;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.bil-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--gray-200);
}

.bil-card.ledig { border-top: 3px solid var(--green); }
.bil-card.ute { border-top: 3px solid var(--orange); }

.bil-card-top {
  padding: 1rem 1rem 0.75rem;
}

.bil-card-meta {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.bil-regnr {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--navy);
  font-family: 'SF Mono', 'Cascadia Code', monospace;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.status-pill.ledig {
  background: var(--green-light);
  color: var(--green);
  border: 1px solid var(--green-border);
}

.status-pill.ute {
  background: var(--orange-light);
  color: var(--orange);
  border: 1px solid #fcd6ae;
}

.status-pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.bil-merke {
  font-size: 0.85rem;
  color: var(--gray-600);
  margin-top: 0.3rem;
  font-weight: 500;
}

.bil-type-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  background: var(--gray-100);
  color: var(--gray-400);
  margin-top: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.bil-status-info {
  padding: 0.6rem 1rem;
  font-size: 0.82rem;
  min-height: 2.5rem;
  line-height: 1.5;
}

.bil-card.ledig .bil-status-info {
  background: var(--green-light);
  color: #15803d;
  border-top: 1px solid var(--green-border);
}

.bil-card.ute .bil-status-info {
  background: var(--orange-light);
  color: #9a450a;
  border-top: 1px solid #fcd6ae;
}

.eu-varsel {
  background: var(--red-light);
  color: var(--red);
  font-size: 0.75rem;
  padding: 0.3rem 1rem;
  font-weight: 600;
  border-top: 1px solid #fecaca;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.bil-card-action {
  padding: 0.75rem;
  background: var(--gray-50);
  border-top: 1px solid var(--gray-100);
}

/* ── Knapper ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  line-height: 1;
  width: 100%;
  letter-spacing: -0.1px;
}

.btn-primary {
  background: var(--orange);
  color: var(--white);
  box-shadow: 0 2px 8px rgba(226,104,15,0.25);
}
.btn-primary:hover {
  background: var(--orange-hover);
  box-shadow: 0 4px 14px rgba(226,104,15,0.35);
  transform: translateY(-1px);
}

.btn-success {
  background: var(--green);
  color: var(--white);
  box-shadow: 0 2px 8px rgba(22,163,74,0.2);
}
.btn-success:hover {
  background: #15803d;
  transform: translateY(-1px);
}

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

.btn-outline {
  background: transparent;
  color: var(--navy);
  border: 1.5px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
}
.btn-outline:hover { background: var(--gray-50); border-color: var(--gray-400); }

.btn-danger { background: var(--red); color: var(--white); }
.btn-danger:hover { background: #b91c1c; }

.btn-ghost {
  background: transparent;
  color: var(--gray-600);
  border: none;
  width: auto;
  padding: 0.5rem 0.75rem;
}
.btn-ghost:hover { background: var(--gray-100); color: var(--navy); }

.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 600;
  width: auto;
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; }

/* ── Modal ── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.5);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop.open { display: flex; }

.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 1px solid var(--gray-200);
}

@keyframes modalIn {
  from { transform: scale(0.92) translateY(16px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

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

.modal-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 1.25rem;
}
.modal-actions .btn { flex: 1; }

/* ── Skjema ── */
.form-group { margin-bottom: 1rem; }

label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

input[type="text"],
input[type="date"],
input[type="search"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--gray-800);
  background: var(--white);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(226,104,15,0.12);
}

.required { color: var(--red); }

/* ── Tabell ── */
.table-wrap {
  overflow-x: auto;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th {
  background: var(--gray-50);
  color: var(--gray-600);
  padding: 0.7rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border-bottom: 1.5px solid var(--gray-200);
  white-space: nowrap;
}

td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
  color: var(--gray-800);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-50); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.badge-green { background: var(--green-light); color: var(--green); border: 1px solid var(--green-border); }
.badge-orange { background: var(--orange-light); color: var(--orange); border: 1px solid #fcd6ae; }
.badge-red { background: var(--red-light); color: var(--red); border: 1px solid #fecaca; }
.badge-gray { background: var(--gray-100); color: var(--gray-400); border: 1px solid var(--gray-200); }

/* ── Toast ── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
}

.toast {
  background: var(--gray-800);
  color: var(--white);
  padding: 0.75rem 1.4rem;
  border-radius: 30px;
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  white-space: nowrap;
  border: 1px solid rgba(255,255,255,0.08);
}

.toast.error { background: var(--red); }
.toast.success { background: var(--green); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Tom tilstand ── */
.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--gray-400);
}

.empty-state p { margin-top: 0.5rem; font-size: 0.9rem; }

/* ── Historikk-filter ── */
.history-filter {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.6rem;
}

/* ── QR-side ── */
.qr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}

.qr-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
}

.qr-card svg { width: 100%; height: auto; }

.qr-regnr {
  font-family: monospace;
  font-size: 1rem;
  font-weight: 800;
  color: var(--navy);
  margin-top: 0.5rem;
  letter-spacing: 1px;
}

.qr-merke { font-size: 0.75rem; color: var(--gray-400); margin-top: 0.15rem; }

/* ── Bil-direkteside ── */
.bil-direkte {
  max-width: 480px;
  margin: 2rem auto;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  overflow: hidden;
}

.bil-direkte-header {
  background: var(--navy);
  color: var(--white);
  padding: 1.5rem;
}

.bil-direkte-regnr {
  font-family: monospace;
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 2px;
}

.bil-direkte-body { padding: 1.25rem; }

/* ── Login ── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy) 100%);
  padding: 1rem;
}

.login-box {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
}

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

.login-logo-icon {
  width: 56px;
  height: 56px;
  background: var(--navy);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  margin: 0 auto 0.75rem;
}

.login-logo h1 {
  font-size: 1.4rem;
  color: var(--navy);
  letter-spacing: -0.5px;
}

.login-logo h1 span { color: var(--orange); }
.login-logo p { color: var(--gray-400); font-size: 0.875rem; margin-top: 0.2rem; }

.feil {
  background: var(--red-light);
  color: var(--red);
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-bottom: 0.85rem;
  display: none;
  border: 1px solid #fecaca;
  font-weight: 500;
}

.feil.vis { display: block; }

@media print {
  header, .btn, nav { display: none !important; }
  .qr-grid { grid-template-columns: repeat(3, 1fr); }
  .qr-card { break-inside: avoid; }
}

/* ── Responsivt ── */
@media (max-width: 500px) {
  .bil-grid { grid-template-columns: 1fr; }
  .modal { padding: 1.25rem; border-radius: var(--radius); }
  nav a { padding: 0.4rem 0.6rem; font-size: 0.82rem; }
  h1 { font-size: 1.2rem; }
}
