@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,200..800;1,200..800&display=swap');
/* Strezia Serviceportal – stilmall
   Ordning: tokens → reset → typografi → primitiv → komponenter → vyer → responsivt
*/

:root {
    --font-display: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --font-sans: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --font-mono: 'Courier New', Courier, monospace;

    /* Färgerna tagna ur strezia.com: svart #241F20, cremevitt #F8F8F0/#F3EFE6,
       aprikos #F4A469 och varmgrått #6F6659. */
    --bg: #F8F8F0;
    --bg-1: #F8F8F0;
    --bg-2: #F3EFE6;
    --bg-3: #EBE6D9;
    --surface: #FFFFFF;
    --surface-2: #F6F3EA;
    --surface-3: #EFEADF;
    --ink: #241F20;
    --ink-2: #4C4641;
    --ink-3: #6F6659;
    --ink-4: #A9A296;
    --border: #E4DFD2;
    --border-strong: #CEC7B6;

    /* Accent = sajtens svarta knapp med cremevit text */
    --accent: #241F20;
    --accent-hover: #000000;
    --accent-soft: #F3EFE6;
    --accent-ink: #8A5220;

    /* Aprikosen används där något är valt eller ska dra blicken */
    --highlight: #F4A469;
    --highlight-strong: #D9843F;
    --highlight-soft: #FDF1E4;

    --ok: #199E70;

    /* Prioritetsfärger — varma toner som lever med paletten */
    --p1: #B43A2B; --p1-soft: #FBEAE6;
    --p2: #D97706; --p2-soft: #FDF1E4;
    --p3: #6F6659; --p3-soft: #F3EFE6;
    --p4: #A9A296; --p4-soft: #F8F8F0;

    --info: #2A78D6; --info-soft: #EDF3FC;

    --shadow-sm: 0 1px 2px rgba(36,31,32,0.05);
    --shadow-md: 0 2px 8px rgba(36,31,32,0.06), 0 1px 2px rgba(36,31,32,0.04);
    --shadow-lg: 0 12px 32px rgba(36,31,32,0.10), 0 2px 8px rgba(36,31,32,0.05);

    --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-ink); }
.auth-foot a:hover { text-decoration: underline; }
/* Inloggning med kod: samma ruta som Strezia Portal */
.auth-card-wide { max-width: 920px; padding: 40px 44px; }
.auth-brand-center { flex-direction: column; justify-content: center; gap: 10px; margin-bottom: 26px; }
.auth-eyebrow {
    font-family: var(--font-sans); font-size: 11px; font-weight: 500;
    color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.18em;
}
.auth-eyebrow-left { display: block; margin-bottom: 6px; letter-spacing: 0.14em; font-size: 10px; }
.auth-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 44px; align-items: center; }
.auth-main .auth-lead { margin-bottom: 18px; }
.auth-small { margin-top: 14px; font-size: 12.5px; line-height: 1.55; color: var(--ink-3); }
.auth-small a { color: var(--accent-ink); }
.auth-info {
    background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 20px 22px;
}
.auth-info h2 { font-family: var(--font-display); font-size: 19px; font-weight: 500; line-height: 1.3; margin: 0 0 10px; }
.auth-features { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.auth-features li { display: flex; align-items: center; gap: 9px; font-size: 13.5px; line-height: 1.4; color: var(--ink-2); }
.auth-features li span {
    flex-shrink: 0; width: 16px; height: 16px; border-radius: 50%; background: var(--ink); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
}
.auth-title-center, .auth-lead-center { text-align: center; }
.form input.auth-kod {
    font-size: 26px; letter-spacing: 0.4em; text-align: center;
    font-family: ui-monospace, Menlo, Monaco, monospace;
}
@media (max-width: 720px) {
    .auth-card-wide { padding: 28px 22px; }
    .auth-layout { grid-template-columns: 1fr; gap: 24px; }
}

.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-ink); 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); }

/* KPI-korten på Kvalitetsenkäter. Klasserna användes i vyn men fanns aldrig i
   stilmallen, så siffrorna radade upp sig som brödtext utan kort eller rubrik.
   Samma formspråk som .stat-card, men i ett rutnät som anpassar sig efter
   antalet kort i stället för fasta fyra. */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 14px; }
.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 16px 18px 14px;
    display: flex; flex-direction: column; gap: 3px;
}
.kpi-label {
    font-size: 11px; font-weight: 600; letter-spacing: 0.07em;
    text-transform: uppercase; color: var(--ink-3);
}
.kpi-value {
    font-family: var(--font-display);
    font-size: 32px; font-weight: 400; letter-spacing: -0.02em; line-height: 1.1;
}
@media (max-width: 720px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .kpi-card { padding: 13px 14px 12px; }
    .kpi-value { font-size: 25px; }
}
@media (max-width: 420px) {
    .kpi-grid { grid-template-columns: 1fr; }
}
.stat-trend.up { color: var(--p1); }
.stat-trend.good { color: var(--ok); }

.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(--highlight); color: var(--ink); border-color: var(--highlight-strong); font-weight: 600; }
.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; }

    /* Tabellrutan klippte tidigare bort allt som inte fick plats (overflow:hidden),
       så på en telefon gick de sista kolumnerna helt enkelt inte att nå. Nu
       scrollar den i sidled i stället. */
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .data-table { min-width: 480px; }
    .search { display: none; }
    .page-title { font-size: 24px; }
    .stat-value { font-size: 28px; }
    .col-hide-sm { display: none !important; }
    .data-table th, .data-table td { padding: 12px 12px; }
    .form .form-row { grid-template-columns: 1fr; }
}

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

    /* Hyresgästens och skötarens topprad — namn och länkar fick inte plats
       på en telefon och bröt sig över logotypen. */
    .t-header { flex-wrap: wrap; gap: 6px 10px; padding: 12px 16px 10px; }
    .t-user { width: 100%; justify-content: flex-start; gap: 8px; }
    .t-user-info { text-align: left; }
    .t-user-name { font-size: 13px; }
    .t-user-meta { font-size: 11px; }
    .t-brand-sub { display: none; }

    /* Knappraden i formulären: stapla i stället för att klämma ihop.
       Den primära knappen först och bred, resten under. */
    .form-actions { flex-direction: column; align-items: stretch; gap: 8px; }
    .form-actions .btn { width: 100%; justify-content: center; }
}

/* Rutnät i formulär som ska stapla på telefon.
   Låg tidigare som inline-styles i besiktningsformuläret, vilket gjorde dem
   omöjliga att bryta i en mediefråga — tre kolumner klämdes ihop på en
   mobilskärm precis där man som mest behöver kunna skriva. */
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.grid-rum { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; }

@media (max-width: 720px) {
    .grid-3, .grid-2 { grid-template-columns: 1fr; }
    .grid-rum { grid-template-columns: 1fr; align-items: stretch; }
    .grid-rum .btn { width: 100%; justify-content: center; }

    /* "Kopiera från tidigare besiktning" låg som en enda flexrad med ikon, text
       och ett formulär bredvid varandra — tillsammans bredare än en telefon, så
       hela sidan gick att dra i sidled. Staplas nu. */
    .insp-kopiera { flex-wrap: wrap; margin-left: 18px !important; margin-right: 18px !important; padding: 12px 14px !important; }
    .insp-kopiera-form { width: 100%; }
    .insp-kopiera-form select { flex: 1; min-width: 0; font-size: 16px !important; padding: 11px 12px !important; }
    .insp-kopiera-form .btn { padding: 11px 14px; }

    /* Fingerstorlek på fält man fyller i ute i en lägenhet. 16px hindrar
       dessutom iOS från att zooma in vid fokus. */
    .form input, .form select, .form textarea,
    .rum-rad input, .rum-rad select, .rum-rad textarea {
        font-size: 16px;
        padding: 11px 12px;
    }
}

/* 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(--highlight-strong);
    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);
    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);
    color: var(--ink-3, #6e6960);
    border: 1px solid var(--border-strong);
    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);
    color: white;
    border-color: var(--accent);
    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: visa förklaringen som ett fält längst ned i vyn.
   Tidigare låg tooltipen absolut placerad bredvid bubblan, vilket sköt ut
   sidan i sidled (den tar plats även när den är osynlig). */
@media (max-width: 720px) {
    .help-bubble::after,
    .help-bubble::before {
        display: none;
    }
    .help-bubble.open::after {
        display: block;
        position: fixed;
        left: 16px;
        right: 16px;
        bottom: 16px;
        top: auto;
        width: auto;
        max-width: none;
        transform: none;
        font-size: 14px;
        padding: 14px 16px;
        box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    }
}

/* === 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;
}


/* ============ MOBILANPASSNING (sept 2026) ============ */
/* Sidopadding som klass i stället för inline-style — en mediefråga kan
   aldrig bryta en inline-style. */
.sida-pad { padding: 16px 32px; }

@media (max-width: 720px) {
    .sida-pad { padding: 14px 16px; }

    /* Knappar med långa etiketter fick tidigare skjuta ut sidan i sidled */
    .btn { white-space: normal; }

    /* Skötarens topprad: hälsning + fyra knappar fick inte plats på en rad */
    .w-header { flex-wrap: wrap; gap: 10px; padding: 16px 18px 12px; }
    .w-header > div { min-width: 0; }
    .w-header > div:last-child { flex-wrap: wrap; }

    /* Tvåkolumnsvyer (underhåll, nycklar): 1fr utgår från innehållets
       minsta bredd, minmax(0,1fr) låter kolumnen krympa på riktigt */
    .show-grid { grid-template-columns: minmax(0, 1fr) !important; }
    .show-grid > * { min-width: 0; }
}

/* Flikar i hyresgastvyn: pagaende arenden forst, tidigare bakom en flik */
.t-tabs {
    display: flex;
    gap: 6px;
    padding: 0 20px 14px;
}
.t-tab {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 16px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--ink-2);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: all .15s ease;
}
.t-tab:hover { border-color: var(--border-strong); color: var(--ink); }
.t-tab.aktiv {
    background: var(--highlight);
    border-color: var(--highlight-strong);
    color: var(--ink);
    font-weight: 600;
}
.t-tab-antal {
    font-family: var(--font-mono);
    font-size: 12px;
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--bg-2);
    color: var(--ink-3);
}
.t-tab.aktiv .t-tab-antal {
    background: rgba(36,31,32,0.14);
    color: var(--ink);
}

/* Delad in-korg för skötare i bolag utan arbetsledare */
.w-order-otagen {
    display: flex;
    align-items: stretch;
    gap: 0;
    border-left: 3px solid var(--highlight-strong);
    padding: 0;
}
.w-order-otagen .w-order-lank {
    display: flex;
    gap: 14px;
    flex: 1;
    min-width: 0;
    padding: 14px 16px;
    text-decoration: none;
    color: inherit;
}
.w-order-ta {
    display: flex;
    align-items: center;
    margin: 0;
    padding: 0 14px 0 0;
    flex-shrink: 0;
}
@media (max-width: 560px) {
    .w-order-otagen { flex-direction: column; }
    .w-order-ta { padding: 0 16px 14px; }
    .w-order-ta .btn { width: 100%; }
}
