/* Strezia Serviceportal – stilmall
   Ordning: tokens → reset → typografi → primitiv → komponenter → vyer → responsivt
*/

:root {
    --font-display: Arial, Helvetica, sans-serif;
    --font-sans: Arial, Helvetica, sans-serif;
    --font-mono: 'Courier New', Courier, monospace;

    /* Färger matchade mot strezia.com — vit business-look, neutrala gråtoner */
    --bg: #FFFFFF;
    --surface: #FFFFFF;
    --surface-2: #F7F7F7;
    --surface-3: #EFEFEF;
    --ink: #1A1A1A;
    --ink-2: #4A4A4A;
    --ink-3: #7A7A7A;
    --ink-4: #B0B0B0;
    --border: #E5E5E5;
    --border-strong: #CCCCCC;

    /* Accent — Strezias mörka grön behålls för fastighetsbrand-kopplingen */
    --accent: #2D4A3E;
    --accent-hover: #243B32;
    --accent-soft: #EEF3F0;
    --accent-ink: #1F3329;

    /* Prioritetsfärger neutraliserade — mindre orange/brun, mer business */
    --p1: #B43A2B; --p1-soft: #FBEAE6;
    --p2: #D97706; --p2-soft: #FEF3C7;
    --p3: #6B7280; --p3-soft: #F3F4F6;
    --p4: #9CA3AF; --p4-soft: #F9FAFB;

    --info: #2563EB; --info-soft: #EFF6FF;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.03);
    --shadow-lg: 0 12px 32px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.04);

    --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 22px; --r-full: 999px;
}

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

html, body {
    font-family: var(--font-sans);
    font-size: 15px;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
    min-height: 100vh;
}

button { font-family: inherit; font-size: inherit; color: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
ul, ol { list-style: none; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* ============ PRIMITIVES ============ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 16px;
    border-radius: var(--r-md);
    font-weight: 500;
    font-size: 14px;
    transition: all .15s ease;
    white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #F5F0E6; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--ink-3); }
.btn-ghost { color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-danger { background: var(--p1); color: #FBEAE6; }
.btn-danger:hover { filter: brightness(0.9); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-icon { padding: 8px; }
.btn-block { width: 100%; }

.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px;
    border-radius: var(--r-full);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
    white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.7; }
.badge.no-dot::before { display: none; }
.badge.p1 { background: var(--p1-soft); color: var(--p1); }
.badge.p2 { background: var(--p2-soft); color: var(--p2); }
.badge.p3 { background: var(--p3-soft); color: var(--p3); }
.badge.p4 { background: var(--p4-soft); color: var(--p4); }
.badge.status-ny { background: var(--info-soft); color: var(--info); }
.badge.status-tilldelad { background: #fef3c7; color: #78350f; }
.badge.status-pagar { background: var(--accent-soft); color: var(--accent-ink); }
.badge.status-vantar { background: var(--p3-soft); color: var(--p3); }
.badge.status-klart { background: var(--p4-soft); color: var(--p4); }

.alert { padding: 12px 16px; border-radius: var(--r-md); font-size: 14px; margin-bottom: 16px; }
.alert-error { background: var(--p1-soft); color: var(--p1); border: 1px solid #F5C6BD; }
.alert-success { background: var(--accent-soft); color: var(--accent-ink); border: 1px solid #C9DCCC; }
.alert-info { background: var(--info-soft); color: var(--info); border: 1px solid #C5D8E7; }

.mono { font-family: var(--font-mono); font-size: 0.9em; }

.icon { width: 18px; height: 18px; flex-shrink: 0; stroke-width: 2; }
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 22px; height: 22px; }

/* ============ AVATAR ============ */
.avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--accent);
    color: #F5F0E6;
    display: flex; align-items: center; justify-content: center;
    font-weight: 500;
    font-size: 14px;
    flex-shrink: 0;
}
.avatar.sm { width: 28px; height: 28px; font-size: 12px; }
.avatar.lg { width: 48px; height: 48px; font-size: 16px; }

/* ============ FORMS ============ */
.form { display: flex; flex-direction: column; gap: 16px; }
.form fieldset { border: none; display: flex; flex-direction: column; gap: 12px; padding: 16px 0 0; }
.form fieldset + fieldset { border-top: 1px solid var(--border); }
.form legend {
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--ink-3); font-weight: 500; margin-bottom: 8px;
}
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-2); font-weight: 500; }
.form label .opt { color: var(--ink-3); font-weight: 400; font-size: 12px; }
.form input[type=text], .form input[type=email], .form input[type=password],
.form input[type=tel], .form input[type=date], .form select, .form textarea {
    border: 1px solid var(--border-strong);
    background: var(--surface);
    border-radius: var(--r-md);
    padding: 10px 14px;
    font-size: 15px;
    color: var(--ink);
    transition: border-color .15s, box-shadow .15s;
    width: 100%;
}
.form input:focus, .form select:focus, .form textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.form textarea { resize: vertical; min-height: 100px; line-height: 1.5; }
.form .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form .form-check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; color: var(--ink); }
.form-actions { display: flex; gap: 10px; padding-top: 8px; }

/* ============ AUTH PAGES ============ */
.auth-page {
    min-height: 100vh;
    background: var(--bg);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 36px 32px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-md);
}
.auth-brand {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 28px;
}
.auth-logo { height: 28px; width: auto; }
.auth-sub {
    font-family: var(--font-sans);
    font-size: 11px;
    font-weight: 500;
    color: var(--ink-3);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding-left: 12px;
    border-left: 1px solid var(--border-strong);
}
.auth-title {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 400;
    letter-spacing: -0.015em;
    margin-bottom: 8px;
}
.auth-lead { color: var(--ink-2); margin-bottom: 22px; font-size: 14px; line-height: 1.55; }
.auth-foot { margin-top: 22px; text-align: center; font-size: 13px; color: var(--ink-2); }
.auth-foot a { color: var(--accent); }
.auth-foot a:hover { text-decoration: underline; }

.setup-list { margin: 16px 0 24px; font-size: 14px; }
.setup-list li {
    padding: 8px 0; border-bottom: 1px solid var(--border);
    color: var(--ink-2);
    display: flex; align-items: baseline; gap: 8px;
}
.setup-list li::before { content: '✓'; color: var(--accent); font-weight: bold; }

/* ============ APP SHELL ============ */
.app {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}
.app.no-sidebar { grid-template-columns: 1fr; }

.sidebar {
    background: var(--surface-2);
    border-right: 1px solid var(--border);
    padding: 20px 14px;
    position: sticky; top: 0;
    height: 100vh;
    overflow-y: auto;
    display: flex; flex-direction: column;
}
.side-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 4px 4px 24px;
}
.side-logo { height: 22px; width: auto; }
.side-tag {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--ink-3);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 2px 7px;
    background: var(--surface-3);
    border-radius: var(--r-sm);
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 10px;
    border-radius: var(--r-md);
    color: var(--ink-2);
    font-size: 14px; font-weight: 500;
    transition: all .12s;
    position: relative;
}
.nav-item:hover { background: var(--surface-3); color: var(--ink); }
.nav-item.active { background: var(--ink); color: var(--bg); }
.nav-item.active .nav-count { background: rgba(245,240,230,0.15); color: var(--bg); }

/* Custom tooltips på sidofältsmenyn — positionerade dynamiskt via JS */
.tooltip-floating {
    position: fixed;
    background: #1a1a1a;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.4;
    max-width: 260px;
    white-space: normal;
    pointer-events: none;
    box-shadow: 0 4px 16px rgba(0,0,0,0.18);
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.15s ease-out;
}
.tooltip-floating.visible { opacity: 1; }
.tooltip-floating::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-right-color: #1a1a1a;
}

/* Stäng av tooltips på touch-enheter */
@media (hover: none) {
    .tooltip-floating { display: none !important; }
}
.nav-left { display: flex; align-items: center; gap: 10px; }
.nav-count {
    font-family: var(--font-mono);
    font-size: 11px;
    background: var(--surface-3);
    color: var(--ink-2);
    padding: 1px 7px;
    border-radius: var(--r-full);
}
.side-foot {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    display: flex; align-items: center; gap: 10px;
}
.side-foot-info { font-size: 13px; line-height: 1.3; min-width: 0; flex: 1; }
.side-foot-name { font-weight: 500; }
.side-foot-org { color: var(--ink-3); font-size: 12px; }
.side-foot a.logout { color: var(--ink-3); padding: 6px; }
.side-foot a.logout:hover { color: var(--p1); }

.main { background: var(--bg); min-width: 0; }

/* Topbar (in main) */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 22px 32px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    position: sticky; top: 0; z-index: 8;
    flex-wrap: wrap; gap: 14px;
}
.page-title {
    font-family: var(--font-display);
    font-size: 30px;
    font-weight: 400;
    letter-spacing: -0.02em;
}
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.search {
    display: flex; align-items: center; gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    padding: 7px 12px;
    width: 260px;
}
.search input { border: none; outline: none; background: transparent; flex: 1; font-size: 14px; }
.search svg { color: var(--ink-3); }

/* ============ TENANT SHELL (no sidebar) ============ */
.t-shell {
    max-width: 720px;
    margin: 0 auto;
    min-height: 100vh;
}
.t-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    position: sticky; top: 0; z-index: 10;
}
.t-brand {
    display: flex; align-items: center; gap: 10px;
}
.t-brand-logo { height: 22px; width: auto; }
.t-brand-sub {
    font-family: var(--font-sans);
    font-size: 10px;
    font-weight: 500;
    color: var(--ink-3);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding-left: 10px;
    border-left: 1px solid var(--border-strong);
}
.t-user { display: flex; align-items: center; gap: 10px; }
.t-user-info { display: flex; flex-direction: column; line-height: 1.2; text-align: right; }
.t-user-name { font-weight: 500; font-size: 14px; }
.t-user-meta { font-size: 12px; color: var(--ink-3); }

.t-page-title {
    padding: 28px 20px 8px;
    font-family: var(--font-display);
    font-size: 32px;
    font-weight: 400;
    letter-spacing: -0.02em;
    line-height: 1.1;
}
.t-page-sub { padding: 0 20px 22px; color: var(--ink-2); font-size: 14px; }

.t-cases { padding: 0 20px 100px; display: flex; flex-direction: column; gap: 10px; }
.t-case-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 16px 18px;
    transition: all .15s;
    display: flex; flex-direction: column; gap: 10px;
}
.t-case-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.t-case-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.t-case-num { font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); }
.t-case-title { font-size: 16px; font-weight: 500; line-height: 1.35; }
.t-case-meta { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-2); flex-wrap: wrap; }
.t-case-meta-sep { color: var(--ink-4); }
.t-case-unread {
    background: var(--accent);
    color: #F5F0E6;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: var(--r-full);
    font-family: var(--font-mono);
}

.t-fab {
    position: fixed;
    bottom: 24px; right: 20px;
    background: var(--ink);
    color: var(--bg);
    padding: 14px 22px;
    border-radius: var(--r-full);
    font-weight: 500;
    font-size: 14px;
    box-shadow: var(--shadow-lg);
    display: flex; align-items: center; gap: 8px;
    transition: transform .15s, background .15s;
    z-index: 20;
}
.t-fab:hover { background: #2A2622; transform: translateY(-2px); }

/* Detail hero */
.detail-hero { padding: 22px 20px 18px; border-bottom: 1px solid var(--border); }
.detail-badges { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.detail-title {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 400;
    letter-spacing: -0.015em;
    line-height: 1.2;
    margin-bottom: 14px;
}
.meta-grid {
    display: grid; grid-template-columns: auto 1fr;
    gap: 8px 16px;
    font-size: 13px;
    color: var(--ink-2);
}
.meta-grid dt { color: var(--ink-3); }
.meta-grid dd { color: var(--ink); }

.detail-header {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    position: sticky; top: 0; z-index: 5;
}
.back-btn {
    width: 36px; height: 36px;
    border-radius: var(--r-md);
    display: flex; align-items: center; justify-content: center;
    color: var(--ink-2);
}
.back-btn:hover { background: var(--surface-2); color: var(--ink); }
.detail-num { font-family: var(--font-mono); font-size: 14px; color: var(--ink-2); }

/* Photos */
.photos { display: flex; gap: 8px; padding: 16px 20px 0; overflow-x: auto; }
.photo {
    width: 96px; height: 96px;
    border-radius: var(--r-md);
    background: var(--surface-3);
    flex-shrink: 0;
    object-fit: cover;
    border: 1px solid var(--border);
}

/* ============ THREAD (chat + status events) ============ */
.thread { padding: 24px 20px; display: flex; flex-direction: column; gap: 14px; padding-bottom: 100px; }

.day-mark {
    display: flex; align-items: center; gap: 12px;
    font-size: 12px;
    color: var(--ink-3);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-family: var(--font-mono);
    margin: 8px 0;
}
.day-mark::before, .day-mark::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.system-msg {
    font-size: 13px;
    color: var(--ink-3);
    text-align: center;
    padding: 4px 12px;
    align-self: center;
    max-width: 80%;
}
.system-msg strong { color: var(--ink-2); font-weight: 500; }

.msg { display: flex; flex-direction: column; gap: 4px; max-width: 82%; }
.msg.me { align-self: flex-end; align-items: flex-end; }
.msg.them { align-self: flex-start; }
.msg-from { font-size: 12px; color: var(--ink-3); padding: 0 4px; }
.msg-bubble {
    padding: 10px 14px;
    border-radius: var(--r-lg);
    font-size: 14.5px;
    line-height: 1.45;
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.msg.me .msg-bubble { background: var(--accent); color: #F5F0E6; border-bottom-right-radius: 4px; }
.msg.them .msg-bubble { background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg-time { font-size: 11px; color: var(--ink-4); padding: 0 4px; font-family: var(--font-mono); }

/* Composer */
.composer {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--bg);
    border-top: 1px solid var(--border);
    padding: 12px 20px 16px;
    z-index: 35;
}
.composer-inner { max-width: 720px; margin: 0 auto; display: flex; align-items: flex-end; gap: 8px; }
.composer.in-panel { position: sticky; bottom: 0; padding: 12px 24px 18px; }
.composer.in-panel .composer-inner { max-width: none; }
.input-wrap {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-xl);
    padding: 10px 14px;
    display: flex; align-items: center; gap: 8px;
    transition: border-color .15s;
}
.input-wrap:focus-within { border-color: var(--accent); }
.input-wrap textarea {
    flex: 1; border: none; outline: none; background: transparent;
    resize: none; font-size: 15px; line-height: 1.4;
    max-height: 120px; padding: 2px 0;
}
.attach-btn { color: var(--ink-3); padding: 4px; }
.attach-btn:hover { color: var(--ink); }
.send-btn {
    background: var(--accent); color: #F5F0E6;
    width: 42px; height: 42px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    transition: all .15s;
}
.send-btn:hover { background: var(--accent-hover); }
.composer-opts { display: flex; gap: 14px; margin-top: 10px; font-size: 12px; color: var(--ink-3); max-width: 720px; margin-left: auto; margin-right: auto; }
.composer-opts label { display: flex; align-items: center; gap: 6px; cursor: pointer; }

/* ============ MANAGER STATS / TABLE ============ */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; padding: 22px 32px; }
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 18px 18px 16px;
    display: flex; flex-direction: column; gap: 4px;
}
.stat-label { font-size: 12px; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 500; }
.stat-value {
    font-family: var(--font-display);
    font-size: 36px;
    font-weight: 400;
    letter-spacing: -0.02em;
    line-height: 1.1;
}
.stat-trend { font-size: 12px; color: var(--ink-3); }
.stat-trend.up { color: var(--p1); }
.stat-trend.good { color: var(--accent); }

.filters { display: flex; gap: 6px; padding: 0 32px 14px; flex-wrap: wrap; }
.filter {
    padding: 6px 14px;
    border-radius: var(--r-full);
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--ink-2);
    font-size: 13px;
    font-weight: 500;
    transition: all .12s;
    display: inline-flex; align-items: center; gap: 6px;
}
.filter:hover { border-color: var(--border-strong); color: var(--ink); }
.filter.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.filter-count { font-family: var(--font-mono); font-size: 11px; opacity: 0.7; }

.table-wrap {
    margin: 0 32px 32px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
}
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead { background: var(--surface-2); }
.data-table th {
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-3);
    font-weight: 500;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13.5px;
    vertical-align: middle;
}
.data-table tbody tr { transition: background .12s; }
.data-table tbody tr.linked { cursor: pointer; }
.data-table tbody tr.linked:hover { background: var(--surface-2); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .num { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-2); }
.data-table .title { font-weight: 500; }
.data-table .sub { color: var(--ink-3); font-size: 12px; margin-top: 2px; }
.data-table .age { font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); }

.empty-state {
    padding: 48px 24px;
    text-align: center;
    color: var(--ink-3);
}
.empty-state h3 {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 400;
    color: var(--ink-2);
    margin-bottom: 8px;
}
.empty-state p { font-size: 14px; margin-bottom: 20px; }

/* Detail panel (manager) */
.detail-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    margin: 0 32px 32px;
    overflow: hidden;
}
.detail-panel-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
}
.detail-panel-actions {
    padding: 14px 24px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    display: flex; gap: 8px; flex-wrap: wrap;
}
.detail-panel-body { padding: 22px 24px; }
.detail-desc {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 14px 16px;
    font-size: 14px;
    line-height: 1.55;
    margin-bottom: 22px;
}
.section-h {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-3);
    font-weight: 500;
    margin: 22px 0 12px;
}

/* ============ WORKER SHELL ============ */
.w-shell { max-width: 760px; margin: 0 auto; min-height: 100vh; }
.w-header {
    padding: 20px 22px 14px;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 10; background: var(--bg);
}
.w-greeting { font-family: var(--font-display); font-size: 24px; font-weight: 400; letter-spacing: -0.015em; }
.w-date { font-size: 13px; color: var(--ink-3); font-family: var(--font-mono); margin-top: 2px; }
.w-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 18px 22px; }
.w-stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 12px 14px; }
.w-stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-3); font-weight: 500; }
.w-stat-num { font-family: var(--font-display); font-size: 28px; font-weight: 400; letter-spacing: -0.02em; line-height: 1.1; margin-top: 4px; }
.w-stat-num.alert { color: var(--p1); }

.w-section-h {
    padding: 12px 22px 10px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-3);
    font-weight: 500;
}
.w-orders { padding: 0 22px 40px; display: flex; flex-direction: column; gap: 10px; }
.w-order {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 14px 16px;
    transition: all .15s;
    display: flex; gap: 14px;
}
.w-order:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.w-order-time {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding-right: 14px;
    border-right: 1px solid var(--border);
    min-width: 56px;
}
.w-order-time-h { font-family: var(--font-display); font-size: 20px; font-weight: 400; line-height: 1; }
.w-order-time-m { font-size: 12px; color: var(--ink-3); font-family: var(--font-mono); margin-top: 2px; }
.w-order-body { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.w-order-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.w-order-num { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); }
.w-order-title { font-size: 15px; font-weight: 500; line-height: 1.3; }
.w-order-addr { font-size: 13px; color: var(--ink-2); }

.w-action-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 16px 22px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}
.w-action {
    padding: 14px 10px;
    border-radius: var(--r-md);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    font-size: 13px;
    font-weight: 500;
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    transition: all .15s;
}
.w-action:hover { border-color: var(--ink); }
.w-action.active { background: var(--accent); color: #F5F0E6; border-color: var(--accent); }
.w-action.active svg { color: #F5F0E6; }
.w-action svg { color: var(--ink-2); }

/* ============ MOBILE MENU TOGGLE ============ */
.menu-btn { display: none; }

@media (max-width: 1024px) {
    .app { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        width: 260px;
        transform: translateX(-100%);
        transition: transform .25s;
        z-index: 50;
        box-shadow: var(--shadow-lg);
    }
    .sidebar.open { transform: translateX(0); }
    .menu-btn { display: flex; }
    .stats { grid-template-columns: repeat(2, 1fr); }
    .search { width: 180px; }
}

@media (max-width: 720px) {
    .topbar { padding: 16px 18px 14px; }
    .stats { padding: 16px 18px; }
    .filters { padding: 0 18px 12px; }
    .table-wrap, .detail-panel { margin-left: 18px; margin-right: 18px; }
    .search { display: none; }
    .page-title { font-size: 24px; }
    .stat-value { font-size: 28px; }
    .data-table .col-hide-sm { display: none; }
    .data-table th, .data-table td { padding: 12px 12px; }
    .form .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 540px) {
    .data-table .col-hide-xs { display: none; }
}

/* Plattformshantering — divider och PLATTFORM-tag */
.nav-divider {
    height: 1px;
    background: var(--border);
    margin: 12px 16px;
}
.nav-tag {
    display: inline-block;
    flex-shrink: 0;
    background: var(--accent);
    color: var(--bg-1);
    font-family: var(--font-mono);
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.08em;
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 10px;
    text-transform: uppercase;
}
/* Säkerställ minst 8px mellanrum mellan menyetiketten och eventuella taggar */
.nav-item { gap: 8px; }
.nav-left { min-width: 0; flex: 1 1 auto; white-space: nowrap; }

/* Footer i sidofältet — visa fullt namn på en rad. 260px sidebar har plats */
.side-foot-name,
.side-foot-org {
    white-space: nowrap;
}

/* Lösenordsfält med visa/dölj-öga */
.pw-wrap {
    position: relative;
    display: block;
    width: 100%;
}
.pw-wrap input[type="password"],
.pw-wrap input[type="text"] {
    padding-right: 44px;
    width: 100%;
}
.pw-toggle {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    color: var(--ink-3);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: color 0.1s, background 0.1s;
}
.pw-toggle:hover {
    color: var(--ink);
    background: var(--bg-2);
}
.pw-toggle:focus {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
    color: var(--ink);
}

/* === Chat-bilagor === */
.msg-bilagor {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.msg-bilaga-bild {
    display: block;
    border-radius: 8px;
    overflow: hidden;
    max-width: 220px;
    border: 1px solid var(--border);
    transition: transform 0.1s;
}
.msg-bilaga-bild:hover {
    transform: scale(1.02);
}
.msg-bilaga-bild img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 280px;
    object-fit: cover;
}
.msg-bilaga-fil {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--ink);
    text-decoration: none;
    font-size: 13px;
    max-width: 100%;
}
.msg-bilaga-fil:hover {
    background: var(--bg-3, #f0ebe2);
    border-color: var(--border-strong);
}
.msg-bilaga-fil .icon {
    color: var(--accent);
    flex-shrink: 0;
}
.msg-bilaga-fil span {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.msg-bilaga-fil strong {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.msg-bilaga-fil small {
    color: var(--ink-3);
    font-size: 11px;
    margin-top: 2px;
}

/* Composer attach-knapp */
.composer-attach-btn {
    background: none;
    border: none;
    color: var(--ink-3);
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.composer-attach-btn:hover {
    background: var(--bg-2);
    color: var(--accent);
}

/* Förhandsgranskning av valda filer i composer */
.composer-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px 0;
}
.composer-attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 16px;
    font-size: 12px;
    color: var(--ink);
}
.composer-attachment-chip .remove {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    color: var(--ink-3);
    display: flex;
    align-items: center;
}
.composer-attachment-chip .remove:hover {
    color: var(--p1);
}

/* === HJÄLP-BUBBLA (?) === */
.help-bubble {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--bg-2, #f3efe6);
    color: var(--ink-3, #6e6960);
    border: 1px solid var(--border-strong, #d4c9b3);
    font-size: 11px;
    font-weight: 700;
    cursor: help;
    margin-left: 4px;
    vertical-align: middle;
    position: relative;
    font-family: inherit;
    padding: 0;
    line-height: 1;
    transition: all 0.15s;
}
.help-bubble:hover,
.help-bubble:focus,
.help-bubble.open {
    background: var(--accent, #2d4a3e);
    color: white;
    border-color: var(--accent, #2d4a3e);
    outline: none;
}

/* Tooltip via ::after pseudo-element från data-help */
.help-bubble::after {
    content: attr(data-help);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    background: #1a1a1a;
    color: white;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.4;
    white-space: normal;
    width: 260px;
    max-width: 260px;
    text-align: left;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s, transform 0.15s;
    z-index: 10000;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
    /* Tillåt brytningar */
    word-break: break-word;
    overflow-wrap: break-word;
}

/* Liten pil under tooltipen */
.help-bubble::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #1a1a1a;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 10001;
}

.help-bubble:hover::after,
.help-bubble:focus::after,
.help-bubble.open::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.help-bubble:hover::before,
.help-bubble:focus::before,
.help-bubble.open::before {
    opacity: 1;
}

/* På mobil: rendera tooltipen åt höger om bubblan är nära vänsterkanten */
@media (max-width: 720px) {
    .help-bubble::after {
        width: 220px;
        max-width: calc(100vw - 32px);
        left: auto;
        right: 50%;
        transform: translateX(50%) translateY(4px);
    }
    .help-bubble.open::after {
        transform: translateX(50%) translateY(0);
    }
    /* Justera pilen på mobil */
    .help-bubble::before {
        left: 50%;
    }
}

/* === SPRINT 4: Intern/extern kommunikation tydligare === */
.msg-intern {
    border-left: 3px solid #d97706;
    padding-left: 12px;
    background: linear-gradient(to right, #fef3c7, transparent 60%);
    border-radius: 6px 6px 6px 0;
    margin-left: 12px;
}
.msg-intern-badge {
    display: inline-block;
    background: #d97706;
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 4px;
    white-space: nowrap;
}

/* Composer-väljare för internt/externt — tydligare visuell distinktion */
.composer-opts label {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px; border-radius: 6px;
    background: #f0fdf4; border: 1px solid #bbf7d0;
    transition: all 0.15s;
    cursor: pointer;
}
.composer-opts label:has(input:not(:checked)) {
    background: #fef3c7;
    border-color: #fde68a;
}
.composer-opts label:has(input:not(:checked))::after {
    content: ' 🔒 INTERN';
    font-size: 10px; font-weight: 700;
    color: #d97706;
    letter-spacing: 0.06em;
}
