/* ── Reset & Base ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --sidebar-w: 250px;
    --topbar-h: 56px;
    --accent: #1e40af;
    --accent-hover: #1d4ed8;
    --accent-light: #eff6ff;
    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-active: #ffffff;
    --sidebar-active-bg: #1e40af;
    --bg: #f1f5f9;
    --card-bg: #ffffff;
    --text: #1e293b;
    --muted: #64748b;
    --border: #e2e8f0;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
}

body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); }

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; width: var(--sidebar-w);
    background: var(--sidebar-bg); display: flex; flex-direction: column;
    z-index: 200; transition: transform .25s ease;
}

.sidebar-brand {
    padding: 18px 20px;
    background: #ffffff;
    border-bottom: 1px solid #1e293b;
    display: flex; align-items: center; justify-content: center;
}
.sidebar-brand img { width: 150px; display: block; }

.sidebar-nav { list-style: none; padding: 16px 0; flex: 1; }
.sidebar-nav li a {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 20px; color: var(--sidebar-text); text-decoration: none;
    font-size: .9rem; font-weight: 500; border-left: 3px solid transparent;
    transition: all .15s;
}
.sidebar-nav li a:hover { color: #fff; background: rgba(255,255,255,.06); }
.sidebar-nav li.active a {
    color: var(--sidebar-active); background: rgba(30,64,175,.4);
    border-left-color: var(--accent-hover);
}
.sidebar-nav li a i { font-size: 1.1rem; width: 20px; text-align: center; }

.sidebar-nav .submenu { list-style: none; padding: 0; background: rgba(0,0,0,.25); }
.sidebar-nav .submenu li a { padding-left: 52px; font-size: .85rem; }
/* Nästlad submenu (t.ex. "Bjud in…" under Partner): djupare indrag, snäppet mörkare bg. */
.sidebar-nav .submenu .submenu { background: rgba(0,0,0,.35); }
.sidebar-nav .submenu .submenu li a { padding-left: 72px; font-size: .82rem; }
.sidebar-nav .submenu-caret { margin-left: auto; font-size: .75rem; transition: transform .2s; width: auto !important; }
.sidebar-nav .nav-badge {
    margin-left: auto;
    color: #ef4444 !important;
    font-weight: 800;
    font-size: .95rem; line-height: 1;
}
.sidebar-nav li a:hover .nav-badge,
.sidebar-nav li.active a .nav-badge { color: #ef4444 !important; }
.sidebar-nav .has-submenu > a .nav-badge + .submenu-caret { margin-left: 8px; }
.sidebar-nav .has-submenu > a[aria-expanded="true"] .submenu-caret { transform: rotate(180deg); }

.sidebar-footer {
    padding: 16px 20px; border-top: 1px solid #1e293b;
    display: flex; flex-direction: column; gap: 10px;
}
.sidebar-user { display: flex; align-items: center; gap: 10px; color: #cbd5e1; font-size: .85rem; font-weight: 500; }
.sidebar-user i { font-size: 1.1rem; }
.sidebar-logout {
    display: flex; align-items: center; gap: 10px;
    color: var(--sidebar-text); text-decoration: none; font-size: .85rem;
    padding: 8px 0; transition: color .15s;
}
.sidebar-logout:hover { color: #f87171; }
.sidebar-lang { display: flex; align-items: center; gap: 6px; font-size: .8rem; }
.sidebar-lang .lang-link {
    display: inline-flex; align-items: center; padding: 3px 5px;
    border-radius: 3px; transition: background .15s, opacity .15s, box-shadow .15s;
    opacity: .55;
}
.sidebar-lang .lang-link:hover { opacity: 1; }
.sidebar-lang .lang-link.active { opacity: 1; }
.sidebar-lang .lang-flag { width: 22px; height: 15px; display: block; border-radius: 2px; }
.sidebar-lang .lang-sep { color: #334155; }

/* ── Topbar (mobile) ─────────────────────────────────────────── */
.topbar {
    position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h);
    background: var(--sidebar-bg); display: flex; align-items: center;
    padding: 0 16px; gap: 14px; z-index: 150;
}
.topbar-toggle {
    background: none; border: none; color: #fff; font-size: 1.5rem;
    cursor: pointer; padding: 4px;
}
.topbar-title { color: #fff; font-weight: 600; font-size: 1rem; }

/* Sidebar open on mobile */
.sidebar-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5);
    z-index: 190;
}
.sidebar-overlay.visible { display: block; }

@media (max-width: 991px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; padding-top: calc(var(--topbar-h) + 24px); }
}

/* ── Main content ────────────────────────────────────────────── */
@media (min-width: 992px) {
    .main-content { margin-left: var(--sidebar-w); }
    .partner-banner { margin-left: var(--sidebar-w); }
}
.main-content { padding: 32px; min-height: 100vh; }

/* ── Page header ─────────────────────────────────────────────── */
.page-header { margin-bottom: 28px; }
.page-header h1 { font-size: 1.6rem; font-weight: 700; color: var(--text); }
.page-header p { color: var(--muted); font-size: .9rem; margin-top: 4px; }

/* ── KPI cards ───────────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 28px; }
.kpi-card {
    background: var(--card-bg); border-radius: 12px; padding: 22px 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
    display: flex; align-items: flex-start; gap: 16px;
}
.kpi-icon {
    width: 48px; height: 48px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem; flex-shrink: 0;
}
.kpi-icon.blue   { background: #dbeafe; color: #1d4ed8; }
.kpi-icon.green  { background: #dcfce7; color: #16a34a; }
.kpi-icon.orange { background: #fef3c7; color: #d97706; }
.kpi-icon.purple { background: #ede9fe; color: #7c3aed; }
.kpi-body { flex: 1; }
.kpi-label { font-size: .78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.kpi-value { font-size: 1.55rem; font-weight: 700; color: var(--text); line-height: 1.2; margin-top: 2px; }
.kpi-sub   { font-size: .8rem; color: var(--muted); margin-top: 3px; }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
    background: var(--card-bg); border-radius: 12px; border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0,0,0,.06); margin-bottom: 24px;
}
.card-header {
    padding: 18px 24px 14px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.card-header h2 { font-size: 1rem; font-weight: 600; color: var(--text); }
.card-header .badge-count {
    background: var(--accent-light); color: var(--accent);
    font-size: .75rem; font-weight: 700; padding: 2px 10px; border-radius: 20px;
}
.card-body { padding: 0; }

/* ── Table ───────────────────────────────────────────────────── */
.portal-table { width: 100%; border-collapse: collapse; }
.portal-table th {
    background: #f8fafc; padding: 11px 16px;
    font-size: .75rem; font-weight: 700; color: var(--muted);
    text-transform: uppercase; letter-spacing: .05em;
    border-bottom: 1px solid var(--border); text-align: left;
    white-space: nowrap;
}
.portal-table td {
    padding: 13px 16px; border-bottom: 1px solid #f1f5f9;
    font-size: .875rem; color: var(--text); vertical-align: middle;
}
.portal-table tbody tr:last-child td { border-bottom: none; }
.portal-table tbody tr:hover td { background: #f8fafc; }
.portal-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.portal-table .mono { font-family: 'Courier New', monospace; font-size: .8rem; color: var(--muted); }

/* ── Badges ──────────────────────────────────────────────────── */
.badge-status {
    display: inline-block; padding: 3px 10px; border-radius: 20px;
    font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
}
.badge-aktiv   { background: #dcfce7; color: #15803d; }
.badge-avslutat{ background: #f1f5f9; color: #64748b; }
.badge-fullbet { background: #dbeafe; color: #1d4ed8; }

/* ── Search bar ──────────────────────────────────────────────── */
.search-bar {
    padding: 16px 24px; border-bottom: 1px solid var(--border);
}
.search-input {
    width: 100%; max-width: 360px; padding: 9px 14px 9px 38px;
    border: 1px solid var(--border); border-radius: 8px;
    font-size: .875rem; color: var(--text); background: #f8fafc;
    outline: none; transition: border-color .15s, box-shadow .15s;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001q.044.06.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1 1 0 0 0-.115-.099zm-5.242 1.656a5.5 5.5 0 1 1 0-11 5.5 5.5 0 0 1 0 11'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: 12px center;
}
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(30,64,175,.1); background-color: #fff; }

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state { padding: 56px 24px; text-align: center; }
.empty-state i { font-size: 2.5rem; color: #cbd5e1; display: block; margin-bottom: 12px; }
.empty-state p { color: var(--muted); font-size: .9rem; }

/* ── Detail row ──────────────────────────────────────────────── */
.detail-link { color: var(--accent); text-decoration: none; font-weight: 600; }
.detail-link:hover { text-decoration: underline; }

/* ── Back button ─────────────────────────────────────────────── */
.btn-back {
    display: inline-flex; align-items: center; gap: 6px;
    color: var(--muted); text-decoration: none; font-size: .875rem;
    margin-bottom: 20px; transition: color .15s;
}
.btn-back:hover { color: var(--text); }

/* ── Login page ──────────────────────────────────────────────── */
.login-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    flex-direction: column; gap: 18px;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
    padding: 24px 24px 40px;
}
.login-card {
    background: #fff; border-radius: 16px; padding: 48px 44px;
    width: 100%; max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
/* CTA-card under inloggningsrutan – marknadsför den fria påminnelseservicen */
.cta-card {
    background: #fff; border-radius: 16px; padding: 22px 24px;
    width: 100%; max-width: 420px;
    box-shadow: 0 12px 36px rgba(0,0,0,.22);
    border-left: 5px solid #c0392b;
}
.cta-card .cta-row { display: flex; align-items: center; gap: 14px; }
.cta-card .cta-icon {
    flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%;
    background: #fef2f2; color: #c0392b;
    display: flex; align-items: center; justify-content: center; font-size: 1.4rem;
}
.cta-card .cta-text { flex: 1; min-width: 0; }
.cta-card .cta-title { font-size: 1rem; font-weight: 600; color: #1e293b; margin: 0 0 2px; }
.cta-card .cta-sub { color: #64748b; font-size: .82rem; line-height: 1.4; margin: 0; }
.cta-card .cta-action {
    margin-top: 14px; display: block; text-align: center;
    background: #c0392b; color: #fff; text-decoration: none;
    padding: 10px 14px; border-radius: 8px; font-weight: 600; font-size: .9rem;
    transition: background .15s;
}
.cta-card .cta-action:hover { background: #a93226; color: #fff; }
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo img { width: 180px; }
.login-card h1 { font-size: 1.4rem; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.login-card p.sub { color: var(--muted); font-size: .875rem; margin-bottom: 28px; }
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: .8rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-control {
    width: 100%; padding: 10px 14px; border: 1px solid var(--border);
    border-radius: 8px; font-size: .9rem; color: var(--text);
    transition: border-color .15s, box-shadow .15s; outline: none;
}
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(30,64,175,.1); }
.form-control.autofylld { border-color: var(--success); background: #f0fdf4; }
.btn-login {
    width: 100%; padding: 11px; background: var(--accent); color: #fff;
    border: none; border-radius: 8px; font-size: .95rem; font-weight: 600;
    cursor: pointer; transition: background .15s; margin-top: 8px;
}
.btn-login:hover { background: var(--accent-hover); }
.login-error {
    background: #fef2f2; border: 1px solid #fecaca; border-radius: 8px;
    padding: 10px 14px; color: #dc2626; font-size: .85rem; margin-bottom: 18px;
}

/* ── Responsive table ────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

/* ── Amount colors ───────────────────────────────────────────── */
.amt { font-weight: 600; }
.amt-large { color: var(--danger); }

/* ── Atgard timeline ─────────────────────────────────────────── */
.timeline { padding: 16px 24px; }
.tl-item { display: flex; gap: 14px; padding: 10px 0; border-bottom: 1px solid #f1f5f9; }
.tl-item:last-child { border-bottom: none; }
.tl-dot {
    width: 32px; height: 32px; border-radius: 50%; background: var(--accent-light);
    color: var(--accent); display: flex; align-items: center; justify-content: center;
    font-size: .85rem; flex-shrink: 0; margin-top: 2px;
}
.tl-body { flex: 1; }
.tl-title { font-size: .875rem; font-weight: 600; color: var(--text); }
.tl-meta  { font-size: .78rem; color: var(--muted); margin-top: 2px; }

/* ── BankID-knapp ─────────────────────────────────────────────── */
.btn-bankid {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    width: 100%; padding: 12px; background: #1b3d6e; color: #fff;
    border: none; border-radius: 8px; font-size: .95rem; font-weight: 600;
    cursor: pointer; text-decoration: none; transition: background .15s; margin-bottom: 4px;
}
.btn-bankid:hover { background: #163060; color: #fff; }
.btn-bankid svg { flex-shrink: 0; }

/* ── Divider ──────────────────────────────────────────────────── */
.login-divider {
    display: flex; align-items: center; gap: 12px;
    margin: 18px 0; color: var(--muted); font-size: .8rem;
}
.login-divider::before, .login-divider::after {
    content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ── Form labels ─────────────────────────────────────────────── */
.form-label {
    display: block; font-size: .8rem; font-weight: 600;
    color: var(--text); margin-bottom: 6px;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn-primary {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 18px; background: var(--accent); color: #fff;
    border: none; border-radius: 8px; font-size: .875rem; font-weight: 600;
    cursor: pointer; text-decoration: none; transition: background .15s; white-space: nowrap;
}
.btn-primary:hover { background: var(--accent-hover); color: #fff; }

.btn-danger-sm {
    padding: 5px 10px; background: #fef2f2; color: #dc2626;
    border: 1px solid #fecaca; border-radius: 6px;
    font-size: .8rem; cursor: pointer; transition: all .15s;
}
.btn-danger-sm:hover { background: #dc2626; color: #fff; border-color: #dc2626; }

/* ── Alert boxes ─────────────────────────────────────────────── */
.alert-box {
    padding: 12px 16px; border-radius: 8px; font-size: .875rem; margin-bottom: 20px;
}
.alert-ok  { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }
.alert-fel { background: #fef2f2; border: 1px solid #fecaca; color: #dc2626; }

/* ── Handläggare sidebar nav ─────────────────────────────────── */
.sidebar-nav li a { /* already defined */ }

/* ── Form grid ───────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-field { display: flex; flex-direction: column; }
.form-field.span2 { grid-column: span 2; }
.req { color: var(--danger); }

/* ── Inkassotyp-kort ─────────────────────────────────────────── */
.inktyp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.inktyp-card {
    display: flex; align-items: center; gap: 12px;
    border: 2px solid var(--border); border-radius: 10px; padding: 14px 16px;
    cursor: pointer; transition: all .15s;
}
.inktyp-card input[type="radio"] { width: 18px; height: 18px; accent-color: var(--accent); flex-shrink: 0; }
.inktyp-card.selected { border-color: var(--accent); background: var(--accent-light); }
.inktyp-card:hover { border-color: var(--accent); }
.inktyp-body { display: flex; flex-direction: column; }
.inktyp-titel { font-size: .875rem; font-weight: 600; color: var(--text); }
.inktyp-sub   { font-size: .78rem; color: var(--muted); margin-top: 2px; }

/* ── Dropzone ────────────────────────────────────────────────── */
.dropzone {
    border: 2px dashed var(--border); border-radius: 10px;
    padding: 40px 24px; text-align: center; cursor: pointer;
    transition: all .2s; background: #fafbfc;
}
.dropzone:hover, .dropzone.drag-over {
    border-color: var(--accent); background: var(--accent-light);
}
.dropzone-inner { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.dropzone-icon  { font-size: 2.5rem; color: #94a3b8; }
.dropzone-text  { font-size: .9rem; color: var(--text); margin: 0; }
.dropzone-link  { color: var(--accent); font-weight: 600; text-decoration: underline; }
.dropzone-sub   { font-size: .78rem; color: var(--muted); margin: 0; }
.dropzone-preview {
    display: flex; align-items: center; gap: 14px;
    padding: 4px 0; justify-content: center;
}

/* ── Bekräftelsebanner ───────────────────────────────────────── */
.bekraftelse-banner {
    display: flex; align-items: center; gap: 16px;
    background: #f0fdf4; border: 1px solid #86efac; border-radius: 10px;
    padding: 18px 22px; margin-bottom: 24px;
}
.bekraftelse-icon { font-size: 1.8rem; color: #16a34a; flex-shrink: 0; }

/* ── Skicka-knapp ────────────────────────────────────────────── */
.btn-skicka {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 12px 28px; background: var(--accent); color: #fff;
    border: none; border-radius: 8px; font-size: 1rem; font-weight: 600;
    cursor: pointer; transition: background .15s;
}
.btn-skicka:hover { background: var(--accent-hover); }

@media (max-width: 768px) {
    .form-grid { grid-template-columns: 1fr; }
    .form-field.span2 { grid-column: span 1; }
    .inktyp-grid { grid-template-columns: 1fr; }
}

@media (max-width: 576px) {
    .main-content { padding: 16px; }
    .login-card { padding: 32px 24px; }
    .kpi-card { padding: 16px 18px; }
    .portal-table th, .portal-table td { padding: 10px 12px; }
}


/* ── Formbredd – begränsa formulärinnehåll på breda skärmar ──── */
.form-outer { max-width: 1200px; }
.form-outer-sm { max-width: 520px; }
