:root {
    --bg-app: #f3f5f8;
    --bg-card: #ffffff;
    --bg-sidebar: #141821;
    --bg-sidebar-hover: #1f2633;
    --text-main: #1a202c;
    --text-muted: #64748b;
    --accent-gold: #eab308;
    --accent-gold-dark: #ca8a04;
    --accent-green: #16a34a;
    --accent-blue: #2563eb;
    --accent-red: #dc2626;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
    --radius: 10px;
}

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

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-app);
    color: var(--text-main);
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* SIDEBAR */
.sidebar {
    width: 225px;
    background-color: var(--bg-sidebar);
    color: #f8fafc;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #262d3d;
    flex-shrink: 0;
}

.brand-box {
    padding: 18px 20px;
    border-bottom: 1px solid #262d3d;
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, #1a202c 0%, #0f131a 100%);
}

.brand-logo-wrap {
    background: #ffffff;
    padding: 5px 8px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-logo-wrap img {
    height: 36px;
    width: auto;
    display: block;
}

.brand-text h1 {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.3px;
    color: #ffffff;
}

.brand-text span {
    font-size: 11px;
    color: var(--accent-gold);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

/* Client Selector in Sidebar */
.client-switcher {
    padding: 14px 16px;
    border-bottom: 1px solid #262d3d;
    background: rgba(255,255,255,0.02);
}

.client-switcher label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: #94a3b8;
    margin-bottom: 6px;
    font-weight: 600;
}

.client-select-row {
    display: flex;
    gap: 6px;
}

.client-select-row select {
    flex: 1;
    background: #1e2533;
    color: #fff;
    border: 1px solid #334155;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    outline: none;
}

.btn-icon {
    background: #283142;
    color: #e2e8f0;
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 0 10px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.15s;
}

.btn-icon:hover {
    background: var(--accent-gold);
    color: #111;
    border-color: var(--accent-gold);
}

/* Navigation */
.nav-menu {
    padding: 12px 10px;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-section-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.9px;
    color: #64748b;
    padding: 10px 10px 4px;
    font-weight: 700;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: #cbd5e1;
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    transition: all 0.15s;
}

.nav-item:hover {
    background-color: var(--bg-sidebar-hover);
    color: #fff;
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(234, 179, 8, 0.18) 0%, rgba(234, 179, 8, 0.04) 100%);
    color: var(--accent-gold);
    border-left: 3px solid var(--accent-gold);
    font-weight: 600;
}

.nav-item .nav-badge {
    margin-left: auto;
    background: #283142;
    color: #94a3b8;
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 12px;
}

.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid #262d3d;
    font-size: 12px;
    color: #94a3b8;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.save-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    color: #4ade80;
}

/* MAIN AREA */
.main-wrapper {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Topbar (Kompakt så den aldrig tar upp onödig höjd i mindre fönster) */
.topbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 8px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px 14px;
    flex-shrink: 0;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.topbar-title h2 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
}

.topbar-title p {
    font-size: 11.5px;
    color: var(--text-muted);
    line-height: 1.25;
}

.quick-kpis {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.kpi-pill {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    padding: 4px 10px;
    border-radius: 7px;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.kpi-pill span.lbl {
    font-size: 9.5px;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
    letter-spacing: 0.3px;
}

.kpi-pill span.val {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
}

.kpi-pill.highlight {
    background: #fefce8;
    border-color: #fde047;
}

/* Content Scroll Area */
.content-area {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 20px 40px;
}

.tab-pane {
    display: none;
    max-width: 1440px;
    width: 100%;
    margin: 0 auto;
}

.tab-pane.active {
    display: block;
}

/* Cards & Grids */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    padding: 18px;
    margin-bottom: 18px;
    min-width: 0;
    max-width: 100%;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 10px;
}

.card-header h3 {
    font-size: 15.5px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 18px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 14px;
}

/* Forms & Inputs */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.form-group label {
    font-size: 12px;
    font-weight: 600;
    color: #475569;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    min-width: 0;
    padding: 7px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 13.5px;
    font-family: inherit;
    background: #fff;
    color: var(--text-main);
    transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(37,99,235,0.12);
}

/* Locked / Disabled Inputs & Mode Switches */
input:disabled,
select:disabled,
textarea:disabled,
button:disabled {
    background-color: #e2e8f0 !important;
    color: #94a3b8 !important;
    border-color: #cbd5e1 !important;
    cursor: not-allowed !important;
    opacity: 0.75;
    box-shadow: none !important;
}

.locked-group {
    background: #f1f5f9 !important;
    border-color: #cbd5e1 !important;
    color: #94a3b8 !important;
    opacity: 0.72;
    pointer-events: none;
}

.mode-switch-bar {
    display: inline-flex;
    flex-wrap: wrap;
    background: #e2e8f0;
    padding: 3px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    gap: 3px;
}

.mode-switch-btn {
    border: none;
    background: transparent;
    color: #475569;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.mode-switch-btn:hover {
    color: #0f172a;
}

.mode-switch-btn.active,
.mode-switch-btn.active-auto,
.mode-switch-btn.active-manual {
    background: #1e293b;
    color: var(--accent-gold);
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

/* Clean, Responsive Macro Distribution Table */
.macro-table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
}

.macro-dist-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.macro-dist-table th {
    background: #f1f5f9;
    color: #334155;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 9px 12px;
    text-align: left;
    border-bottom: 1.5px solid #cbd5e1;
}

.macro-dist-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #e2e8f0;
    vertical-align: middle;
}

.macro-dist-table tbody tr:last-child td {
    border-bottom: none;
}

.macro-input-box {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: #f8fafc;
    border: 1.5px solid #cbd5e1;
    border-radius: 7px;
    padding: 4px 10px;
}

.macro-input-box .num-input {
    width: 82px;
    border: 1px solid #cbd5e1;
    background: #fff;
    font-size: 14px;
    font-weight: 700;
    padding: 5px 8px;
    text-align: right;
}

.macro-input-box .unit-lbl {
    font-size: 12.5px;
    font-weight: 700;
    color: #475569;
}

.macro-input-box.active-mode {
    background: #fefce8;
    border-color: #eab308;
    box-shadow: 0 0 0 2px rgba(234, 179, 8, 0.18);
}

.macro-input-box.locked-mode {
    background: #e2e8f0;
    border-color: #cbd5e1;
    opacity: 0.78;
}

/* Grunddata & Journal Compact Editing Grids (Fits 100% inside window!) */
.gd-edit-grid-row1 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 10px;
}

.gd-edit-grid-row2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
    gap: 8px;
    align-items: end;
}

.inline-edit-panel {
    background: #fefce8;
    border: 2px solid #eab308;
    border-radius: 8px;
    padding: 12px 14px;
    box-shadow: 0 4px 12px rgba(234, 179, 8, 0.15);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Validation & Client Onboarding Form Styles */
.req-star {
    color: #dc2626;
    font-weight: 900;
    margin-left: 2px;
}

.input-invalid {
    border: 2px solid #dc2626 !important;
    background-color: #fef2f2 !important;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15) !important;
}

.field-error-msg {
    color: #dc2626;
    font-size: 11.5px;
    font-weight: 700;
    margin-top: 2px;
    display: none;
}

.form-group.has-error .field-error-msg {
    display: block;
}

.validation-banner {
    background: #fef2f2;
    border: 2px solid #dc2626;
    color: #991b1b;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 13.5px;
    font-weight: 600;
    display: none;
}

.validation-banner.show,
.validation-banner.visible {
    display: block;
}

.editing-row td {
    background-color: #fefce8 !important;
    border-top: 2px solid #eab308 !important;
    border-bottom: 2px solid #eab308 !important;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s;
}

.btn-primary {
    background: #1e293b;
    color: #fff;
}
.btn-primary:hover {
    background: #0f172a;
}

.btn-gold {
    background: var(--accent-gold);
    color: #111827;
    border-color: var(--accent-gold-dark);
}
.btn-gold:hover {
    background: #facc15;
}

.btn-success {
    background: var(--accent-green);
    color: #fff;
}
.btn-success:hover {
    background: #15803d;
}

.btn-outline {
    background: #fff;
    color: #334155;
    border-color: #cbd5e1;
}
.btn-outline:hover {
    background: #f1f5f9;
}

.btn-danger {
    background: #fee2e2;
    color: #b91c1c;
    border-color: #fecaca;
}
.btn-danger:hover {
    background: #fecaca;
}

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

/* Plan Sub-tabs (Kostschema 1..5) */
.plan-tabs-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    padding: 10px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 10px;
}

.plan-tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.plan-tab {
    padding: 7px 14px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: #f8fafc;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    color: #475569;
}

.plan-tab.active {
    background: #1e293b;
    color: var(--accent-gold);
    border-color: #1e293b;
}

/* Meal Builder Cards */
.meal-card {
    background: #fff;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    margin-bottom: 18px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.meal-card-header {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 10px;
}

.meal-card.meal-frukost .meal-card-header { border-left: 5px solid #dc2626; background: #fff5f5; }
.meal-card.meal-mellan1 .meal-card-header { border-left: 5px solid #0284c7; background: #f0f9ff; }
.meal-card.meal-lunch .meal-card-header   { border-left: 5px solid #d97706; background: #fffbeb; }
.meal-card.meal-mellan2 .meal-card-header { border-left: 5px solid #7c3aed; background: #f5f3ff; }
.meal-card.meal-middag .meal-card-header  { border-left: 5px solid #16a34a; background: #f0fdf4; }
.meal-card.meal-kvall .meal-card-header   { border-left: 5px solid #ea580c; background: #fff7ed; }

.meal-title-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.meal-title-group h4 {
    font-size: 16px;
    font-weight: 700;
}

.meal-target-badge {
    font-size: 12px;
    background: rgba(0,0,0,0.06);
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 600;
}

.meal-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.ovrigt-slider-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    background: rgba(255,255,255,0.85);
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
}

/* Builder Table */
.builder-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.builder-table th {
    background: #f8fafc;
    color: #475569;
    font-weight: 700;
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color);
    font-size: 11.5px;
    text-transform: uppercase;
}

.builder-table td {
    padding: 7px 10px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.builder-table tr:hover td {
    background: #fcfcfd;
}

.cat-select {
    font-weight: 700;
    padding: 6px 8px;
    border-radius: 5px;
    border: 1px solid #cbd5e1;
    width: 90px;
}
.cat-select.cat-Prot { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.cat-select.cat-Kolh { background: #fefce8; color: #a16207; border-color: #fde047; }
.cat-select.cat-Fett { background: #fdf2f8; color: #be185d; border-color: #fbcfe8; }
.cat-select.cat-Ovrigt { background: #f3f4f6; color: #374151; border-color: #d1d5db; }

.ing-select {
    width: 100%;
    min-width: 240px;
    padding: 6px 8px;
    border-radius: 5px;
    border: 1px solid #cbd5e1;
    font-size: 13px;
}

.num-input {
    width: 78px;
    padding: 6px 8px;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    text-align: right;
    font-weight: 600;
    font-size: 13px;
}

.lock-btn {
    background: none;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 14px;
    padding: 4px 6px;
    border-radius: 4px;
    opacity: 0.45;
}
.lock-btn.locked {
    opacity: 1;
    background: #fef3c7;
    border-color: #f59e0b;
}

.meal-footer-bar {
    padding: 10px 16px;
    background: #f8fafc;
    border-top: 2px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 13px;
}

.macro-comparison-pills {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.macro-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 6px;
    background: #fff;
    border: 1px solid #cbd5e1;
    font-weight: 600;
}

.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
}
.status-dot.ok { background: #16a34a; }
.status-dot.warn { background: #eab308; }
.status-dot.diff { background: #dc2626; }

/* ==========================================================================
   KO'N'TRA LIVSSTIL CLASSIC KOSTSCHEMA SHEET (Preview & Print/PDF)
   Matches Kostschema (Exempel).png & Exempel 1 kostschema.png
   ========================================================================== */
.kontra-sheet-container {
    width: 100%;
    max-width: 1020px;
    margin: 0 auto;
    color: #000;
    font-family: 'Times New Roman', Times, Georgia, serif;
}

/* Each visual A4 sheet on screen */
.a4-sheet-box {
    background: #ffffff;
    width: 100%;
    min-height: 1120px; /* A4 aspect ratio on screen so even short pages show full-page framing */
    margin: 0 auto 28px auto;
    padding: 22px 26px;
    border: 2px solid #000;
    box-shadow: 0 8px 28px rgba(0,0,0,0.12);
    box-sizing: border-box;
    position: relative;
}

.a4-sheet-box.page-break-before {
    page-break-before: always;
    break-before: page;
}

/* Fixed full-A4 frame for PDF / Print output */
.pdf-page-frame {
    display: none;
}

.print-frame-table {
    width: 100%;
    border-collapse: collapse;
    border: none;
}
.print-frame-table > thead > tr > td,
.print-frame-table > tfoot > tr > td {
    height: 0;
    padding: 0;
    border: none;
}
.print-frame-table > tbody > tr > td {
    padding: 0;
    border: none;
    vertical-align: top;
}

.ks-top-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    border-bottom: 2px solid #000;
    padding-bottom: 6px;
    margin-bottom: 10px;
}

.ks-meta-left {
    flex: 0 0 auto;
    font-size: 13.5px;
    font-weight: bold;
    line-height: 1.3;
    white-space: nowrap;
}

.ks-meta-left .red-val {
    color: #c00000;
}

.ks-main-title {
    flex: 1 1 auto;
    text-align: center;
    min-width: 0;
}

.ks-main-title h1 {
    font-size: 34px;
    font-weight: normal;
    letter-spacing: 1.5px;
    margin: 0;
    line-height: 1;
}

.ks-meta-center {
    display: flex;
    justify-content: center;
    align-items: baseline;
    flex-wrap: nowrap;
    gap: 16px;
    font-size: 13.5px;
    font-weight: bold;
    margin-top: 6px;
    white-space: nowrap;
}

.ks-client-profile-tag {
    font-size: 12.5px;
    font-weight: bold;
    color: #222;
    margin-left: 4px;
}

.ks-logo-right {
    flex: 0 0 auto;
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.ks-logo-right img {
    height: 48px;
    width: auto;
    max-width: 135px;
    object-fit: contain;
}

/* Meal Block inside Classic Sheet */
.ks-meal-block {
    border: 2px solid #000;
    margin-bottom: 14px;
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
}

.ks-meal-wrapper {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
}

.ks-meal-block th,
.ks-meal-block td {
    padding: 3px 6px;
    font-size: 13px;
    border: none;
    white-space: nowrap;
}

.ks-meal-block td.ks-col-ravara {
    width: 100%;
    white-space: nowrap;
    font-weight: bold;
    text-align: left;
    padding-left: 8px;
}

.ks-meal-block td.ks-col-fabrikat {
    white-space: nowrap;
    text-align: center;
    padding: 3px 8px;
}

body.sidebar-collapsed .sidebar {
    display: none;
}

.ks-meal-title-row th {
    font-size: 15.5px;
    font-weight: bold;
    border-bottom: 1px solid #000;
    padding: 4px 8px;
}

.ks-col-headers th {
    font-weight: normal;
    border-bottom: 1px solid #000;
    padding: 3px 8px;
    text-align: center;
}
.ks-col-headers th.left {
    text-align: left;
}

.ks-divider-left {
    border-left: 1.5px dashed #000 !important;
}

.ks-dotted-left {
    border-left: 1px dotted #555 !important;
}

/* Gradient rows matching Excel conditional styling */
.ks-row-frukost td {
    background: linear-gradient(180deg, #ffffff 0%, #f8cbad 100%);
    border-bottom: 1px solid #d9d9d9;
}
.ks-row-lunch td {
    background: linear-gradient(180deg, #ffffff 0%, #ffe699 100%);
    border-bottom: 1px solid #d9d9d9;
}
.ks-row-middag td {
    background: linear-gradient(180deg, #ffffff 0%, #c6e0b4 100%);
    border-bottom: 1px solid #d9d9d9;
}
.ks-row-kvall td, .ks-row-mellan td {
    background: linear-gradient(180deg, #ffffff 0%, #f8cbad 100%);
    border-bottom: 1px solid #d9d9d9;
}

.ks-meal-total-row td {
    border-top: 1.5px solid #000;
    font-weight: bold;
    padding: 5px 8px;
    background: #fff;
}

.ks-green-circle {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #548235;
    vertical-align: middle;
    margin-right: 4px;
}

.ks-arrow-up {
    color: #548235;
    font-weight: 900;
    font-size: 15px;
    margin-right: 3px;
}

.ks-arrow-down {
    color: #c00000;
    font-weight: 900;
    font-size: 15px;
    margin-right: 3px;
}

/* Classic Summary Box at Bottom */
.ks-summary-table {
    width: 100%;
    border: 2px solid #000;
    border-collapse: collapse;
    background: linear-gradient(180deg, #d9d9d9 0%, #ededed 50%, #d9d9d9 100%);
    margin-top: 6px;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
}

.ks-summary-table th,
.ks-summary-table td {
    padding: 5px 12px;
    font-size: 15px;
    border-bottom: 1px solid #a6a6a6;
    white-space: nowrap;
}

.ks-summary-table th {
    border-bottom: 1px solid #000;
    font-weight: bold;
}

/* Attachment Sheets (Receptblad & Inköpslista) */
.ks-attachment-page {
    margin-top: 28px;
    padding-top: 22px;
    border-top: 3px double #000;
    page-break-before: always;
    break-before: page;
}

.ks-recipe-card {
    border: 2px solid #000;
    margin-bottom: 16px;
    background: #fff;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
}

.ks-recipe-card-header {
    background: linear-gradient(180deg, #fff2cc 0%, #ffe699 100%);
    border-bottom: 1.5px solid #000;
    padding: 7px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    font-size: 16px;
}

.ks-recipe-card-body {
    padding: 12px 16px;
    font-size: 14.5px;
    line-height: 1.5;
}

.ks-recipe-grid {
    display: grid;
    grid-template-columns: 1fr 1.3fr;
    gap: 20px;
    margin-top: 8px;
}

.ks-recipe-ing-list {
    margin: 6px 0 0 20px;
    padding: 0;
    list-style-type: disc;
}

.ks-recipe-ing-list li {
    margin-bottom: 4px;
    padding-left: 2px;
}

.ks-recipe-step-list {
    margin: 6px 0 0 20px;
    padding: 0;
}

.ks-recipe-step-list li {
    margin-bottom: 5px;
    padding-left: 2px;
}

.ks-shopping-stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 12px;
    width: 100%;
}

.ks-shop-group {
    border: 2px solid #000;
    background: #fff;
    width: 100%;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
}

.ks-shop-group-title {
    border-bottom: 1.5px solid #000;
    padding: 6px 12px;
    font-weight: bold;
    font-size: 15.5px;
}

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

.ks-shop-table td, .ks-shop-table th {
    padding: 4px 8px;
    border-bottom: 1px solid #d9d9d9;
    white-space: nowrap;
}

.ks-shop-table td.ks-shop-col-name {
    white-space: nowrap;
    width: 100%;
}

/* Modal Dialog (Maila Kostschema) */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
}

.modal-backdrop.open {
    display: flex;
}

.modal-box {
    background: #fff;
    border-radius: 12px;
    max-width: 620px;
    width: 100%;
    padding: 24px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.25);
    border: 1px solid #cbd5e1;
}

.attachment-toggles {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: center;
    background: #f8fafc;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
}

.attachment-toggles label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    color: #1e293b;
}

/* Tables for Journal & Grunddata */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
}

.data-table th {
    background: #f1f5f9;
    padding: 7px 8px;
    text-align: left;
    font-weight: 700;
    color: #334155;
    border-bottom: 2px solid #cbd5e1;
}

.data-table td {
    padding: 6px 8px;
    border-bottom: 1px solid #e2e8f0;
}

.data-table tr:hover td {
    background: #f8fafc;
}

/* Extra stor rullista för Råvarulista (Grunddata) så att många råvaror syns samtidigt */
.gd-large-scroll-box {
    overflow-x: auto;
    overflow-y: auto;
    height: calc(100vh - 275px);
    min-height: 760px;
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    background: #ffffff;
}

.gd-compact-table thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #e2e8f0;
    box-shadow: 0 1px 0 #cbd5e1;
    padding: 8px 10px;
}

.gd-compact-table td {
    padding: 5.5px 10px;
    font-size: 13px;
}

/* Badge styles */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11.5px;
    font-weight: 700;
}
.badge-Prot { background: #dbeafe; color: #1e40af; }
.badge-Kolh { background: #fef9c3; color: #854d0e; }
.badge-Fett { background: #fce7f3; color: #9d174d; }
.badge-Ovrigt { background: #e5e7eb; color: #374151; }

/* Print / PDF Rules - Full A4 border on every single page */
@media print {
    @page {
        size: A4 portrait;
        margin: 10mm;
    }
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    body {
        background: #fff !important;
        height: auto !important;
        overflow: visible !important;
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    .sidebar, .topbar, .no-print, .modal-backdrop {
        display: none !important;
    }
    .main-wrapper, .content-area {
        padding: 0 !important;
        margin: 0 !important;
        overflow: visible !important;
    }
    .tab-pane {
        display: none !important;
    }
    .tab-pane#tab-preview {
        display: block !important;
        max-width: 100% !important;
        margin: 0 !important;
    }
    .kontra-sheet-container {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    /* Draws the 2px solid black border around the entire A4 page on EVERY page of the PDF */
    .pdf-page-frame {
        display: block !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        border: 2px solid #000 !important;
        pointer-events: none !important;
        z-index: 99999 !important;
        box-sizing: border-box !important;
    }
    /* Repeats top and bottom inner spacing on every printed A4 page so content never touches the fixed A4 border */
    .print-frame-table > thead > tr > td {
        height: 14px !important;
    }
    .print-frame-table > tfoot > tr > td {
        height: 14px !important;
    }
    .print-frame-table > tbody > tr > td {
        padding: 0 14px !important;
    }
    .a4-sheet-box {
        border: none !important;
        box-shadow: none !important;
        min-height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }
    .a4-sheet-box.page-break-before {
        page-break-before: always !important;
        break-before: page !important;
    }
    .ks-meal-block, .ks-meal-wrapper, .ks-summary-table, .ks-recipe-card, .ks-shop-group {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }
}
