/* ============================================================
   Älvfalk CRM - Design System
   Refined, editorial, precise
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,300;0,9..144,400;0,9..144,500;0,9..144,600;0,9..144,700;1,9..144,400&family=JetBrains+Mono:wght@400;500&family=Manrope:wght@300;400;500;600;700;800&display=swap');

:root {
    --bg: #fafaf7;
    --bg-elevated: #ffffff;
    --bg-sunken: #f3f2ed;
    --ink: #1a1a1a;
    --ink-muted: #5a5a55;
    --ink-subtle: #8a8a82;
    --line: #e5e3dc;
    --line-strong: #c9c7bd;
    --accent: #2d4a2b;
    --accent-soft: #e8ede3;
    --rust: #a84a1e;
    --gold: #b8923a;
    --danger: #a23030;
    --success: #2d6a4f;
    --shadow: 0 1px 2px rgba(20, 20, 15, 0.04), 0 4px 12px rgba(20, 20, 15, 0.04);
    --shadow-lg: 0 2px 4px rgba(20, 20, 15, 0.06), 0 12px 32px rgba(20, 20, 15, 0.08);
    --radius: 6px;
    --radius-lg: 10px;
    --font-display: 'Fraunces', Georgia, serif;
    --font-body: 'Manrope', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

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

html, body {
    height: 100%;
}

body {
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: opacity 0.15s;
}

a:hover {
    opacity: 0.7;
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 500;
    letter-spacing: -0.02em;
    line-height: 1.15;
}

h1 { font-size: 32px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
h4 { font-size: 15px; font-family: var(--font-body); font-weight: 600; }

/* ============================================================
   Layout
   ============================================================ */

.app {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--ink);
    color: #e8e7e2;
    padding: 24px 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    padding: 0 24px 28px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 16px;
}

.sidebar-brand h1 {
    font-size: 22px;
    font-weight: 400;
    color: #ffffff;
    font-style: italic;
    margin-bottom: 2px;
}

.sidebar-brand span {
    font-family: var(--font-mono);
    font-size: 10px;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.sidebar-nav {
    flex: 1;
    padding: 0 12px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: rgba(255, 255, 255, 0.7);
    border-radius: var(--radius);
    margin-bottom: 2px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s;
}

.sidebar-nav a:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
    opacity: 1;
}

.sidebar-nav a.active {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.sidebar-nav .nav-icon {
    width: 18px;
    height: 18px;
    opacity: 0.8;
}

.sidebar-section {
    padding: 16px 26px 8px;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.4);
}

.sidebar-user {
    padding: 16px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 13px;
}

.sidebar-user .user-name {
    color: #fff;
    font-weight: 500;
}

.sidebar-user .user-email {
    color: rgba(255, 255, 255, 0.5);
    font-size: 12px;
}

.sidebar-user a {
    color: rgba(255, 255, 255, 0.6);
    font-size: 12px;
    margin-top: 8px;
    display: inline-block;
}

.main {
    padding: 32px 40px;
    max-width: 1400px;
    min-width: 0;
}

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--line);
}

.page-header h1 {
    font-size: 38px;
    line-height: 1;
}

.page-header .subtitle {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-subtle);
    margin-top: 6px;
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    background: var(--ink);
    color: #fff;
    border: 1px solid var(--ink);
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    letter-spacing: 0.01em;
}

.btn:hover {
    opacity: 0.85;
}

.btn-secondary {
    background: transparent;
    color: var(--ink);
    border-color: var(--line-strong);
}

.btn-secondary:hover {
    background: var(--bg-sunken);
    opacity: 1;
}

.btn-ghost {
    background: transparent;
    color: var(--ink-muted);
    border-color: transparent;
}

.btn-ghost:hover {
    background: var(--bg-sunken);
    color: var(--ink);
    opacity: 1;
}

.btn-danger {
    background: var(--danger);
    border-color: var(--danger);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* ============================================================
   Cards & Tables
   ============================================================ */

.card {
    background: var(--bg-elevated);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h2, .card-header h3 {
    margin: 0;
}

.card-body {
    padding: 24px;
}

.card-body.tight {
    padding: 0;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th {
    text-align: left;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-subtle);
    font-weight: 500;
    padding: 14px 20px;
    border-bottom: 1px solid var(--line);
    background: var(--bg-sunken);
}

table td {
    padding: 14px 20px;
    border-bottom: 1px solid var(--line);
    font-size: 14px;
    vertical-align: middle;
}

table tr:last-child td {
    border-bottom: none;
}

table tr:hover td {
    background: var(--bg-sunken);
}

table tr.clickable {
    cursor: pointer;
}

/* ============================================================
   Forms
   ============================================================ */

.form-group {
    margin-bottom: 18px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}

label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 6px;
    letter-spacing: 0.01em;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="url"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--ink);
    transition: border-color 0.15s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

textarea {
    resize: vertical;
    min-height: 90px;
    font-family: var(--font-body);
}

select {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%231a1a1a' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    appearance: none;
}

/* ============================================================
   Badges & Pills
   ============================================================ */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 99px;
    background: var(--bg-sunken);
    color: var(--ink);
    letter-spacing: 0.02em;
}

.stage-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 11px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 99px;
    background: var(--bg-sunken);
    color: var(--ink);
    border: 1px solid var(--line);
}

.stage-pill::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--stage-color, var(--ink-subtle));
}

/* ============================================================
   Dashboard stats
   ============================================================ */

.main .stats-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 32px;
}

/* På smalare skärm: bryt till 2-rader-layout */
@media (max-width: 900px) {
    .main .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px;
    }
}

.stat {
    background: var(--bg-elevated);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
    position: relative;
    overflow: hidden;
}

.stat-label {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-subtle);
    margin-bottom: 8px;
}

.stat-value {
    font-family: var(--font-display);
    font-size: 38px;
    font-weight: 400;
    line-height: 1;
    color: var(--ink);
}

.stat-change {
    font-size: 12px;
    color: var(--ink-muted);
    margin-top: 6px;
}

/* ============================================================
   Funnel / Kanban
   ============================================================ */

.funnel {
    display: grid;
    grid-template-columns: repeat(var(--col-count, 5), minmax(240px, 1fr));
    gap: 14px;
    overflow-x: auto;
    padding-bottom: 20px;
    min-height: 500px;
}

.funnel-col {
    background: var(--bg-sunken);
    border-radius: var(--radius-lg);
    padding: 12px;
    min-width: 240px;
}

.funnel-col-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px 12px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--line);
}

.funnel-col-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 13px;
}

.funnel-col-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.funnel-col-count {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--ink-subtle);
    background: var(--bg-elevated);
    padding: 2px 8px;
    border-radius: 99px;
    border: 1px solid var(--line);
}

.funnel-card {
    background: var(--bg-elevated);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 8px;
    cursor: grab;
    transition: all 0.15s;
    box-shadow: var(--shadow);
}

.funnel-card:hover {
    border-color: var(--line-strong);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.funnel-card.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.funnel-col.drag-over {
    background: var(--accent-soft);
}

.funnel-card-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 2px;
}

.funnel-card-sub {
    font-size: 12px;
    color: var(--ink-muted);
}

.funnel-card-meta {
    display: flex;
    gap: 10px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--line);
    font-size: 11px;
    color: var(--ink-subtle);
    font-family: var(--font-mono);
}

/* ============================================================
   Activity timeline
   ============================================================ */

.timeline {
    position: relative;
    min-width: 0;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 17px;
    top: 8px;
    bottom: 8px;
    width: 1px;
    background: var(--line);
}

.timeline-item {
    display: flex;
    gap: 16px;
    padding: 14px 0;
    position: relative;
    min-width: 0;
}

.timeline-dot {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-elevated);
    border: 1px solid var(--line-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    z-index: 1;
}

.timeline-content {
    flex: 1;
    min-width: 0;
    padding-top: 4px;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.timeline-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}

.timeline-title {
    font-weight: 600;
    font-size: 14px;
    overflow-wrap: break-word;
    word-wrap: break-word;
    min-width: 0;
}

.timeline-time {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--ink-subtle);
    white-space: nowrap;
    flex-shrink: 0;
}

.timeline-body {
    font-size: 13px;
    color: var(--ink-muted);
    line-height: 1.55;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.timeline-type {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-subtle);
    margin-left: 8px;
}

/* ============================================================
   Tabs
   ============================================================ */

.tabs {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 24px;
    position: relative; /* för att Mer-dropdown ska positioneras relativt här */
}

.tab {
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.15s;
}

.tab:hover {
    color: var(--ink);
}

.tab.active {
    color: var(--ink);
    border-bottom-color: var(--ink);
}

/* ============================================================
   Detail pages
   ============================================================ */

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 24px;
}

.detail-header {
    background: var(--bg-elevated);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 28px;
    margin-bottom: 24px;
}

.detail-header h1 {
    font-size: 32px;
    margin-bottom: 6px;
}

.detail-header .sub {
    color: var(--ink-muted);
    font-size: 15px;
}

.detail-meta {
    display: flex;
    gap: 24px;
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    font-size: 13px;
}

.detail-meta-item {
    display: flex;
    flex-direction: column;
}

.detail-meta-label {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-subtle);
    margin-bottom: 2px;
}

.detail-meta-value {
    color: var(--ink);
    font-weight: 500;
}

/* ============================================================
   Alerts & messages
   ============================================================ */

.alert {
    padding: 14px 18px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 20px;
    border: 1px solid;
}

.alert-success {
    background: #eef7f0;
    color: var(--success);
    border-color: #c5e0cc;
}

.alert-error {
    background: #fbeeee;
    color: var(--danger);
    border-color: #e8c5c5;
}

.alert-info {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: #c9d4c4;
}

/* ============================================================
   Empty states
   ============================================================ */

.empty {
    text-align: center;
    padding: 60px 24px;
    color: var(--ink-muted);
}

.empty h3 {
    font-family: var(--font-display);
    font-size: 22px;
    color: var(--ink);
    margin-bottom: 8px;
    font-style: italic;
}

.empty p {
    font-size: 14px;
    margin-bottom: 20px;
}

/* ============================================================
   Login page
   ============================================================ */

.login-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: var(--bg);
    background-image: 
        radial-gradient(circle at 20% 30%, rgba(45, 74, 43, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(168, 74, 30, 0.03) 0%, transparent 50%);
}

.login-card {
    background: var(--bg-elevated);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 44px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.login-card h1 {
    font-family: var(--font-display);
    font-size: 36px;
    font-style: italic;
    margin-bottom: 4px;
}

.login-card .login-sub {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-subtle);
    margin-bottom: 32px;
}

/* ============================================================
   Utilities
   ============================================================ */

.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
.mt-sm { margin-top: 8px; }
.mt-md { margin-top: 16px; }
.mt-lg { margin-top: 24px; }
.mb-lg { margin-bottom: 24px; }
.text-muted { color: var(--ink-muted); }
.text-subtle { color: var(--ink-subtle); }
.text-sm { font-size: 12px; }
.text-right { text-align: right; }
.mono { font-family: var(--font-mono); }

/* Tvåkolumns-layout som kollapsar på mobil */
.split-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 24px;
    margin-bottom: 24px;
}

/* ===== Tasks: Visa fler-knapp och kollapsat formulär ===== */
.btn-show-more {
    display: block;
    width: 100%;
    padding: 14px 20px;
    background: transparent;
    border: none;
    border-top: 1px solid var(--line);
    color: var(--accent);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
    transition: background 0.15s;
}

.btn-show-more:hover {
    background: var(--bg-sunken);
}

.add-task-details {
    background: var(--bg-elevated);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    overflow: hidden;
}

.add-task-details > summary {
    padding: 16px 20px;
    cursor: pointer;
    list-style: none;
    font-family: var(--font-body);
    font-size: 15px;
    font-weight: 500;
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
    transition: background 0.15s;
}

.add-task-details > summary::-webkit-details-marker {
    display: none;
}

.add-task-details > summary:hover {
    background: var(--bg-sunken);
}

.add-task-details[open] > summary {
    border-bottom: 1px solid var(--line);
}

.add-task-details > .card-body {
    padding: 20px;
}

/* ===== Pipeline: Fasgrupperad vy på dashboard ===== */
.pipeline-phases {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 12px;
    align-items: stretch;
}

/* Lös start (Prospect) och slut (Vunnen) — kompakta vertikala badges */
.pipeline-loose {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 14px 16px;
    background: var(--bg-sunken);
    border-radius: var(--radius);
    min-width: 90px;
    text-align: center;
}

.pipeline-loose-label {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.05em;
    color: var(--ink-subtle);
    font-weight: 600;
    margin-bottom: 6px;
    text-transform: uppercase;
}

.pipeline-loose-count {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 500;
    color: var(--ink-muted);
    line-height: 1;
}

.pipeline-loose-won {
    background: var(--accent-soft);
}

.pipeline-loose-link {
    text-decoration: none;
    color: inherit;
    transition: all 0.15s;
}

.pipeline-loose-link:hover {
    background: var(--bg-elevated);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.pipeline-loose-link.pipeline-loose-won:hover {
    background: var(--accent-soft);
    filter: brightness(0.97);
}

.pipeline-stage-bar {
    text-decoration: none;
    color: inherit;
    display: block;
    border-radius: var(--radius-sm);
    padding: 4px 6px;
    margin: 0 -6px;
    transition: background 0.15s;
}

.pipeline-stage-bar:hover {
    background: var(--bg-sunken);
}

.pipeline-loose-won .pipeline-loose-label {
    color: var(--accent);
}

.pipeline-loose-won .pipeline-loose-count {
    color: var(--accent);
    font-weight: 600;
}

/* Mellansektionen: faser bredvid varandra */
.pipeline-phases-middle {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    gap: 10px;
}

.pipeline-phase {
    background: var(--bg-elevated);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.pipeline-phase.has-activity {
    border-color: var(--ink-subtle);
}

.pipeline-phase-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--line);
}

.pipeline-phase-name {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-subtle);
    font-weight: 600;
}

.pipeline-phase.has-activity .pipeline-phase-name {
    color: var(--ink);
}

.pipeline-phase-total {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 500;
    color: var(--ink-muted);
    line-height: 1;
}

.pipeline-phase.has-activity .pipeline-phase-total {
    color: var(--ink);
}

.pipeline-phase-bars {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pipeline-stage-bar {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.pipeline-stage-bar-label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 12px;
    color: var(--ink-muted);
    gap: 6px;
    min-width: 0;
}

.pipeline-stage-bar-label > span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.pipeline-stage-bar-count {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--ink-subtle);
    font-weight: 600;
    flex-shrink: 0;
}

.pipeline-stage-bar-track {
    height: 4px;
    background: var(--bg-sunken);
    border-radius: 2px;
    overflow: hidden;
}

.pipeline-stage-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.25s ease;
}

/* Mobil: stackat vertikalt (en fas per rad) */
@media (max-width: 900px) {
    .pipeline-phases {
        grid-template-columns: 1fr;
    }

    .pipeline-phases-middle {
        grid-template-columns: 1fr;
    }

    .pipeline-loose {
        flex-direction: row;
        justify-content: space-between;
        min-width: 0;
    }

    .pipeline-loose-label {
        margin-bottom: 0;
    }
}

/* ===== Kalender: Månadsnavigering ===== */
.cal-monthnav {
    display: flex;
    gap: 8px;
    align-items: center;
}

.cal-monthnav-wrap {
    margin-bottom: 24px;
    max-width: 100%;
    overflow: hidden;
}

/* ===== iCal-sync: diskret utfällbar ===== */
.cal-sync-details {
    margin-bottom: 24px;
}

.cal-sync-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: transparent;
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--ink-muted);
    font-size: 13px;
    list-style: none;
    user-select: none;
    transition: all 0.15s;
}

.cal-sync-summary::-webkit-details-marker {
    display: none;
}

.cal-sync-summary:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--bg-elevated);
}

.cal-sync-summary-arrow {
    font-family: var(--font-mono);
    transition: transform 0.2s;
    flex-shrink: 0;
    margin-left: 12px;
}

.cal-sync-details[open] .cal-sync-summary {
    border-style: solid;
    border-color: var(--accent);
    color: var(--accent);
    background: var(--bg-elevated);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.cal-sync-details[open] .cal-sync-summary-arrow {
    transform: rotate(90deg);
}

.cal-sync-content {
    padding: 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--accent);
    border-top: none;
    border-bottom-left-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
}

.cal-sync-url-row {
    margin-bottom: 14px;
}

.cal-sync-url {
    width: 100%;
    font-family: var(--font-mono);
    font-size: 12px;
    background: #fff !important;
    padding: 10px 12px;
}

.cal-sync-instructions {
    font-size: 13px;
    line-height: 1.6;
    color: var(--ink-muted);
}

.cal-sync-instructions p {
    margin: 0 0 10px 0;
}

.cal-sync-instructions p:last-child {
    margin-bottom: 0;
}

.cal-sync-instructions strong {
    color: var(--ink);
}

.cal-sync-instructions a {
    color: var(--accent);
}

.cal-sync-note {
    margin-top: 12px !important;
    padding-top: 12px;
    border-top: 1px dashed var(--line);
    font-size: 12px;
    color: var(--ink-subtle);
    font-style: italic;
}

.cal-sync-regen {
    margin-top: 14px;
    font-size: 11px !important;
}

/* ===== Pipeline: "Utan stadium" som diskret utfällbar ===== */
.unassigned-details {
    margin-bottom: 24px;
}

.unassigned-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: transparent;
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--ink-muted);
    font-size: 13px;
    list-style: none;
    user-select: none;
    transition: all 0.15s;
}

.unassigned-summary::-webkit-details-marker {
    display: none;
}

.unassigned-summary:hover {
    border-color: var(--ink-subtle);
    color: var(--ink);
    background: var(--bg-elevated);
}

.unassigned-summary-arrow {
    font-family: var(--font-mono);
    transition: transform 0.2s;
    flex-shrink: 0;
    margin-left: 12px;
}

.unassigned-details[open] .unassigned-summary {
    border-style: solid;
    border-color: var(--ink-subtle);
    color: var(--ink);
    background: var(--bg-elevated);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.unassigned-details[open] .unassigned-summary-arrow {
    transform: rotate(90deg);
}

.unassigned-content {
    padding: 14px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--ink-subtle);
    border-top: none;
    border-bottom-left-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.unassigned-item {
    display: inline-block;
    padding: 7px 12px;
    background: var(--bg-sunken);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--ink);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.15s;
}

.unassigned-item:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* ===== Dashboard tabs (Min dag / Översikt) ===== */
.dashboard-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    padding: 4px;
    background: var(--bg-sunken);
    border-radius: var(--radius);
    width: fit-content;
}

.dashboard-tab {
    padding: 10px 18px;
    background: transparent;
    border: none;
    border-radius: calc(var(--radius) - 2px);
    color: var(--ink-muted);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.dashboard-tab:hover {
    color: var(--ink);
}

.dashboard-tab.active {
    background: var(--bg-elevated);
    color: var(--ink);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

/* ===== Min dag-vy ===== */
.mydag-section {
    margin-bottom: 24px;
}

.mydag-section-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line);
}

.mydag-section-header h3 {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 500;
    margin: 0;
    color: var(--ink-muted);
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.mydag-today .mydag-section-header h3 {
    color: var(--ink);
}

.mydag-section-date {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--ink-subtle);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    font-weight: 600;
}

.mydag-count {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--ink-subtle);
    background: var(--bg-sunken);
    padding: 3px 9px;
    border-radius: 999px;
    font-weight: 600;
}

.mydag-overdue .mydag-count {
    background: #fee;
    color: var(--danger);
}

.mydag-empty {
    padding: 14px 16px;
    color: var(--ink-subtle);
    font-size: 13px;
    font-style: italic;
}

.mydag-items {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mydag-item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 12px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: inherit;
    text-decoration: none;
    transition: all 0.15s;
}

.mydag-item:hover {
    border-color: var(--accent);
    transform: translateX(2px);
}

.mydag-item-time {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    flex-shrink: 0;
    min-width: 44px;
    padding-top: 1px;
}

.mydag-item-icon {
    font-size: 16px;
    flex-shrink: 0;
    line-height: 1.2;
    width: 22px;
    text-align: center;
}

.mydag-item-body {
    flex: 1;
    min-width: 0;
}

.mydag-item-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
    line-height: 1.3;
    margin-bottom: 2px;
}

.mydag-item-meta {
    font-size: 12px;
    color: var(--ink-subtle);
    line-height: 1.3;
}

.mydag-item-meeting {
    border-left: 3px solid var(--accent);
}

.mydag-item-task .mydag-item-icon {
    color: var(--ink-subtle);
}

.mydag-checkbox-form {
    margin: 0;
    flex-shrink: 0;
}

.mydag-checkbox {
    width: 22px;
    height: 22px;
    border: 2px solid var(--ink-subtle);
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    padding: 0;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 1px;
}

.mydag-checkbox:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.mydag-checkbox::after {
    content: "✓";
    font-size: 14px;
    color: transparent;
    font-weight: bold;
    line-height: 1;
}

.mydag-checkbox:hover::after {
    color: var(--accent);
}

.mydag-item-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

/* ===== Snabb-anteckning på person ===== */
.quick-note-form {
    background: var(--bg-elevated);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: border-color 0.2s;
}

.quick-note-form:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.quick-note-types {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.quick-note-type {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    padding: 5px 11px;
    background: var(--bg-sunken);
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 12px;
    color: var(--ink-muted);
    transition: all 0.15s;
    user-select: none;
}

.quick-note-type input {
    display: none;
}

.quick-note-type .quick-note-label,
.quick-note-type span:not(.type-direction-arrow) {
    /* Stödjer både gammal markup (bara span) och ny (.quick-note-label) */
    padding: 0;
    background: transparent;
    border: none;
}

.quick-note-type:hover {
    color: var(--ink);
}

.quick-note-type:has(input:checked) {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 600;
}

/* Fallback för browsers utan :has() */
.quick-note-type input:checked + .quick-note-label,
.quick-note-type input:checked + span {
    color: inherit;
}

/* Direction-pil i typ-knapp — visuell indikator (hela knappen är klickbar) */
.type-direction-arrow {
    display: none;  /* Default dold */
    font-weight: 700;
    font-size: 13px;
    line-height: 1;
    margin-left: 2px;
    transition: transform 0.2s ease, color 0.2s;
    color: var(--accent);
    pointer-events: none;  /* Klicket går till hela labeln */
}

/* Visa pilen bara när typen är vald */
.quick-note-type.has-active-direction .type-direction-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* IN-läge: blå färg + roterad pil */
.type-direction-arrow[data-direction="in"] {
    color: #2c5d8c;
}

.quick-note-type.has-active-direction:has(.type-direction-arrow[data-direction="in"]) {
    background: rgba(70, 130, 180, 0.12);
    border-color: rgba(70, 130, 180, 0.4);
    color: #2c5d8c;
}

/* När knappen är vald + direction-typ → visa "klickbar" cursor */
.quick-note-type.has-active-direction {
    cursor: pointer;
    position: relative;
}

.quick-note-text {
    width: 100%;
    border: none;
    background: transparent;
    font-family: var(--font-body);
    font-size: 15px;
    color: var(--ink);
    resize: vertical;
    min-height: 48px;
    padding: 4px 0;
    outline: none;
    line-height: 1.5;
}

.quick-note-text::placeholder {
    color: var(--ink-subtle);
}

.quick-note-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.quick-note-hint {
    font-size: 11px;
    color: var(--ink-subtle);
    font-family: var(--font-mono);
}

@media (max-width: 900px) {
    .quick-note-hint {
        display: none;
    }
    .quick-note-actions {
        justify-content: flex-end;
    }
}

/* ===== Kommunikations-knappar (Ring / SMS) ===== */
.comm-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
}

.comm-btn {
    flex: 1;
    padding: 14px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.15s;
    user-select: none;
}

.comm-btn:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
    transform: translateY(-1px);
}

.comm-btn:active {
    transform: translateY(0);
}

.comm-btn-call {
    border-left: 3px solid var(--accent);
}

.comm-btn-sms {
    border-left: 3px solid var(--rust, #a84a1e);
}

.comm-btn-sms:hover {
    border-color: var(--rust, #a84a1e);
    background: rgba(168, 74, 30, 0.08);
    color: var(--rust, #a84a1e);
}

/* ===== Återvändar-prompt efter samtal ===== */
.call-return-prompt {
    background: var(--accent-soft);
    border: 2px solid var(--accent);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
    margin-bottom: 24px;
    animation: callReturnPulse 0.5s ease-out;
}

@keyframes callReturnPulse {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.call-return-header {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 12px;
}

.call-return-header strong {
    font-size: 15px;
    color: var(--accent);
}

.call-return-subtitle {
    font-size: 13px;
    color: var(--ink-muted);
}

.call-return-options {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.call-return-option {
    cursor: pointer;
    flex: 1;
    min-width: 100px;
}

.call-return-option input {
    display: none;
}

.call-return-option span {
    display: block;
    padding: 8px 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    text-align: center;
    font-size: 13px;
    color: var(--ink-muted);
    transition: all 0.15s;
}

.call-return-option:hover span {
    border-color: var(--accent);
    color: var(--ink);
}

.call-return-option input:checked + span {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    font-weight: 600;
}

.call-return-notes {
    width: 100%;
    background: var(--bg-elevated);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 8px 12px;
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--ink);
    margin-bottom: 10px;
    resize: vertical;
}

.call-return-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.cancel-action-btn {
    color: var(--ink-subtle) !important;
    font-size: 13px !important;
}

.cancel-action-btn:hover {
    color: var(--danger) !important;
}

/* ===== Follow-up datum-rad ===== */
.followup-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    flex-wrap: wrap;
}

.followup-toggle {
    cursor: pointer;
    user-select: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.followup-toggle input {
    display: none;
}

.followup-toggle span {
    display: inline-block;
    padding: 5px 11px;
    background: var(--bg-sunken);
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 12px;
    color: var(--ink-muted);
    transition: all 0.15s;
}

.followup-toggle:hover span {
    color: var(--ink);
}

.followup-toggle input:checked + span {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 600;
}

.followup-datetime {
    font-family: var(--font-body);
    font-size: 13px;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--bg-elevated);
    color: var(--ink);
    transition: opacity 0.15s;
}

.followup-datetime:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ===== Min dag: uppföljnings-aktivitet (skiljer från vanlig task) ===== */
.mydag-item-followup {
    border-left: 3px solid #b8923a;
}

.mydag-item-followup .mydag-item-title::before {
    content: "📅 ";
}

/* tasks.php: visuell markering för uppföljningar */
.task-row-followup {
    background: rgba(184, 146, 58, 0.04);
    border-left: 3px solid #b8923a;
}

/* ===== Läsläge: göm allt som skulle skapa/ändra data ===== */
/* Stora form-kort som leder till skapande */
body[data-readonly="1"] .quick-note-form,
body[data-readonly="1"] .comm-actions,
body[data-readonly="1"] .add-task-details,
body[data-readonly="1"] .call-return-prompt {
    display: none !important;
}

/* Funnel: korten kan visas men inte dras */
body[data-readonly="1"] .funnel-card {
    cursor: default !important;
}

/* Submit-knappar inom POST-formulär — alla utgrå, kan inte klickas */
body[data-readonly="1"] form[method="post"] button[type="submit"],
body[data-readonly="1"] form[method="post"] input[type="submit"] {
    opacity: 0.4;
    pointer-events: none;
}

/* Checkboxar/toggle som postar — också utgrå */
body[data-readonly="1"] .mydag-checkbox,
body[data-readonly="1"] .followup-toggle input,
body[data-readonly="1"] .quick-note-checkbox {
    opacity: 0.4;
    pointer-events: none;
}

/* ===== Läsläge-banner ===== */
.readonly-banner {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 18px;
    background: linear-gradient(90deg, #fef3c7, #fde68a);
    border: 1px solid #b8923a;
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(184, 146, 58, 0.15);
}

.readonly-banner-icon {
    font-size: 22px;
    flex-shrink: 0;
}

.readonly-banner-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.readonly-banner-text strong {
    font-size: 14px;
    color: #78350f;
    letter-spacing: 0.02em;
}

.readonly-banner-text span {
    font-size: 13px;
    color: #92400e;
}

/* ===== Users page ===== */
.user-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--line);
    flex-wrap: wrap;
}

.user-row:last-child {
    border-bottom: none;
}

.user-info {
    flex: 1;
    min-width: 200px;
}

.user-name {
    font-weight: 600;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-email {
    font-size: 13px;
    color: var(--ink-subtle);
    font-family: var(--font-mono);
    margin-top: 2px;
}

.user-badge {
    font-size: 10px;
    padding: 2px 8px;
    background: var(--bg-sunken);
    border-radius: 999px;
    color: var(--ink-subtle);
    font-weight: 600;
    letter-spacing: 0.02em;
    font-family: var(--font-body);
}

.user-badge-main {
    background: var(--accent-soft);
    color: var(--accent);
}

.user-role-form {
    margin: 0;
    display: flex;
    gap: 6px;
    align-items: center;
}

.user-role-form select {
    font-size: 13px;
    padding: 6px 28px 6px 10px;
    min-width: 120px;
}

.user-role-readonly {
    font-size: 13px;
    color: var(--ink-subtle);
    padding: 6px 12px;
    background: var(--bg-sunken);
    border-radius: var(--radius);
}

.user-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.user-pwreset summary {
    cursor: pointer;
    list-style: none;
    font-size: 12px;
    color: var(--ink-subtle);
    padding: 6px 10px;
    background: var(--bg-sunken);
    border-radius: var(--radius);
    user-select: none;
}

.user-pwreset summary::-webkit-details-marker {
    display: none;
}

.user-pwreset summary:hover {
    color: var(--ink);
}

.user-pwreset[open] summary {
    background: var(--accent-soft);
    color: var(--accent);
}

.user-pwreset-form {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    padding: 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    position: absolute;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.user-pwreset-form input[type="text"] {
    width: 180px;
    font-size: 13px;
    padding: 6px 10px;
}

.user-delete-btn {
    color: var(--danger) !important;
    font-size: 12px !important;
}

@media (max-width: 600px) {
    .user-row {
        flex-direction: column;
        align-items: stretch;
    }
    .user-pwreset-form {
        position: static;
        flex-wrap: wrap;
    }
}

/* ===== Säkerhetsöversikt på users.php ===== */
.security-details {
    margin-bottom: 24px;
}

.security-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--ink);
    font-size: 14px;
    font-weight: 500;
    list-style: none;
    user-select: none;
    transition: all 0.15s;
}

.security-summary::-webkit-details-marker {
    display: none;
}

.security-summary:hover {
    border-color: var(--ink-subtle);
}

.security-summary-arrow {
    font-family: var(--font-mono);
    color: var(--ink-subtle);
    transition: transform 0.2s;
    flex-shrink: 0;
}

.security-details[open] .security-summary {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.security-details[open] .security-summary-arrow {
    transform: rotate(90deg);
}

.security-failed-count {
    display: inline-block;
    margin-left: 12px;
    padding: 3px 9px;
    background: #fee;
    color: var(--danger);
    font-size: 11px;
    border-radius: 999px;
    font-weight: 600;
    font-family: var(--font-mono);
}

.security-content {
    padding: 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--line);
    border-top: none;
    border-bottom-left-radius: var(--radius);
    border-bottom-right-radius: var(--radius);
}

.security-empty {
    color: var(--ink-subtle);
    font-style: italic;
    margin: 0;
}

.security-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.security-table th {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.05em;
    color: var(--ink-subtle);
    font-weight: 600;
    text-transform: uppercase;
}

.security-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
    color: var(--ink);
}

.security-table tr:last-child td {
    border-bottom: none;
}

.security-row-fail {
    background: rgba(220, 38, 38, 0.04);
}

.security-time {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--ink-subtle);
    white-space: nowrap;
}

.security-badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}

.security-ok {
    background: var(--accent-soft);
    color: var(--accent);
}

.security-fail {
    background: #fee;
    color: var(--danger);
}

.security-note {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed var(--line);
    font-size: 12px;
    color: var(--ink-subtle);
    font-style: italic;
}

/* ============================================================
   REPORT.PHP — Månadsrapport
   ============================================================ */
.report-doc {
    background: white;
    padding: 36px 40px;
    margin: 0 0 40px 0;
    border-radius: var(--radius-lg);
    border: 1px solid var(--line);
    color: #1a1a1a;
}

.report-header-block {
    border-bottom: 2px solid #1a2942;
    padding-bottom: 12px;
    margin-bottom: 24px;
}

.report-title {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 600;
    color: #1a2942;
    letter-spacing: -0.01em;
}

.report-subtitle {
    font-size: 13px;
    color: var(--ink-subtle);
    margin-top: 4px;
}

.report-section-title {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 600;
    color: #1a2942;
    margin: 32px 0 14px 0;
    padding: 0;
    border: none;
    page-break-after: avoid;
}

.report-section-title:first-of-type {
    margin-top: 8px;
}

.report-section-label {
    color: #b8923a;
    font-weight: 700;
    margin-right: 6px;
}

/* SUMMARY GRID */
.report-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 16px;
}

.report-summary-card {
    background: linear-gradient(135deg, #f4f7fb 0%, #e8f0f9 100%);
    border: 1px solid #d6dee8;
    border-left: 3px solid #1a2942;
    border-radius: var(--radius);
    padding: 14px 16px;
}

.report-summary-label {
    font-size: 11px;
    color: var(--ink-subtle);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    margin-bottom: 6px;
}

.report-summary-value {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 700;
    color: #1a2942;
    line-height: 1;
}

.report-summary-unit {
    font-size: 14px;
    color: var(--ink-subtle);
    font-weight: 500;
}

.report-summary-meta {
    font-size: 11px;
    color: var(--ink-subtle);
    margin-top: 4px;
    font-style: italic;
}

/* COMMENT BLOCKS */
.report-comment-block {
    margin: 14px 0 24px 0;
    background: #fffdf6;
    border: 1px dashed #d4b87a;
    border-radius: var(--radius);
    padding: 12px 16px;
}

.report-comment-label {
    font-size: 10px;
    color: #b8923a;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    margin-bottom: 6px;
}

.report-comment-content {
    min-height: 32px;
    padding: 6px 0;
    font-size: 13px;
    color: #1a1a1a;
    line-height: 1.55;
    outline: none;
    cursor: text;
}

.report-comment-content:focus {
    outline: 2px solid #b8923a;
    outline-offset: 4px;
    border-radius: 4px;
}

.report-placeholder {
    color: #b8923a;
    opacity: 0.5;
    font-style: italic;
}

/* PIPELINE TABLE */
.report-pipeline,
.report-shortlist,
.report-stalled {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    margin-bottom: 8px;
    background: white;
}

.report-pipeline th,
.report-shortlist th,
.report-stalled th {
    background: #1a2942;
    color: white;
    padding: 8px 10px;
    text-align: center;
    font-weight: 600;
    font-size: 11px;
    border: 1px solid #1a2942;
}

.report-status-cell {
    text-align: left !important;
    width: 160px;
}

.report-pipeline-phase-row .report-phase-header {
    background: #1a2942;
    padding: 10px 14px !important;
    font-size: 12px;
    text-align: left !important;
}

.report-pipeline-stage-row th {
    background: white !important;
    color: #1a2942;
    font-weight: 600;
    border: none;
    border-bottom: 2px solid #1a2942;
    font-size: 11px;
    padding: 8px 6px;
}

.report-stage-header { text-align: center !important; }

.report-pipeline td {
    padding: 10px 8px;
    border: 1px solid #d6dee8;
    text-align: center;
    color: #1a1a1a;
}

.report-row-label {
    text-align: left !important;
    font-weight: 600;
    background: white !important;
    width: 160px;
    color: #1a1a1a !important;
}

.report-row-ft td:not(.report-row-label) { background: #e8f0f9; }
.report-row-jv td:not(.report-row-label) { background: #d6e3f0; }
.report-row-sum td { background: #c4d4e3 !important; font-weight: 600; }

/* EVENTS GRID */
.report-events-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 8px;
}

.report-events-block {
    background: white;
    border: 1px solid #d6dee8;
    border-radius: var(--radius);
    overflow: hidden;
    page-break-inside: avoid;
}

.report-events-header {
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 600;
    color: white;
    letter-spacing: 0.02em;
}

.report-events-won { background: #2d4a2b; }
.report-events-advanced { background: #1a2942; }
.report-events-new { background: #b8923a; }
.report-events-lost { background: #92400e; }

.report-events-list {
    list-style: none;
    margin: 0;
    padding: 10px 14px;
    font-size: 12px;
    line-height: 1.5;
}

.report-events-list li {
    padding: 6px 0;
    border-bottom: 1px dashed #eee;
}

.report-events-list li:last-child { border-bottom: none; }

.report-events-meta {
    font-size: 11px;
    color: var(--ink-subtle);
    font-style: italic;
}

.report-events-empty {
    padding: 14px;
    font-size: 12px;
    color: var(--ink-subtle);
    font-style: italic;
    text-align: center;
}

.report-events-more {
    padding: 8px 14px;
    font-size: 11px;
    color: var(--ink-subtle);
    background: #fafafa;
    text-align: center;
    border-top: 1px solid #eee;
}

/* SHORTLIST */
.report-shortlist td,
.report-stalled td {
    padding: 12px 12px;
    border: 1px solid #d6dee8;
    vertical-align: top;
    line-height: 1.5;
    background: white;
}

.report-shortlist tbody tr:nth-child(odd) td:not(.report-row-label),
.report-stalled tbody tr:nth-child(odd) td {
    background: #f4f7fb;
}

.report-shortlist-tag {
    display: inline-block;
    color: white;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.report-tag-jv { background: #1a2942; }
.report-tag-ft { background: #2d4a2b; }

.report-shortlist-members {
    font-size: 11px;
    color: var(--ink-subtle);
    margin-top: 4px;
}

.report-comment-cell {
    font-size: 11px;
    color: #555;
    max-width: 240px;
}

/* STALLED */
.report-stalled-critical td {
    background: #fef9f9 !important;
}

.report-stalled-critical td:first-child {
    border-left: 3px solid var(--danger);
}

.report-stalled-days {
    font-weight: 600;
    color: var(--danger);
    text-align: center;
    width: 80px;
}

.report-empty {
    color: var(--ink-subtle);
    font-style: italic;
    padding: 20px;
    background: var(--bg-sunken);
    border-radius: var(--radius);
    text-align: center;
}

.report-footer {
    margin-top: 32px;
    padding-top: 14px;
    border-top: 1px solid #d6dee8;
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #888;
}

/* PRINT */
@media print {
    .sidebar, .sidebar-backdrop, .bottom-nav, .mobile-topbar,
    .page-header, .readonly-banner, .alert,
    nav, aside, header, footer:not(.report-footer),
    .report-comment-block .report-comment-label {
        display: none !important;
    }
    
    .app { display: block !important; grid-template-columns: 1fr !important; }
    .main { padding: 0 !important; max-width: none !important; margin: 0 !important; }
    
    body { background: white !important; margin: 0; padding: 0; }
    
    .report-doc {
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    .report-comment-block {
        background: transparent !important;
        border: none !important;
        border-top: 1px solid #ddd !important;
        border-radius: 0 !important;
        padding: 8px 0 !important;
        page-break-inside: avoid;
    }
    
    .report-comment-block:empty,
    .report-comment-content.is-empty {
        display: none !important;
    }
    
    .report-section-title { page-break-after: avoid; }
    .report-pipeline, .report-shortlist, .report-stalled, .report-events-block, .report-summary-card { page-break-inside: avoid; }
    
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    @page { size: A4 landscape; margin: 1.2cm; }
}

@media (max-width: 900px) {
    .report-doc { padding: 18px 14px; }
    .report-summary-grid, .report-events-grid { grid-template-columns: 1fr 1fr; }
    .report-pipeline, .report-shortlist, .report-stalled { font-size: 10px; }
    .report-pipeline th, .report-pipeline td,
    .report-shortlist th, .report-shortlist td,
    .report-stalled th, .report-stalled td { padding: 6px 4px; }
    .report-controls { width: 100%; flex-wrap: wrap; }
}

.mydag-item-overdue {
    border-left: 3px solid var(--danger);
    background: #fef9f9;
}

.mydag-item-overdue .mydag-item-meta {
    color: var(--danger);
    font-weight: 500;
}

.mydag-item-cadence {
    border-left: 3px solid #b8923a;
}

/* Mobil-anpassningar */
@media (max-width: 900px) {
    .dashboard-tabs {
        width: 100%;
    }
    .dashboard-tab {
        flex: 1;
        text-align: center;
        padding: 10px 8px;
    }
    .mydag-section-header h3 {
        font-size: 16px;
    }
}

.cal-monthnav-arrow {
    padding: 8px 12px;
    font-size: 16px;
    min-width: 40px;
}

.cal-monthnav-current {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 500;
    padding: 0 16px;
    text-align: center;
    flex: 1;
    min-width: 140px;
}

.cal-monthnav-today {
    margin-left: 8px;
}

/* ============================================================
   MOBILE - skärmar under 900px
   ============================================================ */

/* ============================================================
   MOBIL (≤900px) — Komplett omarbetad UX för iPhone Safari
   ============================================================ */

@media (max-width: 900px) {
    /* iOS safe areas */
    :root {
        --safe-top: env(safe-area-inset-top, 0);
        --safe-bottom: env(safe-area-inset-bottom, 0);
    }

    html, body {
        -webkit-tap-highlight-color: transparent;
        -webkit-text-size-adjust: 100%;
        overscroll-behavior-y: contain;
        overflow-x: hidden;
        max-width: 100vw;
    }

    body {
        font-size: 15px;
    }

    /* Layout */
    .app {
        display: block;
        overflow-x: hidden;
        max-width: 100vw;
    }

    .main {
        overflow-x: hidden;
        max-width: 100vw;
    }

    /* ===== Topbar (hamburger + titel) ===== */
    .mobile-topbar {
        position: sticky;
        top: 0;
        z-index: 50;
        background: var(--bg);
        border-bottom: 1px solid var(--line);
        padding: calc(env(safe-area-inset-top, 0) + 8px) 16px 8px;
        display: flex;
        align-items: center;
        gap: 12px;
        min-height: 52px;
    }

    .mobile-topbar-title {
        font-family: var(--font-display);
        font-size: 20px;
        font-style: italic;
        flex: 1;
    }

    .hamburger {
        background: none;
        border: none;
        width: 40px;
        height: 40px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 4px;
        cursor: pointer;
        padding: 0;
    }

    .hamburger span {
        display: block;
        width: 20px;
        height: 2px;
        background: var(--ink);
        border-radius: 2px;
        transition: all 0.2s;
    }

    /* ===== Sidomeny som drawer ===== */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 280px;
        height: 100vh;
        height: 100dvh;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        padding-top: calc(env(safe-area-inset-top, 0) + 20px);
        padding-bottom: calc(env(safe-area-inset-bottom, 0) + 20px);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.3);
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 99;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s;
    }

    .sidebar-backdrop.open {
        opacity: 1;
        pointer-events: auto;
    }

    /* ===== Main content ===== */
    .main {
        padding: 14px;
        padding-bottom: calc(env(safe-area-inset-bottom, 0) + 80px);
        max-width: 100%;
    }

    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        margin-bottom: 18px;
        padding-bottom: 14px;
    }

    .page-header h1 {
        font-size: 26px;
        line-height: 1.2;
    }

    .page-header .subtitle {
        font-size: 10px;
    }

    /* Header-knappar tar full bredd */
    .page-header .flex,
    .page-header > form {
        width: 100%;
    }

    .page-header .btn {
        width: 100%;
        min-height: 46px;
    }

    .page-header .flex {
        flex-wrap: wrap;
        gap: 8px;
    }

    .page-header .flex .btn {
        flex: 1;
    }

    /* ===== Bottom Nav Bar ===== */
    .bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--bg-elevated);
        border-top: 1px solid var(--line);
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        padding-bottom: env(safe-area-inset-bottom, 0);
        z-index: 50;
        box-shadow: 0 -1px 10px rgba(0, 0, 0, 0.04);
    }

    .bottom-nav a {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        padding: 10px 2px;
        color: var(--ink-subtle);
        font-size: 11px;
        font-weight: 600;
        letter-spacing: 0.01em;
        text-decoration: none;
        min-height: 56px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .bottom-nav a svg {
        width: 22px;
        height: 22px;
    }

    .bottom-nav a.active {
        color: var(--ink);
    }

    .bottom-nav a.active svg {
        stroke: var(--accent);
    }

    /* ===== Stats grid (mobil) ===== */
    .main .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px;
        margin-bottom: 18px;
    }

    .stat {
        padding: 14px 16px;
    }

    .stat-value {
        font-size: 26px;
    }

    /* ===== Dashboard split layout ===== */
    .main div[style*="grid-template-columns: 1fr 380px"],
    .main div[style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
        gap: 14px !important;
    }

    .split-layout {
        grid-template-columns: 1fr !important;
        gap: 14px;
    }

    /* Inline-grids i kort (TB-portfölj etc.) */
    .card-body div[style*="grid-template-columns"] {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 14px !important;
    }

    /* ===== Cards ===== */
    .card {
        border-radius: 10px;
        margin-bottom: 14px;
    }

    .card-body {
        padding: 14px;
    }

    .card-body.tight {
        padding: 0;
    }

    .card-header {
        padding: 12px 14px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .card-header h3 {
        font-size: 15px;
    }

    /* ===== LISTOR: Kompakta kort på mobil ===== */
    .card > table {
        display: block;
    }

    .card > table thead {
        display: none;
    }

    .card > table tbody {
        display: block;
    }

    /* En rad = en kompakt kortlist-rad */
    .card > table tr {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px 14px;
        border-bottom: 1px solid var(--line);
        background: var(--bg-elevated);
        position: relative;
        min-height: 64px;
    }

    .card > table tr:active {
        background: var(--bg-sunken);
    }

    .card > table tr.clickable {
        cursor: pointer;
    }

    /* Avatar */
    .card > table tr::before {
        content: attr(data-initials);
        width: 38px;
        height: 38px;
        background: var(--accent-soft);
        color: var(--accent);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-family: var(--font-display);
        font-size: 13px;
        font-weight: 600;
        text-transform: uppercase;
        flex-shrink: 0;
    }

    /* DÖLJ ALLA TD som default — bara namn + senast visas */
    .card > table td {
        display: none;
    }

    /* Första td (namn) — synlig som primär text */
    .card > table td:nth-child(1) {
        display: block;
        flex: 1;
        min-width: 0;
        font-size: 15px;
        color: var(--ink);
        font-weight: 600;
        line-height: 1.3;
        padding: 0;
        border: none;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Sista td (senast aktivt) — som litet meta i högra sidan */
    .card > table tr td:last-child:not(:first-child) {
        display: block;
        flex: 0 0 auto;
        font-size: 11px;
        color: var(--ink-subtle);
        font-family: var(--font-mono);
        white-space: nowrap;
        padding: 0;
        border: none;
    }

    /* "X RESULTAT"-rubriken */
    .card > div[style*="font-family: var(--font-mono)"] {
        padding: 10px 14px !important;
        font-size: 11px !important;
    }

    /* Sortering på mobil — dropdown istället för klickbara rubriker */
    .mobile-sort-wrap {
        display: flex !important;
        gap: 8px;
        padding: 10px 14px;
        background: var(--bg-sunken);
        border-bottom: 1px solid var(--line);
        align-items: center;
    }

    .mobile-sort-wrap label {
        font-size: 11px;
        color: var(--ink-subtle);
        font-weight: 600;
        letter-spacing: 0.05em;
        text-transform: uppercase;
    }

    .mobile-sort-wrap select {
        flex: 1;
        font-size: 14px;
        padding: 8px 12px;
    }

    /* ===== Sökformulär på listsidor — vertikal stack ===== */
    .card form[method="get"] {
        flex-wrap: wrap !important;
        padding: 12px !important;
        gap: 8px !important;
    }

    .card form[method="get"] input[type="text"],
    .card form[method="get"] input[type="search"] {
        flex: 1 1 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        margin: 0 !important;
        order: 1;
    }

    .card form[method="get"] select,
    .card form[method="get"] input[type="date"] {
        flex: 1 1 calc(50% - 4px) !important;
        min-width: 0 !important;
        order: 2;
    }

    .card form[method="get"] button {
        flex: 0 0 auto !important;
        min-width: 90px !important;
        width: auto !important;
        order: 3;
    }

    .card form[method="get"] a.btn {
        flex: 0 0 auto !important;
        width: auto !important;
        order: 4;
    }

    /* Aktiv/Passiv-flikar */
    .tabs[style*="margin-bottom: 20px"] {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .tabs[style*="margin-bottom: 20px"] .tab {
        flex-shrink: 0;
        font-size: 13px;
        padding: 10px 14px;
    }

    /* ===== DETAIL: Ordning på mobil ===== */
    .detail-grid {
        grid-template-columns: 1fr !important;
        gap: 14px;
    }

    /* Status-rutan flyttas överst för fokus/aktiva personer */
    .detail-grid.status-first-mobile {
        display: flex;
        flex-direction: column;
    }

    .detail-grid.status-first-mobile > div:nth-child(2) {
        order: -1;
    }

    .detail-header {
        padding: 18px;
    }

    .detail-header h1 {
        font-size: 22px;
        line-height: 1.25;
    }

    .detail-meta {
        flex-direction: column;
        gap: 8px;
        margin-top: 12px;
    }

    .detail-meta-item {
        flex: none;
    }

    /* ===== Tabs på mobil — segmented control + Mer-meny ===== */
    .tabs {
        display: flex !important;
        gap: 4px;
        background: var(--bg-sunken);
        padding: 4px;
        border-radius: 10px;
        border: 1px solid var(--line);
        margin: 0 0 18px 0;
        position: relative;
    }

    /* Alla tabs blir lika breda i segmented control */
    .tab {
        flex: 1 1 0;
        text-align: center;
        padding: 10px 8px;
        font-size: 13px;
        font-weight: 600;
        white-space: nowrap;
        border-radius: 7px;
        background: transparent;
        color: var(--ink-muted);
        border-bottom: none !important;
        overflow: hidden;
        text-overflow: ellipsis;
        min-width: 0;
    }

    .tab.active {
        background: var(--bg-elevated);
        color: var(--ink);
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
        border-bottom: none !important;
    }

    /* Sekundära tabs gömda i segmented control — endast i Mer-dropdown */
    .tab-secondary {
        display: none !important;
    }

    /* Mer-knappen */
    .tab-more {
        flex: 0 0 auto;
        min-width: 64px;
        font-weight: 600;
        color: var(--ink-muted);
    }

    .tab-more.active {
        background: var(--accent);
        color: #fff;
    }

    /* Dropdown för Mer-knappen */
    .tab-more-dropdown {
        position: absolute;
        right: 0;
        top: calc(100% + 6px);
        background: var(--bg-elevated);
        border: 1px solid var(--line);
        border-radius: 10px;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
        z-index: 50;
        min-width: 200px;
        overflow: hidden;
    }

    .tab-more-dropdown .tab {
        display: block !important;
        flex: none;
        padding: 14px 16px;
        border-bottom: 1px solid var(--line);
        border-radius: 0;
        background: transparent !important;
        box-shadow: none !important;
        text-align: left;
        font-size: 14px;
        color: var(--ink);
    }

    .tab-more-dropdown .tab:last-child {
        border-bottom: none;
    }

    .tab-more-dropdown .tab.active {
        background: var(--accent-soft) !important;
        color: var(--accent) !important;
    }

    .tab-more-dropdown .tab:active {
        background: var(--bg-sunken) !important;
    }

    /* ===== Snabblogg-knappar ===== */
    .card div[style*="display: flex"][style*="gap: 8px"][style*="align-items: center"][style*="flex-wrap: wrap"] {
        padding: 14px !important;
        gap: 8px !important;
    }

    .card div[style*="display: flex"][style*="flex-wrap: wrap"] form button {
        min-height: 44px !important;
        padding: 10px 14px !important;
        font-size: 14px !important;
        font-weight: 500;
    }

    /* ===== Formulär ===== */
    .form-row, .form-row-3 {
        grid-template-columns: 1fr;
        gap: 0;
    }

    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    input[type="url"],
    input[type="number"],
    input[type="date"],
    input[type="datetime-local"],
    select,
    textarea {
        padding: 13px 14px;
        font-size: 16px; /* 16px+ förhindrar iOS auto-zoom */
        border-radius: 10px;
        width: 100%;
        box-sizing: border-box;
    }

    .btn {
        padding: 13px 20px;
        font-size: 15px;
        border-radius: 10px;
        min-height: 46px;
    }

    .btn-sm {
        padding: 8px 14px;
        font-size: 13px;
        min-height: 36px;
    }

    /* Status-knappar i timeline (markera genomförd / avboka / radera) */
    .timeline div[style*="display: flex"][style*="gap: 6px"][style*="flex-wrap: wrap"] {
        gap: 8px !important;
    }

    .timeline div[style*="display: flex"][style*="gap: 6px"][style*="flex-wrap: wrap"] button {
        min-height: 38px !important;
        padding: 8px 14px !important;
        font-size: 12px !important;
    }

    /* ===== Funnel/Kanban på mobil ===== */
    .funnel {
        display: block;
        padding-bottom: 0;
    }

    .funnel-col {
        margin-bottom: 10px;
        min-width: 0;
        background: var(--bg-elevated);
        border: 1px solid var(--line);
        border-radius: 10px;
        overflow: hidden;
    }

    /* Accordion-läge på mobil */
    .funnel-col.mobile-collapsible .funnel-col-header {
        position: relative;
        padding: 14px 44px 14px 14px;
        margin: 0;
        background: var(--bg-sunken);
    }

    .funnel-col.mobile-collapsible .funnel-col-header::after {
        content: '▾';
        position: absolute;
        right: 16px;
        top: 50%;
        transform: translateY(-50%);
        font-size: 14px;
        color: var(--ink-subtle);
        transition: transform 0.2s;
    }

    .funnel-col.mobile-collapsible.expanded .funnel-col-header::after {
        transform: translateY(-50%) rotate(180deg);
    }

    .funnel-col.mobile-collapsible .funnel-cards {
        display: none;
        padding: 8px;
    }

    .funnel-col.mobile-collapsible.expanded .funnel-cards {
        display: block;
    }

    .funnel-card {
        cursor: pointer;
        padding: 14px 16px;
        margin-bottom: 8px;
    }

    .funnel-card-title {
        font-size: 15px;
    }

    .funnel-card-move {
        display: flex;
        gap: 6px;
        margin-top: 10px;
        padding-top: 10px;
        border-top: 1px dashed var(--line);
    }

    .funnel-card-move button {
        background: var(--bg-sunken);
        border: 1px solid var(--line);
        color: var(--ink-muted);
        padding: 8px 12px;
        border-radius: 6px;
        font-size: 11px;
        font-family: var(--font-mono);
        cursor: pointer;
        min-height: 34px;
    }

    /* ===== Timeline ===== */
    .timeline-head {
        flex-direction: column;
        gap: 4px;
        align-items: flex-start;
    }

    .timeline-time {
        font-size: 11px;
    }

    .timeline::before {
        left: 15px;
    }

    .timeline-dot {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    /* ===== FAB ===== */
    .fab {
        position: fixed;
        right: 16px;
        bottom: calc(env(safe-area-inset-bottom, 0) + 76px);
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: var(--ink);
        color: white;
        border: none;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 24px;
        z-index: 40;
        cursor: pointer;
    }

    .fab:active {
        transform: scale(0.95);
    }

    /* ===== Login ===== */
    .login-card {
        padding: 30px 24px;
        margin: 16px;
        max-width: 100%;
    }

    .login-wrap {
        padding-top: env(safe-area-inset-top, 0);
        padding-bottom: env(safe-area-inset-bottom, 0);
    }

    /* ===== Alerts ===== */
    .alert {
        padding: 12px 14px;
        font-size: 13px;
    }

    /* ===== Stage-pills ===== */
    .stage-pill {
        display: inline-flex;
        white-space: nowrap;
    }

    /* ===== Dölj desktop-only element ===== */
    .desktop-only {
        display: none !important;
    }

    /* ===== Kalender: Månadsnavigering på mobil ===== */
    .cal-monthnav {
        display: flex !important;
        width: 100%;
        gap: 4px;
    }

    .cal-monthnav-arrow {
        flex: 0 0 auto;
        padding: 10px 14px !important;
        min-width: 44px !important;
        min-height: 44px;
    }

    .cal-monthnav-current {
        flex: 1 !important;
        font-size: 17px !important;
        padding: 0 !important;
        min-width: 0 !important;
    }

    .cal-monthnav-today {
        flex: 0 0 auto;
        padding: 10px 14px !important;
        min-height: 44px;
        margin-left: 4px !important;
    }

    /* ===== Kalender: Agenda-vy på mobil ===== */
    .cal-agenda {
        display: block;
    }

    .agenda-day {
        background: var(--bg-elevated);
        border: 1px solid var(--line);
        border-radius: 10px;
        margin-bottom: 12px;
        overflow: hidden;
    }

    .agenda-day.today {
        border-color: var(--accent);
        border-width: 2px;
    }

    .agenda-day.past {
        opacity: 0.7;
    }

    .agenda-day-header {
        display: flex !important;
        align-items: center;
        gap: 12px;
        padding: 10px 14px;
        background: var(--bg-sunken);
        border-bottom: 1px solid var(--line);
    }

    .agenda-day-number {
        font-family: var(--font-display);
        font-size: 22px;
        font-weight: 500;
        line-height: 1;
        color: var(--ink);
        min-width: 32px;
        text-align: center;
        flex-shrink: 0;
    }

    .agenda-day.today .agenda-day-number {
        color: var(--accent);
    }

    .agenda-day-meta {
        flex: 1;
        line-height: 1.2;
        min-width: 0;
    }

    .agenda-day-name {
        font-size: 13px;
        font-weight: 600;
        color: var(--ink);
    }

    .agenda-day-month {
        font-size: 11px;
        color: var(--ink-subtle);
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }

    .agenda-day-badge {
        background: var(--accent);
        color: #fff;
        padding: 3px 8px;
        border-radius: 4px;
        font-size: 10px;
        font-weight: 600;
        letter-spacing: 0.05em;
        flex-shrink: 0;
    }

    .agenda-events {
        display: block;
    }

    .agenda-event {
        display: flex !important;
        align-items: flex-start;
        gap: 12px;
        padding: 12px 14px;
        border-bottom: 1px solid var(--line);
        text-decoration: none !important;
        color: inherit;
        border-left: 3px solid var(--gold);
    }

    .agenda-event:last-child {
        border-bottom: none;
    }

    .agenda-event:active {
        background: var(--bg-sunken);
    }

    .agenda-event.completed {
        border-left-color: var(--accent);
    }

    .agenda-event.cancelled {
        border-left-color: var(--ink-subtle);
        opacity: 0.6;
    }

    .agenda-event.task {
        border-left-color: var(--rust);
    }

    .agenda-event-time {
        font-family: var(--font-mono);
        font-size: 12px;
        font-weight: 600;
        color: var(--ink-muted);
        min-width: 42px;
        padding-top: 2px;
        flex-shrink: 0;
    }

    .agenda-event-body {
        flex: 1;
        min-width: 0;
    }

    .agenda-event-title {
        font-size: 14px;
        font-weight: 600;
        color: var(--ink);
        line-height: 1.3;
    }

    .agenda-event.cancelled .agenda-event-title {
        text-decoration: line-through;
    }

    .agenda-event-sub {
        font-size: 12px;
        color: var(--ink-subtle);
        margin-top: 3px;
    }

    /* ===== Kalender på mobil ===== */
    .cal-month-grid {
        font-size: 11px;
    }

    .cal-day {
        min-height: 70px !important;
        padding: 4px !important;
    }

    .cal-day-number {
        font-size: 11px !important;
    }

    .cal-event {
        font-size: 9px !important;
        padding: 1px 3px !important;
    }

    .cal-weekday {
        padding: 6px 2px !important;
        font-size: 9px !important;
    }

    /* ===== Importsidans tabeller — håll dem läsbara ===== */
    .main form .card table th[style*="min-width"] {
        min-width: auto !important;
    }
}

/* ===== Desktop-only elements ===== */
@media (min-width: 901px) {
    .mobile-topbar,
    .bottom-nav,
    .sidebar-backdrop,
    .hamburger,
    .mobile-topbar-title,
    .funnel-card-move,
    .fab,
    .mobile-sort-wrap,
    .mobile-only {
        display: none !important;
    }
}

/* Touch-feedback */
@media (hover: none) {
    .funnel-card:active,
    .btn:active,
    .card.clickable:active,
    table tr.clickable:active {
        opacity: 0.7;
    }
}

/* ============================================================
   STAGE-TRIGGER MODAL — för konstellation/partnerbolag-val
   ============================================================ */
.stage-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.stage-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 25, 45, 0.55);
    backdrop-filter: blur(2px);
    cursor: pointer;
}

.stage-modal-content {
    position: relative;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    max-width: 560px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    padding: 28px 32px 24px;
}

.stage-modal-close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: transparent;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: var(--ink-subtle);
    cursor: pointer;
    padding: 4px 10px;
    border-radius: var(--radius);
    transition: all 0.15s;
}

.stage-modal-close:hover {
    background: var(--bg-sunken);
    color: var(--ink);
}

.stage-modal-title {
    font-family: var(--font-display);
    font-size: 19px;
    font-weight: 600;
    color: var(--ink);
    margin: 0 0 10px;
    padding-right: 30px;
}

.stage-modal-intro {
    font-size: 13px;
    color: var(--ink-subtle);
    margin: 0 0 20px;
}

.stage-modal-section-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-subtle);
    font-weight: 600;
    margin: 12px 0 8px;
}

.stage-modal-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 8px;
    max-height: 300px;
    overflow-y: auto;
}

.stage-modal-option {
    text-align: left;
    background: var(--bg-elevated);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 10px 14px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s;
}

.stage-modal-option:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
    transform: translateX(2px);
}

.stage-modal-option-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--ink);
}

.stage-modal-option-meta {
    font-size: 11px;
    color: var(--ink-subtle);
    margin-top: 3px;
}

.stage-modal-divider {
    text-align: center;
    color: var(--ink-subtle);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin: 16px 0;
    position: relative;
}

.stage-modal-divider::before,
.stage-modal-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: calc(50% - 30px);
    height: 1px;
    background: var(--line);
}

.stage-modal-divider::before { left: 0; }
.stage-modal-divider::after { right: 0; }

.stage-modal-create {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.stage-modal-create input[type="text"] {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 14px;
}

.stage-modal-create button {
    padding: 10px 16px;
    font-size: 14px;
}

.stage-modal-search {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 14px;
    margin-bottom: 10px;
}

.stage-modal-loading,
.stage-modal-success,
.stage-modal-error {
    padding: 24px;
    text-align: center;
    border-radius: var(--radius);
    font-size: 14px;
    line-height: 1.5;
}

.stage-modal-loading {
    color: var(--ink-subtle);
    font-style: italic;
}

.stage-modal-success {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 500;
}

.stage-modal-error {
    background: #fee;
    color: var(--danger);
}

/* Toast */
.stage-toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--ink);
    color: white;
    padding: 12px 22px;
    border-radius: var(--radius);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
    z-index: 1100;
    font-size: 14px;
    opacity: 0;
    transition: all 0.3s;
    max-width: calc(100vw - 40px);
}

.stage-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

@media (max-width: 600px) {
    .stage-modal-content {
        padding: 22px 18px 18px;
        max-height: 90vh;
    }
    .stage-modal-title {
        font-size: 17px;
    }
}

/* ============================================================
   ALLIANSBOLAG-BADGE — markerar Hub & Spoke partnerbolag
   ============================================================ */
.alliance-badge {
    display: inline-block;
    margin-left: 10px;
    padding: 4px 12px;
    background: linear-gradient(135deg, #2d4a2b 0%, #4a6b46 100%);
    color: white;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    border-radius: 999px;
    vertical-align: middle;
    box-shadow: 0 1px 2px rgba(45, 74, 43, 0.2);
}

.alliance-slussade {
    margin-top: 14px;
    padding: 10px 14px;
    background: var(--accent-soft);
    border: 1px solid rgba(45, 74, 43, 0.15);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.alliance-slussade-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent);
    font-weight: 600;
}

.alliance-slussade-pill {
    display: inline-block;
    background: white;
    color: var(--accent);
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid rgba(45, 74, 43, 0.15);
}

.form-help {
    font-size: 12px;
    color: var(--ink-subtle);
    margin-top: 4px;
    line-height: 1.4;
    font-style: italic;
}

/* ============================================================
   ALLIANSBOLAG (alliances.php / alliance.php)
   ============================================================ */
.alliance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 14px;
    padding: 16px;
}

.alliance-card {
    background: linear-gradient(135deg, #fafdf9 0%, #f0f6ed 100%);
    border: 1px solid rgba(45, 74, 43, 0.15);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius);
    padding: 14px 16px;
    text-decoration: none;
    color: inherit;
    transition: all 0.15s;
    display: block;
}

.alliance-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(45, 74, 43, 0.12);
    border-left-width: 4px;
}

.alliance-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 6px;
}

.alliance-card-name {
    font-weight: 600;
    font-size: 15px;
    color: var(--ink);
}

.alliance-status {
    font-size: 10px;
    padding: 3px 9px;
    border-radius: 999px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    flex-shrink: 0;
}

.alliance-status.status-active {
    background: var(--accent);
    color: white;
}

.alliance-status.status-renegotiation {
    background: #b8923a;
    color: white;
}

.alliance-status.status-paused {
    background: var(--ink-subtle);
    color: white;
}

.alliance-status.status-expired {
    background: var(--danger);
    color: white;
}

.alliance-card-meta {
    font-size: 12px;
    color: var(--ink-subtle);
    margin-bottom: 10px;
}

.alliance-card-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    font-size: 12px;
    color: var(--ink-subtle);
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed rgba(45, 74, 43, 0.15);
}

.alliance-stat {
    white-space: nowrap;
}

.alliance-source-note {
    margin-top: 6px;
    font-size: 13px;
    color: var(--ink-subtle);
    font-style: italic;
}

.alliance-source-note a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

.alliance-source-note a:hover {
    text-decoration: underline;
}

.alliance-members-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.alliance-members-table th {
    text-align: left;
    padding: 8px 12px;
    border-bottom: 1px solid var(--line);
    font-family: var(--font-mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-subtle);
    font-weight: 600;
}

.alliance-members-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
}

.alliance-members-table tr:last-child td {
    border-bottom: none;
}

.alliance-members-table a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

.alliance-members-table a:hover {
    text-decoration: underline;
}

.alliance-member-title {
    font-size: 12px;
    color: var(--ink-subtle);
    margin-top: 2px;
}

.alliance-source-pill {
    display: inline-block;
    background: var(--bg-sunken);
    color: var(--ink-subtle);
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
}

.alliance-add-member {
    margin-top: 12px;
    padding: 14px;
    background: var(--bg-sunken);
    border-radius: var(--radius);
}

@media (max-width: 700px) {
    .alliance-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   PERSON.PHP — Alliansmedlemskap-pills
   ============================================================ */
.person-alliance-memberships {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.person-alliance-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: var(--accent-soft);
    color: var(--accent);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    border: 1px solid rgba(45, 74, 43, 0.15);
    transition: all 0.15s;
}

.person-alliance-pill:hover {
    background: var(--accent);
    color: white;
    transform: translateY(-1px);
}

.person-alliance-pill.inactive {
    background: var(--bg-sunken);
    color: var(--ink-subtle);
    border-color: var(--line);
}

.person-alliance-role {
    color: inherit;
    opacity: 0.75;
    font-size: 11px;
}

/* ============================================================
   REPORT.PHP — Tillägg för alliansbolag och nya summary-grupper
   ============================================================ */
.report-summary-section-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-subtle);
    font-weight: 600;
    margin-bottom: 8px;
}

.report-summary-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.report-summary-card.report-summary-alliance {
    background: linear-gradient(135deg, #fafdf9 0%, #f0f6ed 100%);
    border-color: rgba(45, 74, 43, 0.2);
    border-left: 3px solid var(--accent);
}

.report-summary-card.report-summary-alliance .report-summary-value {
    color: var(--accent);
}

.report-alliances-new {
    margin-top: 12px;
    padding: 10px 14px;
    background: var(--accent-soft);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--ink);
}

@media (max-width: 700px) {
    .report-summary-grid-3 {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   PEOPLE.PHP — Alliansbolag i listan
   ============================================================ */
.people-alliance-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

.people-alliance-link:hover {
    text-decoration: underline;
}

.alliance-active-pill {
    display: inline-block;
    padding: 3px 10px;
    background: var(--accent-soft);
    color: var(--accent);
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.text-xs {
    font-size: 11px;
    line-height: 1.3;
}

/* ============================================================ */
/* WORD CONFIRM MODAL                                            */
/* ============================================================ */
.word-confirm-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 9999; display: flex; align-items: center; justify-content: center; padding: 20px; animation: wcFadeIn 0.15s ease; }
@keyframes wcFadeIn { from { opacity: 0; } to { opacity: 1; } }
.word-confirm-modal { background: var(--bg-card,#fff); border-radius: 12px; padding: 24px 28px; max-width: 460px; width: 100%; box-shadow: 0 20px 50px rgba(0,0,0,0.25); animation: wcSlideUp 0.2s ease; }
@keyframes wcSlideUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.word-confirm-title { margin: 0 0 12px 0; font-size: 18px; color: var(--ink,#1a1a1a); }
.word-confirm-message { margin: 0 0 12px 0; color: var(--ink,#1a1a1a); line-height: 1.45; }
.word-confirm-item { background: var(--bg-sunken,#f4f4f0); border-left: 3px solid var(--rust,#b8923a); padding: 10px 14px; border-radius: 4px; font-weight: 500; margin: 0 0 14px 0; word-break: break-word; }
.word-confirm-warning { color: #c0392b; font-size: 13px; margin: 0 0 16px 0; font-weight: 500; }
.word-confirm-instruction { margin: 0 0 8px 0; color: var(--ink-subtle,#6b6b6b); font-size: 14px; }
.word-confirm-instruction strong { color: var(--ink,#1a1a1a); font-family: ui-monospace,"SF Mono",Menlo,monospace; background: var(--bg-sunken,#f4f4f0); padding: 2px 8px; border-radius: 3px; letter-spacing: 0.05em; }
.word-confirm-input { width: 100%; padding: 10px 14px; font-size: 16px; border: 2px solid var(--line,#e0e0d8); border-radius: 6px; font-family: ui-monospace,"SF Mono",Menlo,monospace; letter-spacing: 0.05em; box-sizing: border-box; background: #fff; color: var(--ink,#1a1a1a); }
.word-confirm-input:focus { outline: none; border-color: var(--rust,#b8923a); }
.word-confirm-buttons { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.word-confirm-buttons button { padding: 9px 20px; border-radius: 6px; border: none; cursor: pointer; font-size: 14px; font-family: inherit; font-weight: 500; transition: all 0.15s; }
.word-confirm-cancel { background: var(--bg-sunken,#f4f4f0); color: var(--ink,#1a1a1a); }
.word-confirm-cancel:hover { background: var(--line,#e0e0d8); }
.word-confirm-go { background: #d0d0d0; color: #888; cursor: not-allowed; }
.word-confirm-go-active { background: #c0392b !important; color: #fff !important; cursor: pointer !important; }
.word-confirm-go-active:hover { background: #a93324 !important; }

/* ============================================================ */
/* FUNNEL SCROLL-KNAPPAR                                         */
/* Inga ändringar i .funnel — knapparna ligger ovanpå           */
/* ============================================================ */
.main .stats-grid.stats-grid-pipeline {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.funnel-wrapper {
    position: relative;
    width: 100%;
    min-width: 0;
    max-width: 100%;
}

.funnel-scroll-btn {
    position: absolute;
    top: 40px;  /* nära funnel-headerns höjd */
    width: 40px;
    height: 60px;
    background: var(--bg-card, #fff);
    border: 1px solid var(--line, #e0e0d8);
    border-radius: 8px;
    cursor: pointer;
    z-index: 5;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--ink, #1a1a1a);
    transition: opacity 0.2s, background 0.15s, top 0.15s;
}

.funnel-scroll-btn:hover:not(:disabled) {
    background: var(--bg-elevated, #f4f4f0);
}

.funnel-scroll-btn:disabled {
    opacity: 0;
    pointer-events: none;
}

.funnel-scroll-btn.left { left: 8px; }
.funnel-scroll-btn.right { right: 8px; }

/* Sticky-läge: när man har scrollat ner i funneln,
   låt knapparna stanna kvar i viewporten via JS */
.funnel-scroll-btn.is-sticky {
    position: fixed;
    top: 50vh;
    transform: translateY(-50%);
    /* left/right sätts av JS för att matcha funnelns position */
}

@media (max-width: 700px) {
    .funnel-scroll-btn { display: none !important; }
}

/* ============================================================
   MOBILE-FIRST AUDIT v1 — 2026-04-28
   ============================================================
   Globala mobilförbättringar baserade på audit:
   - Mindre page-headers
   - Kompaktare tabbar
   - Mindre formulärfält
   - Vänster-justering i loggbok
   - Mindre info-banners
   ============================================================ */

@media (max-width: 700px) {
    
    /* ---- Page headers (mindre dödutrymme) ---- */
    .page-header {
        padding-bottom: 12px !important;
        margin-bottom: 16px !important;
    }
    
    .page-header h1 {
        font-size: 26px !important;
        line-height: 1.15 !important;
        margin: 0 0 4px 0 !important;
    }
    
    /* Kategori-text ovanför h1 (DASHBOARD, FÖRETAG · DETALJER etc.) */
    .page-header .breadcrumb,
    .page-header .subtitle,
    .page-header .text-muted-uppercase,
    .page-header > .text-muted {
        font-size: 10px !important;
        letter-spacing: 0.08em !important;
        margin-bottom: 2px !important;
    }
    
    /* ---- Tab-rader (Min dag / Översikt etc.) ---- */
    .tab-row,
    .tabs-container,
    .dashboard-tabs,
    [class*="tab-bar"] {
        padding: 4px !important;
        gap: 4px !important;
    }
    
    .tab-row > *,
    .tab-row a,
    .tab-row button,
    .tabs-container > a,
    .tabs-container > button,
    .dashboard-tab {
        padding: 8px 12px !important;
        font-size: 13px !important;
        min-height: 36px !important;
    }
    
    /* ---- Stat-kort (på Översikt-fliken) ---- */
    .stat-card,
    .stats-grid > .stat,
    .overview-stat {
        padding: 12px 14px !important;
    }
    
    .stat-card .stat-label,
    .stats-grid .stat-label {
        font-size: 10px !important;
        letter-spacing: 0.08em !important;
        margin-bottom: 4px !important;
    }
    
    .stat-card .stat-value,
    .stats-grid .stat-value {
        font-size: 28px !important;
        line-height: 1.1 !important;
    }
    
    /* ---- Formulär (Lägg till aktivitet etc.) ---- */
    .form-group,
    .field {
        margin-bottom: 14px !important;
    }
    
    .form-group label,
    .field label,
    label.form-label {
        font-size: 13px !important;
        margin-bottom: 4px !important;
        font-weight: 500 !important;
    }
    
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    input[type="number"],
    input[type="date"],
    input[type="datetime-local"],
    input[type="search"],
    select,
    textarea {
        padding: 10px 12px !important;
        font-size: 16px !important;  /* iOS no-zoom */
        min-height: 42px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    
    textarea {
        min-height: 80px !important;
    }
    
    /* ---- Kort/cards (mindre padding) ---- */
    .card {
        padding: 14px !important;
        margin-bottom: 14px !important;
    }
    
    .card.tight {
        padding: 12px !important;
    }
    
    .card h2,
    .card .card-title {
        font-size: 17px !important;
        margin-bottom: 12px !important;
    }
    
    /* ---- Loggbok-aktiviteter (vänster-justering) ---- */
    .activity-list-item,
    .activity-row,
    .timeline-item {
        text-align: left !important;
    }
    
    .activity-list-item .meta,
    .activity-list-item .activity-date,
    .activity-list-item time {
        text-align: left !important;
    }
    
    /* ---- Pipeline info-banner (mindre) ---- */
    .funnel-hint,
    .info-banner {
        padding: 8px 12px !important;
        font-size: 12px !important;
        line-height: 1.4 !important;
    }
    
    /* ---- Stora "+ Person/+ Bolag" knappar i page-header (dölj på mobil) ---- */
    /* FAB tar över rollen */
    .page-header .header-actions,
    .page-header .index-quick-actions,
    .index-quick-actions,
    .quick-add-buttons {
        display: none !important;
    }
}

/* ---- iPhone SE och mindre ---- */
@media (max-width: 380px) {
    .page-header h1 {
        font-size: 22px !important;
    }
    
    .stat-card .stat-value,
    .stats-grid .stat-value {
        font-size: 24px !important;
    }
    
    .card {
        padding: 12px !important;
    }
}

/* ============================================================
   FLOATING ACTION BUTTON (FAB)
   ============================================================
   + Person / + Bolag som flytande knapp på mobil
   ============================================================ */

.fab-container {
    display: none;  /* Default: dolt på desktop */
}

@media (max-width: 700px) {
    .fab-container {
        display: block;
        position: fixed;
        /* Bottennav är 56px hög + safe-area-inset-bottom.
           Vi vill ha FAB ovanför bottennav med tydlig luft. */
        bottom: calc(env(safe-area-inset-bottom, 0px) + 72px);
        right: 16px;
        z-index: 100;
    }
    
    .fab-main {
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: #1a1a1a;
        color: #fff;
        border: none;
        font-size: 32px;
        font-weight: 300;
        cursor: pointer;
        box-shadow: 0 4px 16px rgba(0,0,0,0.25);
        display: flex;
        align-items: center;
        justify-content: center;
        transition: transform 0.2s, background 0.2s;
        line-height: 1;
        padding-bottom: 4px;
        font-family: -apple-system, sans-serif;
    }
    
    .fab-main:active {
        transform: scale(0.95);
    }
    
    .fab-main.open {
        transform: rotate(45deg);
        background: #c0392b;
    }
    
    .fab-menu {
        position: absolute;
        bottom: 70px;
        right: 0;
        display: flex;
        flex-direction: column;
        gap: 10px;
        opacity: 0;
        pointer-events: none;
        transform: translateY(10px);
        transition: opacity 0.2s, transform 0.2s;
    }
    
    .fab-menu.open {
        opacity: 1;
        pointer-events: auto;
        transform: translateY(0);
    }
    
    .fab-menu a {
        background: #fff;
        color: #1a1a1a;
        padding: 12px 18px;
        border-radius: 28px;
        text-decoration: none;
        font-size: 14px;
        font-weight: 500;
        box-shadow: 0 2px 12px rgba(0,0,0,0.15);
        white-space: nowrap;
        display: flex;
        align-items: center;
        gap: 8px;
        border: 1px solid #e0e0d8;
    }
    
    .fab-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.2);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s;
        z-index: 99;
    }
    
    .fab-backdrop.open {
        opacity: 1;
        pointer-events: auto;
    }
}

/* ============================================================
   MOBILE IDENTITY STRIP
   ============================================================
   Kompakt identitetskort på detaljsidor (mobil only)
   ============================================================ */

.mobile-identity-strip {
    display: none;  /* Dolt på desktop */
}

@media (max-width: 700px) {
    .mobile-identity-strip {
        display: block;
        background: var(--bg-elevated, #fff);
        border: 1px solid var(--line, #e0e0d8);
        border-radius: 10px;
        padding: 14px 16px;
        margin-bottom: 14px;
    }
    
    .mob-id-title {
        font-family: var(--font-display, serif);
        font-size: 22px;
        line-height: 1.15;
        margin: 0 0 4px 0;
        font-weight: 600;
    }
    
    .mob-id-subtitle {
        color: var(--ink-muted, #555);
        font-size: 14px;
        margin-bottom: 10px;
        line-height: 1.4;
    }
    
    .mob-id-subtitle a {
        color: inherit;
        text-decoration: none;
        font-weight: 500;
    }
    
    .mob-id-contact {
        display: flex;
        flex-direction: column;
        gap: 8px;
        padding-top: 10px;
        border-top: 1px solid var(--line, #e0e0d8);
        margin-top: 6px;
    }
    
    .mob-id-link {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 8px 0;
        color: var(--ink, #1a1a1a);
        text-decoration: none;
        font-size: 14px;
        min-height: 36px;
    }
    
    .mob-id-icon {
        font-size: 16px;
        flex-shrink: 0;
        width: 20px;
        text-align: center;
    }
    
    .mob-id-text {
        flex: 1;
        word-break: break-word;
        color: var(--accent, #2d4a2b);
        font-weight: 500;
    }
    
    .mob-id-extras {
        margin-top: 8px;
        padding-top: 8px;
        border-top: 1px solid var(--line, #e0e0d8);
        font-size: 13px;
        color: var(--ink-muted, #555);
    }
    
    .mob-id-extra {
        padding: 2px 0;
    }
    
    /* Dölj nedre detail-header på mobil när vi har strip */
    .has-mobile-id-strip .detail-header {
        display: none;
    }
}

/* ============================================================
   DIRECTION (ingående/utgående) — UI
   ============================================================ */

/* Liten pil bredvid aktivitetstypen */
.direction-arrow {
    display: inline-block;
    margin-left: 2px;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    vertical-align: baseline;
}

.direction-arrow.direction-out {
    color: var(--accent, #2d4a2b);  /* Grönt — utgående */
}

.direction-arrow.direction-in {
    color: var(--rust, #c0392b);  /* Rött — inkommande */
}

/* Direction-rad i snabblogga (i quick-note-form) */
.direction-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.direction-label {
    font-size: 12px;
    color: var(--ink-subtle, #666);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Direction-flip: en flippbar knapp, ↗ Ut → ↙ In */
.direction-flip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px 6px 10px;
    border: 1px solid;
    border-radius: 999px;
    background: var(--accent-soft, #e8f5e8);
    border-color: rgba(45, 74, 43, 0.2);
    color: var(--accent, #2d4a2b);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    user-select: none;
    line-height: 1;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
    min-height: 30px;
}

.direction-flip:hover {
    filter: brightness(0.97);
}

.direction-flip:active {
    transform: scale(0.97);
}

.direction-flip-icon {
    display: inline-block;
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    transition: transform 0.25s ease;
    transform: rotate(0deg);
}

.direction-flip-label {
    line-height: 1;
}

/* IN-läge: blå färgschema, ikonen flippad 180° */
.direction-flip[data-direction="in"] {
    background: rgba(70, 130, 180, 0.12);
    border-color: rgba(70, 130, 180, 0.3);
    color: #2c5d8c;
}

.direction-flip[data-direction="in"] .direction-flip-icon {
    transform: rotate(180deg);
}

/* Direction-row i Logga utförligt (full bredd, samma stil som andra form-rows) */
.direction-row-detailed {
    display: flex;
    gap: 12px;
}

@media (max-width: 700px) {
    .direction-row {
        flex-wrap: wrap;
    }
    .direction-flip {
        padding: 8px 14px 8px 12px;
        font-size: 14px;
        min-height: 36px;
    }
    .direction-flip-icon {
        font-size: 16px;
    }
}


/* ============================================================
   GLOBAL SÖK
   ============================================================ */

/* === Trigger i mobile-topbar (mobil) === */
.search-trigger-topbar {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--ink-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    transition: background 0.15s;
    margin-left: auto;
}

.search-trigger-topbar:active {
    background: var(--bg-sunken);
}

.search-trigger-topbar svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
}

/* === Flytande sökknapp på desktop === */
.search-trigger-floating {
    display: none;
}

@media (min-width: 901px) {
    .search-trigger-floating {
        position: fixed;
        top: 18px;
        right: 22px;
        z-index: 100;
        width: 42px;
        height: 42px;
        padding: 0;
        border-radius: 50%;
        background: var(--bg-elevated);
        border: 1px solid var(--line);
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
        cursor: pointer;
        color: var(--ink-subtle);
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.15s ease;
    }
    
    .search-trigger-floating:hover {
        background: var(--bg);
        border-color: var(--ink-subtle);
        color: var(--ink);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
        transform: translateY(-1px);
    }
    
    .search-trigger-floating:active {
        transform: translateY(0);
    }
    
    .search-trigger-floating svg {
        width: 18px;
        height: 18px;
        stroke: currentColor;
        fill: none;
    }
}

/* === Backdrop === */
.gs-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 15, 15, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 998;
}

.gs-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

/* === Modal === */
.gs-modal {
    position: fixed;
    top: 90px;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    width: 92%;
    max-width: 600px;
    max-height: calc(100vh - 140px);
    background: var(--bg-elevated);
    border-radius: 14px;
    box-shadow: 
        0 0 0 1px rgba(0, 0, 0, 0.04),
        0 20px 60px rgba(0, 0, 0, 0.18);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s, transform 0.15s;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.gs-modal.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

/* === Modal header (sökfält) === */
.gs-modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
    background: var(--bg-elevated);
}

.gs-modal-icon {
    color: var(--ink-subtle);
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.gs-modal-icon svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
}

.gs-modal-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 16px;
    color: var(--ink);
    font-family: inherit;
    padding: 4px 0;
    -webkit-appearance: none;
    appearance: none;
    min-width: 0;
}

.gs-modal-input::-webkit-search-cancel-button,
.gs-modal-input::-webkit-search-decoration {
    -webkit-appearance: none;
}

.gs-modal-input::placeholder {
    color: var(--ink-muted);
}

.gs-modal-esc {
    font-size: 11px;
    color: var(--ink-muted);
    background: var(--bg-sunken);
    border: 1px solid var(--line);
    padding: 2px 7px;
    border-radius: 5px;
    font-family: ui-monospace, Menlo, monospace;
    flex-shrink: 0;
}

/* === Resultat === */
.gs-modal-results {
    flex: 1;
    overflow-y: auto;
    padding: 6px 0 8px;
    -webkit-overflow-scrolling: touch;
}

.gs-empty {
    padding: 32px 20px;
    text-align: center;
    color: var(--ink-muted);
    font-size: 14px;
    line-height: 1.5;
}

.gs-loading {
    padding: 24px 20px;
    text-align: center;
    color: var(--ink-muted);
    font-size: 13px;
}

.gs-section {
    padding: 4px 0 8px;
}

.gs-section-header {
    padding: 10px 18px 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-muted);
}

.gs-section-count {
    color: var(--ink-muted);
    font-weight: 400;
}

.gs-result {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    text-decoration: none;
    color: var(--ink);
    transition: background 0.1s;
    cursor: pointer;
    border-left: 3px solid transparent;
}

.gs-result:hover,
.gs-result.selected {
    background: var(--bg-sunken);
}

.gs-result.selected {
    border-left-color: var(--accent);
    background: var(--accent-soft);
}

.gs-result-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-sunken);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
    font-weight: 600;
    color: var(--ink-subtle);
    letter-spacing: -0.02em;
}

.gs-result-body {
    flex: 1;
    min-width: 0;
}

.gs-result-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.3;
}

.gs-result-context {
    font-size: 12px;
    color: var(--ink-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 2px;
    line-height: 1.3;
}

.gs-result-meta {
    font-size: 11px;
    color: var(--ink-muted);
    flex-shrink: 0;
    text-align: right;
    white-space: nowrap;
}

.gs-result mark {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
    padding: 0 2px;
    border-radius: 2px;
}

/* === Mobil-anpassning === */
@media (max-width: 700px) {
    .gs-modal {
        top: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        transform: translateY(-10px);
    }
    
    .gs-modal.open {
        transform: translateY(0);
    }
    
    .gs-modal-header {
        padding: calc(env(safe-area-inset-top, 0) + 12px) 16px 12px;
    }
    
    .gs-modal-input {
        font-size: 16px;  /* iOS no-zoom */
    }
    
    .gs-modal-esc {
        display: none;
    }
}

/* ============================================================
   MOBIL: förhindra horizontell sid-scroll vid lång inklistrad text
   ============================================================ */
@media (max-width: 900px) {
    /* Förhindra horizontell scroll på hela sidan */
    html, body {
        overflow-x: hidden;
        max-width: 100%;
    }
    
    /* Säkerställ att main-content håller sig inom skärmbredd */
    .main {
        overflow-x: hidden;
        max-width: 100vw;
    }
    
    /* Card-body skall kunna krympa men inte spräcka */
    .card-body, .card {
        min-width: 0;
        max-width: 100%;
    }
    
    /* Timeline aktivitets-text — bryt långa rader */
    .timeline-body,
    .timeline-body p,
    .timeline-body div,
    .timeline-body li,
    .timeline-content {
        overflow-wrap: anywhere;
        word-break: break-word;
        max-width: 100%;
    }
    
    /* Detail-grid och nested cards */
    .detail-grid,
    .detail-section,
    .detail-meta {
        min-width: 0;
        max-width: 100%;
    }
    
    /* Pre-formaterad text (om någon klistrar kod-liknande) */
    pre, code {
        white-space: pre-wrap;
        overflow-wrap: anywhere;
        max-width: 100%;
    }
    
    /* Tab-row får inte spräcka layouten */
    .tabs {
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ============================================================
   PARTICIPANT CHIPS — kompakta deltagar-piller
   ============================================================ */

.participant-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin-top: 8px;
}

.participant-chips-label {
    font-size: 12px;
    color: var(--ink-subtle);
    margin-right: 2px;
}

.participant-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 4px 3px 10px;
    background: var(--bg-sunken, #f0f0ec);
    border-radius: 999px;
    font-size: 12px;
    line-height: 1.4;
    max-width: 100%;
    box-sizing: border-box;
}

.participant-chip-current {
    background: var(--accent-soft, #e8f5e8);
    padding: 3px 10px;
}

.participant-chip-name {
    color: var(--ink, #1a1a1a);
    text-decoration: none;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.participant-chip-name:hover {
    text-decoration: underline;
}

.participant-chip-form {
    margin: 0;
    padding: 0;
    display: inline-flex;
    align-items: center;
}

.participant-chip-remove {
    background: transparent;
    border: none;
    color: var(--ink-muted, #999);
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0;
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.1s;
}

.participant-chip-remove:hover {
    background: var(--bg, #fafaf7);
    color: var(--ink, #1a1a1a);
}

/* ============================================================
   DEMO-LÄGE (testkonto / readonly)
   ============================================================ */

/* Banner i toppen */
.demo-banner {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #fff;
    text-align: center;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.01em;
    position: sticky;
    top: 0;
    z-index: 200;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.demo-banner strong {
    font-weight: 700;
}

@media (max-width: 700px) {
    .demo-banner {
        font-size: 12px;
        padding: 6px 12px;
    }
}

/* Justera sidebar och topbar så de inte täcks av banner */
body[data-demo="1"] .sidebar {
    top: 36px;  /* Banner-höjden */
    height: calc(100vh - 36px);
}

body[data-demo="1"] .search-trigger-floating {
    top: 54px;  /* 18 + 36 (banner) */
}

body[data-demo="1"] .mobile-topbar {
    top: 30px;  /* mobil banner-höjd */
}

body[data-demo="1"] .gs-modal {
    top: 116px;  /* 80 + 36 */
}

@media (max-width: 700px) {
    body[data-demo="1"] .sidebar {
        top: 30px;
        height: calc(100vh - 30px);
    }
    body[data-demo="1"] .gs-modal {
        top: 30px;
    }
}

/* ===== BLUR-REGLER ===== */

/* Detail-header (personnamn, företagsnamn) */
body[data-demo="1"] .detail-header h1,
body[data-demo="1"] .detail-header .sub {
    filter: blur(6px);
    user-select: none;
    pointer-events: none;
}

/* Page-header h1 — bara på person/företag/formation-sidor (inte översikt etc.) */
body[data-demo="1"] .page-header h1 {
    filter: blur(6px);
    user-select: none;
    pointer-events: none;
}

/* Whitelist: page-header på sidor utan persondata */
body[data-demo="1"].page-overview .page-header h1,
body[data-demo="1"].page-static .page-header h1 {
    filter: none;
}

/* Mobile identity strip */
body[data-demo="1"] .mobile-identity-strip {
    filter: blur(6px);
    user-select: none;
    pointer-events: none;
}

/* Detail-meta (kontaktuppgifter) */
body[data-demo="1"] .detail-meta {
    filter: blur(5px);
    user-select: none;
    pointer-events: none;
}

/* Timeline aktivitetsinnehåll */
body[data-demo="1"] .timeline-title,
body[data-demo="1"] .timeline-body,
body[data-demo="1"] .timeline-content > div:not(.timeline-head) {
    filter: blur(5px);
    user-select: none;
    pointer-events: none;
}

/* Behåll timeline tid + typ + status synliga (inget innehåll exponeras där) */
body[data-demo="1"] .timeline-time,
body[data-demo="1"] .timeline-type,
body[data-demo="1"] .timeline-dot,
body[data-demo="1"] .timeline-head .badge,
body[data-demo="1"] .timeline-head [class*="status"],
body[data-demo="1"] .direction-arrow {
    filter: none !important;
    user-select: auto;
    pointer-events: auto;
}

/* Tabellceller med personnamn / företagsnamn / kontaktinfo */
body[data-demo="1"] table tbody td:not(.numeric):not(.badge-cell) {
    filter: blur(5px);
    user-select: none;
    pointer-events: none;
}

/* Tab-knappar i tabellrader (klickbara) ska inte blurras */
body[data-demo="1"] table tbody td a {
    filter: blur(5px);
    user-select: none;
    pointer-events: none;
}

/* Funnel-kort (pipeline-vy) */
body[data-demo="1"] .funnel-card .funnel-card-name,
body[data-demo="1"] .funnel-card .funnel-card-company,
body[data-demo="1"] .funnel-card .funnel-card-meta,
body[data-demo="1"] .funnel-card-extra {
    filter: blur(5px);
    user-select: none;
    pointer-events: none;
}

/* Behåll kort-strukturen synlig (dragbarhet, status, knappar) */
body[data-demo="1"] .funnel-card-actions,
body[data-demo="1"] .funnel-card-move,
body[data-demo="1"] .funnel-stage-header {
    filter: none;
}

/* Index/dashboard-listor: namn på personer/företag i "Borde kontaktas", fokus etc. */
body[data-demo="1"] .focus-item-name,
body[data-demo="1"] .focus-item-meta,
body[data-demo="1"] .cadence-warn-name,
body[data-demo="1"] .agenda-event,
body[data-demo="1"] .mydag-event-title,
body[data-demo="1"] .mydag-task-title {
    filter: blur(5px);
    user-select: none;
    pointer-events: none;
}

/* Aktivitetslogg (loggboken) */
body[data-demo="1"] .activity-list .activity-subject,
body[data-demo="1"] .activity-list .activity-body,
body[data-demo="1"] .activity-list .activity-meta strong {
    filter: blur(5px);
    user-select: none;
    pointer-events: none;
}

/* Pipeline-status / kontaktperson-sektion på personkortet */
body[data-demo="1"] .relationship-list-item-name,
body[data-demo="1"] .matchmaking-name {
    filter: blur(5px);
    user-select: none;
    pointer-events: none;
}

/* Sökresultat — blurra namn men behåll struktur */
body[data-demo="1"] .gs-result-title,
body[data-demo="1"] .gs-result-context {
    filter: blur(5px);
    user-select: none;
    pointer-events: none;
}

/* Form-fält i Logga-formulär (om någon försöker skriva, syns inget) */
body[data-demo="1"] .quick-note-text,
body[data-demo="1"] textarea:not(:focus),
body[data-demo="1"] input[type="text"]:not(:focus),
body[data-demo="1"] input[type="email"]:not(:focus),
body[data-demo="1"] input[type="tel"]:not(:focus) {
    filter: blur(4px);
}

/* Deltagar-chips */
body[data-demo="1"] .participant-chip-name {
    filter: blur(5px);
    user-select: none;
    pointer-events: none;
}

/* Anti-CSS-trick: tooltips som kan visa originaltext */
body[data-demo="1"] *[title] {
    pointer-events: none;
}

body[data-demo="1"] *[title]:hover::after {
    content: none;
}

/* Re-aktivera klickbarhet på pipeline/sidebar-länkar (de innehåller bara struktur-text) */
body[data-demo="1"] .sidebar a,
body[data-demo="1"] .sidebar button,
body[data-demo="1"] .bottom-nav a,
body[data-demo="1"] .funnel-stage a,
body[data-demo="1"] .tabs a,
body[data-demo="1"] .btn,
body[data-demo="1"] button:not([disabled]) {
    pointer-events: auto;
}

/* Print: dölj allt för readonly */
@media print {
    body[data-demo="1"] {
        display: none;
    }
}


/* ============================================================
   Inline-uppgifter på person/company-kort — kompakt enrads-form
   ============================================================ */
.inline-task-form {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--line);
}

.inline-task-title {
    flex: 1;
    min-width: 0;
    padding: 7px 10px;
    font-size: 13px;
    font-family: inherit;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--bg-elevated, #fff);
    color: var(--ink);
    outline: none;
    transition: border-color 0.15s;
}
.inline-task-title:focus {
    border-color: var(--ink-subtle, #999);
}

/* Datum: kalenderikon som triggar native datepicker */
.inline-task-date {
    position: relative;
    width: 36px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--bg-sunken, #f5f5f5);
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color 0.15s, background 0.15s;
}
.inline-task-date:hover {
    border-color: var(--ink-subtle, #999);
}
.inline-task-date-icon {
    font-size: 15px;
    line-height: 1;
    pointer-events: none;
}
.inline-task-date input[type="date"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    border: 0;
    padding: 0;
    font-size: 16px; /* hindrar iOS auto-zoom */
}
/* Dölj native datepicker-ikonen som vissa browsers visar */
.inline-task-date input[type="date"]::-webkit-calendar-picker-indicator {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    opacity: 0;
}

/* Plus-knapp: liten cirkulär */
.inline-task-add {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent, #1a1a1a);
    color: #fff;
    border: 0;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 400;
    line-height: 1;
    cursor: pointer;
    font-family: inherit;
    padding: 0;
    transition: opacity 0.15s;
}
.inline-task-add:hover {
    opacity: 0.85;
}
.inline-task-add:active {
    transform: scale(0.95);
}

/* Task-rader på person/company-kort */
.task-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 8px 16px;
    border-bottom: 1px solid var(--line);
}
.task-row:last-child {
    border-bottom: 0;
}
.task-checkbox {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 1.5px solid var(--ink-subtle, #999);
    background: transparent;
    cursor: pointer;
    padding: 0;
    margin-top: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 11px;
    line-height: 1;
    font-family: inherit;
    transition: background 0.15s, border-color 0.15s;
}
.task-checkbox:hover {
    border-color: var(--ink, #1a1a1a);
}
.task-checkbox.is-done {
    background: var(--accent, #1a1a1a);
    border-color: var(--accent, #1a1a1a);
}
.task-row-content {
    flex: 1;
    min-width: 0;
}
.task-row-title {
    font-weight: 500;
    font-size: 13px;
    line-height: 1.4;
    word-wrap: break-word;
}
.task-row-title.is-done {
    text-decoration: line-through;
    color: var(--ink-subtle, #999);
}
.task-row-meta {
    font-size: 11px;
    margin-top: 2px;
    color: var(--ink-subtle, #999);
    font-family: var(--font-mono, monospace);
}
.task-row-meta.is-overdue {
    color: var(--danger, #c33);
}
.task-row-empty {
    padding: 14px 16px;
    color: var(--ink-subtle, #999);
    font-size: 13px;
}

/* ============================================================
   Historik-collapse: visa 3 senaste, expand för resten
   ============================================================ */
.timeline-collapse {
    margin-top: 8px;
}

.timeline-collapse > summary {
    list-style: none;
    cursor: pointer;
    padding: 12px 16px;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-muted, #666);
    background: var(--bg-sunken, #f5f5f5);
    border-radius: 8px;
    user-select: none;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.timeline-collapse > summary:hover {
    background: var(--bg-subtle, #ebe8e0);
    color: var(--ink, #1a1a1a);
}
.timeline-collapse > summary::-webkit-details-marker {
    display: none;
}
.timeline-collapse > summary::marker {
    display: none;
}
.timeline-collapse-chevron {
    display: inline-block;
    transition: transform 0.2s;
    font-size: 11px;
}
.timeline-collapse[open] > summary > .timeline-collapse-chevron {
    transform: rotate(180deg);
}
.timeline-collapse[open] > summary > .timeline-collapse-text::after {
    content: ' (klicka för att stänga)';
    font-weight: normal;
    color: var(--ink-subtle, #999);
    font-size: 11px;
}
.timeline-collapse > .timeline {
    margin-top: 12px;
}

/* ============================================================
   Försenade-badge på Uppgifter-rubriken
   ============================================================ */
.tasks-overdue-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    background: var(--danger, #c33);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    border-radius: 99px;
    vertical-align: middle;
}

/* ============================================================
   Mobile-only: dölj "Logga utförligt" på mobil
   ============================================================ */
@media (max-width: 768px) {
    .mobile-hide {
        display: none !important;
    }
}

/* ============================================================
   Mobil: Aktivitet-kortet överst på Översikt-pane
   ============================================================ */
/* ============================================================
   Defensiv: säkerställ att hidden-attribut döljer dashboard-paner
   ============================================================ */
.dashboard-pane[hidden] {
    display: none !important;
}

@media (max-width: 768px) {
    .dashboard-pane[data-pane="overview"]:not([hidden]) {
        display: flex;
        flex-direction: column;
    }
    /* Default: alla element renderas i HTML-ordning, fast bakom prioriterade */
    .dashboard-pane[data-pane="overview"]:not([hidden]) > * {
        order: 10;
    }
    /* Element med data-mobile-priority hamnar först (1 = högst upp) */
    .dashboard-pane[data-pane="overview"]:not([hidden]) > [data-mobile-priority="1"] {
        order: 1;
    }
}

/* ============================================================
   Pipeline utan prospect-ruta: ändra grid till 1fr auto
   ============================================================ */
.pipeline-phases.pipeline-phases-no-prospect {
    grid-template-columns: 1fr auto;
}

/* TB-rutor: undvik radbrytning av MSEK-värden */
.tb-prospect-cell {
    min-width: 0;
}

/* ============================================================
   Konfetti-state: när "Försenade enligt cadens" är tomt
   ============================================================ */
.card.cadens-celebration {
    background: linear-gradient(135deg, var(--bg-elevated, #fff) 0%, rgba(34, 139, 34, 0.04) 100%);
    border-color: rgba(34, 139, 34, 0.2);
}
.card.cadens-celebration .card-header h3 {
    color: var(--success, #228b22);
}
.cadens-empty-celebrate p {
    color: var(--ink, #1a1a1a);
}

/* ============================================================
   Hall of Shame
   ============================================================ */
.shame-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid var(--line);
    color: inherit;
    text-decoration: none;
    transition: background 0.15s;
}
.shame-row:hover {
    background: var(--bg-sunken, #f5f5f5);
}
.shame-row-name {
    font-weight: 600;
    font-size: 14px;
}
.shame-row-meta {
    font-size: 12px;
    color: var(--ink-muted, #666);
    margin-top: 2px;
}
.shame-days {
    font-family: var(--font-mono, monospace);
    font-size: 13px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 99px;
    flex-shrink: 0;
}
.shame-days.tier-yellow {
    background: rgba(234, 179, 8, 0.15);
    color: #92400e;
}
.shame-days.tier-orange {
    background: rgba(234, 88, 12, 0.15);
    color: #9a3412;
}
.shame-days.tier-red {
    background: rgba(220, 38, 38, 0.15);
    color: #991b1b;
}
.shame-prospect-tag {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    font-size: 10px;
    color: var(--ink-muted, #666);
    font-weight: normal;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================================
   Bokningsnyckel
   ============================================================ */
.booking-key-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1px;
    background: var(--line);
    border-radius: 8px;
    overflow: hidden;
}
.booking-key-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    background: var(--bg-elevated, #fff);
}
.booking-key-row.row-primary {
    padding: 18px 20px;
}
.booking-key-label {
    font-size: 13px;
    color: var(--ink-muted, #666);
}
.booking-key-row.row-primary .booking-key-label {
    font-size: 14px;
    color: var(--ink, #1a1a1a);
    font-weight: 500;
}
.booking-key-value {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 500;
    color: var(--ink, #1a1a1a);
}
.booking-key-row.row-primary .booking-key-value {
    font-size: 28px;
}
.booking-key-value.tier-green { color: var(--success, #228b22); }
.booking-key-value.tier-yellow { color: var(--gold, #b8860b); }
.booking-key-value.tier-red { color: var(--danger, #c33); }
.booking-key-row.row-summary {
    background: var(--bg-sunken, #f5f5f5);
}

/* ============================================================
   Mobil: krymp Cadens-konfetti-state
   ============================================================ */
@media (max-width: 768px) {
    .cadens-empty-celebrate {
        padding: 18px !important;
    }
    .cadens-empty-celebrate > div:first-child {
        font-size: 28px !important;
        margin-bottom: 4px !important;
    }
    .cadens-empty-celebrate p {
        font-size: 14px;
        line-height: 1.4;
    }
}

/* ============================================================
   Tomma rader i timeline: hantera via kompakta paragrafer
   ============================================================ */
.timeline-body p {
    margin: 0;
    padding: 0;
}
.timeline-body p + p {
    margin-top: 0.6em; /* mellan stycken — mindre än en hel tom rad */
}

/* ============================================================
   Mobil: Bokningsnyckeln — kompaktare layout
   ============================================================ */
@media (max-width: 768px) {
    /* Padding krymps */
    .booking-key-row {
        padding: 12px 14px;
    }
    .booking-key-row.row-primary {
        padding: 14px 14px;
    }
    
    /* Värdet (X / Y) tvingas på en rad */
    .booking-key-value {
        font-size: 18px !important;
        white-space: nowrap;
        flex-shrink: 0;
        margin-left: 12px;
    }
    .booking-key-row.row-primary .booking-key-value {
        font-size: 22px !important;
    }
    
    /* Labels får mindre font så de wrappar mindre */
    .booking-key-label {
        font-size: 13px;
        line-height: 1.3;
    }
    .booking-key-row.row-primary .booking-key-label {
        font-size: 14px;
    }
    
    /* Den lilla under-texten ("sedan måndag", "Mål ✓") behåller liten font */
    .booking-key-row .text-sm {
        font-size: 11px !important;
    }
}
