/***************
 * THEME (Light, Stripe-vibe)
 ***************/
:root {
  /* Base colors */
  --bg-main: #eef3ff;
  --bg-card: #ffffff;
  --bg-card-2: #f7faff;

  --text-main: #1a2340;
  --text-muted: #6c7a99;

  --border-color: #d7dff0;
  --shadow-sm: 0 4px 18px rgba(18, 38, 90, .04);
  --shadow-md: 0 8px 24px rgba(18, 38, 90, .06);

  /* Inputs & accents */
  --input-bg: #ffffff;
  --input-border: #c9d4ee;
  --accent: #5a6ff0;
  --accent-2: #7488ff;
  --danger: #e6585a;

  /* Sidebar */
  --sidebar-bg: #1e2a4a;
  --sidebar-active: #2a3a63;
  --sidebar-text: #f3f5fa;
}

/***************
 * GLOBAL
 ***************/
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg-main);
  color: var(--text-main);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

/***************
 * LAYOUT
 ***************/
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 20px;
  display: flex; flex-direction: column; gap: 12px;
  position: sticky; top: 0; height: 100vh;
}
.brand {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 52px;
  margin: 0 0 8px;
  text-decoration: none;
}
.brand img {
  display: block;
  width: 100%;
  max-width: 190px;
  height: auto;
  filter: brightness(0) invert(1);
  opacity: 0.96;
}
.sidebar nav a {
  display: block; text-decoration: none;
  color: #d9e2ff; padding: 10px 12px; border-radius: 8px;
}
.sidebar nav a:hover,
.sidebar nav a.active { background: var(--sidebar-active); color: #fff; }
.sidebar .spacer { flex: 1; }
.lang { display: flex; gap: 8px; }
.lang button {
  border: 1px solid #3a4670; background: transparent; color: #d9e2ff;
  border-radius: 8px; padding: 6px 10px; cursor: pointer;
}
.lang button.active { background: #3a4670; }

.main { flex: 1; padding: 24px; overflow: auto; }
.main h1 { letter-spacing: .2px; font-size: 28px; margin: 0 0 14px; }

/***************
 * CARDS
 ***************/
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 18px;
  box-shadow: var(--shadow-sm);
  margin: 16px 0;
}
.hero {
  background: var(--bg-card-2);
  border: 1px dashed #c9d4ee;
}

/***************
 * TYPO & UTILITIES
 ***************/
h1, h2, h3 { margin: 0 0 12px; }
.muted { color: var(--text-muted); font-size: 14px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }


/* ===== Toolbar / filter controls (Invoices etc.) ===== */
.card label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  color: #31426b;
  font-size: 0.9rem;
}

/* Stil på selects/inputs i toppraden (utan form-grid) */
.card select,
.card input[type="month"],
.card input[type="date"] {
  background: var(--input-bg);
  color: var(--text-main);
  border: 1px solid var(--input-border);
  border-radius: 12px;
  padding: 9px 12px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
  box-shadow: 0 1px 2px rgba(18, 38, 90, .04);
}

/* Fokus */
.card select:focus,
.card input[type="month"]:focus,
.card input[type="date"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(90,111,240,.18);
}

/* Modern dropdown-pil */
.card select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 34px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--accent) 50%),
    linear-gradient(135deg, var(--accent) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 52%,
    calc(100% - 12px) 52%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

/***************
 * FORMS
 ***************/
.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 12px 16px;
}
.form-grid label {
  display: block; font-weight: 600; margin-bottom: 6px; color: #31426b;
}
.form-grid input, .form-grid select {
  width: 100%;
  background: var(--input-bg);
  color: var(--text-main);
  border: 1px solid var(--input-border);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.form-grid input:focus, .form-grid select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(90,111,240,.18);
}

/***************
 * BUTTONS
 ***************/
.btn {
  background: #fff;
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, transform .05s ease;
}
.btn:hover { background:#f5f8ff; border-color:#c4cff1; }
.btn:active { transform: translateY(1px); }
.btn-sm { padding: 6px 10px; border-radius: 10px; font-size: .92rem; }

.btn-primary { background: var(--accent); color:#fff; border-color: transparent; }
.btn-primary:hover { background: var(--accent-2); }

.btn-danger { background:#ffe9ea; border-color:#ffc9cb; color:#a41b27; }
.btn-danger:hover { background:#ffd9db; }

/***************
 * TABLES
 ***************/
.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table thead th {
  text-align: left; font-weight: 700;
  color: #31426b; background: #f3f6ff;
  border-bottom: 1px solid var(--border-color);
  padding: 10px 12px;
  position: sticky; top: 0;
}
.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
}
.table tbody tr { transition: background .12s ease; }
.table tbody tr:hover { background: #f8faff; }
.table .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size:.9em; }

/***************
 * KPI CARDS
 ***************/
.kpis { display: grid; grid-template-columns: repeat(4, minmax(160px,1fr)); gap: 12px; }
.kpi {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 14px;
  box-shadow: var(--shadow-sm);
}
.kpi .label { color: var(--text-muted); font-size: .9rem; }
.kpi .value { font-size: 1.35rem; font-weight: 800; }

/* KPI icons */
.kpi{
  display:grid; grid-template-columns: 40px 1fr; gap:10px; align-items:center;
}
.kpi .icon{
  width:40px; height:40px; border-radius:10px;
  display:flex; align-items:center; justify-content:center;
  background: #eff3ff; color:#4c62df; font-weight:800;
}

/***************
 * SIMPLE BAR CHART (CSS)
 ***************/
.bars { display: flex; align-items: flex-end; gap: 8px; height: 160px; padding: 8px 2px; }
.bar {
  width: 28px;
  background: linear-gradient(180deg, #8fa2ff, #5a6ff0);
  border-radius: 6px 6px 2px 2px;
  box-shadow: var(--shadow-md);
}
.bar small { display: block; text-align: center; margin-top: 6px; color: #586791; }

/***************
 * MODAL
 ***************/
.modal-backdrop {
  position: fixed; inset: 0; display: none;
  align-items: center; justify-content: center;
  background: rgba(6,10,20,.35); z-index: 1000;
}
.modal-backdrop.show { display: flex; animation: fadeIn .12s ease-out; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 18px;
  width: min(520px, 92vw);
  box-shadow: var(--shadow-md);
}
.modal-title { margin: 0 0 6px; font-size: 18px; font-weight: 800; }
.modal-message { margin: 0 0 14px; color: var(--text-muted); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }
@keyframes fadeIn { from { opacity: 0; transform: scale(.98); } to { opacity: 1; transform: scale(1); } }

/* ===== Dialog (Create/Edit) ===== */
dialog.dialog{
  border: 0;
  padding: 0;
  background: transparent;
  width: min(860px, 94vw);
  max-height: 90vh;
}

dialog.dialog::backdrop{
  background: rgba(6,10,20,.35);
}

dialog.dialog .modal-card{
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  overflow: auto;
  max-height: 90vh;
}

/***************
 * MISC (optional pills/progress if used)
 ***************/
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; }
.pill.red { background: #ffe5e5; color: #b30000; }
.pill.orange { background: #fff1e0; color: #a45a00; }
.pill.green { background: #e9ffe9; color: #1b7a1b; }

.progress { width: 100%; height: 12px; border-radius: 999px; background: #ecf1ff; overflow: hidden; }
.progress .bar { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

/* Section header */
.section-header{
  display:flex; align-items:center; justify-content:space-between;
  margin-bottom:8px;
}
.section-header h2{ margin:0; font-size:18px; }
.section-controls{ display:flex; align-items:center; gap:8px; }
.section-controls select{
  background:var(--bg-card); border:1px solid var(--border-color); color:var(--text-main);
  border-radius:10px; padding:6px 10px;
}

/* Bars + labels */
.axis-labels{
  display:flex; justify-content:space-between; margin-top:6px; padding:0 6px; color:#586791; font-size:.85rem;
}

/* Timeline list */
.timeline{ list-style:none; padding-left:0; margin:0; }
.timeline li{
  display:flex; gap:10px; align-items:flex-start; padding:8px 0;
  border-bottom:1px solid var(--border-color);
}
.timeline li:last-child{ border-bottom:0; }
.timeline .dot{
  width:10px; height:10px; border-radius:50%; margin-top:6px;
  background:linear-gradient(180deg, #8fa2ff, #5a6ff0);
  box-shadow: 0 0 0 3px rgba(90,111,240,.15);
}
.timeline .meta{ color:var(--text-muted); font-size:.9rem; }

/* --- Tenant Modal Form Layout --- */
dialog.dialog .grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 20px;
    padding: 0; /* <-- viktigt */
}
dialog.dialog .grid hr {
  grid-column: 1 / -1;
  border: none;
  border-top: 1px solid #e4e7ec;
  margin: 10px 0;
}
dialog.dialog .grid label {
  display: flex;
  flex-direction: column;
  font-size: 0.9rem;
  color: #475467;
  font-weight: 500;
}
dialog.dialog input,
dialog.dialog select,
dialog.dialog textarea {
  margin-top: 6px;
  padding: 8px 10px;
  border: 1px solid var(--input-border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--bg-card);
  color: var(--text-main);
}
dialog.dialog input:focus,
dialog.dialog select:focus,
dialog.dialog textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(90,111,240,.18);
}
/* Medhyresgäst rubrik */
dialog.dialog .grid .section-label {
  grid-column: 1 / -1;
  margin-top: 5px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #667085;
}
/* Responsive */
@media (max-width: 600px) {
   dialog.dialog .grid { grid-template-columns: 1fr; }
}

.grid-2 { display:grid; grid-template-columns: 1fr 1fr; gap:14px 20px; }
@media (max-width: 800px){ .grid-2 { grid-template-columns: 1fr; } }
.summary-row { display:flex; justify-content:space-between; align-items:center; gap:1rem; padding-top:8px; }
.kpi-lg { font-size:1.6rem; font-weight:700; }

/* Tabs (single definition) */
.tabs { display:flex; gap:8px; margin-bottom:12px; }
.tab-btn { padding:6px 10px; border:1px solid var(--input-border); border-radius:10px; background:#fff; }
.tab-btn.active { background:var(--primary-50,#eef2ff); border-color:var(--primary-200,#c7d2fe); }

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
}
.badge-active {
  background: #D1FAE5;
  color: #065F46;
  border: 1px solid #A7F3D0;
}
.badge-ended {
  background: #E5E7EB;
  color: #374151;
  border: 1px solid #D1D5DB;
}

/* ===== Settings page (clean, consolidated) ===== */
.page-header { display:flex; justify-content:space-between; align-items:flex-end; margin-bottom:14px; }
.card-pad { padding: 16px 18px; }

.settings-grid {
  display: grid;
  grid-template-columns: 1fr minmax(320px, 420px);
  gap: 28px;
}
@media (max-width: 980px) {
  .settings-grid { grid-template-columns: 1fr; }
}

.section-title { display:flex; gap:10px; align-items:center; margin:0 0 12px; }
.section-title .emoji { font-size:22px; line-height:1; }
.section-title h3 { margin:0; }
.section-title .muted { margin-top:2px; }

.settings-form .field { display:flex; flex-direction:column; gap:6px; margin-bottom:14px; }
.settings-form .field > span { font-weight:600; }
.settings-form .req { color: var(--accent); font-weight:700; }
.settings-form input {
  width: 100%;
  height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-card);
}
.settings-form input:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-color: var(--accent);
}
.settings-form .help { color:#6b7280; font-size:12px; }

.actions { display:flex; align-items:center; gap:10px; margin-top:6px; }
.actions .btn { border-radius:999px; padding:8px 14px; }
.chip { display:inline-block; padding:4px 8px; border-radius:999px; font-size:12px; }
.chip-success { background:#e8f7ee; color:#2e7d32; }

.settings-preview {
  border-left:1px dashed var(--border-color);
  padding-left:20px;
}
@media (max-width: 980px) {
  .settings-preview { border-left:0; padding-left:0; }
}

.preview-card {
  display:flex; gap:14px; align-items:center;
  border:1px solid var(--border-color); border-radius:14px;
  background: var(--bg-card);
  padding:12px 14px;
  box-shadow:0 6px 16px rgba(10,10,20,.05);
}
.preview-title { font-weight:700; }

.logo-chip {
  width:64px; height:64px; border-radius:50%;
  background: linear-gradient(135deg, #f3f0ff, #e9f0ff);
  display:grid; place-items:center;
  border:1px solid var(--border-color);
}
.logo-chip img { max-height:38px; max-width:46px; display:block; }

  
.status-pill {
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  background: #eee;
}
.status-PAID {
  background: #bbf7d0;
}
.status-PARTIAL {
  background: #fde68a;
}
.status-OVERDUE {
  background: #fecaca;
}
.status-DUE_TODAY {
  background: #e0e7ff;
}
.status-UPCOMING,
.status-NOT_DUE {
  background: #f3f4f6;
}

/* -------- Fakturor – Paid stamp -------- */
.paid-stamp {
  display: inline-block;
  padding: 0.15rem 0.4rem;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #f9fafb;
}

/* -------- Modal – Betalningsdialog -------- */
.pay-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.pay-modal-hidden {
  display: none;
}
.pay-modal {
  width: 100%;
  max-width: 480px;
  background: white;
  border-radius: 1rem;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.25);
}
.pay-modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.pay-modal-form label {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}
.pay-modal-form input[type="number"],
.pay-modal-form input[type="date"] {
  width: 100%;
  padding: 0.4rem 0.5rem;
  border-radius: 0.5rem;
  border: 1px solid #e5e7eb;
  font-size: 0.9rem;
}
.pay-modal-actions {
  margin-top: 1rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* --- Knappstil för "Redigera" länkliknande knapp --- */
.btn-ghost {
  background: transparent;
  border: none !important;
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
  color: #3b82f6;
  cursor: pointer;
  text-decoration: underline;
}
.btn-ghost:hover {
  color: #1d4ed8;
}
@media (max-width: 900px) {
  .cols-2 {
    grid-template-columns: 1fr;
  }
}
.card .btn {
  border-radius: 999px;
  padding: 9px 14px;
}
.btn-accent {
  background: linear-gradient(135deg, #6b8cff, #7c5cff);
  color: #fff;
  border: none;
}

.btn-accent:hover {
  background: linear-gradient(135deg, #5f83ff, #6f4fff);
  color: #fff;
  border: none;
  transform: translateY(-1px);
}

.btn-accent:active {
  background: linear-gradient(135deg, #5678f0, #6546f0);
  color: #fff;
  transform: translateY(0);
}
/* ===== Toast ===== */
.toast-wrap{
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast{
  pointer-events: auto;
  min-width: 260px;
  max-width: 360px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  animation: toastIn .14s ease-out;
}

.toast .title{ font-weight: 800; font-size: 0.92rem; margin: 0; }
.toast .msg{ margin: 2px 0 0; color: var(--text-muted); font-size: 0.88rem; }

.toast-success{ border-left: 4px solid var(--accent); }
.toast-error{ border-left: 4px solid var(--danger); }

.toast .x{
  margin-left: auto;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 700;
}

@keyframes toastIn{
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
/* Centrera åtgärdsknappar i tabell */
.actions-cell {
  text-align: center;
}

.actions-wrap {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}
/* Centrera Åtgärd-kolumnen (rubrik + celler) */
.table thead th:last-child {
  text-align: center;
}

.table tbody td:last-child {
  text-align: center;
}
/* Modal section card (used for Taxa/historik) */
.modal-section{
  margin-top: .9rem;
  padding: .9rem;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  background: var(--bg-card-2);
}

.modal-section .section-head h4{
  margin: 0 0 .25rem 0;
}

.modal-section .section-head p{
  margin: 0;
  line-height: 1.35;
}

/* tighter grid inside section */
.modal-section .section-grid{
  margin-top: .75rem;
}

/* field hint under input */
.field-hint{
  display:block;
  margin-top: .25rem;
  font-size: .85rem;
  opacity: .85;
}

/* actions row in taxa section */
.section-actions{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: .75rem;
  margin-top: .25rem;
}
dialog.dialog .modal-card{ overflow-x: hidden; }

dialog.dialog .modal-body{
  padding: 12px 18px;
}
.sidebar-user {
  padding: 12px 0;
  border-top: 1px solid #eee;
  margin-top: 10px;
}

.sidebar-user-name {
  font-size: 14px;
  font-weight: 600;
  word-break: break-word;
}

.sidebar-user-role {
  font-size: 12px;
  color: #777;
  margin-top: 2px;
}
/* ===== DASHBOARD ===== */

.dashboard-hero,
.chart-hero-card,
.mini-insight-card,
.dashboard-summary-card,
.todo-card,
.dashboard-recent-card,
.dashboard-portfolio-card,
.dashboard-cash-grid > .card,
.dashboard-bottom-grid > .card {
  border-radius: 20px;
  border: 1px solid #dbe4fb;
  background: linear-gradient(180deg, #ffffff 0%, #fcfdff 100%);
  box-shadow: 0 10px 30px rgba(31, 41, 55, 0.05);
}

.dashboard-hero,
.dashboard-main-visuals,
.dashboard-summary-row,
.dashboard-cash-grid,
.dashboard-bottom-grid,
.dashboard-recent-card,
.dashboard-portfolio-card {
  margin-bottom: 1rem;
}

.dashboard-soft-hidden {
  display: none !important;
}

.dashboard-hero {
  border: 1px dashed #cdd7f0;
  background: linear-gradient(180deg, #f8faff 0%, #f3f7ff 100%);
}

.dashboard-hero-row {
  display: grid;
  grid-template-columns: minmax(240px, 1.1fr) auto auto;
  align-items: center;
  gap: 1rem;
}

.dashboard-hero-copy {
  min-width: 0;
}

.dashboard-hero-copy .muted {
  margin: 0;
  line-height: 1.45;
}

.dashboard-period-chip {
  min-width: 130px;
}

.hero-eyebrow {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #5a67d8;
  margin-bottom: 0.35rem;
}

.hero-chip {
  min-width: 140px;
  background: #ffffff;
  border: 1px solid #d9e2f5;
  border-radius: 16px;
  padding: 0.7rem 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  box-shadow: 0 6px 20px rgba(35, 57, 120, 0.06);
}

.hero-chip strong {
  font-size: 1rem;
  color: #162447;
}

#kpiRow {
  margin-top: 0.9rem;
  margin-bottom: 1rem;
}

.kpi {
  border-radius: 18px;
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  background: #fff;
  border: 1px solid #dbe4fb;
  box-shadow: 0 8px 22px rgba(32, 53, 110, 0.06);
  min-height: 92px;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.kpi:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(32, 53, 110, 0.1);
  border-color: #c9d8fb;
}

.kpi .icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  font-weight: 700;
  flex-shrink: 0;
}

.kpi .copy {
  min-width: 0;
}

.kpi .label {
  color: #5f6f97;
  font-size: 0.92rem;
  margin-bottom: 0.2rem;
}

.kpi .value {
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 1.1;
  color: #14213d;
}

.kpi .sub {
  margin-top: 0.2rem;
  font-size: 0.82rem;
  color: #7b89ad;
}

.kpi-blue .icon { background: #e9efff; }
.kpi-purple .icon { background: #efe9ff; }
.kpi-sky .icon { background: #e8f6ff; }
.kpi-green .icon { background: #e8f8ee; }
.kpi-red .icon { background: #fdecec; }

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.35rem;
}

.section-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: #132347;
  letter-spacing: -0.01em;
}

.section-header .muted {
  font-size: 0.85rem;
  color: #7b89ad;
}

.section-controls label {
  display: block;
  font-size: 0.82rem;
  color: #65739b;
  margin-bottom: 0.32rem;
  font-weight: 600;
}

.dashboard-filters,
.dashboard-filters-global {
  display: flex;
  gap: 0.75rem;
  flex-wrap: nowrap;
  align-items: flex-end;
  border: 1px solid #dbe6fb;
  border-radius: 16px;
  padding: 0.7rem 0.8rem;
  background: rgba(255, 255, 255, 0.82);
}

.filter-group {
  min-width: 90px;
}

.filter-property {
  min-width: 180px;
}
.dashboard-filters-global {
  justify-self: end;
}

.dashboard-filters-global .filter-group {
  min-width: 76px;
}

.dashboard-filters-global .filter-property {
  min-width: 150px;
}

.dashboard-filters select,
.dashboard-filters-global select {
  height: 42px;
  min-width: 90px;
  border-radius: 12px;
  border: 1px solid #ced8f2;
  background: #fff;
  padding: 0 0.8rem;
  color: #20325a;
}

.dashboard-filters select:focus,
.dashboard-filters-global select:focus {
  outline: none;
  border-color: #7f9cf5;
  box-shadow: 0 0 0 3px rgba(127, 156, 245, 0.16);
}

#dashReload {
  height: 42px;
  padding: 0 1rem;
  border-radius: 12px;
  min-width: 120px;
  font-weight: 700;
}

.dashboard-main-visuals,
.dashboard-summary-row,
.dashboard-cash-grid,
.dashboard-bottom-grid {
  align-items: stretch;
}

.chart-hero-card {
  min-height: 460px;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at top right, rgba(127, 156, 245, 0.12), transparent 30%),
    linear-gradient(180deg, #ffffff 0%, #f9fbff 100%);
}

.chart-header-upgraded {
  padding-bottom: 0.6rem;
  border-bottom: 1px solid #edf2ff;
}

.chart-toolbar-simple {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-top: 0.35rem;
}

.chart-view-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.8rem;
  border-radius: 999px;
  background: #f5f8ff;
  border: 1px solid #dbe6fb;
}

.chart-view-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: #7180a8;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

#chartPeriodLabel {
  color: #162447;
  font-size: 0.95rem;
}

.chart-hero-wrap {
  position: relative;
  flex: 1;
  min-height: 340px;
  margin-top: 0.5rem;
}

.chart-hero-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

.dashboard-right-rail {
  display: grid;
  gap: 1rem;
}

.mini-insight-card {
  min-height: 200px;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.mini-insight-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 26px rgba(32, 53, 110, 0.08);
}

.collection-hero {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 1rem;
  align-items: center;
  margin-top: 1rem;
}

.collection-ring-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
}

.collection-ring {
  width: 130px;
  height: 130px;
  border-radius: 999px;
  background: conic-gradient(
    #5a67d8 0deg,
    #7f9cf5 0deg,
    #e8eefb 0deg,
    #e8eefb 360deg
  );
  display: grid;
  place-items: center;
  transition: background 0.3s ease;
}

.collection-ring-inner {
  width: 92px;
  height: 92px;
  border-radius: 999px;
  background: #fff;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 0.5rem;
  box-shadow: inset 0 0 0 1px #edf2ff;
}

#collectionPctBig {
  font-size: 1.45rem;
  font-weight: 800;
  color: #14213d;
}

.small {
  font-size: 0.8rem;
}

.collection-summary {
  display: grid;
  gap: 0.55rem;
}

.collection-summary .summary-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.2rem 0;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.25rem;
  margin-top: 0.75rem;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.32rem 0;
  color: #243559;
}

.summary-row-strong {
  font-weight: 800;
  font-size: 1.02rem;
}

.summary-divider {
  margin: 0.5rem 0;
  border: 0;
  border-top: 1px solid #e6edfc;
}

.summary-progress {
  margin-top: 0.75rem;
}

.summary-progress-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.35rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.summary-result-band {
  margin-top: 1rem;
  border-radius: 16px;
  padding: 1rem;
  background: linear-gradient(180deg, #f8fbff 0%, #edf3ff 100%);
  border: 1px solid #dbe6fb;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.result-label {
  font-size: 0.84rem;
  color: #6f7ea7;
  margin-bottom: 0.2rem;
}

.big-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: #14213d;
}

.big-value.small {
  font-size: 1.4rem;
}

.collection-box {
  text-align: right;
}

.progress {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #e8eefb;
  overflow: hidden;
}

.progress .bar {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #5a67d8 0%, #7f9cf5 100%);
  transition: width 0.25s ease;
}

.todo-card {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.alerts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.alert-card {
  border-radius: 16px;
  padding: 1rem;
  border: 1px solid #d9e2f5;
  background: #fff;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.alert-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(32, 53, 110, 0.08);
}

.alert-count {
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 0.35rem;
  color: #14213d;
}

.alert-label {
  font-weight: 700;
  color: #243559;
  margin-bottom: 0.15rem;
}

.alert-note {
  font-size: 0.83rem;
  color: #7381a7;
}

.tone-red { background: #fff6f6; border-color: #f2c9c9; }
.tone-orange { background: #fffaf2; border-color: #f6dec0; }
.tone-purple { background: #faf7ff; border-color: #ddd1ff; }
.tone-green { background: #f5fcf7; border-color: #cde8d6; }
.tone-blue { background: #f7faff; border-color: #d7e4ff; }
.tone-sky { background: #f3fbff; border-color: #cfeeff; }

.insight-list {
  display: grid;
  gap: 0.85rem;
  margin-top: 1rem;
}

.insight-item {
  border: 1px solid #dbe4fb;
  border-radius: 14px;
  padding: 0.85rem 1rem;
  background: linear-gradient(180deg, #fbfcff 0%, #f5f8ff 100%);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.insight-item:hover {
  transform: translateY(-2px);
  border-color: #cbd9fb;
  box-shadow: 0 10px 20px rgba(32, 53, 110, 0.07);
}

.insight-item.insight-good {
  background: linear-gradient(180deg, #f4fcf7 0%, #edf9f1 100%);
  border-color: #cfe9d8;
}

.insight-item.insight-warning {
  background: linear-gradient(180deg, #fffaf2 0%, #fff4e8 100%);
  border-color: #f5dcc2;
}

.insight-item.insight-danger {
  background: linear-gradient(180deg, #fff6f6 0%, #fff0f0 100%);
  border-color: #f0caca;
}

.insight-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #7180a8;
  margin-bottom: 0.2rem;
}

.insight-value {
  font-size: 1.05rem;
  font-weight: 800;
  color: #14213d;
}

.insight-sub {
  margin-top: 0.2rem;
  color: #6f7ea7;
  font-size: 0.86rem;
}

.dashboard-cash-grid > .card,
.dashboard-portfolio-card,
.dashboard-bottom-grid > .card,
.dashboard-recent-card {
  background:
    radial-gradient(circle at top right, rgba(127, 156, 245, 0.08), transparent 28%),
    linear-gradient(180deg, #ffffff 0%, #fbfcff 100%);
}

.dashboard-recent-card,
.dashboard-portfolio-card,
.dashboard-cash-grid > .card,
.dashboard-bottom-grid > .card {
  padding: 1.1rem 1rem 1rem 1rem;
}

.dashboard-recent-card {
  overflow: hidden;
}

.timeline {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0 0;
}

.timeline li {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 0.85rem;
  align-items: start;
  margin: 0;
  padding: 1rem 0.2rem;
  border-bottom: 1px solid #edf2ff;
  transition: background 0.18s ease, transform 0.18s ease;
}

.timeline li:last-child {
  border-bottom: none;
}

.timeline li:hover {
  background: rgba(92, 124, 250, 0.04);
  transform: translateX(2px);
}

.timeline .dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(180deg, #6b7cff 0%, #5166ee 100%);
  margin-top: 0.35rem;
  box-shadow: 0 0 0 4px rgba(92, 124, 250, 0.12);
}

.timeline .meta {
  color: #7d89ab;
  font-size: 0.82rem;
  margin-top: 0.22rem;
}

.timeline-content {
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
}

.timeline-title {
  font-weight: 600;
  color: #1c2f57;
  line-height: 1.35;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border-radius: 16px;
}

.table-wrap::-webkit-scrollbar {
  height: 10px;
}

.table-wrap::-webkit-scrollbar-track {
  background: #eef3ff;
  border-radius: 999px;
}

.table-wrap::-webkit-scrollbar-thumb {
  background: #c9d7fb;
  border-radius: 999px;
}

.dashboard-page .table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-top: 0.9rem;
  font-size: 0.95rem;
}

.dashboard-page .table thead th {
  background: linear-gradient(180deg, #f7f9ff 0%, #eef3ff 100%);
  color: #223763;
  font-size: 0.88rem;
  font-weight: 800;
  text-align: left;
  padding: 0.95rem 1rem;
  border-bottom: 1px solid #dbe4fb;
}

.dashboard-page .table thead th:first-child {
  border-top-left-radius: 14px;
}

.dashboard-page .table thead th:last-child {
  border-top-right-radius: 14px;
}

.dashboard-page .table tbody td,
.dashboard-page .table tfoot th,
.dashboard-page .table tfoot td {
  padding: 0.95rem 1rem;
  border-bottom: 1px solid #edf2ff;
  color: #1f2f54;
  vertical-align: middle;
}

.dashboard-page .table tbody tr {
  transition: background 0.18s ease;
}

.dashboard-page .table tbody tr:hover {
  background: #f8fbff;
}

.dashboard-page .table tfoot tr th,
.dashboard-page .table tfoot tr td {
  background: #fbfcff;
  font-weight: 800;
  color: #132347;
}

.dashboard-page .table a {
  color: #2d5bff;
  font-weight: 700;
  text-decoration: none;
}

.dashboard-page .table a:hover {
  text-decoration: underline;
}

.value-positive {
  color: #0f9f4f !important;
  font-weight: 800;
}

.value-negative {
  color: #d13b3b !important;
  font-weight: 800;
}

.value-neutral {
  color: #243559 !important;
  font-weight: 700;
}

.dashboard-page .table tfoot .value-positive,
.dashboard-page .table tfoot .value-negative,
.dashboard-page .table tfoot .value-neutral {
  font-size: 1rem;
}

.dashboard-page .muted {
  color: #7c89ad;
}

@media (max-width: 1200px) {
  .alerts-grid {
    grid-template-columns: 1fr 1fr;
  }

  .filter-property {
    min-width: 160px;
  }
}

@media (max-width: 1100px) {
  .collection-hero {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
.dashboard-hero-row,
.summary-result-band {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.dashboard-filters-global,
.dashboard-filters {
  width: 100%;
  flex-wrap: wrap;
}

.dashboard-filters-global .filter-group,
.dashboard-filters-global .filter-property,
.filter-group,
.filter-property {
  width: 100%;
  min-width: 100%;
}

.dashboard-period-chip {
  width: 100%;
}

  .dashboard-main-visuals,
  .dashboard-summary-row,
  .dashboard-cash-grid,
  .dashboard-bottom-grid {
    grid-template-columns: 1fr !important;
  }

  .chart-toolbar-simple {
    width: 100%;
    justify-content: flex-start;
  }

  .collection-box {
    text-align: left;
  }

  .alerts-grid {
    grid-template-columns: 1fr;
  }
}
.dashboard-period-inline {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 110px;
}

.dashboard-period-label {
  font-size: 0.78rem;
  color: #7b89ad;
  margin-bottom: 0.15rem;
}

.dashboard-period-inline strong {
  font-size: 1rem;
  color: #162447;
}
.dashboard-filters input[type="month"] {
  height: 42px;
  border-radius: 12px;
  border: 1px solid #ced8f2;
  padding: 0 0.6rem;
  background: #fff;
  color: #20325a;
}

.dashboard-filters input[type="month"]:focus {
  border-color: #7f9cf5;
  box-shadow: 0 0 0 3px rgba(127,156,245,0.16);
}
/* ===== Loans modal ===== */
#loanModal.dialog {
  width: min(860px, 94vw);
}

#loanModal .modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

#loanModal .modal-header {
  padding: 20px 24px 8px;
}

#loanModal .modal-header h3 {
  margin: 0;
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--text-main);
}

#loanModal .modal-body {
  padding: 8px 24px 18px;
}

#loanModal .modal-body.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 18px;
}

#loanModal label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #4b5b7c;
}

#loanModal input,
#loanModal select {
  width: 100%;
  margin-top: 0;
  padding: 10px 12px;
  border: 1px solid var(--input-border);
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--bg-card);
  color: var(--text-main);
}

#loanModal input:focus,
#loanModal select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(90,111,240,.18);
}

#loanModal .modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 24px 18px;
  border-top: 1px solid #e8edf7;
}

#loanModal .modal-footer .btn {
  border-radius: 14px;
  padding: 10px 16px;
}

/* Plan-modal */
#planModal.dialog {
  width: min(760px, 94vw);
}

#planModal .modal-card,
#deleteLoanModal .modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

#planModal .modal-header,
#deleteLoanModal .modal-header {
  padding: 20px 24px 8px;
}

#planModal .modal-body,
#deleteLoanModal .modal-body {
  padding: 8px 24px 18px;
}

#planModal .modal-footer,
#deleteLoanModal .modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 24px 18px;
  border-top: 1px solid #e8edf7;
}

@media (max-width: 700px) {
  #loanModal .modal-body.grid-2 {
    grid-template-columns: 1fr;
  }
}
/* ===== Loan property multi-select ===== */
.loan-properties-field {
  grid-column: 1 / -1;
}

.loan-properties-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 6px;
  padding: 12px;
  border: 1px solid var(--input-border);
  border-radius: 12px;
  background: var(--bg-card);
  max-height: 220px;
  overflow-y: auto;
}

.loan-property-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: #f9fbff;
}

.loan-property-option input[type="checkbox"] {
  margin-top: 2px;
}

.loan-property-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.loan-property-name {
  font-weight: 600;
  color: var(--text-main);
}

.loan-property-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
}

@media (max-width: 700px) {
  .loan-properties-list {
    grid-template-columns: 1fr;
  }
}

/* =========================================================
   Investment calculator / Kalkylator
   ========================================================= */

body.calculator-page {
  background: #edf3ff;
}

.calculator-page .layout {
  min-height: 100vh;
}

.calculator-page .main,
.calc-main {
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 32px;
  background: linear-gradient(180deg, #f6f8ff 0%, #f8fafc 45%, #ffffff 100%);
}

.calc-hero,
.calc-score-card,
.calc-decision-card,
.calc-form,
.calc-kpi-panel,
.calc-scenario-card,
.calc-saved-card,
.calc-forecast-card {
  background: #fff;
  border: 1px solid #d8e0f0;
  border-radius: 18px;
  box-shadow: 0 14px 35px rgba(15, 23, 42, 0.07);
  padding: 20px;
}

.calc-hero {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
  background:
    radial-gradient(circle at top right, rgba(99, 102, 241, .18), transparent 30%),
    linear-gradient(135deg, #ffffff 0%, #eef4ff 100%);
}

.calculator-page .hero-eyebrow {
  color: #4f46e5;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.calc-hero h1 {
  margin: 6px 0;
  font-size: 30px;
}

.calculator-page .muted {
  color: #64748b;
}

.calc-hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.calculator-page .btn {
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #fff;
  padding: 10px 15px;
  font-weight: 800;
  cursor: pointer;
}

.calculator-page .btn-primary,
.calculator-page .btn.btn-primary {
  background: linear-gradient(135deg, #4f46e5, #2563eb);
  color: white;
  border-color: transparent;
}

.calc-score-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.75fr) 1.25fr;
  gap: 18px;
  margin-bottom: 18px;
}

.score-topline,
.score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.score-number {
  font-size: 44px;
  font-weight: 950;
  color: #0f172a;
}

.score-number small {
  font-size: 16px;
  color: #64748b;
}

.score-bar {
  flex: 1;
  height: 14px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.score-bar > div {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ef4444, #f59e0b, #22c55e);
}

.section-header.compact {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.section-header.compact h2 {
  margin: 0;
  font-size: 18px;
}

.calc-badge {
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 900;
  background: #e2e8f0;
}

.calc-layout-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(350px, 0.65fr);
  gap: 18px;
  align-items: start;
}

.calc-right {
  position: sticky;
  top: 20px;
  display: grid;
  gap: 18px;
}

.calc-form-header h2 {
  margin: 0 0 8px;
  font-size: 26px;
}

.calc-section {
  border: 1px solid #e2e8f0;
  border-radius: 18px;
  margin: 14px 0;
  overflow: hidden;
  background: #fff;
}

.calc-section summary {
  cursor: pointer;
  padding: 15px 16px;
  font-weight: 950;
  color: #0f172a;
  background: linear-gradient(90deg, #f8fafc, #eef2ff);
}

.calc-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 16px;
}

.calc-fields label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: #475569;
  font-weight: 800;
}

.calc-fields input,
.calc-fields select,
.calc-fields textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 11px 12px;
  font: inherit;
  color: #0f172a;
  background: #fff;
  outline: none;
}

.calc-fields input:focus,
.calc-fields select:focus,
.calc-fields textarea:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, .12);
}

.calc-wide {
  grid-column: 1 / -1;
}

.calc-info-box {
  margin: 16px 16px 0;
  padding: 14px 16px;
  border-radius: 16px;
  background: #eff6ff;
  color: #1e3a8a;
  border: 1px solid #bfdbfe;
  line-height: 1.5;
}

.calc-kpi-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.calc-kpi {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

.calc-kpi span {
  color: #64748b;
  font-size: 12px;
  font-weight: 900;
}

.calc-kpi strong {
  color: #0f172a;
  font-size: 15px;
  white-space: nowrap;
}

.calc-kpi.good {
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.calc-kpi.good strong {
  color: #15803d;
}

.calc-kpi.warn {
  background: #fffbeb;
  border-color: #fde68a;
}

.calc-kpi.warn strong {
  color: #b45309;
}

.calc-kpi.bad {
  background: #fef2f2;
  border-color: #fecaca;
}

.calc-kpi.bad strong {
  color: #b91c1c;
}

.scenario-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.scenario-buttons button,
.saved-actions button {
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #fff;
  padding: 9px 12px;
  cursor: pointer;
  font-weight: 800;
  color: #334155;
}

.scenario-buttons button:hover,
.saved-actions button:hover {
  background: #eef2ff;
  border-color: #818cf8;
}

.saved-list {
  display: grid;
  gap: 10px;
}

.saved-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  background: #f8fafc;
}

.saved-item > button {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 0;
  cursor: pointer;
}

.saved-item strong {
  color: #0f172a;
}

.saved-item span {
  color: #64748b;
  font-size: 12px;
}

.saved-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.calc-forecast-card {
  margin-top: 18px;
}

.calc-chart-wrap {
  height: 360px;
  margin: 12px 0 18px;
}

.calc-forecast-table {
  width: 100%;
  border-collapse: collapse;
}

.calc-forecast-table th,
.calc-forecast-table td {
  border-bottom: 1px solid #e5e7eb;
  padding: 10px;
  text-align: right;
  white-space: nowrap;
}

.calc-forecast-table th:first-child,
.calc-forecast-table td:first-child {
  text-align: left;
}

@media (max-width: 1180px) {
  .calc-layout-grid,
  .calc-score-grid {
    grid-template-columns: 1fr;
  }

  .calc-right {
    position: static;
  }
}

@media (max-width: 720px) {
  .calc-main {
    padding: 16px;
  }

  .calc-hero {
    flex-direction: column;
    align-items: stretch;
  }

  .calc-fields {
    grid-template-columns: 1fr;
  }

  .scenario-buttons {
    grid-template-columns: 1fr;
  }

  .score-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .score-bar {
    width: 100%;
  }
}
/* Centrera 20-årstabellen i kalkylatorn */
.calc-forecast-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}

.calc-forecast-table th,
.calc-forecast-table td {
  text-align: center !important;
  vertical-align: middle;
  padding: 14px 18px;
}

.calc-forecast-table th:first-child,
.calc-forecast-table td:first-child {
  text-align: center !important;
  width: 80px;
}

.calc-forecast-table thead th {
  font-weight: 900;
  background: #eef3ff;
}

.calc-forecast-table tbody tr {
  height: 48px;
}


/* FIX: Dashboard - stabil höjd utan att sidan växer oändligt */
.dashboard-main-visuals {
  align-items: start;
}

.chart-hero-card {
  min-width: 0;
  overflow: hidden;
}

.chart-hero-wrap {
  position: relative;
  width: 100%;
  height: clamp(360px, 50vw, 610px);
  min-height: 360px;
  max-height: 610px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.chart-hero-wrap canvas,
#economyOverviewChart {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-height: 100% !important;
}

@media (max-width: 800px) {
  .layout {
    display: block;
  }

  .sidebar {
    position: static;
    width: 100%;
    height: auto;
  }

  .sidebar nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .main {
    padding: 16px;
    overflow: visible;
  }

  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chart-hero-wrap {
    height: 340px;
    min-height: 340px;
    max-height: 340px;
  }
}

@media (max-width: 520px) {
  .kpis {
    grid-template-columns: 1fr;
  }
}
/* ===== Property page: finance toolbar ===== */

.property-finance-toolbar {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px;
  background: linear-gradient(135deg, #f8faff, #ffffff);
  border: 1px solid var(--border-color);
  border-radius: 16px;
}

.property-finance-field label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
}

.property-number-control {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  border: 1px solid var(--input-border);
  border-radius: 14px;
  padding: 6px 10px;
  box-shadow: 0 2px 8px rgba(18, 38, 90, 0.04);
}

.property-number-control input {
  width: 58px;
  border: none;
  outline: none;
  background: transparent;
  font-weight: 700;
  color: var(--text-main);
}

.property-number-control span {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.property-number-control:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(90, 111, 240, 0.16);
}

.property-update-btn {
  height: 42px;
  padding: 0 18px;
  border-radius: 999px;
  font-weight: 700;
}
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.section-note {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: rgba(90, 111, 240, 0.08);
  border: 1px solid rgba(90, 111, 240, 0.15);
  padding: 6px 12px;
  border-radius: 999px;
}
/* ===== Onboarding ===== */

.onboarding-card {
  position: relative;
  overflow: hidden;
  margin-bottom: 1.75rem;
  padding: 0;
  border: 1px solid rgba(79, 70, 229, .18);
  background: linear-gradient(145deg, #ffffff 55%, #f5f7ff 100%);
  box-shadow: 0 18px 55px rgba(44, 55, 110, .12);
}

.onboarding-card::before {
  content: "";
  position: absolute;
  width: 260px;
  height: 260px;
  right: -90px;
  top: -150px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(91, 104, 240, .18), rgba(91, 104, 240, 0) 68%);
  pointer-events: none;
}

.onboarding-welcome {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(250px, 340px);
  align-items: end;
  gap: 32px;
  padding: 30px 32px 26px;
  color: #fff;
  background: linear-gradient(120deg, #172554 0%, #263b86 58%, #4f46e5 100%);
}

.onboarding-kicker {
  display: inline-block;
  margin-bottom: 8px;
  font-size: .76rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #c7d2fe;
}

.onboarding-welcome h2 { margin: 0; font-size: clamp(1.55rem, 3vw, 2.2rem); line-height: 1.12; color: #fff; }
.onboarding-welcome p { max-width: 650px; margin: 10px 0 0; color: rgba(255,255,255,.78); line-height: 1.55; }
.onboarding-progress-panel { padding: 16px 18px; border: 1px solid rgba(255,255,255,.16); border-radius: 14px; background: rgba(255,255,255,.1); backdrop-filter: blur(8px); }
.onboarding-progress-top { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 10px; font-size: .82rem; color: rgba(255,255,255,.7); }
.onboarding-progress-top strong { color: #fff; }
.onboarding-progress-track { height: 8px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.18); }
.onboarding-progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #a5f3fc, #fff); transition: width .35s ease; }

.onboarding-steps {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 24px 32px;
}

.onboarding-step {
  position: relative;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 92px;
  padding: 16px;
  border: 1px solid #e4e8f3;
  border-radius: 15px;
  color: var(--text);
  background: rgba(255,255,255,.92);
  box-shadow: 0 6px 18px rgba(30, 41, 80, .04);
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.onboarding-step:hover { transform: translateY(-2px); border-color: rgba(79,70,229,.4); box-shadow: 0 12px 25px rgba(46,57,120,.1); }
.onboarding-step.next-step { border-color: rgba(79,70,229,.5); box-shadow: 0 0 0 3px rgba(79,70,229,.07), 0 12px 25px rgba(46,57,120,.1); }
.step-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 13px; font-weight: 800; color: #4338ca; background: #eef2ff; }
.step-copy { min-width: 0; }
.step-copy strong, .step-copy small { display: block; }
.step-copy strong { margin-bottom: 5px; font-size: .96rem; }
.step-copy small { color: var(--text-muted); line-height: 1.4; }
.step-action { white-space: nowrap; font-size: .78rem; font-weight: 800; color: #4f46e5; }

.onboarding-step.completed {
  background: #f5fbf7;
  border-color: #b9dfc7;
}
.onboarding-step.completed .step-icon { color: #087443; background: #dcfce7; }
.onboarding-step.completed .step-action { color: #087443; }
.onboarding-footer { display: flex; justify-content: space-between; gap: 18px; padding: 0 32px 24px; font-size: .82rem; color: var(--text-muted); }
.onboarding-optional-link { font-weight: 700; color: #475569; text-align: right; }
.onboarding-optional-link:hover { color: #4f46e5; }

@media (max-width: 900px) {
  .onboarding-welcome { grid-template-columns: 1fr; align-items: start; gap: 20px; }
  .onboarding-steps { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .onboarding-welcome, .onboarding-steps { padding-left: 20px; padding-right: 20px; }
  .onboarding-welcome { padding-top: 24px; }
  .onboarding-step { grid-template-columns: 40px minmax(0, 1fr); min-height: 86px; }
  .step-icon { width: 40px; height: 40px; }
  .step-action { grid-column: 2; }
  .onboarding-footer { flex-direction: column; padding: 0 20px 22px; }
  .onboarding-optional-link { text-align: left; }
}

/* ===== Onboarding completed ===== */

.onboarding-success-card {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid rgba(34, 197, 94, 0.25);
  background: linear-gradient(
    135deg,
    rgba(34, 197, 94, 0.05),
    rgba(255,255,255,1)
  );
}

.success-icon {
  font-size: 3rem;
  flex-shrink: 0;
}

.success-content {
  flex: 1;
}

.success-content h2 {
  margin: 0 0 0.5rem 0;
}

.success-content p {
  margin: 0 0 0.75rem 0;
  color: var(--text-muted);
}

.success-content ul {
  margin: 0;
  padding-left: 1rem;
}

.success-content li {
  margin-bottom: 0.25rem;
}
/* Fristående informationssidor för den privata piloten */
.legal-page {
  width: min(760px, calc(100% - 32px));
  margin: 40px auto;
  padding: clamp(24px, 5vw, 48px);
  background: var(--card, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 16px;
  box-shadow: 0 12px 35px rgba(15, 23, 42, .08);
  line-height: 1.65;
}
.legal-page h1 { margin-top: 20px; }
.legal-page h2 { margin-top: 28px; font-size: 1.15rem; }
