:root {
    --navy: #172548;
    --navy-deep: #111c38;
    --blue: #3569f6;
    --surface: #ffffff;
    --canvas: #f1f5fa;
    --text: #172033;
    --muted: #73809a;
    --border: #e3e9f2;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--text); font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif; }
.sidebar, .mobile-menu { background: linear-gradient(180deg, var(--navy-deep), #203b79); color: #fff; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 240px; z-index: 1040; flex-direction: column; }
.mobile-menu { width: 280px !important; }
.mobile-menu .offcanvas-body { display: flex; flex-direction: column; }
.brand-block { display: flex; align-items: center; gap: 12px; padding: 24px 20px; min-height: 88px; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; background: rgba(255,255,255,.14); font-weight: 800; font-size: 1.15rem; }
.brand-block strong { display: block; font-size: .95rem; letter-spacing: .01em; }
.brand-block small { display: block; margin-top: 2px; color: #91a4cb; font-size: .62rem; letter-spacing: .16em; }
.sidebar-nav { padding: 16px 14px; flex: 1; }
.sidebar-nav a { display: flex; align-items: center; gap: 13px; color: #aebbd4; text-decoration: none; padding: 13px 15px; border-radius: 10px; margin-bottom: 7px; font-size: .9rem; transition: .2s ease; }
.sidebar-nav a i { display: grid; place-items: center; width: 26px; height: 26px; }
.sidebar-nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-nav a.active { background: var(--blue); color: #fff; box-shadow: 0 10px 22px rgba(32,88,235,.3); }
.sidebar-foot { padding: 20px 28px; font-size: .75rem; color: #9eb0d1; border-top: 1px solid rgba(255,255,255,.08); }
.status-dot { display: inline-block; width: 8px; height: 8px; background: #34d399; border-radius: 50%; margin-right: 8px; box-shadow: 0 0 0 4px rgba(52,211,153,.12); }
.main-content { min-height: 100vh; margin-left: 240px; }
.topbar { height: 76px; padding: 0 24px; display: flex; align-items: center; gap: 15px; color: #fff; background: linear-gradient(105deg, #1a294e, #2455d5); box-shadow: 0 10px 30px rgba(30,55,110,.18); }
.page-chip { padding: 7px 13px; border-radius: 99px; background: rgba(255,255,255,.13); font-size: .68rem; font-weight: 700; letter-spacing: .12em; }
.topbar-meta { margin-left: auto; font-size: .78rem; color: #d7e2ff; }
.language-selector .btn { min-width: 54px; padding: 6px 10px; color: #fff; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.12); border-radius: 9px; font-size: .7rem; font-weight: 750; }
.language-selector .btn:hover, .language-selector .btn:focus { color: #fff; background: rgba(255,255,255,.2); }
.language-selector .dropdown-menu { min-width: 125px; padding: 6px; border: 0; box-shadow: 0 12px 30px rgba(22,37,72,.2); }
.language-selector .dropdown-item { padding: 7px 9px; border-radius: 6px; font-size: .75rem; }
.language-selector .dropdown-item.active { background: var(--blue); }
.menu-button { color: #fff; padding: 3px 8px; font-size: 1.5rem; border: 0; }
.page-body { padding: 32px; width: 100%; margin: 0; }
.page-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 22px; }
.page-heading span, .panel-heading span { color: #8090aa; font-size: .66rem; font-weight: 750; letter-spacing: .13em; }
.page-heading h1 { margin: 3px 0 0; font-size: 1.65rem; font-weight: 700; }
.snapshot-note { color: var(--muted); font-size: .78rem; }
.snapshot-note i { color: var(--blue); margin-right: 6px; }
.metric-card { --accent: var(--blue); position: relative; min-height: 158px; padding: 21px; overflow: hidden; background: var(--surface); border: 1px solid rgba(220,228,240,.8); border-radius: 17px; box-shadow: 0 14px 32px rgba(29,48,84,.07); }
.metric-card::after { content: ""; position: absolute; inset: auto 0 0; height: 3px; background: var(--accent); }
.metric-card > div:nth-child(2) { position: absolute; top: 22px; right: 21px; text-align: right; }
.metric-card span { display: block; color: #8090aa; font-size: .66rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.metric-card strong { display: block; margin-top: 2px; font-size: 1.75rem; line-height: 1.1; }
.metric-card small { position: absolute; left: 21px; right: 21px; bottom: 17px; padding-top: 12px; border-top: 1px solid var(--border); color: var(--muted); font-size: .72rem; }
.metric-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; color: #fff; background: var(--accent); }
.accent-green { --accent: #119b78; }.accent-violet { --accent: #7c3aed; }.accent-orange { --accent: #f97316; }.accent-red { --accent: #dc3545; }
.section-label { margin: 2px 0 10px; color: #8090aa; font-size: .66rem; font-weight: 750; letter-spacing: .13em; }
.panel { padding: 22px; background: var(--surface); border: 1px solid rgba(220,228,240,.8); border-radius: 18px; box-shadow: 0 14px 34px rgba(29,48,84,.06); }
.panel-heading { display: flex; align-items: end; justify-content: space-between; gap: 15px; margin-bottom: 20px; }
.panel-heading h2 { margin: 3px 0 0; font-size: 1rem; font-weight: 700; }
.chart-wrap { position: relative; height: 300px; }.chart-wide { height: 320px; }
.snapshot-table th, .machine-table th { color: #74819a; font-size: .66rem; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; border-bottom-color: var(--border); }
.snapshot-table td, .machine-table td { color: #46536a; font-size: .78rem; border-bottom-color: #edf1f6; }
.machine-panel { padding: 22px 22px 14px; overflow: hidden; }
.machine-table { margin-top: 8px !important; }
.machine-table td { white-space: nowrap; padding-top: 13px; padding-bottom: 13px; }
.serial-cell { color: #244fc8; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 750; text-decoration: none; }
.serial-cell:hover { color: #173aa0; text-decoration: underline; }
.model-pill { display: inline-block; padding: 5px 9px; border-radius: 7px; color: #4d5f7d; background: #eef2f8; font-size: .7rem; font-weight: 650; }
.state-pill { display: inline-flex; align-items: center; gap: 7px; padding: 5px 9px; border-radius: 99px; font-size: .68rem; font-weight: 700; }
.state-pill span { width: 7px; height: 7px; border-radius: 50%; }
.state-pill.online { color: #087457; background: #e5f8f1; }.state-pill.online span { background: #10b981; }
.state-pill.offline { color: #9a4f12; background: #fff1e2; }.state-pill.offline span { background: #f59e0b; }
.machine-table th:first-child, .machine-table td.health-cell { text-align: left !important; }
.machine-table td.health-cell { min-width: 120px; white-space: nowrap; }
.health-pill { display: inline-flex; align-items: center; gap: 7px; padding: 5px 9px; border-radius: 99px; font-size: .68rem; font-weight: 750; }
.health-pill span { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; }
.health-pill.healthy { color: #087457; background: #e5f8f1; }.health-pill.healthy span { background: #10b981; }
.health-pill.attention { color: #96600c; background: #fff3d8; }.health-pill.attention span { background: #e6a11b; }
.health-pill.critical { color: #b12b36; background: #ffe8eb; }.health-pill.critical span { background: #dc3545; }
.health-pill.stale { color: #9a4f12; background: #fff1e2; }.health-pill.stale span { background: #f59e0b; }
.health-pill.offline { color: #536079; background: #edf1f6; }.health-pill.offline span { background: #74819a; }
.health-pill.unknown { color: #52698c; background: #eaf0f8; }.health-pill.unknown span { background: #7690b7; }
.machine-health-report { display: grid; grid-template-columns: minmax(170px, .7fr) minmax(260px, 1.5fr) minmax(260px, 1fr); align-items: center; gap: 0; padding: 0; overflow: hidden; border-left: 4px solid #74819a; }
.machine-health-report.health-healthy { border-left-color: #10b981; }
.machine-health-report.health-attention { border-left-color: #e6a11b; }
.machine-health-report.health-critical { border-left-color: #dc3545; }
.machine-health-report.health-stale { border-left-color: #f59e0b; }
.machine-health-report.health-unknown { border-left-color: #7690b7; }
.machine-health-report > div { min-height: 86px; display: flex; flex-direction: column; justify-content: center; padding: 18px 22px; border-right: 1px solid var(--border); }
.machine-health-report > div:last-child { border-right: 0; }
.health-report-status > span:first-child, .health-report-details > span { display: block; margin-bottom: 8px; color: #8390a6; font-size: .64rem; font-weight: 750; letter-spacing: .07em; text-transform: uppercase; }
.health-report-status .health-pill { align-self: flex-start; }
.health-report-details strong { color: #344056; font-size: .78rem; line-height: 1.45; }
.dt-container .dt-search input, .dt-container .dt-length select { border-color: var(--border) !important; border-radius: 9px !important; font-size: .8rem; }
.dt-container .dt-search input { min-width: 220px; padding: 8px 12px !important; }
.dt-container .dt-info, .dt-container .dt-length { color: var(--muted); font-size: .75rem; }
.pagination { --bs-pagination-active-bg: var(--blue); --bs-pagination-active-border-color: var(--blue); --bs-pagination-color: #4d5f7d; }
.back-link { color: #dbe6ff; text-decoration: none; font-size: .78rem; font-weight: 650; }
.back-link:hover { color: #fff; }
.machine-heading { align-items: center; }
.machine-heading h1 { max-width: 1050px; }
.machine-heading p { margin: 5px 0 0; color: var(--muted); font-size: .84rem; }
.machine-state { padding: 8px 13px; }
.detail-heading-actions { display: flex; align-items: flex-end; gap: 12px; }
.period-selector label { display: block; margin-bottom: 4px; color: #8090aa; font-size: .62rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.period-selector select { min-width: 118px; color: #46536a; border-color: var(--border); border-radius: 9px; font-size: .75rem; }
.detail-stat { min-height: 128px; padding: 20px; background: #fff; border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 12px 28px rgba(29,48,84,.055); }
.detail-stat span { display: block; color: #8090aa; font-size: .66rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.detail-stat strong { display: block; margin: 8px 0 4px; font-size: 1.55rem; }
.detail-stat small { color: var(--muted); font-size: .73rem; }
.info-strip { display: grid; grid-template-columns: repeat(5, minmax(150px, 1fr)); gap: 0; padding: 0; overflow: hidden; }
.info-strip > div { padding: 18px 20px; border-right: 1px solid var(--border); }
.info-strip > div:last-child { border-right: 0; }
.info-strip span { display: block; margin-bottom: 5px; color: #8390a6; font-size: .64rem; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
.info-strip strong { color: #344056; font-size: .78rem; font-weight: 650; }
.matrix-panel { padding: 24px; }
.matrix-heading { align-items: center; margin-bottom: 6px; }
.matrix-help { margin: 0 0 18px; color: var(--muted); font-size: .76rem; }
.matrix-legend { display: flex; align-items: center; gap: 16px; color: var(--muted); font-size: .7rem; }
.matrix-legend span { display: flex; align-items: center; gap: 6px; letter-spacing: 0; text-transform: none; }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }.legend-dot.available { background: #10b981; }.legend-dot.low { background: #f59e0b; }.legend-dot.empty { background: #ef4444; }
.machine-matrix-wrap { width: 100%; overflow-x: auto; padding-bottom: 8px; }
.machine-matrix { display: grid; grid-template-columns: 64px repeat(var(--lane-count), minmax(138px, 1fr)); min-width: calc(64px + var(--lane-count) * 138px); gap: 7px; }
.matrix-corner, .lane-label, .floor-label { display: grid; place-items: center; color: #73819a; background: #f2f5fa; border-radius: 8px; font-size: .68rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.matrix-corner, .lane-label { min-height: 38px; }
.floor-label { min-height: 155px; color: #3154ad; background: #eaf0ff; }
.matrix-cell { min-height: 155px; padding: 5px; background: #f7f9fc; border: 1px dashed #dce3ed; border-radius: 11px; }
.matrix-cell.unused { display: grid; place-items: center; }
.empty-position { color: #c0cad8; }
.product-slot { height: 100%; min-height: 143px; display: flex; flex-direction: column; padding: 11px; background: #fff; border: 1px solid var(--border); border-top: 3px solid #10b981; border-radius: 9px; box-shadow: 0 5px 12px rgba(40,56,88,.05); }
.product-slot.low { border-top-color: #f59e0b; }.product-slot.empty { border-top-color: #ef4444; background: #fffafa; }
.slot-top, .slot-bottom { display: flex; align-items: center; justify-content: space-between; gap: 7px; }
.motor-code { color: #3154ad; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .68rem; font-weight: 800; }
.stock-count { color: #46536a; font-size: .68rem; font-weight: 800; }
.product-slot > strong { display: -webkit-box; margin: 10px 0 4px; overflow: hidden; color: #2b3548; font-size: .72rem; line-height: 1.35; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.product-slot > small { overflow: hidden; color: #8995a9; font-size: .62rem; text-overflow: ellipsis; white-space: nowrap; }
.slot-bottom { margin-top: auto; padding-top: 9px; border-top: 1px solid #edf1f6; color: #8995a9; font-size: .61rem; }
.slot-bottom b { color: #3b465a; font-size: .68rem; }
.detail-collapse-panel { padding: 0; overflow: hidden; }
.panel-toggle { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 22px 24px; color: inherit; background: transparent; border: 0; text-align: left; }
.panel-toggle > div:first-child > span { color: #8090aa; font-size: .66rem; font-weight: 750; letter-spacing: .13em; }
.panel-toggle h2 { margin: 3px 0 0; font-size: 1rem; font-weight: 700; }
.toggle-summary { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: .72rem; }
.toggle-summary i { display: grid; place-items: center; width: 30px; height: 30px; color: #52617a; background: #f0f4fa; border-radius: 9px; transition: transform .2s ease; }
.panel-toggle:not(.collapsed) .toggle-summary i { transform: rotate(180deg); }
.collapse-content { padding: 4px 24px 24px; border-top: 1px solid var(--border); }
.temperature-chart { height: 360px; padding-top: 20px; }
.retention-note { margin: 14px 0 0; color: #8a6a20; font-size: .7rem; }
.retention-note i { margin-right: 5px; }
.order-collapse-content { padding-top: 20px; }
.order-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 8px; }
.order-kpis > div { padding: 14px 16px; background: #f6f8fc; border: 1px solid #e7ecf4; border-radius: 11px; }
.order-kpis span { display: block; color: #8390a6; font-size: .62rem; font-weight: 750; letter-spacing: .07em; text-transform: uppercase; }
.order-kpis strong { display: block; margin-top: 5px; color: #26334a; font-size: 1rem; }
.order-chart { height: 350px; padding-top: 12px; }
.empty-panel { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 130px; color: var(--muted); font-size: .8rem; }
.empty-panel i { color: #7990bd; font-size: 1.25rem; }
.event-summary { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 7px; }
.event-summary > strong { margin-left: 5px; color: #536079; font-size: .72rem; }
.event-collapse-content { padding-top: 18px; }
.collapse-note { margin: 0 0 16px; color: var(--muted); font-size: .7rem; }
.severity-badge { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 99px; font-size: .64rem; font-weight: 750; }
.severity-badge.severity-info { color: #2456b8; background: #e9f1ff; }
.severity-badge.severity-notification { color: #96600c; background: #fff3d8; }
.severity-badge.severity-warning { color: #b12b36; background: #ffe8eb; }
.event-timeline { position: relative; max-height: 650px; overflow-y: auto; padding-right: 7px; }
.event-entry { display: grid; grid-template-columns: 22px 82px minmax(0, 1fr) auto; gap: 12px; min-height: 82px; }
.event-marker { position: relative; display: flex; justify-content: center; }
.event-marker::after { content: ""; position: absolute; top: 22px; bottom: -1px; width: 1px; background: #dfe5ef; }
.event-entry:last-child .event-marker::after { display: none; }
.event-marker i { position: relative; z-index: 1; width: 11px; height: 11px; margin-top: 7px; background: #4c7be8; border: 3px solid #e6efff; border-radius: 50%; box-sizing: content-box; }
.event-entry.severity-notification .event-marker i { background: #e6a11b; border-color: #fff2d4; }
.event-entry.severity-warning .event-marker i { background: #dc3545; border-color: #ffe4e7; }
.event-entry time { padding-top: 3px; color: #536079; }
.event-entry time strong, .event-entry time span { display: block; font-size: .7rem; }
.event-entry time span { margin-top: 3px; color: #8a96aa; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .64rem; }
.event-copy { min-width: 0; padding: 0 0 17px; }
.event-copy > div { display: flex; align-items: center; gap: 7px; margin-bottom: 6px; }
.event-copy code { color: #78859b; font-size: .63rem; }
.event-copy > strong { display: block; color: #303b4e; font-size: .76rem; line-height: 1.4; }
.event-copy p { margin: 4px 0 0; color: var(--muted); font-size: .7rem; }
.event-motor { padding: 5px 8px; align-self: start; color: #76839a; background: #f3f6fa; border-radius: 6px; font-size: .63rem; white-space: nowrap; }
.matrix-collapse-content { position: relative; padding-top: 50px; }
.matrix-collapse-content .matrix-legend { position: absolute; top: 18px; right: 24px; }

@media (max-width: 991.98px) {
    .main-content { margin-left: 0; }
    .page-body { padding: 24px 18px; }
    .topbar { height: 66px; padding: 0 15px; }
    .mobile-menu .brand-block { padding-top: 4px; }
    .info-strip { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
    .info-strip > div { border-bottom: 1px solid var(--border); }
    .machine-health-report { grid-template-columns: 1fr 2fr; }
    .machine-health-report > div:last-child { grid-column: 1 / -1; border-top: 1px solid var(--border); }
    .event-entry { grid-template-columns: 22px 72px minmax(0, 1fr); }
    .event-motor { display: none; }
}
@media (max-width: 575.98px) {
    .page-heading { align-items: start; flex-direction: column; gap: 8px; }
    .snapshot-note { display: none; }
    .topbar-meta { font-size: .68rem; }
    .metric-card { min-height: 145px; }
    .panel { padding: 17px; border-radius: 14px; }
    .chart-wrap, .chart-wide { height: 270px; }
    .dt-container .dt-layout-row { align-items: stretch !important; flex-direction: column; gap: 8px; }
    .dt-container .dt-search input { width: 100%; min-width: 0; margin-left: 0 !important; }
    .detail-page { padding-left: 12px; padding-right: 12px; }
    .machine-heading { align-items: start; }
    .detail-heading-actions { width: 100%; align-items: center; justify-content: space-between; }
    .machine-state { display: none; }
    .detail-stat { min-height: 112px; padding: 16px; }
    .detail-stat strong { font-size: 1.3rem; }
    .info-strip { grid-template-columns: 1fr; }
    .info-strip > div { border-right: 0; }
    .machine-health-report { grid-template-columns: 1fr; }
    .machine-health-report > div { min-height: 74px; border-right: 0; border-bottom: 1px solid var(--border); }
    .machine-health-report > div:last-child { grid-column: auto; border-top: 0; border-bottom: 0; }
    .matrix-panel { padding: 16px; }
    .matrix-heading { align-items: start; flex-direction: column; }
    .matrix-legend { flex-wrap: wrap; }
    .panel-toggle { align-items: flex-start; padding: 18px 17px; }
    .toggle-summary > span { display: none; }
    .collapse-content { padding: 4px 17px 18px; }
    .temperature-chart { height: 300px; }
    .event-summary { flex-wrap: nowrap; }
    .event-summary .severity-badge, .event-summary > strong { display: none; }
    .event-entry { grid-template-columns: 18px 58px minmax(0, 1fr); gap: 8px; }
    .event-entry time strong { font-size: .65rem; }
    .event-entry time span { font-size: .58rem; }
    .matrix-collapse-content { padding-top: 72px; }
    .matrix-collapse-content .matrix-legend { top: 18px; left: 17px; right: 17px; }
    .order-kpis { grid-template-columns: 1fr; }
    .order-chart { height: 300px; }
}
