@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/Inter-Variable.woff2') format('woff2');
}

:root {
  --red: #E52325;
  --red-dark: #b81a1c;
  --bg: #F7F3EA;
  --pearl: #EDE2CC;
  --rosewood: #421112;
  --blackbean: #2F0506;
  --ink: #201313;
  --ink-soft: #6b5d55;
  --line: #e2d8c4;
  --white: #ffffff;
  --green: #2f8f4e;
  --green-bg: #e4f3e8;
  --amber: #b8790a;
  --amber-bg: #fbeed4;
  --red-bg: #fbdedb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(66, 17, 18, 0.06), 0 6px 20px rgba(66, 17, 18, 0.05);
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
}

h1, h2, h3, h4 { font-weight: 700; margin: 0 0 0.4em; line-height: 1.2; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { line-height: 1.55; }
a { color: var(--red-dark); }

.app-shell { display: flex; min-height: 100vh; }

/* Topbar */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 60px;
  background: var(--rosewood);
  color: var(--bg);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 10px;
  z-index: 20;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.05rem; color: #fff; text-decoration: none; }
.topbar .brand img, .topbar .brand svg { height: 30px; width: 30px; }
.topbar .app-name { opacity: 0.85; font-weight: 500; font-size: 0.85rem; border-left: 1px solid rgba(255,255,255,0.25); padding-left: 10px; margin-left: 2px; }
.topbar .spacer { flex: 1; }
.topbar .company { font-size: 0.85rem; opacity: 0.85; }
.topbar .whoami { font-size: 0.85rem; opacity: 0.9; display: flex; align-items: center; gap: 6px; }
.topbar .btn-ghost { color: #fff; border-color: rgba(255,255,255,0.35); }
.topbar .btn-ghost:hover { border-color: #fff; background: rgba(255,255,255,0.08); }

.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 6px;
  margin-right: 2px;
}
.nav-toggle svg { width: 22px; height: 22px; }

.nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  top: 60px;
  background: rgba(47, 5, 6, 0.45);
  z-index: 9;
}
.nav-overlay.open { display: block; }

/* Hjälpikon med hover-tooltip (native title-attribut) */
.help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--pearl);
  color: var(--rosewood);
  font-size: 0.68rem;
  font-weight: 800;
  font-style: normal;
  cursor: help;
  flex-shrink: 0;
}
.field label { display: flex; align-items: center; gap: 6px; }

/* Side nav */
.sidenav {
  position: fixed;
  top: 60px; left: 0; bottom: 0;
  width: 190px;
  background: var(--pearl);
  border-right: 1px solid var(--line);
  padding: 10px 8px;
  overflow-y: auto;
  z-index: 10;
}
.sidenav a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  border-radius: 7px;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 1px;
  line-height: 1.25;
}
.sidenav a svg { width: 15px; height: 15px; flex-shrink: 0; }
.sidenav a:hover { background: rgba(66,17,18,0.06); }
.sidenav a.active { background: var(--red); color: #fff; }
.sidenav .nav-section {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  margin: 12px 9px 4px;
}
.sidenav .nav-section:first-child { margin-top: 2px; }

/* Content */
.content {
  margin-left: 190px;
  margin-top: 60px;
  padding: 26px 30px 60px;
  width: 100%;
  max-width: 1180px;
}
.page-header { margin-bottom: 20px; }
.page-header p { color: var(--ink-soft); margin-top: 4px; max-width: 70ch; }

@media (max-width: 860px) {
  .nav-toggle { display: inline-flex; }
  .topbar .app-name, .topbar .company { display: none; }
  .sidenav {
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: var(--shadow);
  }
  .sidenav.open { transform: translateX(0); }
  .content { margin-left: 0; padding: 20px 16px 50px; }
}

/* Cards */
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}
.card h2, .card h3 { margin-bottom: 10px; }

/* Dashboard stat grid */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.stat-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}
.stat-card .stat-value { font-size: 1.9rem; font-weight: 800; line-height: 1; margin-bottom: 6px; }
.stat-card .stat-label { color: var(--ink-soft); font-size: 0.85rem; }
.stat-card.accent-red .stat-value { color: var(--red); }
.stat-card.accent-green .stat-value { color: var(--green); }
.stat-card.accent-amber .stat-value { color: var(--amber); }

.backup-summary-card, .risk-summary-card { padding-bottom: 14px; }
.summary-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.summary-table td { padding: 5px 0; }
.summary-table td:last-child { text-align: right; }
.summary-table a { text-decoration: none; }

.two-col { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

.deadline-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.deadline-list li { display: flex; justify-content: space-between; gap: 10px; padding: 9px 11px; border-radius: 8px; background: var(--bg); font-size: 0.87rem; }
.deadline-list li strong { font-weight: 600; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn:hover:not(:disabled) { border-color: var(--rosewood); }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--red-dark); border-color: var(--red-dark); }
.btn-ghost { background: transparent; border-color: transparent; padding: 6px 8px; }
.btn-danger { color: var(--red-dark); }
.btn-sm { padding: 5px 10px; font-size: 0.8rem; }
.btn:disabled { background: var(--pearl); border-color: var(--line); color: var(--ink-soft); opacity: 0.7; cursor: not-allowed; }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.span-2 { grid-column: span 2; }
@media (max-width: 700px) { .field.span-2 { grid-column: span 1; } }
.field label { font-size: 0.83rem; font-weight: 600; color: var(--ink); }
.field .hint { font-size: 0.76rem; color: var(--ink-soft); }
input, select, textarea {
  font-family: inherit;
  font-size: 0.92rem;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--red); outline-offset: 0; border-color: var(--red); }
textarea { resize: vertical; min-height: 70px; }
.checkbox-field { flex-direction: row; align-items: center; gap: 8px; }
.checkbox-field input { width: 16px; height: 16px; }
.multiselect-group { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.multiselect-option { display: flex; align-items: center; gap: 6px; font-size: 0.88rem; font-weight: 400; }
.multiselect-option input { width: 15px; height: 15px; }
.form-actions { display: flex; gap: 10px; margin-top: 16px; }

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.87rem; }
thead th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink-soft);
  padding: 8px 10px;
  border-bottom: 2px solid var(--line);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
thead th:hover { color: var(--ink); }
tbody td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:hover { background: rgba(66,17,18,0.03); }
.table-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.table-toolbar input[type="search"] { min-width: 220px; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.filter-select { font-size: 0.82rem; padding: 6px 9px; background: var(--bg); }
.empty-row td { text-align: center; color: var(--ink-soft); padding: 26px; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-red { background: var(--red-bg); color: var(--red-dark); }
.badge-neutral { background: var(--pearl); color: var(--ink); }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(47, 5, 6, 0.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto; z-index: 100;
}
.modal {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  width: 100%; max-width: 640px; padding: 24px;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }

/* Toast */
.toast {
  position: fixed; bottom: 22px; right: 22px; background: var(--rosewood); color: #fff;
  padding: 12px 18px; border-radius: 8px; font-size: 0.88rem; box-shadow: var(--shadow);
  z-index: 200; opacity: 0; transform: translateY(8px); transition: all .2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* Policy docs */
.doc-tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.doc-content { white-space: pre-wrap; line-height: 1.6; font-size: 0.93rem; }
.doc-content h2 { font-size: 1.05rem; margin-top: 1.1em; }

.signature-block { margin-top: 16px; padding: 10px 14px; border-radius: 8px; font-size: 0.88rem; }
.signature-signed { background: var(--green-bg); color: var(--green); }
.signature-pending { background: var(--amber-bg); color: var(--amber); }
.signature-none { background: var(--pearl); color: var(--ink-soft); }
.signature-image { display: block; margin-top: 8px; max-width: 260px; background: #fff; border: 1px solid var(--border); border-radius: 6px; }
.status-msg { color: var(--red-dark); font-size: 0.88rem; }

.name-field { margin-bottom: 14px; }
.name-field .label {
  display: block;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.name-field .locked-name {
  margin: 0;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-alt, #F1EDE1);
  font-size: 0.95rem;
}
.sign-pad-canvas {
  width: 100%;
  height: 180px;
  background: #FBFAF6;
  border: 1px dashed var(--border-strong, var(--border));
  border-radius: 8px;
  touch-action: none;
  cursor: crosshair;
  display: block;
}
.pad-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; gap: 12px; }

.muted { color: var(--ink-soft); }
.cell-time { color: var(--ink-soft); font-size: 0.85em; font-variant-numeric: tabular-nums; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.mt-0 { margin-top: 0; }

.stat-grid.compact { margin-bottom: 16px; }
.stat-grid.compact .stat-card { padding: 12px 14px; }
.stat-grid.compact .stat-value { font-size: 1.4rem; }
.stat-card-link { text-decoration: none; color: inherit; display: block; cursor: pointer; transition: border-color .15s, transform .1s; }
.stat-card-link:hover { border-color: var(--red); transform: translateY(-1px); }
.chart-card { padding: 18px 20px 8px; }
.chart-card svg { display: block; }
.chart-card svg text { user-select: none; }
.filter-chip { padding: 5px 10px; }
.date-filter { display: flex; align-items: center; gap: 6px; font-size: 0.82rem; color: var(--ink-soft); }
.date-filter input { font-size: 0.82rem; padding: 5px 7px; }

/* --- Utskrift --- */
#print-report { display: none; }
.print-header { margin-bottom: 18px; border-bottom: 2px solid var(--rosewood); padding-bottom: 10px; display: flex; align-items: center; gap: 14px; }
.print-header p { color: var(--ink-soft); margin: 2px 0 0; }
.print-logo { width: 40px; height: 40px; flex-shrink: 0; }
.print-section { margin-bottom: 26px; }
.print-section h2 { border-bottom: 1px solid var(--line); padding-bottom: 4px; margin-bottom: 10px; }
.print-chart { margin: 10px 0 14px; max-width: 480px; }
.print-stats { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 10px; font-size: 0.85rem; }
.print-stats span { background: var(--pearl); padding: 4px 10px; border-radius: 6px; }
.print-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
.print-table th, .print-table td { border: 1px solid var(--line); padding: 5px 7px; text-align: left; vertical-align: top; }
.print-record dl { display: grid; grid-template-columns: 220px 1fr; gap: 7px 14px; margin: 0; }
.print-record dt { font-weight: 600; color: var(--ink-soft); }
.print-record dd { margin: 0; }

@media print {
  body * { visibility: hidden; }
  #print-report, #print-report * { visibility: visible; }
  #print-report {
    display: block;
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    padding: 10mm;
  }
}
