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

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #f0f2f5;
  color: #1a1a2e;
  line-height: 1.6;
  min-height: 100vh;
}

main {
  max-width: 860px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

h1 {
  font-size: 1.8rem;
  font-weight: 700;
  color: #003366;
  margin-bottom: 0.5rem;
}

.lysing {
  color: #555;
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

/* Form */
.innslattr {
  background: #fff;
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  margin-bottom: 1.5rem;
}

.form-rod label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.4rem;
  font-size: 0.95rem;
}

.slider-hluti {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid #eee;
}

.slider-hluti > label {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}

.slider-hluti > label strong {
  color: #003366;
}

.slider-hluti input[type="range"] {
  width: 100%;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  height: 18px; /* hæð = thumb-stærð svo Chrome skráir smelli á allan thumb */
  background: transparent;
  outline: none;
  display: block;
  margin: 0.25rem 0;
}

/* Track — Chrome/Safari */
.slider-hluti input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: #ccd5e0;
}

/* Thumb — Chrome/Safari */
.slider-hluti input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #003366;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  margin-top: -6px; /* miðjar thumb á 6px track: (6 - 18) / 2 */
}

/* Track — Firefox */
.slider-hluti input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: #ccd5e0;
}

/* Thumb — Firefox */
.slider-hluti input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #003366;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.slider-ar-merki {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: #888;
  margin-top: 0.2rem;
}

.input-takki {
  display: flex;
  gap: 0.5rem;
}

.input-takki input {
  flex: 1;
  padding: 0.6rem 0.8rem;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  outline: none;
  transition: border-color 0.2s;
}

.input-takki input:focus {
  border-color: #003366;
  box-shadow: 0 0 0 2px rgba(0, 51, 102, 0.15);
}

.input-takki button {
  padding: 0.6rem 1.4rem;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: #003366;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.input-takki button:hover {
  background: #004a99;
}

.villa {
  color: #c0392b;
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

/* Tafla */
.tafla-umgjord {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

#skattafla {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  font-size: 0.92rem;
}

#skattafla thead th {
  background: #003366;
  color: #fff;
  padding: 0.7rem 0.8rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
}

#skattafla tbody td {
  padding: 0.55rem 0.8rem;
  border-bottom: 1px solid #e8eaed;
}

#skattafla tbody tr:nth-child(even) {
  background: #f7f8fa;
}

#skattafla tbody tr:hover {
  background: #e8f0fe;
}

#skattafla tbody tr.nuverandi-ar {
  font-weight: 700;
  background: #dbe9ff;
}

.tala {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.nedanmals {
  margin-top: 1rem;
  font-size: 0.82rem;
  color: #777;
  line-height: 1.5;
}

/* ── Vísitala-toggle ───────────────────────────────────────── */
.visitala-toggle {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.toggle-merkiord {
  font-weight: 600;
  font-size: 0.9rem;
  color: #555;
  white-space: nowrap;
}

.toggle-hnappar {
  display: flex;
  gap: 0.25rem;
}

.toggle-takki {
  padding: 0.35rem 1rem;
  font-size: 0.88rem;
  border: 1.5px solid #003366;
  border-radius: 20px;
  background: #fff;
  color: #003366;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.toggle-takki.active {
  background: #003366;
  color: #fff;
}

.toggle-takki:hover:not(.active) {
  background: #e8f0fe;
}

/* ── Línurit ───────────────────────────────────────────────── */
.grafikk-umgjord {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  padding: 1.25rem;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

.grafikk-stillingar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin-bottom: 1rem;
}

.grafikk-takki {
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  border: 1.5px solid #ccc;
  border-radius: 20px;
  background: #fff;
  color: #555;
  cursor: pointer;
  transition: opacity 0.15s, border-color 0.15s;
}

.grafikk-takki:not(.active) {
  opacity: 0.45;
}

.launavisitala-litur { border-color: #003366; color: #003366; }
.neysluverds-litur   { border-color: #2980b9; color: #2980b9; }
.utborgud-litur      { border-color: #27ae60; color: #27ae60; }
.skattprosen-litur   { border-color: #e74c3c; color: #e74c3c; }

.launavisitala-litur.active { background: #003366; color: #fff; }
.neysluverds-litur.active   { background: #2980b9; color: #fff; }
.utborgud-litur.active      { background: #27ae60; color: #fff; }
.skattprosen-litur.active   { background: #e74c3c; color: #fff; }

#skattagrafikk {
  max-height: 360px;
}

/* ── CSV útflutningur ──────────────────────────────────────── */
.export-rad {
  display: flex;
  justify-content: flex-end;
  margin-top: 1rem;
}

.csv-takki {
  padding: 0.5rem 1.2rem;
  font-size: 0.88rem;
  font-weight: 600;
  background: #fff;
  color: #003366;
  border: 1.5px solid #003366;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}

.csv-takki:hover {
  background: #e8f0fe;
}

/* ── Modal ─────────────────────────────────────────────────── */
.modal-bakgrunnur {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-bakgrunnur[hidden] {
  display: none;
}

.modal-innihald {
  background: #fff;
  border-radius: 10px;
  padding: 2rem;
  max-width: 540px;
  width: 90%;
  position: relative;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-innihald h2 {
  margin: 0 0 1.25rem;
  font-size: 1.15rem;
  color: #003366;
  padding-right: 2rem;
}

.modal-loka {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: #555;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}

.modal-loka:hover {
  background: #f0f2f5;
  color: #003366;
}

.modal-tafla {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.modal-tafla th {
  background: #003366;
  color: #fff;
  padding: 0.5rem 0.75rem;
  text-align: left;
  font-weight: 600;
}

.modal-tafla th:not(:first-child),
.modal-tafla td:not(:first-child) {
  text-align: right;
}

.modal-tafla tbody tr:nth-child(even) {
  background: #f5f7fa;
}

.modal-tafla td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #e8ecf0;
}

.modal-tafla tfoot td {
  padding: 0.5rem 0.75rem;
}

.modal-tafla tfoot tr:first-child td {
  border-top: 2px solid #ccd5e0;
  padding-top: 0.75rem;
}

.modal-samantala td {
  font-weight: 600;
}

.modal-nidurstada td {
  background: #e8f0fe;
  border-top: 2px solid #003366 !important;
}

/* ── Samanburður ────────────────────────────────────────────── */

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.samanburdur-tengill {
  display: inline-block;
  padding: 0.4rem 1rem;
  border: 1.5px solid #003366;
  border-radius: 20px;
  color: #003366;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.samanburdur-tengill:hover {
  background: #003366;
  color: #fff;
}

.til-baka-tengill {
  display: inline-block;
  margin-bottom: 1rem;
  color: #555;
  text-decoration: none;
  font-size: 0.9rem;
}

.til-baka-tengill:hover {
  color: #003366;
}

.dual-slider {
  position: relative;
  height: 18px;
  margin: 0.25rem 0;
}

.dual-slider input[type="range"] {
  position: absolute;
  width: 100%;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
  height: 18px;
  background: transparent;
  outline: none;
}

.dual-slider input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: #ccd5e0;
}

.dual-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #003366;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  pointer-events: all;
  margin-top: -6px;
}

.dual-slider input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: #ccd5e0;
}

.dual-slider input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #003366;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  pointer-events: all;
}

/* Toggle litir fyrir samanburð */
.grafikk-takki.nuverandi-litur { border-color: #003366; color: #003366; }
.grafikk-takki.nuverandi-litur.active { background: #003366; color: #fff; }
.grafikk-takki.xd-litur { border-color: #e67e22; color: #e67e22; }
.grafikk-takki.xd-litur.active { background: #e67e22; color: #fff; }
.grafikk-takki.munur-litur { border-color: #27ae60; color: #27ae60; }
.grafikk-takki.munur-litur.active { background: #27ae60; color: #fff; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 600px) {
  main {
    padding: 1rem;
  }

  h1 {
    font-size: 1.4rem;
  }

  .input-takki {
    flex-direction: column;
  }

  .input-takki button {
    width: 100%;
  }

  #skattafla {
    font-size: 0.82rem;
  }

  #skattafla thead th,
  #skattafla tbody td {
    padding: 0.45rem 0.5rem;
  }

  .visitala-toggle {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
  }

  .grafikk-stillingar {
    gap: 0.3rem;
  }

  #skattagrafikk {
    max-height: 240px;
  }
}
