:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --ink: #1c2330;
  --muted: #6b7686;
  --line: #e3e8ef;
  --brand: #1f4e79;
  --brand-2: #2d6da3;
  --ok: #1f9d57;
  --ok-bg: #e7f6ee;
  --warn: #b8770a;
  --warn-bg: #fdf3e0;
  --crit: #c1373a;
  --crit-bg: #fbe9e9;
  --high: #d97a1e;
  --high-bg: #fdf0e3;
  --med: #2d6da3;
  --med-bg: #e8f1f8;
  --low: #6b7686;
  --low-bg: #eef1f5;
  --info: #2d6da3;
  --info-bg: #e8f1f8;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(20, 30, 50, 0.08), 0 1px 2px rgba(20, 30, 50, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.5;
}

/* ---- Topbar ---- */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  background: var(--brand);
  color: #fff;
  padding: 10px 20px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  background: #fff;
  color: var(--brand);
  font-weight: 800;
  letter-spacing: 0.5px;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 16px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 15px; }
.brand-text small { opacity: 0.85; font-size: 12px; }

.org { display: flex; flex-direction: column; gap: 2px; margin-left: auto; }
.org label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; opacity: 0.85; }
.org input {
  border: none;
  border-radius: 6px;
  padding: 6px 10px;
  min-width: 240px;
  font-size: 14px;
}
.topbar-actions { display: flex; gap: 8px; }

/* ---- Layout ---- */
.layout { display: flex; min-height: calc(100vh - 56px); }
.sidebar {
  width: 220px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
}
.nav-item:hover { background: var(--bg); }
.nav-item.active { background: var(--med-bg); color: var(--brand); font-weight: 600; }
.nav-ico { width: 18px; display: inline-block; text-align: center; opacity: 0.7; }
.sidebar-foot { margin-top: auto; padding: 12px; color: var(--muted); font-size: 11px; }

.content { flex: 1; padding: 24px 28px; outline: none; max-width: 1200px; }

/* ---- Headings ---- */
.view-head { display: flex; align-items: center; gap: 16px; margin-bottom: 4px; }
.view-head h1 { font-size: 22px; margin: 0; }
.view-head .btn { margin-left: auto; }
h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--muted); font-size: 13px; }
.view-head .muted { margin-left: auto; }

/* ---- Buttons ---- */
.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2); }
.btn-ghost { background: rgba(255, 255, 255, 0.15); color: #fff; border-color: rgba(255, 255, 255, 0.35); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.28); }
.content .btn-ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.content .btn-ghost:hover { background: var(--bg); }
.btn-danger { background: var(--crit); color: #fff; }
.btn-danger:hover { filter: brightness(0.95); }
.link {
  background: none; border: none; color: var(--brand-2);
  cursor: pointer; font-size: 13px; padding: 2px 4px; font-family: inherit;
}
.link:hover { text-decoration: underline; }
.link-danger { color: var(--crit); }

/* ---- Panels & cards ---- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-top: 18px;
  box-shadow: var(--shadow);
}
.intro p { max-width: 720px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-2 .panel { margin-top: 18px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 18px; }
@media (max-width: 900px) { .cards { grid-template-columns: repeat(2, 1fr); } }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.card-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }
.card-value { font-size: 30px; font-weight: 700; margin: 4px 0; }
.card-sub { font-size: 12px; color: var(--muted); }
.card-score { color: #fff; border: none; }
.card-score .card-label, .card-score .card-sub { color: rgba(255, 255, 255, 0.85); }
.card-ok { background: var(--ok); }
.card-warn { background: var(--warn); }
.card-crit { background: var(--crit); }

/* ---- Tables ---- */
.table { width: 100%; border-collapse: collapse; margin-top: 8px; background: var(--panel); }
.content > .table, .view-head + .table { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); background: #fafbfc; }
.table tr:last-child td { border-bottom: none; }
.cell-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.row-actions { white-space: nowrap; text-align: right; }

/* ---- Badges ---- */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-default { background: var(--low-bg); color: var(--low); }
.badge-crit { background: var(--crit-bg); color: var(--crit); }
.badge-high { background: var(--high-bg); color: var(--high); }
.badge-med { background: var(--med-bg); color: var(--med); }
.badge-low { background: var(--low-bg); color: var(--low); }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-info { background: var(--info-bg); color: var(--info); }

/* ---- Misc text ---- */
.empty {
  padding: 28px;
  text-align: center;
  color: var(--muted);
  background: var(--panel);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  margin-top: 18px;
}
.ok-text { color: var(--ok); font-weight: 600; }
.crit-text { color: var(--crit); font-weight: 600; }
.gaplist { list-style: none; padding: 0; margin: 8px 0 0; }
.gaplist li { padding: 6px 0; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.gaplist li:last-child { border-bottom: none; }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(18, 26, 40, 0.5);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; z-index: 100; overflow-y: auto;
}
.modal {
  background: #fff; border-radius: 12px; width: 100%; max-width: 520px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25); animation: pop 0.12s ease-out;
}
.modal-wide { max-width: 720px; }
@keyframes pop { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-header { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0; }
.modal-close { margin-left: auto; background: none; border: none; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); }
.modal-body { padding: 20px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.confirm-text { margin: 0; }

/* ---- Forms ---- */
.field { display: block; margin-bottom: 14px; }
.field-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.field-hint { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 14px; font-family: inherit; color: var(--ink); background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--med); border-color: var(--med); }
.field textarea { resize: vertical; }
.form-note { background: var(--bg); border-radius: 8px; padding: 10px 12px; margin-bottom: 16px; font-size: 14px; }
.time-field { display: grid; grid-template-columns: 1fr 130px; gap: 8px; }
.grid-2-tight { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .grid-2-tight { grid-template-columns: 1fr; } }

.check-group {
  display: flex; flex-direction: column; gap: 6px; max-height: 180px; overflow-y: auto;
  border: 1px solid var(--line); border-radius: 8px; padding: 10px;
}
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 400; cursor: pointer; }
.check input { width: auto; }

.impact-grid { display: flex; flex-direction: column; gap: 8px; }
.impact-row { display: grid; grid-template-columns: 1fr 160px; align-items: center; gap: 10px; }

/* ---- Gjenopprettingsplaner ---- */
.plan-list { display: flex; flex-direction: column; gap: 16px; }
.plan-card { margin-top: 0; }
.plan-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.plan-head h2 { margin: 0 0 2px; }
.plan-head .row-actions { text-align: right; }
.plan-meta { display: grid; grid-template-columns: 160px 1fr; gap: 4px 16px; margin: 14px 0 0; font-size: 14px; }
.plan-meta dt { color: var(--muted); font-weight: 600; }
.plan-meta dd { margin: 0; }
.steps { margin: 14px 0 0; padding-left: 22px; }
.steps li { padding: 4px 0; }
.steps li span { display: inline; }
.step-meta { color: var(--muted); font-size: 12px; margin-left: 8px; }

.steps-editor { border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.step-head, .step-row { display: grid; grid-template-columns: 1fr 130px 90px 28px; gap: 8px; align-items: center; }
.step-head { font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); margin-bottom: 6px; }
.step-row { margin-bottom: 8px; }
.step-row input { width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; font-size: 14px; font-family: inherit; }
.step-del { font-size: 20px; line-height: 1; padding: 0; }
.btn-sm { padding: 6px 10px; font-size: 13px; }
@media (max-width: 640px) { .plan-meta { grid-template-columns: 1fr; } }

/* ---- Toast ---- */
.toast-root { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast {
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px;
  font-size: 14px; box-shadow: var(--shadow); opacity: 0; transform: translateX(20px);
  transition: opacity 0.25s, transform 0.25s; max-width: 320px;
}
.toast.show { opacity: 1; transform: none; }
.toast-ok { background: var(--ok); }
.toast-warn { background: var(--warn); }
.toast-crit { background: var(--crit); }
