/* Boligbudsjett 2.0 — Inndata + Dashboard */

:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --card: #fbfcfe;
  --border: #dfe4ea;
  --border-soft: #ebeef2;
  --text: #1c2733;
  --muted: #64707d;
  --accent: #1f5fa8;
  --accent-soft: #e8f0f9;
  --danger: #c0392b;
  --danger-soft: #fdf0ee;
  --warn: #9a6700;
  --warn-soft: #fdf6e3;
  --ok: #1a7f4e;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(28, 39, 51, 0.07);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

/* ---------- header ---------- */

.app-header {
  padding: 22px 20px 10px;
}
.app-header h1 { margin: 0; font-size: 24px; letter-spacing: -0.3px; }
.app-header .accent { color: var(--accent); }
.tagline { margin: 2px 0 0; color: var(--muted); }

.view { padding: 12px 20px 120px; }

/* ---------- panels & grid ---------- */

/* Inndata: settings panel to the left of the content sections. */
.inndata-layout { display: flex; gap: 14px; align-items: flex-start; }
.settings-col { flex: 0 0 260px; position: sticky; top: 10px; }
.inndata-main { flex: 1 1 auto; min-width: 0; }

.sections-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
}
@media (max-width: 900px) {
  .view { padding: 12px 8px 140px; }
  .inndata-layout { flex-direction: column; }
  .settings-col { position: static; flex: none; width: 100%; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px 16px;
  margin-bottom: 16px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.panel-header h2 { margin: 0; font-size: 16px; }
.panel-title { display: inline-flex; align-items: center; gap: 6px; }
.panel-header-right { display: inline-flex; align-items: center; gap: 8px; }

/* Collapse/expand of a main section */
.panel-toggle {
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 2px 4px;
  transition: transform 0.15s ease;
}
.panel.collapsed .panel-toggle { transform: rotate(-90deg); }
.panel.collapsed > :not(.panel-header) { display: none; }
.panel.collapsed .panel-header { margin-bottom: 0; }

/* ---------- cards ---------- */

.cards { display: flex; flex-direction: row; flex-wrap: wrap; gap: 10px; align-items: flex-start; }
.cards .card { flex: 1 1 300px; max-width: 400px; min-width: 260px; }
#cards-properties .card { flex: 1 1 340px; max-width: 440px; }
@media (max-width: 640px) {
  .cards .card, #cards-properties .card { max-width: none; }
}

.card {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 10px 12px 12px;
  position: relative;
}

.card-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
.card-title .kind {
  font-weight: 600;
  font-size: 13px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.card-title-left { display: inline-flex; align-items: baseline; gap: 4px; min-width: 0; }

/* Drag-and-drop reordering within a section */
.drag-handle {
  color: var(--muted);
  cursor: grab;
  padding: 0 5px;
  font-size: 13px;
  line-height: 1;
  letter-spacing: 1px;
  opacity: 0.6;
}
.drag-handle:hover { opacity: 1; }
.drag-handle:active { cursor: grabbing; }
.card.dragging { opacity: 0.45; }
.card.drop-before { box-shadow: -3px 0 0 var(--accent); }
.card.drop-after { box-shadow: 3px 0 0 var(--accent); }
.cards-col > .card.drop-before { box-shadow: 0 -3px 0 var(--accent); }
.cards-col > .card.drop-after { box-shadow: 0 3px 0 var(--accent); }
.btn-delete {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}
.btn-delete:hover { color: var(--danger); background: var(--danger-soft); }

/* ---------- fields ---------- */

.field-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 3px 0;
}
.field-row > label:first-child,
.field-row > .field-label {
  color: var(--muted);
  flex: 1 1 auto;
  min-width: 0;
}
.field-row input[type="text"],
.field-row input[type="number"],
.field-row input[type="date"],
.field-row input[type="month"],
.field-row select {
  flex: 0 0 auto;
  width: 130px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  color: var(--text);
  background: #fff;
  text-align: right;
}
.field-row input.wide { width: 170px; text-align: left; }
.field-row select { text-align: left; width: 150px; }
.field-row input:focus, .field-row select:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}
.field-row input.narrow { width: 80px; }

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--muted);
  user-select: none;
}
.toggle input { accent-color: var(--accent); width: 15px; height: 15px; }

.computed {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  padding: 7px 10px;
  background: var(--accent-soft);
  border-radius: 6px;
  font-size: 13px;
}
.computed b { font-variant-numeric: tabular-nums; }
.field-note { font-size: 12px; color: var(--muted); margin-left: 8px; white-space: nowrap; }

.info-line {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}
/* An explanation directly under its field hugs it (e.g. «Årslønn» →
   «Inkludert bonus og overtid.»). */
.field-row + .info-line { margin-top: -2px; }

.card-warning {
  margin-top: 6px;
  padding: 6px 9px;
  border-radius: 6px;
  font-size: 12.5px;
  background: var(--warn-soft);
  color: var(--warn);
}
.card-warning.blocking { background: var(--danger-soft); color: var(--danger); }

.subsection {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-soft);
}
.subsection-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
  margin-bottom: 4px;
}

.field-row input[type="date"],
.field-row input[type="month"] { width: 150px; text-align: left; }

.empty-hint { color: var(--muted); font-size: 13px; padding: 6px 2px; }

/* ---------- details expander ---------- */

.details { margin-top: 6px; }
.details-toggle {
  border: none;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 0;
}
.details-toggle:hover { text-decoration: underline; }
.details-body {
  margin-top: 4px;
  padding: 6px 9px;
  background: #fff;
  border: 1px dashed var(--border-soft);
  border-radius: 6px;
}

/* ---------- segmented control ---------- */

.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.segmented .seg {
  border: none;
  background: #fff;
  padding: 5px 14px;
  font: inherit;
  color: var(--muted);
  cursor: pointer;
}
.segmented .seg + .seg { border-left: 1px solid var(--border); }
.segmented .seg.active { background: var(--accent); color: #fff; }

/* ---------- info tooltip ---------- */

.info-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-style: italic;
  font-weight: 700;
  font-family: Georgia, serif;
  cursor: help;
  vertical-align: middle;
}
.info-tip .tip-text {
  display: none;
  position: absolute;
  bottom: calc(100% + 7px);
  right: -12px;
  width: 250px;
  padding: 8px 10px;
  background: #26313d;
  color: #fff;
  border-radius: 6px;
  font-size: 12px;
  font-style: normal;
  font-weight: 400;
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  text-align: left;
  line-height: 1.4;
  z-index: 60;
}
.info-tip:hover .tip-text,
.info-tip:focus .tip-text { display: block; }

/* ---------- linked rental lines ---------- */

.linked-lines { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.linked-line {
  padding: 8px 10px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  background: #fff;
}

/* ---------- add menu ---------- */

.add-menu { position: relative; }
.add-menu-items[hidden] { display: none; }
.add-menu-items {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(28, 39, 51, 0.13);
  z-index: 30;
  min-width: 180px;
  padding: 4px;
  display: flex;
  flex-direction: column;
}
.add-menu-items button {
  border: none;
  background: none;
  text-align: left;
  padding: 8px 10px;
  font: inherit;
  border-radius: 6px;
  cursor: pointer;
}
.add-menu-items button:hover { background: var(--accent-soft); color: var(--accent); }

/* ---------- allocation ---------- */

.allocation-box {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--card);
}
.allocation-box h3 { margin: 0 0 6px; font-size: 13.5px; }
.allocation-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 0;
  color: var(--muted);
}
.allocation-row input { width: 70px; text-align: right; padding: 4px 6px; border: 1px solid var(--border); border-radius: 6px; font: inherit; }
.allocation-total { margin-top: 6px; font-size: 13px; }
.allocation-total.bad { color: var(--danger); font-weight: 600; }
.allocation-total.ok { color: var(--ok); }

/* ---------- buttons ---------- */

.btn {
  font: inherit;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-add {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  padding: 5px 11px;
}
.btn-add:hover { background: #dbe9f8; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover { background: #17497f; color: #fff; }

/* ---------- global parameters (left settings panel) ---------- */

.param-item { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.param-item input[type="number"], .param-item input[type="month"], .param-item select {
  width: 80px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  text-align: right;
}
.param-item select { width: 92px; text-align: left; }
.param-item input[type="month"] { width: 150px; text-align: left; }

/* ---------- calc bar (sticky) ---------- */

.calc-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(4px);
  padding: 12px 32px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 18px;
  z-index: 50;
}
.btn-calc { font-size: 16px; padding: 10px 38px; }

.validation-summary { flex: 1 1 auto; font-size: 13px; }
.validation-summary .v-error { color: var(--danger); }
.validation-summary .v-warn { color: var(--warn); }
.validation-summary div { padding: 1px 0; }

/* ---------- dashboard ---------- */

.dash-layout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.dash-sidebar {
  width: 360px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: sticky;
  top: 12px;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
}
.dash-sidebar > .btn { align-self: flex-start; }
.dash-main { flex: 1 1 auto; min-width: 0; }
@media (max-width: 900px) {
  .dash-layout { flex-direction: column; }
  .dash-sidebar { width: 100%; position: static; max-height: none; }
}

#dash-sections { display: flex; flex-direction: column; gap: 8px; }

.dash-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.dash-section-head {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  border: none;
  background: none;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  padding: 11px 14px;
  cursor: pointer;
}
.dash-section-head:hover { color: var(--accent); }
.dash-head-right { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 400; }
.dash-count {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  border-radius: 10px;
  padding: 1px 8px;
}
.dash-section-body { padding: 0 10px 10px; }

/* Sidebar cards stack vertically and fill the width */
.cards-col { flex-direction: column; }
.cards-col .card, .cards-col > .card { max-width: none; min-width: 0; flex: none; width: 100%; }
.cards-col .btn-add, .cards-col .add-menu { align-self: flex-start; }
.cards-col .allocation-box { margin-top: 2px; }

/* Minimized card (dashboard sidebar) */
.card-min { padding: 0; }
.card-min-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  border: none;
  background: none;
  font: inherit;
  padding: 9px 12px;
  cursor: pointer;
  text-align: left;
}
.card-min-head:hover .card-summary { color: var(--accent); }
.card-min-head .kind {
  font-weight: 600;
  font-size: 12px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  flex-shrink: 0;
}
.card-min-head .card-summary {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 13px;
}
.card-min-head .chev { color: var(--muted); flex-shrink: 0; }

.card-title-actions { display: inline-flex; align-items: center; gap: 2px; }
.btn-collapse {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}
.btn-collapse:hover { color: var(--accent); background: var(--accent-soft); }

/* Tabs */

.dash-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.dash-tabs button {
  border: none;
  background: none;
  font: inherit;
  font-weight: 600;
  color: var(--muted);
  padding: 9px 16px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.dash-tabs button:hover { color: var(--accent); }
.dash-tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Chart panels */

.chart-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px 16px;
  margin-bottom: 14px;
}
.chart-panel h3 { margin: 0 0 10px; font-size: 14.5px; }
.chart-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.chart-head h3 { margin: 0; }
.chart-month { color: var(--muted); font-size: 13px; }
.chart-month select {
  font: inherit;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-left: 6px;
}
/* Month-budget breakdown table */

table.budget { width: 100%; max-width: 560px; border-collapse: collapse; font-size: 13.5px; }
.budget td { padding: 6px 10px; border-bottom: 1px solid var(--border-soft); }
.budget td:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  width: 130px;
}
.budget tr.sec th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
  padding: 14px 10px 4px;
  border-bottom: 1px solid var(--border);
}
.budget tr.subtotal td { font-weight: 600; background: var(--card); }
.budget tr.total td {
  font-weight: 700;
  font-size: 14.5px;
  border-top: 2px solid var(--border);
  border-bottom: none;
}

.chart-box { position: relative; height: 300px; }
.chart-box.tall { height: 340px; }
@media (max-width: 640px) {
  .chart-box, .chart-box.tall { height: 240px; }
}

/* Results (step 2: raw dump) */

.dash-summary { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.sum-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px 16px;
  min-width: 130px;
}
.sum-card .lbl { font-size: 12px; color: var(--muted); }
.sum-card .val { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.sum-card .val.neg { color: var(--danger); }

.results-tablewrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: auto;
  max-height: 72vh;
}
table.results { border-collapse: collapse; font-size: 12.5px; white-space: nowrap; }
.results th, .results td {
  padding: 4px 10px;
  text-align: right;
  border-bottom: 1px solid var(--border-soft);
  font-variant-numeric: tabular-nums;
}
.results thead th {
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 2;
  border-bottom: 1px solid var(--border);
}
.results td.neg { color: var(--danger); }
.results tbody tr:hover td { background: var(--accent-soft); }

/* Tabeller tab (step 4) */

.table-toolbar { display: flex; justify-content: flex-end; margin-bottom: 12px; }
.btn-csv { font-size: 12.5px; padding: 5px 12px; }
.chart-panel .results-tablewrap { box-shadow: none; max-height: 60vh; }
.chart-panel table.results { width: 100%; }

.dash-error { color: var(--danger); margin-bottom: 10px; font-weight: 600; }

.dashboard-header { margin-bottom: 14px; }
.dashboard-placeholder {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 48px;
  text-align: center;
  color: var(--muted);
}
.dashboard-placeholder h2 { color: var(--text); margin-top: 0; }

/* Percent sliders (replaces numeric % inputs) */

/* Sliders sit to the right, tight against the value; the label keeps the
   remaining row width. */
.slider-wrap { display: inline-flex; align-items: center; gap: 3px; margin-left: auto; }
.slider-wrap input[type="range"] {
  width: 90px;
  accent-color: var(--accent);
}
.slider-val {
  min-width: 40px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--text);
}

/* Slider steppers */

.slider-step {
  width: 22px;
  height: 22px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.slider-step:hover { background: var(--accent-soft); border-color: var(--accent); }


/* Chart footnote (bottom-right explanation under a chart) */
.chart-note {
  text-align: right;
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

/* Header params: Startdato + Tidshorisont floating top right, no background */

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
}

/* Parameters as a dashboard-sidebar section */

.param-col { display: flex; flex-direction: column; gap: 12px; }
.param-col .param-item { justify-content: space-between; }
