:root {
    --bg-main: #f1f5f9;
    --surface: #ffffff;
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --sidebar-text: #cbd5e1;
    --sidebar-active-text: #ffffff;
    --sidebar-active-bg: #1e293b;
    --sidebar-border: #334155;
    
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-soft: #e2e8f0;
    --border-strong: #cbd5e1;
    
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary: #475569;
    --secondary-hover: #334155;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #10b981;
    --warning: #f59e0b;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    --radius-md: 8px;
    --radius-lg: 12px;
}

body {
    margin: 0;
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
}

.page-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
}

.page-heading h1 {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 800;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--primary);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.toolbar-form,
.form-grid,
.form-grid--wide {
    display: grid;
    gap: 12px;
}

.toolbar-form {
    grid-template-columns: repeat(2, minmax(150px, 1fr)) auto;
    align-items: center;
}

.content-grid {
    display: grid;
    gap: 20px;
}

.content-grid--two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.content-grid--form {
    grid-template-columns: minmax(280px, 0.75fr) minmax(0, 1.5fr);
}

.surface-card {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 20px;
}

.surface-card__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 18px;
}

.treatment-products-picker,
.treatment-plan-list {
    display: grid;
    gap: 10px;
}

.treatment-products-picker__head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(180px, 0.8fr);
    gap: 10px;
    align-items: end;
}

.treatment-products-picker__list {
    display: grid;
    gap: 10px;
}

.treatment-search {
    margin: 0;
}

.treatment-journal-search {
    display: block;
    margin-bottom: 12px;
}

.treatment-product-check {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    min-height: 54px;
    padding: 12px;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    background: #f8fafc;
    cursor: pointer;
}

.treatment-product-check input {
    margin-top: 4px;
}

.treatment-product-check strong,
.treatment-product-check small {
    display: block;
}

.treatment-product-check small {
    color: var(--text-muted);
    margin-top: 2px;
}

.treatment-product-check:has(input:checked) {
    border-color: rgba(37, 99, 235, 0.55);
    background: rgba(37, 99, 235, 0.07);
}

.treatment-product-check:has(input:disabled) {
    opacity: 0.55;
    cursor: not-allowed;
}

.treatment-plan-card {
    position: relative;
    max-width: 100%;
    min-width: 0;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
}

.treatment-plan-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: #2563eb;
}

.treatment-plan-card.is-done {
    border-color: rgba(16, 185, 129, 0.24);
}

.treatment-plan-card.is-late {
    border-color: rgba(239, 68, 68, 0.28);
}

.treatment-plan-card.is-planned {
    border-color: rgba(37, 99, 235, 0.24);
}

.treatment-plan-card.is-done::before {
    background: var(--success);
}

.treatment-plan-card.is-late::before {
    background: var(--danger);
}

.treatment-plan-card__head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto 30px;
    align-items: center;
    gap: 12px;
    padding: 14px;
    padding-left: 18px;
    cursor: pointer;
    list-style: none;
    background: linear-gradient(180deg, #fff 0%, #fbfcfe 100%);
}

.treatment-plan-card__head::-webkit-details-marker {
    display: none;
}

.treatment-plan-card[open] {
    box-shadow: var(--shadow-sm);
}

.treatment-plan-card[open] .employee-card__chevron {
    transform: rotate(180deg);
}

.treatment-plan-card__main {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.treatment-plan-card__head h3 {
    margin: 0;
    color: var(--text-main);
    font-size: 1rem;
    font-weight: 900;
    overflow-wrap: anywhere;
}

.treatment-plan-card__meta,
.treatment-plan-card__metrics {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
}

.treatment-plan-card__metrics {
    justify-content: flex-end;
    white-space: nowrap;
}

.treatment-plan-card__body {
    display: grid;
    gap: 12px;
    padding: 14px;
    min-width: 0;
    border-top: 1px solid var(--border-soft);
    background: #fff;
}

.treatment-status {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 0.74rem;
    font-weight: 850;
}

.treatment-status--done {
    color: #065f46;
    background: #bbf7d0;
}

.treatment-status--late {
    color: #991b1b;
    background: #fecaca;
}

.treatment-status--planned {
    color: #1e3a8a;
    background: #bfdbfe;
}

.treatment-actions,
.treatment-complete-form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: end;
}

.treatment-complete-form label {
    min-width: 170px;
}

.treatment-table {
    margin-bottom: 0;
}

.treatment-comments {
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: #fbfcfe;
}

.treatment-comments__head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}

.treatment-comments__head h4 {
    margin: 0;
    font-size: 0.92rem;
    font-weight: 850;
}

.treatment-comment-list {
    display: grid;
    gap: 8px;
}

.treatment-comment {
    display: grid;
    gap: 4px;
    padding: 10px;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: #fff;
}

.treatment-comment__meta {
    color: var(--text-muted);
    font-size: 0.74rem;
    font-weight: 750;
}

.treatment-comment__text {
    color: var(--text-main);
    font-size: 0.9rem;
    overflow-wrap: anywhere;
}

.treatment-comment-form {
    display: grid;
    gap: 10px;
}

.section-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 800;
}

.section-subtitle,
.helper-note {
    color: var(--text-muted);
    font-size: 0.86rem;
}

.finance-summary-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(140px, 1fr));
    gap: 14px;
}

.finance-kpi {
    display: grid;
    gap: 6px;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-sm);
}

.finance-kpi__label {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.finance-kpi__value {
    font-size: 1.35rem;
    font-weight: 800;
}

.app-table {
    margin-bottom: 0;
    vertical-align: middle;
}

.app-table th {
    color: var(--text-muted);
    font-size: 0.78rem;
    text-transform: uppercase;
}

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

.form-grid--wide {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.line-items {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.line-item {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr;
    gap: 10px;
}

.expenses-period-form {
    margin-bottom: 16px;
}

.season-actions {
    max-width: 760px;
}

.modal-season-form,
.season-editor-row {
    display: grid;
    gap: 12px;
    align-items: end;
}

.modal-season-form {
    grid-template-columns: repeat(2, minmax(160px, 1fr)) auto;
}

.season-editor-list {
    display: grid;
    gap: 12px;
}

.season-editor-row {
    grid-template-columns: 90px minmax(180px, 1.2fr) minmax(150px, 0.8fr) minmax(150px, 0.8fr) minmax(150px, 0.8fr) auto;
    padding: 12px;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    background: #f8fafc;
}

.season-editor-row__status {
    align-self: center;
}

.analytics-open-card {
    width: 100%;
    text-align: left;
    color: inherit;
    cursor: pointer;
}

.analytics-open-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.analytics-open-card .table {
    pointer-events: none;
}

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

.table-check {
    margin: 0;
    white-space: nowrap;
}

.salary-accordion {
    display: grid;
    gap: 12px;
}

.salary-employee {
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    background: #f8fafc;
    overflow: hidden;
}

.salary-employee__summary {
    display: grid;
    grid-template-columns: minmax(180px, 1.5fr) repeat(5, minmax(120px, 1fr));
    gap: 12px;
    align-items: center;
    padding: 14px 16px;
    cursor: pointer;
    font-weight: 700;
}

.salary-employee__summary:hover {
    background: #eff6ff;
}

.salary-employee__body {
    padding: 16px;
    border-top: 1px solid var(--border-soft);
    background: #fff;
}

.salary-employee__grid {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr);
    gap: 16px;
}

.salary-balance--due {
    color: #dc2626;
}

.salary-balance--over {
    color: #2563eb;
}

.analytics-chart-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.analytics-chart-card {
    min-width: 0;
    border-radius: 14px;
    background: var(--surface);
}

.analytics-chart-card--wide {
    grid-column: 1 / -1;
}

.analytics-chart-card--structure,
.analytics-chart-card--timeline {
    padding: 28px;
}

.analytics-chart-title {
    margin: 0;
    color: var(--text-main);
    font-size: 1.85rem;
    font-weight: 850;
    line-height: 1.1;
}

.analytics-chart-subtitle {
    margin: 6px 0 0;
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 650;
}

.chart-canvas-wrap {
    position: relative;
    min-height: 320px;
}

.chart-canvas-wrap--structure {
    min-height: 390px;
}

.chart-canvas-wrap--timeline {
    min-height: 430px;
}

.chart-scroll-x {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 8px;
}

.chart-scroll-x__inner {
    position: relative;
    min-width: 1100px;
    height: 520px;
}

.chart-canvas-wrap--wide {
    min-height: 380px;
}

.analytics-chart-card canvas {
    max-height: 360px;
}

.chart-legend {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 10px;
    color: var(--text-muted);
    font-size: 0.86rem;
    font-weight: 700;
}

.chart-legend--wrap {
    max-height: 96px;
    overflow: auto;
    padding-right: 4px;
}

.chart-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
}

.legend-dot--revenue { background: #16a34a; }
.legend-dot--expenses { background: #dc2626; }
.legend-dot--profit { background: #2563eb; }
.legend-dot--price { background: #9333ea; }

.line-chart {
    display: block;
    width: 100%;
    height: auto;
    min-height: 220px;
    overflow: visible;
    border-radius: var(--radius-md);
    background:
        linear-gradient(180deg, rgba(248, 250, 252, 0.78), rgba(255, 255, 255, 0.92));
}

.line-chart--wide {
    min-height: 280px;
}

.line-chart__grid {
    stroke: #e2e8f0;
    stroke-width: 1;
    stroke-dasharray: 4 7;
}

.line-chart__tick,
.line-chart__date {
    fill: var(--text-muted);
    font-size: 12px;
    font-family: 'IBM Plex Mono', monospace;
}

.line-chart__date {
    text-anchor: middle;
}

.line-chart__line {
    fill: none;
    stroke-width: 3.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: drop-shadow(0 2px 3px rgba(15, 23, 42, 0.14));
}

.line-chart__line--revenue { stroke: #16a34a; }
.line-chart__line--expenses { stroke: #dc2626; }
.line-chart__line--profit { stroke: #2563eb; }
.line-chart__line--price { stroke: #9333ea; }

.line-chart__dot {
    stroke: #fff;
    stroke-width: 2.4;
}

.line-chart__dot--revenue { fill: #16a34a; }
.line-chart__dot--expenses { fill: #dc2626; }
.line-chart__dot--profit { fill: #2563eb; }
.line-chart__dot--price { fill: #9333ea; }

.check-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.mono {
    font-family: 'IBM Plex Mono', monospace;
}

.nested-row {
    background: #f8fafc;
    color: var(--text-muted);
    font-size: 0.86rem;
}

.item-chip {
    display: inline-flex;
    margin: 2px 6px 2px 0;
    padding: 4px 8px;
    border-radius: 6px;
    background: #e2e8f0;
    color: #334155;
    font-weight: 700;
}

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-card {
    width: min(420px, 100%);
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 28px;
}

.auth-brand {
    margin-bottom: 24px;
}

.auth-card h1 {
    margin: 0 0 20px;
    font-size: 1.6rem;
    font-weight: 800;
}

.auth-settings-card {
    max-width: 520px;
}

@media (max-width: 1100px) {
    .finance-summary-grid,
    .analytics-chart-grid,
    .content-grid--two,
    .content-grid--form,
    .form-grid--wide,
    .salary-employee__summary,
    .salary-employee__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .erp-shell {
        height: auto;
        min-height: 100vh;
        overflow: visible;
        flex-direction: column;
    }

    .erp-sidebar {
        width: 100%;
    }

    .erp-main {
        overflow: visible;
    }

    .erp-topbar,
    .page-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .page-content {
        padding: 18px;
    }

    .finance-summary-grid,
    .content-grid--two,
    .content-grid--form,
    .form-grid--wide,
    .toolbar-form,
    .line-item,
    .modal-season-form,
    .season-editor-row,
    .salary-employee__summary,
    .salary-employee__grid {
        grid-template-columns: 1fr;
    }
}

/* --- Layout Shell --- */
.erp-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* --- Sidebar --- */
.erp-sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--sidebar-border);
    transition: all 0.3s ease;
    z-index: 20;
}

.erp-sidebar__brand {
    padding: 20px 24px;
    border-bottom: 1px solid var(--sidebar-border);
}

.brand-mark {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.brand-mark__dot {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    background: var(--primary);
    box-shadow: 0 0 10px rgba(37, 99, 235, 0.5);
}

.brand-mark__title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.02em;
}

.brand-mark__caption {
    display: block;
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: 2px;
}

.erp-nav {
    flex: 1;
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
}

.erp-nav__link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    color: var(--sidebar-text);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.erp-nav__link:hover {
    background-color: var(--sidebar-hover);
    color: #fff;
}

.erp-nav__link.active {
    background-color: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    box-shadow: inset 3px 0 0 var(--primary);
}

.erp-nav__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.85rem;
    color: #fff;
}

.erp-nav__link.active .erp-nav__icon {
    background: var(--primary);
}

.erp-nav__group {
    display: grid;
    gap: 6px;
}

.erp-nav__children {
    display: none;
    gap: 4px;
    padding-left: 42px;
}

.erp-nav__group.open .erp-nav__children {
    display: grid;
}

.erp-nav__sublink {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 6px 10px;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.72);
    text-decoration: none;
    font-size: 0.84rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.erp-nav__sublink:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.erp-nav__sublink.active {
    color: #fff;
    background: rgba(37, 99, 235, 0.22);
}

.erp-nav__subgroup {
    display: grid;
    gap: 4px;
}

.erp-nav__subgroup > .erp-nav__sublink {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.erp-nav__subgroup > .erp-nav__sublink::after {
    content: "▾";
    font-size: 0.72rem;
    opacity: 0.72;
}

.erp-nav__subchildren {
    display: none;
    gap: 4px;
    margin-left: 10px;
    padding-left: 12px;
    border-left: 1px solid rgba(148, 163, 184, 0.28);
}

.erp-nav__subgroup.open .erp-nav__subchildren {
    display: grid;
}

.erp-nav__sublink--nested {
    min-height: 28px;
    padding: 5px 10px 5px 12px;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.66);
}

.erp-sidebar__footer {
    padding: 20px;
    border-top: 1px solid var(--sidebar-border);
}

.erp-plan-card {
    background: rgba(255,255,255,0.05);
    padding: 12px;
    border-radius: var(--radius-md);
}

.erp-plan-card__label { font-size: 0.7rem; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.5px;}
.erp-plan-card__value { font-size: 0.9rem; color: #fff; font-weight: 600; margin: 4px 0;}
.erp-plan-card__meta { font-size: 0.75rem; color: #64748b;}

/* --- Main Area & Topbar --- */
.erp-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.erp-topbar {
    min-height: 64px;
    background-color: var(--surface);
    border-bottom: 1px solid var(--border-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 12px 32px;
    box-shadow: var(--shadow-sm);
    z-index: 10;
}

.erp-topbar__status {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.erp-topbar__status-title {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.erp-door-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.erp-door-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    padding: 8px 12px;
    border-radius: 12px;
    border: 1px solid var(--border-soft);
    background: var(--surface);
}

.erp-door-chip--button {
    cursor: pointer;
    text-align: left;
}

.erp-door-chip--button:hover {
    border-color: rgba(15, 23, 42, 0.16);
    box-shadow: var(--shadow-sm);
}

.erp-door-chip__name {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-main);
}

.erp-door-chip__state {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.erp-door-chip__time {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.erp-door-chip--success {
    background: #f0fdf4;
    border-color: rgba(34, 197, 94, 0.22);
}

.erp-door-chip--danger {
    background: #fef2f2;
    border-color: rgba(239, 68, 68, 0.22);
}

.erp-door-chip--secondary {
    background: var(--bg-main);
}

.erp-door-status-empty {
    font-size: 0.84rem;
    color: var(--text-muted);
}

.erp-topbar__actions { display: flex; align-items: center; gap: 20px; }
.erp-icon-btn {
    background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--text-muted);
}
.erp-user { display: flex; align-items: center; gap: 12px; }
.erp-user__meta { text-align: right; }
.erp-user__name { font-weight: 600; font-size: 0.9rem; color: var(--text-main); }
.erp-user__role { font-size: 0.75rem; color: var(--text-muted); }
.erp-user__avatar {
    width: 36px; height: 36px; border-radius: 50%; background: var(--primary);
    color: #fff; display: flex; align-items: center; justify-content: center; font-weight: bold;
}

/* --- Page Content --- */
.page-content {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
}

/* --- Workspace Headers --- */
.workspace-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
    gap: 16px;
    flex-wrap: wrap;
}

.workspace-head__title {
    font-size: 1.75rem;
    font-weight: 800;
    margin: 0 0 8px 0;
    letter-spacing: -0.03em;
    color: var(--text-main);
}

.workspace-head__subtitle {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin: 0;
    max-width: 600px;
    line-height: 1.5;
}

.workspace-head__tools {
    display: flex;
    gap: 14px;
    align-items: center;
    flex-wrap: wrap;
}

.workspace-period-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 320px;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    box-shadow: var(--shadow-sm);
}

.workspace-period-card__title {
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0;
}

.workspace-period-card__form {
    display: grid;
    grid-template-columns: minmax(0, 132px) minmax(0, 132px) auto;
    gap: 10px;
    align-items: end;
}

.workspace-period-card__field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

.workspace-period-card__label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0;
}

.workspace-period-card__actions {
    display: flex;
    align-items: end;
    justify-content: flex-end;
}

.workspace-period-card .action-row__group {
    gap: 8px;
    flex-wrap: wrap;
}

.workspace-period-card .form-control-app {
    min-height: 38px;
    padding: 7px 10px;
    font-size: 0.88rem;
    box-shadow: none;
}

.workspace-period-card .btn-app {
    min-height: 38px;
    padding: 8px 12px;
}

/* --- Cards & Panels --- */
.surface-card, .erp-block, .hero-panel {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-soft);
    padding: 24px;
    margin-bottom: 24px;
}

.surface-card__header, .erp-block__head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    gap: 16px;
    flex-wrap: wrap;
}

.section-title, .erp-block__title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 4px 0;
    color: var(--text-main);
}

.section-subtitle, .erp-block__subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0;
}

/* --- Stats & KPIs --- */
.stats-inline {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: stretch;
}
.stat-chip {
    background: var(--bg-main);
    padding: 10px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-soft);
    display: flex; flex-direction: column;
}
.stat-chip__value { font-size: 1.1rem; font-weight: 700; color: var(--text-main); font-family: 'IBM Plex Mono', monospace;}
.stat-chip__label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; font-weight: 600; margin-top: 2px;}

.finance-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.finance-kpi {
    padding: 20px;
    border-radius: var(--radius-lg);
    background: #fff;
    border: 1px solid var(--border-soft);
    box-shadow: var(--shadow-sm);
    display: flex; flex-direction: column; gap: 8px;
}
.finance-kpi__label { font-size: 0.85rem; color: var(--text-muted); font-weight: 600;}
.finance-kpi__value { font-size: 1.5rem; font-weight: 800; color: var(--text-main); }
.finance-kpi--income { border-bottom: 4px solid var(--success); }
.finance-kpi--expense { border-bottom: 4px solid var(--danger); }
.finance-kpi--balance-positive { border-bottom: 4px solid var(--primary); }
.finance-kpi--balance-negative { border-bottom: 4px solid var(--warning); }

/* --- Forms & Inputs --- */
.stack-form { display: flex; flex-direction: column; gap: 18px; }
.stack-form > * { margin: 0; }
.grid-two { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 18px; }
.grid-three { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 18px; }
.grid-5 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 18px; }

.field-group { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-size: 0.85rem; font-weight: 600; color: var(--text-main); }
.field-group--actions { justify-content: flex-end; }

.form-control-app, .form-select.form-control-app {
    width: 100%;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-strong);
    background-color: #fff;
    color: var(--text-main);
    font-size: 0.95rem;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}
.form-control-app:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
.form-control-app--textarea { resize: vertical; min-height: 80px; }

.form-control-app,
.form-select.form-control-app,
.btn-app {
    line-height: 1.25;
}

/* --- Compact Period Filters --- */
.period-filter {
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(248, 250, 252, 0.96) 100%);
    border: 1px solid var(--border-strong);
    border-radius: 14px;
    box-shadow: var(--shadow-sm);
    padding: 12px 14px 14px;
    margin-bottom: 20px;
}

.period-filter__title {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 10px;
    margin: 0 0 10px;
    border-radius: 999px;
    background: #eef2ff;
    color: var(--primary);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.period-filter__form {
    display: grid;
    grid-template-columns: repeat(3, minmax(150px, 170px)) minmax(110px, auto);
    gap: 14px;
    align-items: end;
    min-width: 0;
}

.period-filter__field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.period-filter__label {
    font-size: 0.73rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0;
}

.period-filter__actions {
    display: flex;
    justify-content: flex-end;
    align-items: end;
    min-width: 0;
}

.period-filter .action-row__group {
    gap: 8px;
    flex-wrap: wrap;
}

.period-filter .form-control-app,
.period-filter .form-select.form-control-app {
    min-height: 42px;
    padding: 9px 12px;
    font-size: 0.92rem;
    box-shadow: none;
}

.period-filter .btn-app {
    min-height: 40px;
    padding: 8px 14px;
}

/* --- Buttons --- */
.btn-app {
    display: inline-flex; justify-content: center; align-items: center;
    padding: 10px 18px; border-radius: var(--radius-md); font-weight: 600;
    font-size: 0.9rem; border: none; cursor: pointer; transition: all 0.2s;
    text-decoration: none; text-align: center;
}
.btn-app:active { transform: scale(0.98); }
.btn-app-small { padding: 6px 12px; font-size: 0.85rem; }

.btn-app-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-app-primary:hover { background: var(--primary-hover); color: #fff; box-shadow: var(--shadow-md); }

.btn-app-secondary { background: var(--secondary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-app-secondary:hover { background: var(--secondary-hover); color: #fff; }

.btn-app-ghost { background: var(--bg-main); color: var(--text-main); border: 1px solid var(--border-strong); }
.btn-app-ghost:hover { background: var(--border-soft); }

.btn-app-danger { background: #fee2e2; color: var(--danger); }
.btn-app-danger:hover { background: #fecaca; color: var(--danger-hover); }

.action-row__group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.action-row__group > .btn-app,
.action-row__group > form,
.workspace-head__tools > .btn-app,
.workspace-head__tools > form {
    margin: 0;
}

.action-row__group > form {
    display: inline-flex;
}

/* --- Tables --- */
.table-responsive-app {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-soft);
    background: #fff;
}
.table-app, .management-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
    font-size: 0.9rem;
}
.table-app th, .management-table th {
    background: var(--bg-main);
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 12px 16px;
    text-align: left;
    position: sticky;
    top: 0;
    z-index: 2;
    border-bottom: 2px solid var(--border-soft);
}
.table-app td, .management-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-soft);
    vertical-align: middle;
}
.table-app tbody tr:hover, .management-table tbody tr:hover {
    background-color: #f8fafc;
}
.table-app tbody tr:last-child td { border-bottom: none; }

/* --- Specific Components --- */
.shipment-card { display: flex; flex-direction: column; gap: 12px; }
.shipment-card__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    flex-wrap: wrap;
}
.eyebrow { font-size: 0.75rem; text-transform: uppercase; color: var(--primary); font-weight: 700; letter-spacing: 0.5px; margin-bottom: 4px; display: block;}
.shipment-meta { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 8px; font-size: 0.85rem; color: var(--text-muted); }

.history-control-panel {
    display: grid;
    gap: 18px;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid rgba(148, 163, 184, 0.36);
    border-radius: 18px;
    background:
        linear-gradient(135deg, rgba(15, 23, 42, 0.04), rgba(37, 99, 235, 0.06)),
        var(--surface);
    box-shadow: var(--shadow-sm);
}

.history-control-panel__main {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
    flex-wrap: wrap;
    min-width: 0;
}

.history-customer-filter {
    display: flex;
    align-items: end;
    gap: 10px;
    flex-wrap: wrap;
    min-width: min(100%, 360px);
}

.history-customer-filter .field-group {
    flex: 1 1 260px;
}

.history-kpi-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    min-width: 0;
}

.history-kpi {
    display: grid;
    gap: 4px;
    min-width: 0;
    min-height: 86px;
    padding: 14px 16px;
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.82);
}

.history-kpi--success {
    border-color: rgba(16, 185, 129, 0.26);
    background: linear-gradient(180deg, #ecfdf5, #ffffff);
}

.history-kpi--warning {
    border-color: rgba(245, 158, 11, 0.28);
    background: linear-gradient(180deg, #fffbeb, #ffffff);
}

.history-kpi__label {
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.history-kpi__value {
    color: var(--text-main);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 1.28rem;
    line-height: 1.1;
}

.history-kpi__meta {
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 700;
}

.history-ledger {
    display: grid;
    gap: 12px;
    min-width: 0;
}

.history-shipment-card {
    display: grid;
    grid-template-columns: 126px minmax(0, 1fr);
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--border-soft);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.history-shipment-card__rail {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 18px;
    padding: 18px;
    background: linear-gradient(180deg, #0f172a, #1e293b);
    color: #fff;
}

.history-shipment-card__number {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.04em;
}

.history-shipment-card__date {
    color: rgba(255, 255, 255, 0.74);
    font-size: 0.82rem;
    font-weight: 700;
}

.history-shipment-card__body {
    display: grid;
    gap: 14px;
    min-width: 0;
    padding: 18px;
}

.history-shipment-card__top {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
    flex-wrap: wrap;
    min-width: 0;
}

.history-shipment-card__identity {
    min-width: 0;
    overflow-wrap: anywhere;
}

.history-shipment-card__customer {
    margin: 0;
    color: var(--text-main);
    font-size: 1.16rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    overflow-wrap: anywhere;
}

.history-shipment-card__facts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.history-shipment-card__facts span {
    display: inline-flex;
    min-height: 26px;
    align-items: center;
    padding: 4px 9px;
    border-radius: 999px;
    background: var(--bg-main);
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 700;
}

.history-shipment-card__amount {
    display: grid;
    gap: 8px;
    justify-items: end;
    min-width: 130px;
    overflow-wrap: anywhere;
}

.history-shipment-card__amount strong {
    color: var(--text-main);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 1.28rem;
    letter-spacing: -0.04em;
}

.history-pay-badge {
    display: inline-flex;
    min-height: 28px;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.history-pay-badge--paid {
    background: #dcfce7;
    color: #166534;
}

.history-pay-badge--open {
    background: #fef3c7;
    color: #92400e;
}

.history-shipment-card__controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    min-width: 0;
    padding-top: 12px;
    border-top: 1px solid var(--border-soft);
}

.history-date-form,
.history-action-grid {
    display: flex;
    align-items: end;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
    max-width: 100%;
}

.history-action-grid {
    justify-content: flex-end;
}

.history-action-grid > form {
    display: inline-flex;
    margin: 0;
}

.history-action-grid .btn-app,
.history-date-form .btn-app {
    white-space: nowrap;
}

.history-date-form__field {
    display: grid;
    gap: 4px;
    margin: 0;
}

.history-date-form__field span {
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.form-control-app--compact {
    min-height: 34px;
    padding: 6px 10px;
    font-size: 0.86rem;
    box-shadow: none;
}

.history-items-table {
    overflow-x: auto;
    max-width: 100%;
    min-width: 0;
    margin-top: 4px;
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    background: #fff;
}

.history-items-table .table-app th {
    background: #f8fafc;
}

.summary-chip {
    display: inline-flex;
    align-items: center;
    padding: 5px 10px;
    background: var(--bg-main);
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--secondary);
    margin: 0 8px 8px 0;
}

.production-batch {
    background: #f8fafc;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 16px;
}
.production-plan-row {
    background: #fff; padding: 12px; border-radius: var(--radius-md); border: 1px solid var(--border-soft); margin-bottom: 10px; align-items: center;
}

.production-order-head {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 10px;
    text-align: center;
}

.roll-assignment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
}

.roll-assignment-card {
    padding: 10px 12px;
    background: #fff;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
}

.roll-assignment-label {
    color: var(--text-muted);
    margin-bottom: 2px;
}

.production-settings-box {
    padding: 16px;
    background: var(--bg-main);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-soft);
}

.production-batch-stack,
.production-history-stack {
    display: grid;
    gap: 16px;
}

.production-history-order {
    display: grid;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    background: #fff;
}

.production-check-form {
    display: inline-flex;
}
.helper-note { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 8px; line-height: 1.4; }
.helper-note--inline { margin-bottom: 0; font-weight: 600; }

.finance-chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: 24px; margin-top: 24px;}
.finance-chart-card { background: #fff; padding: 20px; border-radius: var(--radius-lg); border: 1px solid var(--border-soft); }
.finance-chart-card--wide { grid-column: 1 / -1; }

.employee-modal-card + .employee-modal-card {
    margin-top: 20px;
}

.employee-page {
    display: grid;
    gap: 14px;
    margin-bottom: 16px;
    min-width: 0;
}

.employee-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 2px 0 4px;
    min-width: 0;
    flex-wrap: wrap;
}

.employee-title {
    margin: 0;
    color: var(--text-main);
    font-size: 1.35rem;
    line-height: 1.15;
    font-weight: 850;
}

.employee-toolbar__subtitle {
    margin: 4px 0 0;
    color: var(--text-muted);
    font-size: 0.88rem;
}

.employee-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
}

.employee-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 10px;
    min-width: 0;
}

.employee-kpi {
    display: grid;
    gap: 4px;
    min-width: 0;
    min-height: 72px;
    padding: 11px 12px;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: #fff;
}

.employee-kpi__label {
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 850;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.employee-kpi__value {
    color: var(--text-main);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 1.12rem;
    font-weight: 850;
    overflow-wrap: anywhere;
}

.employee-panel {
    margin-top: 14px;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: #fff;
}

.employee-panel__head,
.employee-panel__summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 46px;
    min-width: 0;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-soft);
}

.employee-panel__summary {
    cursor: pointer;
    list-style: none;
}

.employee-panel__summary::-webkit-details-marker,
.employee-card__summary::-webkit-details-marker {
    display: none;
}

.employee-panel__chevron,
.employee-card__chevron {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border: 1px solid var(--border-soft);
    border-radius: 999px;
    color: var(--text-muted);
    background: #fff;
    transition: transform 0.15s ease;
}

.employee-panel[open] .employee-panel__chevron,
.employee-card[open] .employee-card__chevron {
    transform: rotate(180deg);
}

.employee-panel__title {
    margin: 0;
    color: var(--text-main);
    font-size: 0.92rem;
    font-weight: 850;
}

.employee-panel__subtitle {
    margin: 4px 0 0;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.employee-panel__body {
    padding: 12px;
    min-width: 0;
}

.employee-list {
    display: grid;
    gap: 10px;
    min-width: 0;
}

.employee-card {
    max-width: 100%;
    min-width: 0;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
}

.employee-card[open] {
    box-shadow: var(--shadow-sm);
}

.employee-card__summary {
    display: grid;
    grid-template-columns: minmax(220px, 1.4fr) minmax(280px, 1.6fr) 30px;
    gap: 12px;
    align-items: center;
    padding: 12px;
    cursor: pointer;
    list-style: none;
    background: linear-gradient(180deg, #fff 0%, #fbfcfe 100%);
}

.employee-card__person {
    display: grid;
    gap: 5px;
    min-width: 0;
}

.employee-card__name {
    margin: 0;
    color: var(--text-main);
    font-size: 1rem;
    font-weight: 900;
    overflow-wrap: anywhere;
}

.employee-card__meta {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    min-width: 0;
}

.employee-pill {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 8px;
    border: 1px solid var(--border-soft);
    border-radius: 999px;
    background: #fff;
    color: var(--text-muted);
    font-size: 0.74rem;
    font-weight: 750;
    max-width: 100%;
    overflow-wrap: anywhere;
}

.employee-card__metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
    gap: 8px;
    min-width: 0;
}

.employee-mini {
    display: grid;
    gap: 2px;
    min-width: 0;
    padding: 8px 9px;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: #fff;
}

.employee-mini__label {
    color: var(--text-muted);
    font-size: 0.64rem;
    font-weight: 850;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.employee-mini__value {
    color: var(--text-main);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.92rem;
    font-weight: 850;
    overflow-wrap: anywhere;
}

.employee-mini--danger {
    border-color: rgba(239, 68, 68, 0.22);
    background: #fff7f7;
}

.employee-mini--good {
    border-color: rgba(16, 185, 129, 0.22);
    background: #f7fffb;
}

.employee-card__body {
    display: grid;
    gap: 12px;
    padding: 12px;
    min-width: 0;
    border-top: 1px solid var(--border-soft);
    background: #fff;
}

.employee-analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    min-width: 0;
}

.employee-pay-form {
    padding: 12px;
    min-width: 0;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: #fbfcfe;
}

.employee-table-wrap {
    max-width: 100%;
    max-height: 430px;
    overflow: auto;
}

.employee-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f7f9fc;
}

.employee-check {
    min-height: 42px;
    align-items: center;
}

.employee-delete-form {
    margin-top: 16px;
}

.user-access-list {
    display: grid;
    gap: 14px;
}

.user-access-card {
    display: grid;
    gap: 14px;
    min-width: 0;
    padding: 16px;
    border: 1px solid var(--border-soft);
    border-radius: 8px;
    background: #fbfcfe;
}

.user-access-card__identity {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.user-access-card__name {
    margin: 0;
    color: var(--text-main);
    font-size: 1rem;
    font-weight: 850;
}

.user-access-card__meta {
    margin: 4px 0 0;
    color: var(--text-muted);
    font-size: 0.84rem;
}

.user-access-form {
    display: grid;
    gap: 14px;
}

.user-access-card__permissions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.user-permission-check,
.user-permission-pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 34px;
    padding: 7px 10px;
    border: 1px solid var(--border-soft);
    border-radius: 999px;
    background: #fff;
    color: var(--text-main);
    font-size: 0.84rem;
    font-weight: 750;
}

.user-permission-check input {
    margin: 0;
}

.empty-state { padding: 40px; text-align: center; color: var(--text-muted); font-size: 0.95rem; background: var(--bg-main); border-radius: var(--radius-md); border: 1px dashed var(--border-strong);}

.flash-stack { margin-bottom: 24px; }
.flash-alert { padding: 16px; border-radius: var(--radius-md); font-weight: 500; }
.flash-alert--success { background: #d1fae5; color: #065f46; border: 1px solid #34d399; }
.flash-alert--danger { background: #fee2e2; color: #991b1b; border: 1px solid #f87171; }

/* Modals Refinement */
.app-modal .modal-content { border-radius: var(--radius-lg); border: none; box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25); }
.app-modal__header { background: var(--bg-main); border-bottom: 1px solid var(--border-soft); padding: 20px 24px; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.app-modal__body { padding: 24px; }
.panel__title { font-size: 1.4rem; font-weight: 700; margin: 0; }
.panel__subtitle { font-size: 0.9rem; color: var(--text-muted); margin: 4px 0 0 0; }

.app-modal__header,
.app-modal__body,
.document-options,
.document-summary,
.shipment-card__summary {
    gap: 12px;
}

.shipment-card__summary,
.document-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

.toolbar-filters,
.filter-bar {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    align-items: end;
    margin-bottom: 18px;
}

.toolbar-filters > *,
.filter-bar > * {
    margin: 0;
}

.inline-form-actions,
.editor-strip__actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.inline-form-actions > *,
.editor-strip__actions > * {
    margin: 0;
}

.position-card__body,
.product-editor,
.production-plan-items,
.data-list {
    display: grid;
    gap: 14px;
}

.data-list__row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.data-list__row--form {
    align-items: end;
}

.management-table-wrap,
.table-responsive-app {
    margin-top: 6px;
}

/* Utilities */
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 4px; }
.mt-3 { margin-top: 16px; }
.m-0 { margin: 0; }
.is-hidden { display: none !important; }
.field-span-2 { grid-column: span 2; }

@media (max-width: 900px) {
    .workspace-period-card {
        min-width: 100%;
    }

    .workspace-period-card__form {
        grid-template-columns: 1fr;
    }

    .workspace-period-card__actions {
        justify-content: flex-start;
    }

    .period-filter__form {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .period-filter__actions {
        justify-content: flex-start;
    }

    .employee-kpi-grid,
    .employee-analytics-grid,
    .employee-card__metrics {
        grid-template-columns: 1fr;
    }

    .history-shipment-card {
        grid-template-columns: 1fr;
    }

    .history-shipment-card__rail {
        flex-direction: row;
        align-items: center;
    }

    .history-shipment-card__amount {
        justify-items: start;
    }

    .employee-toolbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .employee-actions {
        justify-content: flex-start;
    }

    .employee-kpi-grid,
    .employee-analytics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .employee-card__summary {
        grid-template-columns: 1fr;
    }

    .employee-card__chevron {
        display: none;
    }
}

/* --- Professional Mobile App Layer --- */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

@media (max-width: 860px) {
    html {
        scroll-padding-bottom: 96px;
    }

    body {
        background: #eef4f8;
    }

    .erp-shell {
        display: block;
        height: auto;
        min-height: 100dvh;
        overflow: visible;
        padding-bottom: calc(82px + env(safe-area-inset-bottom));
    }

    .erp-main {
        display: block;
        min-height: 100dvh;
        overflow: visible;
    }

    .erp-sidebar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        z-index: 1040;
        display: block;
        width: 100%;
        height: calc(74px + env(safe-area-inset-bottom));
        padding: 8px max(8px, env(safe-area-inset-left)) calc(8px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-right));
        border-right: 0;
        border-top: 1px solid rgba(148, 163, 184, 0.28);
        background: rgba(15, 23, 42, 0.97);
        box-shadow: 0 -18px 42px rgba(15, 23, 42, 0.18);
        backdrop-filter: blur(18px);
    }

    .erp-sidebar__brand,
    .erp-sidebar__footer {
        display: none;
    }

    .erp-nav {
        flex: none;
        flex-direction: row;
        align-items: stretch;
        justify-content: space-around;
        height: 100%;
        gap: 4px;
        padding: 0;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
    }

    .erp-nav::-webkit-scrollbar {
        display: none;
    }

    .erp-nav__link {
        flex: 1 0 62px;
        display: grid;
        place-items: center;
        align-content: center;
        min-width: 58px;
        max-width: 96px;
        min-height: 54px;
        gap: 3px;
        padding: 6px 4px;
        border-radius: 14px;
        color: rgba(226, 232, 240, 0.86);
        font-size: 0.66rem;
        font-weight: 800;
        line-height: 1.05;
        text-align: center;
        white-space: nowrap;
    }

    .erp-nav__icon {
        width: 27px;
        height: 25px;
        border-radius: 9px;
        font-size: 0.72rem;
        background: rgba(255, 255, 255, 0.08);
    }

    .erp-nav__link.active {
        color: #fff;
        background: rgba(37, 99, 235, 0.26);
        box-shadow: none;
    }

    .erp-nav__link.active .erp-nav__icon {
        background: var(--primary);
        box-shadow: 0 6px 18px rgba(37, 99, 235, 0.34);
    }

    .erp-nav__link > span[data-mobile-label] {
        font-size: 0;
    }

    .erp-nav__link > span[data-mobile-label]::after {
        content: attr(data-mobile-label);
        font-size: 0.66rem;
    }

    .erp-topbar {
        position: sticky;
        top: 0;
        z-index: 1030;
        min-height: 58px;
        padding: 8px 12px;
        gap: 10px;
        background: rgba(255, 255, 255, 0.94);
        box-shadow: 0 8px 22px rgba(15, 23, 42, 0.06);
        backdrop-filter: blur(16px);
    }

    .erp-topbar__status {
        gap: 2px;
    }

    .erp-topbar__status-title {
        font-size: 0.68rem;
    }

    .erp-topbar__status .helper-note {
        display: none;
    }

    .erp-topbar__actions {
        gap: 7px;
        margin-left: auto;
    }

    .erp-icon-btn {
        display: grid;
        place-items: center;
        width: 36px;
        height: 36px;
        border: 1px solid var(--border-soft);
        border-radius: 12px;
        background: #fff;
        color: var(--text-main);
        font-size: 0.9rem;
        font-weight: 850;
        text-decoration: none;
        box-shadow: var(--shadow-sm);
    }

    .erp-icon-btn[aria-label="Сотрудники"],
    .erp-icon-btn[aria-label="Пользователи"] {
        display: none;
    }

    .erp-user {
        gap: 0;
    }

    .erp-user__meta {
        display: none;
    }

    .erp-user__avatar {
        width: 36px;
        height: 36px;
        border-radius: 12px;
        box-shadow: var(--shadow-sm);
    }

    .page-content {
        padding: 14px 12px calc(98px + env(safe-area-inset-bottom));
        overflow: visible;
    }

    .page-heading,
    .workspace-head,
    .employee-toolbar {
        display: grid;
        grid-template-columns: 1fr;
        align-items: start;
        gap: 12px;
        margin-bottom: 16px;
    }

    .page-heading h1,
    .workspace-head__title,
    .employee-title {
        font-size: 1.38rem;
        line-height: 1.13;
        letter-spacing: 0;
        overflow-wrap: anywhere;
    }

    .eyebrow {
        margin-bottom: 5px;
        font-size: 0.7rem;
    }

    .section-subtitle,
    .workspace-head__subtitle,
    .employee-toolbar__subtitle,
    .helper-note {
        font-size: 0.82rem;
        line-height: 1.42;
    }

    .surface-card,
    .erp-block,
    .hero-panel,
    .employee-panel,
    .employee-card,
    .user-access-card,
    .period-filter {
        border-radius: 14px;
        box-shadow: 0 8px 22px rgba(15, 23, 42, 0.05);
    }

    .surface-card,
    .erp-block,
    .hero-panel {
        padding: 14px;
        margin-bottom: 14px;
    }

    .surface-card__header,
    .erp-block__head {
        display: grid;
        grid-template-columns: 1fr;
        align-items: start;
        gap: 10px;
        margin-bottom: 12px;
    }

    .section-title,
    .erp-block__title,
    .employee-panel__title {
        font-size: 1rem;
        line-height: 1.2;
    }

    .content-grid,
    .content-grid--two,
    .content-grid--form,
    .analytics-chart-grid,
    .form-grid--wide,
    .toolbar-form,
    .modal-season-form,
    .season-editor-row,
    .grid-two,
    .grid-three,
    .grid-4,
    .grid-5,
    .workspace-period-card__form,
    .period-filter__form,
    .employee-pay-form .grid-three {
        grid-template-columns: 1fr;
    }

    .content-grid,
    .analytics-chart-grid {
        gap: 14px;
    }

    .finance-summary-grid,
    .employee-kpi-grid,
    .employee-analytics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px;
    }

    .finance-kpi,
    .employee-kpi {
        min-height: 78px;
        padding: 12px;
        border-radius: 14px;
    }

    .finance-kpi__label,
    .employee-kpi__label {
        font-size: 0.64rem;
        letter-spacing: 0.05em;
        line-height: 1.2;
    }

    .finance-kpi__value,
    .employee-kpi__value {
        font-size: clamp(1rem, 5.2vw, 1.28rem);
        line-height: 1.15;
        overflow-wrap: anywhere;
    }

    .btn-app,
    .btn:not(.btn-close),
    .form-control,
    .form-select,
    .form-control-app,
    .form-select.form-control-app,
    input,
    select {
        min-height: 44px;
        font-size: 16px;
    }

    textarea {
        font-size: 16px;
    }

    .btn-app,
    .btn:not(.btn-close) {
        border-radius: 12px;
        padding: 10px 14px;
        line-height: 1.2;
    }

    .btn-app-small,
    .btn-sm {
        min-height: 38px !important;
        padding: 8px 11px !important;
        font-size: 0.82rem !important;
    }

    .toolbar-form .btn,
    .form-grid > .btn,
    .invoice-form > .btn,
    .field-group--actions .btn-app,
    .period-filter__actions .btn-app,
    .modal-season-form .btn,
    .season-editor-row .btn,
    .workspace-head__tools .btn-app {
        width: 100%;
    }

    label,
    .field-group,
    .period-filter__field,
    .history-date-form__field {
        min-width: 0;
        font-weight: 700;
    }

    label > .form-control,
    label > .form-select {
        margin-top: 6px;
    }

    .line-items {
        gap: 8px;
    }

    .line-item {
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 10px;
        border: 1px solid var(--border-soft);
        border-radius: 12px;
        background: #fbfcfe;
    }

    .employee-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
        gap: 8px;
    }

    .employee-actions .btn {
        width: 100%;
    }

    .employee-panel {
        margin-top: 12px;
        overflow: visible;
    }

    .employee-panel__head,
    .employee-panel__summary {
        padding: 12px;
        align-items: flex-start;
    }

    .employee-panel__body,
    .employee-card__body {
        padding: 12px;
    }

    .employee-card__summary {
        position: relative;
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 12px;
    }

    .treatment-plan-card__head {
        position: relative;
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 12px 12px 12px 16px;
    }

    .employee-card__chevron {
        display: grid;
        position: absolute;
        top: 12px;
        right: 12px;
        width: 30px;
        height: 30px;
    }

    .employee-card__person {
        padding-right: 38px;
    }

    .treatment-plan-card__main {
        padding-right: 38px;
    }

    .employee-card__meta {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 4px;
        scrollbar-width: none;
    }

    .employee-card__meta::-webkit-scrollbar {
        display: none;
    }

    .employee-pill {
        flex: 0 0 auto;
    }

    .employee-card__metrics {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
        gap: 7px;
    }

    .treatment-plan-card__metrics {
        justify-content: flex-start;
    }

    .treatment-products-picker__head {
        grid-template-columns: 1fr;
    }

    .employee-mini {
        padding: 8px;
    }

    .employee-mini__label {
        font-size: 0.56rem;
    }

    .employee-mini__value {
        font-size: 0.82rem;
        line-height: 1.15;
    }

    .employee-pay-form {
        padding: 10px;
        border-radius: 12px;
    }

    .employee-table-wrap {
        max-height: none;
        overflow: visible;
    }

    .user-access-card {
        padding: 12px;
    }

    .user-access-card__permissions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .user-permission-check,
    .user-permission-pill {
        justify-content: center;
        min-height: 42px;
        border-radius: 12px;
        text-align: center;
    }

    .analytics-open-card {
        padding: 14px;
    }

    .analytics-chart-card,
    .analytics-chart-card--structure,
    .analytics-chart-card--timeline {
        padding: 14px;
    }

    .analytics-chart-title {
        font-size: 1.18rem;
        line-height: 1.18;
    }

    .analytics-chart-subtitle {
        font-size: 0.82rem;
        line-height: 1.35;
    }

    .chart-canvas-wrap,
    .chart-canvas-wrap--structure,
    .chart-canvas-wrap--timeline,
    .chart-canvas-wrap--wide {
        min-height: 280px;
    }

    .chart-canvas-wrap--timeline {
        min-height: 310px;
    }

    .analytics-chart-card canvas {
        max-height: none;
    }

    .chart-scroll-x {
        margin: 0 -4px;
        padding: 2px 4px 12px;
        background: #fff;
        -webkit-overflow-scrolling: touch;
    }

    .chart-scroll-x__inner {
        min-width: 900px;
        height: 390px;
        background: #fff;
    }

    .table-responsive,
    .table-responsive-app,
    .management-table-wrap {
        overflow: visible;
        border: 0;
        border-radius: 0;
        background: transparent;
    }

    .app-table,
    .table-app,
    .management-table {
        display: block;
        width: 100%;
        border-collapse: separate;
        border-spacing: 0;
        font-size: 0.9rem;
    }

    .app-table thead,
    .table-app thead,
    .management-table thead {
        display: none;
    }

    .app-table tbody,
    .table-app tbody,
    .management-table tbody {
        display: grid;
        gap: 10px;
    }

    .app-table tr,
    .table-app tr,
    .management-table tr {
        display: grid;
        padding: 10px 12px;
        border: 1px solid var(--border-soft);
        border-radius: 14px;
        background: #fff;
        box-shadow: var(--shadow-sm);
    }

    .app-table td,
    .table-app td,
    .management-table td {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 12px;
        min-width: 0;
        padding: 8px 0 !important;
        border-bottom: 1px solid #eef2f7 !important;
        text-align: right;
        overflow-wrap: anywhere;
    }

    .app-table td::before,
    .table-app td::before,
    .management-table td::before {
        content: attr(data-label);
        flex: 0 0 42%;
        max-width: 42%;
        color: var(--text-muted);
        font-size: 0.65rem;
        font-weight: 850;
        letter-spacing: 0.05em;
        line-height: 1.25;
        text-align: left;
        text-transform: uppercase;
    }

    .app-table td:last-child,
    .table-app td:last-child,
    .management-table td:last-child {
        border-bottom: 0 !important;
    }

    .app-table td[colspan],
    .table-app td[colspan],
    .management-table td[colspan] {
        display: block;
        padding: 8px 0 !important;
        border-bottom: 0 !important;
        text-align: left;
    }

    .app-table td[colspan]::before,
    .table-app td[colspan]::before,
    .management-table td[colspan]::before {
        display: none;
    }

    .nested-row {
        background: transparent;
    }

    .item-chip {
        max-width: 100%;
        margin: 3px 5px 3px 0;
        white-space: normal;
    }

    .empty-state {
        padding: 20px 14px;
        border-radius: 14px;
        font-size: 0.9rem;
    }

    .modal {
        padding: 0 !important;
    }

    .modal.show,
    .modal-backdrop.show {
        background: #fff;
    }

    .modal-backdrop.show {
        opacity: 1;
    }

    body.modal-open .erp-sidebar {
        transform: translateY(110%);
        pointer-events: none;
    }

    .modal-dialog {
        width: 100%;
        max-width: none;
        min-height: 100%;
        margin: 0;
    }

    .modal-content,
    .app-modal .modal-content,
    .app-modal {
        min-height: 100dvh;
        border-radius: 0 !important;
    }

    .app-modal__header {
        position: sticky;
        top: 0;
        z-index: 4;
        padding: 13px 14px;
        background: #fff;
        border-radius: 0 !important;
    }

    .app-modal__body {
        padding: 12px;
        background: #fff;
    }

    .panel__title {
        font-size: 1.15rem;
        line-height: 1.2;
    }

    .season-editor-list {
        gap: 10px;
    }

    .season-editor-row {
        padding: 12px;
        border-radius: 14px;
    }

    .flash-stack {
        margin-bottom: 14px;
    }

    .flash-alert {
        padding: 12px 14px;
        border-radius: 14px;
        font-size: 0.9rem;
    }
}

@media (max-width: 420px) {
    .page-content {
        padding-left: 10px;
        padding-right: 10px;
    }

    .finance-summary-grid,
    .employee-kpi-grid,
    .employee-analytics-grid {
        gap: 8px;
    }

    .finance-kpi,
    .employee-kpi {
        padding: 10px;
    }

    .finance-kpi__value,
    .employee-kpi__value {
        font-size: clamp(0.94rem, 4.8vw, 1.12rem);
    }

    .employee-card__metrics {
        grid-template-columns: 1fr !important;
    }

    .user-access-card__permissions {
        grid-template-columns: 1fr;
    }
}
