/*
 ClientX Polish / Salgsklar v1
 Global UI layer for portal + admin. Uses tenant CSS variables from Theme.php.
*/
:root {
    --bg-color: #0f172a;
    --surface-color: #111827;
    --card-color: #1e293b;
    --text-color: #ffffff;
    --muted-text-color: #94a3b8;
    --primary-color: #2563eb;
    --primary-hover-color: #1d4ed8;
    --border-color: #334155;
    --success-color: #16a34a;
    --warning-color: #f59e0b;
    --danger-color: #dc2626;
    --button-text-color: #ffffff;
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 26px;
    --shadow-soft: 0 18px 55px rgba(0,0,0,.20);
    --shadow-card: 0 14px 36px rgba(0,0,0,.18);
    --glass: rgba(255,255,255,.07);
    --glass-strong: rgba(255,255,255,.105);
    --focus-ring: 0 0 0 3px rgba(96,165,250,.34);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, Helvetica, sans-serif;
    line-height: 1.5;
    text-rendering: geometricPrecision;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); }
::selection { background: rgba(96,165,250,.38); color: #fff; }

/* Public landing */
.public-body { background: radial-gradient(circle at top left, rgba(37,99,235,.22), transparent 35%), #07111f; color: #fff; }
.public-header { display: flex; align-items: center; justify-content: space-between; padding: 22px 6vw; border-bottom: 1px solid rgba(255,255,255,.1); backdrop-filter: blur(12px); }
.public-header nav { display: flex; flex-wrap: wrap; gap: 18px; color: rgba(255,255,255,.75); }
.public-header nav a:hover { color: #fff; }
.brand { font-weight: 900; font-size: 1.3rem; letter-spacing: .04em; }
.hero { padding: 90px 6vw; max-width: 1100px; margin: 0 auto; }
.hero.small { max-width: 760px; }
.hero h1 { font-size: clamp(2.2rem, 6vw, 5rem); line-height: .98; margin: 0 0 22px; letter-spacing: -.055em; }
.hero p { color: rgba(255,255,255,.76); font-size: 1.15rem; max-width: 760px; }

/* Base components */
.eyebrow, .dash-eyebrow {
    color: #60a5fa;
    text-transform: uppercase;
    letter-spacing: .16em;
    font-weight: 900;
    font-size: .74rem;
}
.actions, .dash-actions, .row-actions, .table-actions, .project-detail-actions, .calendar-nav-actions, .actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}
.actions { margin-top: 28px; }
.btn, .dash-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid rgba(255,255,255,.10);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    background: var(--primary-color, #2563eb);
    color: var(--button-text-color, #fff);
    font-weight: 900;
    cursor: pointer;
    line-height: 1.2;
    min-height: 42px;
    box-shadow: 0 10px 26px rgba(37,99,235,.20);
    transition: transform .14s ease, background .14s ease, border-color .14s ease, opacity .14s ease;
}
.btn:hover, .dash-btn:hover { transform: translateY(-1px); background: var(--primary-hover-color, #1d4ed8); }
.btn:active, .dash-btn:active { transform: translateY(0); }
.btn.secondary, .dash-btn:not(.primary), .btn.gray {
    background: var(--glass);
    color: var(--text-color, #fff);
    box-shadow: none;
}
.btn.secondary:hover, .dash-btn:not(.primary):hover { background: var(--glass-strong); }
.btn.danger, .btn.delete { background: var(--danger-color, #dc2626); color: #fff; }
.btn.warning { background: var(--warning-color, #f59e0b); color: #111827; }
.btn.success { background: var(--success-color, #16a34a); color: #fff; }
.btn.small, .dash-btn.small { padding: 8px 11px; border-radius: var(--radius-sm); font-size: .88rem; min-height: 34px; }
.btn[disabled], button[disabled] { opacity: .55; cursor: not-allowed; transform: none !important; }
.grid { display: grid; gap: 18px; }
.cards { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); padding: 0 6vw 70px; max-width: 1180px; margin: 0 auto; }
.card, .dash-card, .login-card {
    background: linear-gradient(180deg, color-mix(in srgb, var(--card-color, #1e293b) 92%, white 8%), var(--card-color, #1e293b));
    border: 1px solid color-mix(in srgb, var(--border-color, #334155) 76%, white 10%);
    border-radius: var(--radius-xl);
    padding: 22px;
    box-shadow: var(--shadow-card);
}
.card h2, .dash-card h2 { margin-top: 0; letter-spacing: -.025em; }
.card p, .dash-card p { color: var(--muted-text-color, rgba(255,255,255,.72)); }
.muted, .muted-text, .dash-subtitle, .hint { color: var(--muted-text-color, #94a3b8); }

/* Shell */
.portal-body {
    background:
        radial-gradient(circle at top right, color-mix(in srgb, var(--primary-color, #2563eb) 22%, transparent), transparent 34%),
        var(--bg-color, #0f172a);
    color: var(--text-color, #fff);
}
.admin-body {
    background:
        radial-gradient(circle at top left, rgba(37,99,235,.18), transparent 35%),
        #0b1020;
    color: #fff;
}
.portal-shell, .admin-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 292px minmax(0, 1fr);
}
.sidebar {
    background: color-mix(in srgb, var(--surface-color, #111827) 94%, black 6%);
    border-right: 1px solid var(--border-color, #334155);
    padding: 22px;
    position: sticky;
    top: 0;
    align-self: start;
    min-height: 100vh;
    max-height: 100vh;
    overflow-y: auto;
}
.admin-sidebar { background: #090d18; }
.tenant-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.tenant-logo strong { display: block; line-height: 1.15; }
.tenant-logo small { display: block; color: var(--muted-text-color, rgba(255,255,255,.55)); margin-top: 2px; }
.tenant-logo img { width: 46px; height: 46px; object-fit: contain; border-radius: 12px; }
.tenant-logo-large img { width: 54px; height: 54px; }
.side-nav { display: grid; gap: 7px; }
.side-nav a {
    color: var(--muted-text-color, rgba(255,255,255,.72));
    padding: 11px 12px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    font-weight: 780;
    transition: background .14s ease, color .14s ease, border-color .14s ease;
}
.side-nav a:hover { background: var(--glass); color: var(--text-color, #fff); }
.side-nav a.active { background: color-mix(in srgb, var(--primary-color, #2563eb) 28%, transparent); color: #fff; border-color: color-mix(in srgb, var(--primary-color, #2563eb) 45%, white 8%); }
.portal-main { padding: clamp(20px, 3vw, 38px); min-width: 0; }
.page-header, .tenant-page-header { margin-bottom: 24px; }
.page-header h1, .tenant-page-header h1 { margin: 0 0 8px; font-size: clamp(1.8rem, 4vw, 3rem); line-height: 1.05; letter-spacing: -.045em; }
.page-header p, .tenant-page-header p { margin: 0; color: var(--muted-text-color, rgba(255,255,255,.7)); }

/* Login */
.login-wrap, .tenant-login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.tenant-login-wrap { background: radial-gradient(circle at top right, color-mix(in srgb, var(--primary-color, #2563eb) 28%, transparent), transparent 34%), var(--bg-color, #0f172a); }
.login-card { width: min(450px, 100%); padding: 30px; box-shadow: 0 24px 70px rgba(0,0,0,.35); }
.login-logo { max-height: 64px; width: auto; margin-bottom: 20px; }
.login-card h1 { margin: 0 0 8px; }
.login-card p, .login-card small { color: var(--muted-text-color, #94a3b8); }
.login-card label { display: block; margin-top: 16px; margin-bottom: 6px; font-weight: 800; }
.login-card input { width: 100%; border: 1px solid var(--border-color, #334155); background: rgba(0,0,0,.18); color: var(--text-color, #fff); border-radius: var(--radius-md); padding: 13px 14px; }
.login-card button { width: 100%; margin-top: 20px; }

/* Forms */
.form-grid { display: grid; gap: 14px; }
.form-grid.columns { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); align-items: end; }
.form-grid label, .compact-form label { display: grid; gap: 6px; font-weight: 850; color: var(--text-color, #fff); }
.form-grid small, .compact-form small { color: var(--muted-text-color, rgba(255,255,255,.62)); font-weight: 500; }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--border-color, rgba(255,255,255,.16));
    background: rgba(0,0,0,.20);
    color: var(--text-color, #fff);
    border-radius: var(--radius-md);
    padding: 11px 12px;
    min-height: 42px;
}
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--border-color, #334155) 60%, white 20%); }
input:focus, select:focus, textarea:focus { border-color: var(--primary-color, #2563eb); }
select option { color: #111827; }
.admin-body input, .admin-body select, .admin-body textarea { color: #fff; }
.admin-body select option { color: #111827; }
textarea { min-height: 90px; resize: vertical; }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: auto; accent-color: var(--primary-color, #2563eb); }
input[type="color"] { min-height: 44px; padding: 3px; }
.full-span { grid-column: 1 / -1; }
.checkbox-line, .checkbox-row { display: flex !important; align-items: center; gap: 10px; }
.checkbox-line input, .checkbox-row input { width: auto; }
.checkbox-options, .checkbox-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.checkbox-options label, .check-card {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 13px 14px;
    border-radius: var(--radius-lg);
    background: var(--glass);
    border: 1px solid rgba(255,255,255,.10);
    cursor: pointer;
}
.checkbox-options label:hover, .check-card:hover { background: var(--glass-strong); }
.inline-form, .inline-post-form { display: inline-flex; gap: 10px; align-items: center; margin: 0; }
.inline-form select { max-width: 420px; }
.filter-bar, .time-filter-bar, .activity-filter-grid, .calendar-filter-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; align-items: end; }

/* Alerts / empty states */
.alert {
    border-radius: var(--radius-lg);
    padding: 13px 15px;
    margin: 14px 0;
    border: 1px solid transparent;
    font-weight: 800;
    animation: alertIn .18s ease-out;
}
.alert.error { background: color-mix(in srgb, var(--danger-color, #dc2626) 18%, transparent); border-color: color-mix(in srgb, var(--danger-color, #dc2626) 45%, transparent); color: #fecaca; }
.alert.success { background: color-mix(in srgb, var(--success-color, #16a34a) 18%, transparent); border-color: color-mix(in srgb, var(--success-color, #16a34a) 45%, transparent); color: #bbf7d0; }
.alert.warning { background: color-mix(in srgb, var(--warning-color, #f59e0b) 18%, transparent); border-color: color-mix(in srgb, var(--warning-color, #f59e0b) 45%, transparent); color: #fde68a; }
.info-box, .dash-empty, .empty-state {
    background: var(--glass);
    border: 1px dashed color-mix(in srgb, var(--border-color, #334155) 78%, white 10%);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    color: var(--muted-text-color, #94a3b8);
}
.dash-empty { text-align: center; padding: 18px; }
@keyframes alertIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }

/* User chip */
.user-chip {
    color: rgba(255,255,255,.78);
    font-size: .9rem;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.08);
    padding: 10px 12px;
    border-radius: var(--radius-md);
    margin: -8px 0 22px;
}
.user-chip small { color: rgba(255,255,255,.56); }

/* Tables */
.table-card { margin-top: 8px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.section-heading h2, .section-heading h3 { margin: 0; }
.section-heading p { margin: 0; color: var(--muted-text-color, rgba(255,255,255,.7)); }
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius-lg); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; border-bottom: 1px solid var(--border-color, rgba(255,255,255,.12)); padding: 12px 10px; vertical-align: middle; }
th { color: var(--muted-text-color, rgba(255,255,255,.72)); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; white-space: nowrap; }
td { color: color-mix(in srgb, var(--text-color, #fff) 88%, var(--muted-text-color, #94a3b8)); }
td a { color: #93c5fd; font-weight: 850; }
tbody tr:hover { background: rgba(255,255,255,.035); }
.table-wrap input, .table-wrap select, .table-wrap textarea { min-width: 130px; }
.table-wrap textarea { min-width: 220px; }
.table-wrap form { display: contents; }

/* Badges and statuses */
.status-pill, .dash-badge, .activity-badge, .module-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 4px 10px;
    font-weight: 900;
    font-size: .78rem;
    line-height: 1.25;
    background: rgba(148,163,184,.18);
    color: #e2e8f0;
    white-space: nowrap;
}
.status-pill.active, .status-pill.godkjent, .status-pill.approved, .status-pill.done, .dash-badge.success, .activity-badge.success { background: color-mix(in srgb, var(--success-color, #16a34a) 22%, transparent); color: #bbf7d0; }
.status-pill.inactive, .status-pill.sent, .status-pill.sendt, .status-pill.planlagt, .status-pill.planned, .status-pill.waiting, .status-pill.venter, .dash-badge.warning { background: color-mix(in srgb, var(--warning-color, #f59e0b) 22%, transparent); color: #fde68a; }
.status-pill.suspended, .status-pill.locked, .status-pill.kansellert, .status-pill.cancelled, .status-pill.canceled, .status-pill.avslatt, .btn.danger + .status-pill { background: color-mix(in srgb, var(--danger-color, #dc2626) 22%, transparent); color: #fecaca; }
.status-pill.ferdig, .status-pill.completed { background: rgba(59,130,246,.20); color: #bfdbfe; }
.status-pill.arkivert, .status-pill.archived { background: rgba(100,116,139,.25); color: #cbd5e1; }

/* Layout helpers */
.compact-cards { padding: 0 0 24px; max-width: none; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.two-col { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); align-items: start; margin-bottom: 22px; }
.narrow-card { max-width: 680px; }
.tenant-dashboard-grid, .dashboard-grid, .project-detail-layout, .calendar-layout, .sja-layout, .time-layout, .offers-layout, .customer-layout, .project-layout, .files-layout { grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr); align-items: start; }
.tenant-stat-grid, .dash-stat-grid, .time-stat-grid { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stat-card span, .dash-stat .label { display: block; color: var(--muted-text-color, rgba(255,255,255,.68)); font-size: .85rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.stat-card strong, .dash-stat .value { display: block; font-size: clamp(1.7rem, 3.3vw, 2.35rem); margin-top: 6px; letter-spacing: -.04em; line-height: 1; }
.detail-list { display: grid; gap: 10px; }
.detail-list div { display: grid; grid-template-columns: minmax(120px, .35fr) 1fr; gap: 12px; padding-bottom: 10px; border-bottom: 1px solid rgba(255,255,255,.08); }
.detail-list dt, .detail-list strong { color: var(--muted-text-color, #94a3b8); font-weight: 850; }
.detail-list dd { margin: 0; }
.mini-list, .dash-list, .active-time-list, .project-note-list, .calendar-timeline, .activity-feed { display: grid; gap: 10px; }
.dash-item, .calendar-event-card, .project-note-card, .activity-item, .linked-offer-box, .field-summary-card, .project-file-card, .active-time-card {
    border-radius: var(--radius-lg);
    background: rgba(255,255,255,.055);
    border: 1px solid rgba(255,255,255,.09);
    padding: 13px 14px;
}
.dash-item:hover, .calendar-event-card:hover, .project-file-card:hover, .activity-item:hover { background: rgba(255,255,255,.075); }
.dash-item-title, .activity-title { font-weight: 900; }
.dash-item-meta, .activity-meta { color: var(--muted-text-color, #94a3b8); font-size: .9rem; margin-top: 3px; }

/* Admin specific */
.tenant-selector { margin-bottom: 22px; }
.logo-preview { min-height: 96px; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,.06); border: 1px dashed rgba(255,255,255,.22); border-radius: var(--radius-lg); padding: 16px; margin-bottom: 14px; }
.logo-preview img { max-height: 76px; width: auto; }
.palette-list { display: grid; gap: 10px; margin-top: 16px; }
.palette-row { display: flex; align-items: center; gap: 8px; padding: 10px; border-radius: var(--radius-lg); background: rgba(255,255,255,.05); }
.palette-row strong { min-width: 180px; }
.palette-row span { display: inline-block; width: 28px; height: 28px; border-radius: 999px; border: 1px solid rgba(255,255,255,.22); }
.color-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.color-input-row { display: grid; grid-template-columns: 54px 1fr; gap: 8px; }
.theme-preview { border: 1px solid; border-radius: var(--radius-lg); padding: 16px; }
.theme-preview > div { border-radius: var(--radius-lg); padding: 18px; }
.theme-preview button { border: 0; border-radius: var(--radius-md); padding: 11px 16px; font-weight: 900; }
.module-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }

/* Dashboard polish */
.dashboard-hero, .project-detail-hero, .calendar-hero, .activity-hero, .time-hero {
    border-radius: var(--radius-xl);
    padding: clamp(20px, 3vw, 34px);
    background: linear-gradient(135deg, color-mix(in srgb, var(--primary-color, #2563eb) 25%, var(--card-color, #1e293b)), var(--card-color, #1e293b));
    border: 1px solid color-mix(in srgb, var(--primary-color, #2563eb) 38%, var(--border-color, #334155));
    box-shadow: var(--shadow-soft);
}
.dash-title { margin: 0; font-size: clamp(2rem, 4vw, 3.3rem); line-height: 1.02; letter-spacing: -.055em; }
.dash-mini-calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin-top: 10px; }
.dash-day { min-height: 34px; border-radius: 10px; display: grid; place-items: center; background: rgba(255,255,255,.055); color: var(--muted-text-color, #94a3b8); font-size: .86rem; font-weight: 850; }
.dash-day.today { background: var(--primary-color, #2563eb); color: #fff; }
.dash-activity-icon, .activity-icon { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: color-mix(in srgb, var(--primary-color, #2563eb) 25%, transparent); flex: 0 0 auto; }
.activity-row, .activity-item { display: flex; gap: 12px; align-items: flex-start; }
.activity-message { color: var(--muted-text-color, #94a3b8); margin-top: 5px; }
.activity-badges { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.activity-badge.important { background: color-mix(in srgb, var(--primary-color, #2563eb) 22%, transparent); color: #bfdbfe; }

/* Files/projects */
.project-file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.project-file-thumb, .file-thumb { border-radius: var(--radius-md); overflow: hidden; background: rgba(0,0,0,.18); border: 1px solid rgba(255,255,255,.09); min-height: 118px; display: grid; place-items: center; color: var(--muted-text-color, #94a3b8); }
.project-file-thumb img, .file-thumb img { width: 100%; height: 130px; object-fit: cover; }
.file-title-cell { display: flex; align-items: center; gap: 10px; }
.file-title-cell .file-thumb { width: 54px; min-height: 42px; height: 42px; flex: 0 0 auto; }
.file-category-pills, .module-pill-list { display: flex; flex-wrap: wrap; gap: 8px; }
.project-description-box { background: var(--glass); border-radius: var(--radius-lg); padding: 14px; border: 1px solid rgba(255,255,255,.09); color: color-mix(in srgb, var(--text-color, #fff) 86%, var(--muted-text-color, #94a3b8)); }
.project-field-summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.project-status-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* Offers */
.offer-lines-head, .offer-line-row {
    display: grid;
    grid-template-columns: minmax(180px, 1.5fr) 85px 90px 120px 90px 110px 44px;
    gap: 8px;
    align-items: center;
}
.offer-lines-head { color: var(--muted-text-color, #94a3b8); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 900; margin: 12px 0 6px; }
.offer-line-row { padding: 10px; border-radius: var(--radius-lg); background: rgba(255,255,255,.045); border: 1px solid rgba(255,255,255,.08); margin-bottom: 8px; }
.offer-total-box { display: grid; gap: 8px; max-width: 380px; margin-left: auto; background: rgba(0,0,0,.16); border-radius: var(--radius-lg); border: 1px solid rgba(255,255,255,.1); padding: 14px; }
.offer-total-box div { display: flex; justify-content: space-between; gap: 14px; }
.offer-total-box .grand-total { border-top: 1px solid rgba(255,255,255,.12); padding-top: 8px; font-size: 1.15rem; font-weight: 950; }

/* SJA / Signatures */
.sja-check-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.sja-block { display: grid; gap: 12px; }
.sja-participants { display: grid; gap: 12px; }
.sja-participant-card { background: rgba(255,255,255,.055); border: 1px solid rgba(255,255,255,.09); border-radius: var(--radius-lg); padding: 14px; }
.sja-participant-top, .sja-signature-header, .signature-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.signature-pad-wrap { border: 1px dashed color-mix(in srgb, var(--border-color, #334155) 72%, white 12%); border-radius: var(--radius-lg); background: rgba(255,255,255,.04); padding: 10px; }
.signature-pad { width: 100%; height: 180px; background: rgba(255,255,255,.96); border-radius: var(--radius-md); touch-action: none; }
.clear-signature, .remove-participant { color: #fecaca; }

/* Time */
.time-participants { display: grid; gap: 10px; }
.active-time-card { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }

/* Calendar */
.real-calendar-card { overflow: hidden; }
.real-calendar-toolbar { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.calendar-legend { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; color: var(--muted-text-color, #94a3b8); }
.legend-dot { width: 10px; height: 10px; border-radius: 999px; display: inline-block; margin-right: 4px; }
.legend-dot.project { background: var(--primary-color, #2563eb); }
.legend-dot.planned { background: var(--warning-color, #f59e0b); }
.legend-dot.done { background: var(--success-color, #16a34a); }
.legend-dot.cancelled { background: var(--danger-color, #dc2626); }
.month-grid { display: grid; grid-template-columns: repeat(7, minmax(130px, 1fr)); gap: 1px; background: rgba(255,255,255,.10); border: 1px solid rgba(255,255,255,.10); border-radius: var(--radius-lg); overflow: hidden; min-width: 820px; }
.weekday-cell { background: rgba(0,0,0,.20); padding: 10px; font-weight: 900; color: var(--muted-text-color, #94a3b8); text-transform: uppercase; letter-spacing: .07em; font-size: .78rem; }
.month-day { min-height: 132px; background: color-mix(in srgb, var(--card-color, #1e293b) 90%, black 10%); padding: 8px; }
.month-day.other-month { opacity: .52; }
.month-day.today { outline: 2px solid color-mix(in srgb, var(--primary-color, #2563eb) 75%, white 5%); outline-offset: -2px; }
.month-day-head { display: flex; justify-content: space-between; align-items: center; font-weight: 900; margin-bottom: 6px; }
.month-day-items { display: grid; gap: 4px; }
.calendar-chip { display: block; padding: 5px 7px; border-radius: 8px; font-size: .78rem; font-weight: 850; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: rgba(148,163,184,.22); }
.calendar-chip.project { background: color-mix(in srgb, var(--primary-color, #2563eb) 28%, transparent); color: #dbeafe; }
.calendar-chip.done { background: color-mix(in srgb, var(--success-color, #16a34a) 25%, transparent); color: #bbf7d0; }
.calendar-chip.cancelled { background: color-mix(in srgb, var(--danger-color, #dc2626) 25%, transparent); color: #fecaca; }
.calendar-more { color: var(--muted-text-color, #94a3b8); font-size: .8rem; margin-top: 4px; }
.calendar-timeline { margin-top: 10px; }
.calendar-event-card { display: grid; grid-template-columns: 90px 1fr auto; gap: 12px; align-items: center; }
.calendar-event-date { color: var(--muted-text-color, #94a3b8); font-weight: 900; }

/* Code/utility */
code { background: rgba(255,255,255,.08); padding: 2px 6px; border-radius: 7px; color: #bfdbfe; }
hr { border: 0; border-top: 1px solid var(--border-color, rgba(255,255,255,.12)); margin: 22px 0; }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--primary-color, #2563eb) 45%, #64748b) rgba(15,23,42,.3); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: rgba(15,23,42,.2); }
::-webkit-scrollbar-thumb { background: rgba(148,163,184,.35); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(148,163,184,.55); }

/* Mobile */
@media (max-width: 980px) {
    .portal-shell, .admin-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; min-height: auto; max-height: none; }
    .side-nav { grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); }
    .tenant-dashboard-grid, .dashboard-grid, .project-detail-layout, .calendar-layout, .sja-layout, .time-layout, .offers-layout, .customer-layout, .project-layout, .files-layout { grid-template-columns: 1fr; }
    .portal-main { padding: 22px; }
    .public-header { align-items: flex-start; flex-direction: column; gap: 14px; }
    .month-grid { min-width: 760px; }
    .real-calendar-card { overflow-x: auto; }
}
@media (max-width: 720px) {
    .portal-main { padding: 16px; }
    .card, .dash-card, .login-card { padding: 18px; border-radius: 20px; }
    .section-heading { align-items: flex-start; flex-direction: column; }
    .actions, .dash-actions, .row-actions, .table-actions, .project-detail-actions, .calendar-nav-actions { align-items: stretch; }
    .btn, .dash-btn { width: 100%; }
    .btn.small { width: auto; }
    .inline-form, .inline-post-form { display: flex; flex-direction: column; align-items: stretch; width: 100%; }
    .palette-row { flex-wrap: wrap; }
    .palette-row strong { min-width: 100%; }
    .detail-list div { grid-template-columns: 1fr; gap: 3px; }
    .calendar-event-card { grid-template-columns: 1fr; }
    .offer-lines-head { display: none; }
    .offer-line-row { grid-template-columns: 1fr 1fr; }
    .offer-line-row > :first-child { grid-column: 1 / -1; }
    th, td { white-space: normal; min-width: 110px; }
}

@media print {
    .sidebar, .dash-actions, .actions, .project-detail-actions, .row-actions, .btn { display: none !important; }
    .portal-shell, .admin-shell { display: block; }
    .portal-main { padding: 0; }
    body { background: #fff !important; color: #111 !important; }
    .card, .dash-card { box-shadow: none !important; border-color: #ddd !important; color: #111 !important; }
}

/* ClientX Offer Lines Layout Fix v1
   Rydder tilbudslinje-skjemaet etter at generell grid-styling traff nested fields. */
.offer-form-card {
    overflow: visible;
}

.offer-lines-head {
    display: flex !important;
    justify-content: space-between;
    align-items: flex-end;
    gap: 14px;
    padding: 0;
    margin: 18px 0 10px;
    color: var(--text-color, #fff);
    text-transform: none;
    letter-spacing: normal;
    font-size: 1rem;
}
.offer-lines-head h3 {
    margin: 0 0 4px;
    font-size: 1.05rem;
    letter-spacing: .02em;
    text-transform: uppercase;
}
.offer-lines-head p {
    margin: 0;
    color: var(--muted-text-color, #94a3b8);
    font-size: .88rem;
    font-weight: 700;
    letter-spacing: .02em;
}
.offer-lines-list {
    display: grid;
    gap: 14px;
}
.offer-line-row {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    gap: 14px !important;
    align-items: start !important;
    padding: 18px !important;
    border-radius: var(--radius-lg);
    background: color-mix(in srgb, var(--card-color, #1e293b) 82%, white 5%);
    border: 1px solid color-mix(in srgb, var(--border-color, #334155) 72%, white 8%);
}
.offer-line-row > .form-grid.columns:first-child,
.offer-line-row > .form-grid.offer-line-numbers {
    grid-column: 1 / -1;
}
.offer-line-row > .form-grid.columns:first-child {
    grid-template-columns: minmax(140px, .85fr) minmax(220px, 1.2fr) minmax(240px, 1.4fr);
    align-items: end;
}
.offer-line-row > .form-grid.offer-line-numbers {
    grid-template-columns: minmax(90px, .7fr) minmax(90px, .7fr) minmax(140px, 1fr) minmax(90px, .7fr) minmax(130px, 1fr);
    align-items: end;
}
.offer-line-row > label {
    grid-column: 1 / 2;
    min-width: 0;
}
.offer-line-row > label textarea {
    width: 100%;
    min-height: 74px;
}
.offer-line-row > .remove-offer-line {
    grid-column: 2 / 3;
    align-self: end;
    justify-self: end;
    white-space: nowrap;
    margin-bottom: 2px;
}
.offer-line-row input,
.offer-line-row select,
.offer-line-row textarea {
    width: 100%;
    min-width: 0;
}
.offer-line-row .line-total-preview {
    font-weight: 900;
    background: rgba(0,0,0,.18);
}

@media (max-width: 980px) {
    .offer-line-row > .form-grid.columns:first-child,
    .offer-line-row > .form-grid.offer-line-numbers {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .offer-lines-head {
        display: grid !important;
        align-items: start;
    }
    .offer-lines-head .btn {
        width: 100%;
    }
    .offer-line-row {
        grid-template-columns: 1fr !important;
        padding: 14px !important;
    }
    .offer-line-row > .form-grid.columns:first-child,
    .offer-line-row > .form-grid.offer-line-numbers {
        grid-column: 1 / -1;
        grid-template-columns: 1fr;
    }
    .offer-line-row > label,
    .offer-line-row > .remove-offer-line {
        grid-column: 1 / -1;
        justify-self: stretch;
        width: 100%;
    }
    .offer-line-row > .remove-offer-line {
        margin-top: 2px;
    }
    .offer-total-box {
        max-width: none;
        margin-left: 0;
    }
}

/* Portaladmin / e-postinnstillinger */
.portal-admin-grid .logo-preview,
.portal-logo-preview {
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, .35);
    border: 1px solid var(--border-color, #334155);
    border-radius: 18px;
    padding: 18px;
    margin: 12px 0 18px;
}
.portal-logo-preview img {
    max-width: 260px;
    max-height: 120px;
    object-fit: contain;
}
.email-settings-form .smtp-grid {
    margin-top: 12px;
}
.checkbox-card {
    border: 1px solid var(--border-color, #334155);
    border-radius: 14px;
    padding: 12px 14px;
    background: var(--input-bg-color, rgba(15, 23, 42, .75));
    min-height: 70px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.inline-form {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto;
    gap: 14px;
    align-items: end;
}
@media (max-width: 760px) {
    .inline-form {
        grid-template-columns: 1fr;
    }
    .portal-admin-grid .grid.three-col,
    .email-settings-form .grid.three-col {
        grid-template-columns: 1fr;
    }
}
