:root {
    color-scheme: light;
    --canvas: #f2f4f5;
    --surface: #ffffff;
    --surface-soft: #f8f9fa;
    --sidebar: #172126;
    --sidebar-soft: #223039;
    --ink: #172026;
    --muted: #66727a;
    --line: #d8dee2;
    --line-strong: #bec8ce;
    --green: #176b4d;
    --green-dark: #10543c;
    --green-soft: #e8f3ee;
    --blue: #286f9b;
    --blue-soft: #eaf2f7;
    --amber: #b4670a;
    --amber-soft: #fbf1e4;
    --red: #b33a32;
    --red-soft: #faecea;
    --violet: #665c7a;
    --violet-soft: #f0edf4;
    --shadow: 0 1px 2px rgba(23, 32, 38, 0.05), 0 8px 24px rgba(23, 32, 38, 0.05);
    --mobile-nav-height: 76px;
    --mobile-safe-bottom: env(safe-area-inset-bottom, 0px);
    --mobile-safe-top: env(safe-area-inset-top, 0px);
    font-family: Tahoma, Arial, sans-serif;
    font-size: 16px;
    letter-spacing: 0;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { min-height: 100vh; margin: 0; background: var(--canvas); color: var(--ink); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.numeric-value, bdi, [dir="ltr"] { font-variant-numeric: tabular-nums; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 244px minmax(0, 1fr); direction: rtl; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 22px 16px 18px; background: var(--sidebar); color: #edf2f4; display: flex; flex-direction: column; z-index: 20; }
.brand { min-height: 58px; display: flex; align-items: center; gap: 12px; padding: 0 8px 18px; border-bottom: 1px solid #334047; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; }
.brand small { margin-top: 4px; color: #99a8b0; font-size: 11px; direction: ltr; text-align: right; }
.brand-symbol { width: 34px; height: 34px; padding: 7px; border: 1px solid #4b5a62; display: flex; align-items: flex-end; gap: 3px; flex: 0 0 auto; }
.brand-symbol i { width: 5px; background: #77c7a7; display: block; }
.brand-symbol i:nth-child(1) { height: 10px; }
.brand-symbol i:nth-child(2) { height: 18px; }
.brand-symbol i:nth-child(3) { height: 14px; }
.brand-symbol.large { width: 46px; height: 46px; border-color: #52636b; }
.brand-symbol.large i { width: 7px; }
.nav-section-label { padding: 26px 10px 10px; color: #7f9098; font-size: 11px; font-weight: 700; }
.primary-nav { display: grid; gap: 5px; }
.nav-link { min-height: 46px; padding: 8px 10px; border-right: 3px solid transparent; color: #bac5ca; display: flex; align-items: center; gap: 11px; transition: background-color 120ms ease, color 120ms ease; }
.nav-link:hover { background: var(--sidebar-soft); color: white; }
.nav-link.active { background: #233a33; border-right-color: #72c6a3; color: white; }
.nav-mark { width: 25px; color: #82939b; font-size: 11px; direction: ltr; }
.nav-link.active .nav-mark { color: #8ed3b6; }
.sidebar-footer { margin-top: auto; padding: 15px 10px 0; border-top: 1px solid #334047; display: grid; gap: 6px; }
.system-state { display: inline-flex; align-items: center; gap: 8px; color: #d9e5e0; font-size: 12px; }
.system-state i { width: 8px; height: 8px; border-radius: 50%; background: #44b986; box-shadow: 0 0 0 3px rgba(68, 185, 134, 0.13); }
.environment-label { color: #7f9098; font-size: 11px; }

.workspace { min-width: 0; min-height: 100vh; }
.topbar { height: 66px; padding: 0 28px; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 20px; position: sticky; top: 0; z-index: 15; }
.topbar-context span, .topbar-context strong { display: block; }
.topbar-context span { margin-bottom: 3px; color: var(--muted); font-size: 11px; }
.topbar-context strong { font-size: 14px; }
.topbar-user { display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--blue-soft); color: var(--blue); display: grid; place-items: center; font-size: 12px; font-weight: 800; direction: ltr; }
.user-identity strong, .user-identity small { display: block; }
.user-identity strong { font-size: 13px; }
.user-identity small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.topbar-user form { margin: 0 5px 0 0; }
.icon-command { width: 36px; height: 36px; padding: 0; border: 1px solid var(--line); border-radius: 5px; background: white; color: var(--muted); cursor: pointer; }
.icon-command:hover { border-color: var(--red); color: var(--red); background: var(--red-soft); }

.page { width: 100%; padding: 28px; }
.page-header { min-height: 78px; margin-bottom: 22px; display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.page-header.compact { min-height: 62px; }
.section-kicker { display: block; margin-bottom: 7px; color: var(--green); font-size: 11px; font-weight: 800; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: 27px; line-height: 1.25; }
h2 { margin-bottom: 5px; font-size: 17px; }
p { margin-bottom: 0; color: var(--muted); font-size: 13px; line-height: 1.75; }
.page-actions, .form-actions { display: flex; align-items: center; gap: 9px; }
.back-link { display: inline-flex; gap: 6px; margin-bottom: 9px; color: var(--blue); font-size: 12px; font-weight: 700; }
.workflow-badge { min-height: 34px; padding: 7px 11px; border: 1px solid #d7e5dc; background: var(--green-soft); color: var(--green-dark); display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700; }
.workflow-badge i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.workflow-badge.live { border-color: #c9dee9; background: var(--blue-soft); color: var(--blue); }
.workflow-badge.live i { background: var(--blue); }

.button { min-height: 42px; padding: 9px 16px; border: 1px solid transparent; border-radius: 5px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; cursor: pointer; font-weight: 700; font-size: 13px; }
.button.primary { background: var(--green); color: white; }
.button.primary:hover { background: var(--green-dark); }
.button.secondary { border-color: #a9c9bb; background: white; color: var(--green-dark); }
.button.secondary:hover { background: var(--green-soft); }
.button.quiet { border-color: var(--line); background: white; color: var(--ink); }
.button.quiet:hover { background: var(--surface-soft); border-color: var(--line-strong); }
.button.wide { width: 100%; }
.button-symbol { font-size: 19px; line-height: 1; }

.message { margin-bottom: 18px; padding: 12px 14px; border: 1px solid var(--line); border-right-width: 4px; background: white; display: flex; align-items: center; gap: 10px; font-size: 13px; }
.message i { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); }
.message.success { border-color: #9dcdb9; border-right-color: var(--green); background: var(--green-soft); }
.message.success i { background: var(--green); }
.message.error { border-color: #e1aaa6; border-right-color: var(--red); background: var(--red-soft); }
.message.error i { background: var(--red); }

.metric-strip { margin-bottom: 20px; border: 1px solid var(--line); background: var(--surface); display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); box-shadow: var(--shadow); }
.metric-cell { min-height: 102px; padding: 18px 20px; border-left: 1px solid var(--line); display: grid; align-content: center; }
.metric-cell:last-child { border-left: 0; }
.metric-cell > span { color: var(--muted); font-size: 11px; }
.metric-cell strong { margin: 5px 0; font-size: 26px; font-variant-numeric: tabular-nums; }
.metric-cell strong.metric-text { font-size: 16px; }
.metric-cell small { color: #839098; font-size: 10px; }

.data-panel, .structured-form { border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }
.panel-toolbar { min-height: 66px; padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.panel-title, .panel-subtitle { display: block; }
.panel-title { font-size: 14px; font-weight: 800; }
.panel-subtitle { margin-top: 3px; color: var(--muted); font-size: 10px; }
.table-filters { display: flex; gap: 8px; }
.search-control input { width: 250px; }
.filter-control select { width: 140px; }
.table-wrap { width: 100%; overflow-x: auto; }


.filter-bar { margin-bottom: 16px; padding: 12px; border: 1px solid var(--line); background: var(--surface); display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; box-shadow: var(--shadow); }
.filter-bar .button { align-self: stretch; justify-content: center; }
.detail-grid { padding: 18px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.detail-grid p { margin: 0; padding: 12px; border: 1px solid var(--line); background: var(--surface-soft); }
.detail-grid b, .detail-grid span { display: block; }
.detail-grid b { margin-bottom: 5px; color: var(--muted); font-size: 10px; }
.detail-grid span { font-size: 12px; font-weight: 800; }
.danger-panel { border-right: 4px solid var(--red); background: var(--red-soft); padding: 16px; }
.factory-input-form { max-width: none; }
.factory-input-form .table-wrap input, .factory-input-form .table-wrap select, .factory-input-form .table-wrap textarea { min-width: 120px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 15px; text-align: right; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { height: 42px; background: var(--surface-soft); color: #5e6a72; font-size: 10px; font-weight: 800; white-space: nowrap; }
td { font-size: 12px; }
tbody tr:hover { background: #fafcfc; }
tbody tr:last-child td { border-bottom: 0; }
td strong, td small { display: block; }
td small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.record-id { display: block; color: var(--blue); font-weight: 800; font-size: 13px; text-align: right; }
.date-value { direction: ltr; display: inline-block; }
.action-column { width: 96px; }
.row-action { min-height: 34px; padding: 7px 10px; border: 1px solid #a9c9bb; color: var(--green-dark); display: inline-flex; align-items: center; gap: 7px; font-weight: 800; }
.row-action:hover { background: var(--green-soft); }
.no-action { color: #a4adb2; }
.empty-state, .filter-empty { padding: 42px 20px !important; text-align: center !important; color: var(--muted); }

.status { min-height: 27px; padding: 4px 8px; border: 1px solid var(--line); background: #f1f3f4; color: #566269; display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; font-size: 10px; font-weight: 800; }
.status i, .stock-status i { width: 7px; height: 7px; border-radius: 50%; background: #7c898f; }
.status-released, .status-active, .status-in_production { border-color: #acd2c0; background: var(--green-soft); color: var(--green-dark); }
.status-released i, .status-active i, .status-in_production i { background: var(--green); }
.status-partially_completed, .status-completion_pending, .status-handed_off { border-color: #e5c99e; background: var(--amber-soft); color: #86500c; }
.status-partially_completed i, .status-completion_pending i, .status-handed_off i { background: var(--amber); }
.status-cancelled { border-color: #e2b2ae; background: var(--red-soft); color: var(--red); }
.status-cancelled i { background: var(--red); }
.status-submitted, .status-approved, .status-closed { border-color: #b8d4e4; background: var(--blue-soft); color: var(--blue); }
.status-submitted i, .status-approved i, .status-closed i { background: var(--blue); }

input, select, textarea { width: 100%; min-height: 44px; padding: 9px 11px; border: 1px solid var(--line-strong); border-radius: 4px; background: white; color: var(--ink); font-size: 13px; }
textarea { min-height: 84px; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: #89979f; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 3px solid rgba(40, 111, 155, 0.18); outline-offset: 1px; border-color: var(--blue); }
label { display: block; margin-bottom: 7px; color: #334047; font-size: 12px; font-weight: 800; }
.field-group { min-width: 0; position: relative; }
.field-help { display: block; margin-top: 6px; color: var(--muted); font-size: 10px; line-height: 1.6; }
.errorlist, .form-errors { margin: 6px 0 0; padding: 0; color: var(--red); list-style: none; font-size: 11px; }
.form-errors-block { margin-bottom: 18px; padding: 12px 14px; border: 1px solid #e2b2ae; border-right: 4px solid var(--red); background: var(--red-soft); }
.structured-form { max-width: 1120px; }
.form-section { padding: 22px; border-bottom: 1px solid var(--line); }
.form-section:last-of-type { border-bottom: 0; }
.form-section.compact-section { padding-top: 18px; padding-bottom: 18px; }
.section-heading { margin-bottom: 18px; display: flex; align-items: flex-start; gap: 12px; }
.section-number { width: 32px; height: 32px; border: 1px solid #b7c5cc; color: var(--blue); display: grid; place-items: center; flex: 0 0 auto; font-size: 10px; font-weight: 800; direction: ltr; }
.section-heading h2 { margin-bottom: 3px; }
.section-heading p { font-size: 11px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px; }
.form-grid.three-columns { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.check-label { min-height: 58px; margin: 0; padding: 11px 13px; border: 1px solid #c7dbe6; background: var(--blue-soft); display: flex; align-items: center; gap: 12px; cursor: pointer; }
.check-label input { width: 20px; min-height: 20px; flex: 0 0 auto; }
.check-label strong, .check-label small { display: block; }
.check-label small { margin-top: 4px; color: var(--muted); font-size: 10px; font-weight: 400; }
.measurement-section { background: #fbfcfc; }
.measurement-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.metric-input { padding: 14px; border: 1px solid var(--line); border-top: 3px solid var(--blue); background: white; }
.metric-input.scrap { border-top-color: var(--red); }
.metric-input input { min-height: 52px; font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; direction: ltr; text-align: right; }
.input-unit { float: left; margin-top: 1px; color: var(--muted); font-size: 10px; }
.stock-row { margin-top: 16px; align-items: stretch; }
.measurement-note { min-height: 70px; padding: 12px 14px; border-right: 4px solid var(--blue); background: var(--blue-soft); color: #315a70; display: flex; align-items: center; gap: 10px; font-size: 11px; line-height: 1.7; }
.measurement-note i { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); flex: 0 0 auto; }
.form-action-bar { min-height: 74px; padding: 14px 20px; background: var(--surface-soft); border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.action-summary strong, .action-summary span { display: block; }
.action-summary strong { font-size: 12px; }
.action-summary span { margin-top: 3px; color: var(--muted); font-size: 10px; }

.run-header { margin-bottom: 18px; padding: 20px 22px; border: 1px solid var(--line); border-right: 5px solid var(--green); background: white; display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; box-shadow: var(--shadow); }
.run-identity { display: flex; align-items: center; gap: 14px; }
.run-identity h1 { margin: 0; text-align: right; font-size: 25px; }
.run-product { text-align: left; }
.run-product strong, .run-product span { display: block; }
.run-product strong { font-size: 16px; }
.run-product span { margin-top: 5px; color: var(--muted); font-size: 11px; }
.context-band { margin-bottom: 14px; border: 1px solid var(--line); background: white; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.context-band > div { min-height: 74px; padding: 14px 16px; border-left: 1px solid var(--line); display: grid; align-content: center; }
.context-band > div:last-child { border-left: 0; }
.context-band span, .context-band strong { display: block; }
.context-band span { margin-bottom: 5px; color: var(--muted); font-size: 10px; }
.context-band strong { font-size: 12px; }
.production-kpis { margin-bottom: 14px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.production-kpi { min-height: 132px; padding: 16px; border: 1px solid var(--line); border-top: 4px solid var(--blue); background: white; position: relative; box-shadow: var(--shadow); }
.production-kpi.success { border-top-color: var(--green); }
.production-kpi.danger { border-top-color: var(--red); }
.kpi-index { position: absolute; top: 12px; left: 13px; color: #a4adb2; font-size: 10px; direction: ltr; }
.kpi-label { display: block; color: var(--muted); font-size: 11px; }
.production-kpi strong { display: block; margin: 14px 0 4px; font-size: 30px; line-height: 1; font-variant-numeric: tabular-nums; }
.production-kpi small { color: var(--muted); font-size: 10px; }
.stock-state-band { margin-bottom: 14px; padding: 13px 16px; border: 1px solid var(--line); background: white; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.stock-state-band > div { display: flex; align-items: center; gap: 12px; }
.stock-state-band > div > span { color: var(--muted); font-size: 11px; }
.stock-status { min-height: 29px; padding: 5px 9px; display: inline-flex; align-items: center; gap: 7px; font-size: 11px; }
.stock-pending { background: var(--amber-soft); color: #86500c; }
.stock-pending i { background: var(--amber); }
.stock-accepted { background: var(--green-soft); color: var(--green-dark); }
.stock-accepted i { background: var(--green); }
.stock-hold { background: var(--violet-soft); color: var(--violet); }
.stock-hold i { background: var(--violet); }
.record-count { color: var(--muted); font-size: 11px; }

.auth-page { background: #e9edef; }
.auth-main { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-workspace { width: min(920px, 100%); min-height: 520px; border: 1px solid #cad2d6; background: white; display: grid; grid-template-columns: 44% 56%; box-shadow: 0 18px 60px rgba(23, 32, 38, 0.14); direction: rtl; }
.login-identity { padding: 34px; background: var(--sidebar); color: white; display: flex; flex-direction: column; }
.login-brand { display: flex; align-items: center; gap: 14px; }
.login-brand strong, .login-brand span { display: block; }
.login-brand strong { font-size: 16px; }
.login-brand span { margin-top: 4px; color: #91a2aa; font-size: 11px; direction: ltr; text-align: right; }
.login-context { margin: auto 0; }
.login-context .section-kicker { color: #78c9a8; }
.login-context h1 { max-width: 290px; font-size: 34px; }
.login-context p { max-width: 310px; color: #adbac0; }
.login-system-state { padding-top: 17px; border-top: 1px solid #344148; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.login-system-state > span:last-child { color: #7f9098; font-size: 10px; }
.login-form-zone { padding: 54px 58px; display: flex; flex-direction: column; justify-content: center; }
.login-form-heading { margin-bottom: 24px; }
.login-form-heading h2 { font-size: 22px; }
.stack-form { display: grid; gap: 16px; }
.login-submit { margin-top: 4px; min-height: 48px; justify-content: space-between; }
.shared-device-note { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); display: flex; align-items: flex-start; gap: 9px; font-size: 10px; line-height: 1.7; }
.note-mark { width: 19px; height: 19px; border: 1px solid #d8b87b; background: var(--amber-soft); color: var(--amber); display: grid; place-items: center; flex: 0 0 auto; font-weight: 800; }

@media (max-width: 980px) {
    .app-shell { grid-template-columns: 82px minmax(0, 1fr); }
    .sidebar { padding-inline: 10px; }
    .brand { justify-content: center; }
    .brand > span:last-child, .nav-section-label, .nav-link > span:last-child, .sidebar-footer .environment-label { display: none; }
    .nav-link { justify-content: center; border-right-width: 0; border-bottom: 3px solid transparent; }
    .nav-link.active { border-bottom-color: #72c6a3; }
    .nav-mark { width: auto; }
    .sidebar-footer { justify-items: center; }
    .system-state { font-size: 0; }
    .form-grid.three-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .measurement-grid, .production-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .context-band { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .context-band > div:nth-child(2) { border-left: 0; }
    .context-band > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}

@media (max-width: 720px) {
    .app-shell { display: block; padding-bottom: calc(var(--mobile-nav-height) + var(--mobile-safe-bottom) + 18px); }
    .workspace { min-height: 100dvh; }
    .page { padding-bottom: calc(var(--mobile-nav-height) + var(--mobile-safe-bottom) + 24px); }
    .sidebar { position: fixed; top: auto; bottom: 0; right: 0; left: 0; width: 100%; height: calc(var(--mobile-nav-height) + var(--mobile-safe-bottom)); padding: 7px 10px calc(8px + var(--mobile-safe-bottom)); display: block; border-top: 1px solid #39474e; }
    .brand, .nav-section-label, .sidebar-footer { display: none; }
    .primary-nav { height: 100%; display: grid; grid-template-columns: repeat(5, minmax(76px, 1fr)); gap: 4px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
    .primary-nav::-webkit-scrollbar { display: none; }
    .nav-link { min-height: 58px; padding: 7px 9px; justify-content: center; border: 0; border-top: 3px solid transparent; flex-direction: column; gap: 4px; font-size: 10px; border-radius: 6px; }
    .nav-link.active { border: 0; border-top: 3px solid #72c6a3; background: #233a33; color: #fff; }
    .nav-link > span:last-child { display: block; }
    .nav-mark { font-size: 9px; }
    .topbar { height: 58px; padding: 0 14px; }
    .topbar-context span, .user-identity small { display: none; }
    .topbar-context strong { font-size: 12px; }
    .user-identity strong { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .page { padding: 16px 10px; }
    .page-header { min-height: 0; display: block; }
    .page-actions { margin-top: 15px; }
    .page-actions .button { flex: 1; }
    h1 { font-size: 23px; }
    .workflow-badge { margin-top: 14px; }
    .metric-strip { grid-template-columns: 1fr; }
    .metric-cell { min-height: 78px; border-left: 0; border-bottom: 1px solid var(--line); }
    .metric-cell:last-child { border-bottom: 0; }
    .panel-toolbar { display: block; }
    .table-filters { margin-top: 12px; }
    .search-control { flex: 1; }
    .search-control input, .filter-control select { width: 100%; }
    .operations-table, .operations-table tbody, .operations-table tr, .operations-table td { display: block; width: 100%; }
    .operations-table thead { display: none; }
    .operations-table tr { padding: 12px 14px; border-bottom: 1px solid var(--line); }
    .operations-table tr[hidden] { display: none; }
    .operations-table td { min-height: 34px; padding: 7px 0 7px 42%; border: 0; position: relative; text-align: left; }
    .operations-table td::before { content: attr(data-label); position: absolute; right: 0; top: 8px; width: 38%; color: var(--muted); text-align: right; font-size: 10px; font-weight: 700; }
    .operations-table td strong, .operations-table td small, .record-id { text-align: left; }
    .action-column { width: 100%; }
    .row-action { width: 100%; justify-content: center; margin-top: 4px; }
    .form-section { padding: 18px 14px; }
    .form-grid, .form-grid.three-columns, .measurement-grid, .production-kpis, .context-band { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
    .form-action-bar { align-items: stretch; flex-direction: column; }
    .form-actions .button { flex: 1; }
    .context-band > div { border-left: 0; border-bottom: 1px solid var(--line); }
    .context-band > div:last-child { border-bottom: 0; }
    .run-header { align-items: flex-start; flex-direction: column; }
    .run-product { text-align: right; }
    .stock-state-band { align-items: flex-start; flex-direction: column; }
    .stock-state-band > div { align-items: flex-start; flex-direction: column; }
    .login-workspace { min-height: 0; grid-template-columns: 1fr; }
    .login-identity { min-height: 220px; padding: 24px; }
    .login-context { margin: 34px 0 20px; }
    .login-context h1 { font-size: 27px; }
    .login-form-zone { padding: 28px 22px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}


/* Operational dashboards */
.dashboard-header { align-items: center; }
.dashboard-stamp { min-width: 176px; padding: 10px 13px; border: 1px solid var(--line); background: white; }
.dashboard-stamp span, .dashboard-stamp strong { display: block; }
.dashboard-stamp span { margin-bottom: 4px; color: var(--muted); font-size: 10px; }
.dashboard-stamp strong { font-size: 12px; text-align: right; }
.dashboard-kpis { margin-bottom: 18px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.dashboard-kpi { min-height: 120px; padding: 16px 17px; border: 1px solid var(--line); border-top: 4px solid var(--blue); background: white; box-shadow: var(--shadow); }
.dashboard-kpi.success { border-top-color: var(--green); }
.dashboard-kpi.danger { border-top-color: var(--red); }
.dashboard-kpi.attention { border-top-color: var(--amber); }
.dashboard-kpi.info { border-top-color: var(--violet); }
.dashboard-kpi > span, .dashboard-kpi strong, .dashboard-kpi small { display: block; }
.dashboard-kpi > span { color: var(--muted); font-size: 11px; }
.dashboard-kpi strong { margin: 13px 0 5px; font-size: 28px; line-height: 1; font-variant-numeric: tabular-nums; }
.dashboard-kpi small { color: var(--muted); font-size: 10px; }
.dashboard-split { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(330px, .65fr); gap: 14px; align-items: start; }
.dashboard-split.production-columns { grid-template-columns: minmax(0, 1.55fr) minmax(320px, .75fr); }
.dashboard-stack { display: grid; gap: 14px; }
.panel-link { color: var(--blue); font-size: 11px; font-weight: 800; }
.state-summary { padding: 14px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.state-count { min-height: 68px; padding: 10px 12px; border-right: 3px solid var(--line-strong); background: var(--surface-soft); }
.state-count.running { border-right-color: var(--green); }
.state-count.idle { border-right-color: #7c898f; }
.state-count.pending { border-right-color: var(--amber); }
.state-count.inactive { border-right-color: var(--red); }
.state-count span, .state-count strong { display: block; }
.state-count span { color: var(--muted); font-size: 9px; }
.state-count strong { margin-top: 7px; font-size: 20px; }
.machine-compact-list, .activity-list, .queue-list { display: grid; }
.machine-compact-row, .activity-row, .queue-row { min-height: 58px; padding: 10px 14px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.machine-compact-row:last-child, .activity-row:last-child, .queue-row:last-child { border-bottom: 0; }
.machine-compact-row > div, .activity-row > div:first-child, .queue-row > div { min-width: 0; flex: 1; }
.machine-compact-row strong, .machine-compact-row small, .activity-row strong, .activity-row small, .queue-row strong, .queue-row small { display: block; }
.machine-compact-row small, .activity-row small, .queue-row small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.machine-compact-state { min-width: 92px; color: var(--muted); font-size: 10px; }
.machine-compact-row > a, .muted-value { color: var(--blue); font-size: 10px; }
.muted-value { color: var(--muted); }
.machine-state-dot { width: 9px; height: 9px; border-radius: 50%; background: #7c898f; flex: 0 0 auto; }
.state-running { background: var(--green); box-shadow: 0 0 0 3px rgba(23,107,77,.12); }
.state-idle { background: #7c898f; }
.state-pending { background: var(--amber); }
.state-inactive { background: var(--red); }
.activity-value { text-align: left; display: grid; justify-items: end; gap: 5px; }
.dashboard-empty { min-height: 150px; padding: 28px; color: var(--muted); display: grid; place-items: center; align-content: center; gap: 6px; text-align: center; font-size: 11px; }
.dashboard-empty strong, .dashboard-empty span { display: block; }
.dashboard-empty.compact { min-height: 90px; }
.dashboard-empty.full-span { grid-column: 1 / -1; width: 100%; }
.active-run-grid { padding: 12px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.active-run-card { min-height: 190px; padding: 14px; border: 1px solid var(--line); border-top: 3px solid var(--green); background: white; }
.active-run-card:hover { border-color: #9dcdb9; box-shadow: var(--shadow); }
.active-run-head { display: flex; align-items: center; gap: 8px; }
.active-run-head .status { margin-right: auto; }
.run-code { display: block; margin-top: 15px; color: var(--blue); font-size: 11px; text-align: right; }
.active-run-card h3 { margin: 6px 0 3px; font-size: 15px; }
.active-run-card p { font-size: 10px; }
.run-card-metrics { margin-top: 14px; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(2, 1fr); }
.run-card-metrics span { padding: 8px 0; color: var(--muted); font-size: 9px; }
.run-card-metrics b { color: var(--ink); font-size: 12px; }
.run-card-metrics .scrap-value b { color: var(--red); }
.queue-row { justify-content: space-between; }
.queue-row > span:last-child { color: var(--green); font-size: 10px; font-weight: 800; }
.machine-summary-strip { margin-bottom: 15px; border: 1px solid var(--line); background: white; display: grid; grid-template-columns: repeat(4, 1fr); box-shadow: var(--shadow); }
.machine-summary-strip > div { min-height: 76px; padding: 12px 16px; border-left: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.machine-summary-strip > div:last-child { border-left: 0; }
.machine-summary-strip strong { font-size: 23px; }
.machine-summary-strip small { color: var(--muted); font-size: 10px; }
.machine-monitor-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.machine-monitor-card { min-height: 310px; border: 1px solid var(--line); border-top: 4px solid #7c898f; background: white; box-shadow: var(--shadow); }
.machine-monitor-card.state-border-running { border-top-color: var(--green); }
.machine-monitor-card.state-border-pending { border-top-color: var(--amber); }
.machine-monitor-card.state-border-inactive { border-top-color: var(--red); }
.machine-monitor-card > header { min-height: 62px; padding: 12px 15px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.machine-monitor-card > header > div { display: grid; grid-template-columns: auto auto; align-items: center; gap: 4px 8px; }
.machine-monitor-card > header small { grid-column: 2; color: var(--muted); font-size: 9px; }
.machine-state-label { padding: 5px 8px; background: #f1f3f4; color: var(--muted); font-size: 9px; font-weight: 800; }
.state-label-running { background: var(--green-soft); color: var(--green-dark); }
.state-label-pending { background: var(--amber-soft); color: #86500c; }
.state-label-inactive { background: var(--red-soft); color: var(--red); }
.machine-run-context { padding: 15px 16px 10px; }
.machine-run-context h2 { margin: 6px 0 3px; }
.machine-run-context p { font-size: 10px; }
.machine-live-metrics { margin: 0 15px; border: 1px solid var(--line); display: grid; grid-template-columns: repeat(4, 1fr); }
.machine-live-metrics > div { min-height: 70px; padding: 10px; border-left: 1px solid var(--line); }
.machine-live-metrics > div:last-child { border-left: 0; }
.machine-live-metrics span, .machine-live-metrics strong { display: block; }
.machine-live-metrics span { color: var(--muted); font-size: 9px; }
.machine-live-metrics strong { margin-top: 9px; font-size: 16px; }
.machine-live-metrics strong small { font-size: 8px; }
.machine-live-metrics .scrap strong { color: var(--red); }
.machine-monitor-card > footer { min-height: 50px; margin-top: 14px; padding: 10px 15px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 9px; }
.machine-monitor-card > footer a { color: var(--blue); font-weight: 800; }
.machine-idle-state { min-height: 240px; padding: 25px; display: grid; place-items: center; align-content: center; gap: 8px; text-align: center; }
.machine-idle-state p { max-width: 280px; font-size: 10px; }
.machine-idle-state .button { margin-top: 8px; }
.machine-outline { width: 42px; height: 32px; border: 2px solid #aeb9bf; position: relative; }
.machine-outline::before, .machine-outline::after { content: ""; position: absolute; bottom: -7px; width: 8px; height: 5px; background: #aeb9bf; }
.machine-outline::before { right: 3px; }
.machine-outline::after { left: 3px; }

@media (max-width: 1100px) {
    .dashboard-split, .dashboard-split.production-columns { grid-template-columns: 1fr; }
    .machine-monitor-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
    .dashboard-stamp { margin-top: 13px; width: 100%; }
    .dashboard-kpis, .machine-summary-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dashboard-kpi { min-height: 105px; }
    .state-summary { grid-template-columns: repeat(2, 1fr); }
    .machine-compact-row { flex-wrap: wrap; }
    .machine-compact-state { min-width: auto; margin-right: auto; }
    .active-run-grid { grid-template-columns: 1fr; }
    .machine-summary-strip > div { border-bottom: 1px solid var(--line); }
    .machine-live-metrics { grid-template-columns: repeat(2, 1fr); }
    .machine-live-metrics > div:nth-child(2) { border-left: 0; }
    .machine-live-metrics > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
    .machine-monitor-card > footer { align-items: flex-start; flex-direction: column; }
}


/* Phase 2 operational intelligence */
.primary-nav { overflow-y: auto; scrollbar-width: thin; }
.nav-link { flex: 0 0 auto; }
.command-kpis { margin-bottom: 14px; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.command-kpis.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.command-kpi { min-height: 142px; padding: 18px; border: 1px solid var(--line); border-top: 5px solid #66747b; background: var(--surface); box-shadow: var(--shadow); display: flex; flex-direction: column; justify-content: center; }
.command-kpi.primary { border-top-color: var(--blue); background: #f7fbfd; }
.command-kpi.success { border-top-color: var(--green); }
.command-kpi.warning { border-top-color: var(--amber); }
.command-kpi.danger { border-top-color: var(--red); }
.command-kpi span { color: var(--muted); font-size: 11px; font-weight: 700; }
.command-kpi strong { margin: 12px 0 7px; font-size: 32px; line-height: 1; font-variant-numeric: tabular-nums; }
.command-kpi small { color: var(--muted); font-size: 10px; }
.executive-rankings { margin-bottom: 14px; border: 1px solid var(--line); background: var(--surface); display: grid; grid-template-columns: repeat(4, 1fr); box-shadow: var(--shadow); }
.executive-rankings article { min-height: 82px; padding: 13px 16px; border-left: 1px solid var(--line); display: grid; align-content: center; }
.executive-rankings article:last-child { border-left: 0; }
.executive-rankings span, .executive-rankings strong, .executive-rankings small { display: block; }
.executive-rankings span, .executive-rankings small { color: var(--muted); font-size: 9px; }
.executive-rankings strong { margin: 5px 0; font-size: 15px; }
.owner-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.owner-machine-list { display: grid; }
.owner-machine-list a { min-height: 62px; padding: 10px 14px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 12px 82px 110px minmax(0, 1fr); align-items: center; gap: 9px; }
.owner-machine-list a:last-child { border-bottom: 0; }
.owner-machine-list a:hover { background: var(--surface-soft); }
.owner-machine-list span, .owner-machine-list small { font-size: 10px; color: var(--muted); }
.progress-list { display: grid; }
.progress-row { padding: 13px 15px; border-bottom: 1px solid var(--line); }
.progress-row:last-child { border-bottom: 0; }
.progress-row > div:first-child { display: flex; justify-content: space-between; gap: 12px; font-size: 11px; }
.progress-row small { display: block; margin-top: 6px; color: var(--muted); font-size: 9px; }
.progress-track, .table-progress > div, .mini-track { height: 7px; margin-top: 8px; overflow: hidden; background: #e5eaed; }
.progress-track i, .table-progress i, .mini-track i { height: 100%; background: var(--green); display: block; }
.progress-row.delayed .progress-track i { background: var(--red); }
.notification-count { min-width: 28px; height: 28px; background: var(--red-soft); color: var(--red); display: grid; place-items: center; font-size: 11px; font-weight: 800; }
.notification-list { max-height: 350px; overflow-y: auto; }
.notice { min-height: 72px; padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; gap: 11px; }
.notice > i { width: 8px; height: 8px; margin-top: 5px; border-radius: 50%; background: var(--blue); flex: 0 0 auto; }
.notice-warning > i { background: var(--amber); }
.notice-critical > i { background: var(--red); }
.notice strong, .notice small { display: block; }
.notice strong { font-size: 11px; }
.notice p { margin: 3px 0; font-size: 10px; line-height: 1.5; }
.notice small { color: var(--muted); font-size: 8px; }
.analytics-grid { margin-bottom: 14px; display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(320px, .5fr); gap: 14px; }
.bar-chart { height: 280px; padding: 28px 20px 15px; display: flex; align-items: flex-end; justify-content: space-around; gap: 10px; direction: ltr; }
.bar-column { height: 100%; min-width: 34px; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 5px; }
.bar-column span, .bar-column small { color: var(--muted); font-size: 9px; }
.bar-column i { width: min(46px, 70%); min-height: 4px; background: var(--blue); border-top: 3px solid #175579; }
.hourly-list > div { min-height: 48px; padding: 8px 14px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 48px 1fr 72px; align-items: center; gap: 10px; font-size: 10px; }
.hourly-list strong { text-align: left; }
.mini-track { margin: 0; }
.breakdown-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.compact-table th, .compact-table td { padding-block: 10px; }
.machine-summary-strip.five { grid-template-columns: repeat(5, 1fr); }
.machine-control-table { min-width: 1180px; }
.machine-control-table td { height: 72px; }
.machine-row { border-right: 4px solid #839098; }
.machine-row.state-row-running { border-right-color: var(--green); }
.machine-row.state-row-idle { border-right-color: var(--amber); }
.machine-row.state-row-stopped { border-right-color: var(--red); }
.machine-row.state-row-fault { border-right-color: #111; background: #f3f3f3; }
.machine-control-state { min-height: 28px; padding: 5px 8px; display: inline-flex; align-items: center; gap: 7px; background: #eef1f2; font-size: 10px; font-weight: 800; }
.machine-control-state i { width: 8px; height: 8px; border-radius: 50%; background: #839098; }
.state-label-running i { background: var(--green); }
.state-label-idle i { background: var(--amber); }
.state-label-stopped i { background: var(--red); }
.state-label-fault { background: #222; color: white; }
.state-label-fault i, .state-fault { background: #111; }
.state-stopped { background: var(--red); }
.table-progress { min-width: 110px; }
.table-progress > span { display: block; font-size: 9px; font-weight: 800; }
.master-tabs { margin-bottom: 14px; padding: 6px; border: 1px solid var(--line); background: white; display: flex; gap: 4px; overflow-x: auto; }
.master-tabs a { min-height: 36px; padding: 8px 13px; background: var(--surface-soft); white-space: nowrap; font-size: 11px; font-weight: 800; }
.master-tabs a:hover { background: var(--blue-soft); color: var(--blue); }
.color-chip, .color-swatch-large { width: 14px; height: 14px; margin-left: 7px; border: 1px solid rgba(0,0,0,.15); background: var(--chip-color); display: inline-block; vertical-align: middle; }
.color-swatch-large { width: 34px; height: 34px; margin: 0; }
.operations-layout { display: grid; grid-template-columns: minmax(380px, .7fr) minmax(0, 1.3fr); gap: 14px; align-items: start; }
.compact-form .form-grid { grid-template-columns: 1fr; }
.compact-form .form-section { max-height: 560px; overflow-y: auto; }
.color-intelligence { margin-top: 14px; }
.color-metrics-grid { padding: 12px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.color-metrics-grid article { min-height: 160px; padding: 14px; border: 1px solid var(--line); display: grid; grid-template-columns: 40px 1fr; gap: 10px; }
.color-metrics-grid article small { color: var(--muted); font-size: 9px; }
.color-metrics-grid dl { grid-column: 1 / -1; margin: 5px 0 0; display: grid; grid-template-columns: repeat(4, 1fr); }
.color-metrics-grid dl div { padding: 8px; border-right: 1px solid var(--line); }
.color-metrics-grid dt { color: var(--muted); font-size: 8px; }
.color-metrics-grid dd { margin: 5px 0 0; font-size: 11px; font-weight: 800; }
.checkbox-field input { width: 20px; min-height: 20px; }

@media (max-width: 1250px) {
    .command-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .operations-layout { grid-template-columns: 1fr; }
    .compact-form .form-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
    .owner-grid, .analytics-grid, .breakdown-grid { grid-template-columns: 1fr; }
    .color-metrics-grid { grid-template-columns: repeat(2, 1fr); }
    .executive-rankings { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
    .app-shell { padding-bottom: calc(var(--mobile-nav-height) + var(--mobile-safe-bottom) + 24px); }
    .sidebar { height: calc(var(--mobile-nav-height) + var(--mobile-safe-bottom)); }
    .primary-nav { grid-template-columns: repeat(13, minmax(82px, 1fr)); overflow-x: auto; overflow-y: hidden; }
    .nav-link { min-height: 58px; padding: 7px 8px; flex-direction: column; justify-content: center; gap: 4px; font-size: 9px; text-align: center; }
    .nav-link > span:last-child { display: block; }
    .nav-mark { width: auto; font-size: 8px; }
    .page { padding: 17px 13px; }
    .command-kpis, .command-kpis.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .command-kpi { min-height: 126px; padding: 14px; }
    .command-kpi strong { font-size: 27px; }
    .executive-rankings { grid-template-columns: 1fr 1fr; }
    .executive-rankings article { border-bottom: 1px solid var(--line); }
    .owner-machine-list a { grid-template-columns: 10px 55px 82px 1fr; padding-inline: 10px; gap: 6px; }
    .owner-grid .data-panel { box-shadow: none; }
    .notification-panel { order: -1; }
    .bar-chart { height: 230px; padding-inline: 8px; }
    .machine-summary-strip.five { grid-template-columns: repeat(2, 1fr); }
    .machine-summary-strip.five > div:last-child { grid-column: 1 / -1; }
    .color-metrics-grid { grid-template-columns: 1fr; }
    .compact-form .form-grid { grid-template-columns: 1fr; }
    .master-form .form-grid { grid-template-columns: 1fr; }
}

.active-production-strip { margin-bottom: 14px; }
.active-run-lineup { padding: 10px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.active-run-lineup a { min-height: 72px; padding: 11px 12px; border: 1px solid var(--line); display: flex; align-items: center; gap: 9px; }
.active-run-lineup a:hover { border-color: #9dcdb9; background: var(--green-soft); }
.active-run-lineup div { min-width: 0; flex: 1; }
.active-run-lineup strong, .active-run-lineup small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.active-run-lineup strong { font-size: 11px; }
.active-run-lineup small { margin-top: 4px; color: var(--muted); font-size: 9px; }
.active-run-lineup b { color: var(--green); font-size: 11px; white-space: nowrap; }
@media (max-width: 900px) { .active-run-lineup { grid-template-columns: 1fr; } }

.profile-yield-grid { margin-bottom: 14px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.profile-yield-grid article { min-height: 130px; padding: 13px; border: 1px solid var(--line); border-top: 4px solid var(--green); background: white; box-shadow: var(--shadow); }
.profile-yield-grid > article > span { color: var(--muted); font-size: 10px; }
.profile-yield-grid > article > strong { display: block; margin: 9px 0; font-size: 24px; }
.profile-yield-grid dl { margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.profile-yield-grid dl div { padding: 5px; background: var(--surface-soft); }
.profile-yield-grid dt { color: var(--muted); font-size: 7px; }
.profile-yield-grid dd { margin: 4px 0 0; font-size: 9px; font-weight: 800; }
@media (max-width: 1000px) { .profile-yield-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .profile-yield-grid { grid-template-columns: 1fr; } }


/* Phase 2 executive dashboard refinement */
.executive-header { min-height: 58px; margin-bottom: 14px; align-items: center; }
.executive-header h1 { margin-bottom: 0; font-size: 24px; }
.live-shift { min-width: 190px; padding: 9px 12px; border: 1px solid var(--line); background: white; display: grid; grid-template-columns: 9px 1fr; gap: 2px 8px; align-items: center; }
.live-shift i { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(23,107,77,.12); grid-row: 1 / 3; }
.live-shift span { color: var(--muted); font-size: 9px; }
.live-shift strong { font-size: 11px; }
.executive-kpi-grid { margin-bottom: 12px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.executive-kpi-grid.four, .executive-kpi-grid.machine-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.executive-kpi { min-height: 138px; padding: 15px; border: 1px solid var(--line); border-right: 5px solid var(--blue); border-radius: 6px; background: white; box-shadow: 0 5px 18px rgba(23,32,38,.06); display: grid; grid-template-columns: 38px 1fr; align-content: center; gap: 8px 12px; overflow: hidden; }
.executive-kpi.info { border-right-color: #1976a8; background: #f6fbfe; }
.executive-kpi.healthy { border-right-color: #16835c; background: #f5fbf8; }
.executive-kpi.warning { border-right-color: #d57a08; background: #fffaf3; }
.executive-kpi.critical { border-right-color: #c43b31; background: #fff7f6; }
.executive-kpi.dark { border-right-color: #22292d; background: #f5f6f6; }
.kpi-symbol { width: 38px; height: 38px; border-radius: 6px; background: var(--blue-soft); color: var(--blue); display: grid; place-items: center; font-size: 15px; font-weight: 900; }
.executive-kpi.healthy .kpi-symbol { background: var(--green-soft); color: var(--green); }
.executive-kpi.warning .kpi-symbol { background: var(--amber-soft); color: var(--amber); }
.executive-kpi.critical .kpi-symbol { background: var(--red-soft); color: var(--red); }
.executive-kpi.dark .kpi-symbol { background: #22292d; color: white; }
.executive-kpi div { min-width: 0; }
.executive-kpi small, .executive-kpi strong, .executive-kpi b { display: block; }
.executive-kpi small { color: var(--muted); font-size: 10px; font-weight: 700; }
.executive-kpi strong { margin-top: 8px; font-size: 32px; line-height: 1; font-variant-numeric: tabular-nums; }
.executive-kpi b { margin-top: 4px; color: var(--muted); font-size: 10px; }
.executive-kpi footer { grid-column: 1 / -1; padding-top: 9px; border-top: 1px solid rgba(100,115,123,.14); color: var(--muted); font-size: 9px; }
.executive-status-strip { margin-bottom: 12px; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border: 1px solid var(--line); background: white; }
.executive-status-strip article { min-height: 76px; padding: 12px 15px; border-left: 1px solid var(--line); border-bottom: 3px solid var(--blue); display: grid; align-content: center; }
.executive-status-strip article:nth-child(2) { border-bottom-color: var(--green); }
.executive-status-strip article:nth-child(3) { border-bottom-color: var(--violet); }
.executive-status-strip article.warning { border-bottom-color: var(--amber); }
.executive-status-strip span, .executive-status-strip strong, .executive-status-strip b { display: block; }
.executive-status-strip span { color: var(--muted); font-size: 9px; }
.executive-status-strip strong { margin: 4px 0; font-size: 14px; }
.executive-status-strip b { color: var(--muted); font-size: 9px; }
.executive-dashboard-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: start; }
.executive-dashboard-grid > .span-2-panel { grid-column: span 2; }
.chart-panel, .order-progress-panel, .alert-panel, .inventory-alert-panel { min-width: 0; }
.machine-visual-strip { padding: 10px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.machine-tile { min-height: 150px; padding: 12px; border: 1px solid var(--line); border-top: 4px solid #d57a08; border-radius: 5px; background: white; display: flex; flex-direction: column; }
.machine-tile.running { border-top-color: #16835c; }
.machine-tile.stopped { border-top-color: #c43b31; }
.machine-tile.fault { border-top-color: #22292d; }
.machine-tile header { display: flex; justify-content: space-between; gap: 8px; }
.machine-tile header strong { font-size: 14px; }
.machine-tile header span { color: var(--muted); font-size: 9px; }
.machine-tile > b { margin-top: 15px; color: var(--blue); font-size: 11px; }
.machine-tile > small { margin-top: 5px; color: var(--muted); font-size: 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-meter { height: 7px; margin-top: auto; background: #e5e9eb; overflow: hidden; }
.tile-meter i { height: 100%; background: var(--green); display: block; }
.machine-tile footer { margin-top: 6px; color: var(--muted); font-size: 8px; }
.machine-no-run { margin: auto; color: var(--muted); font-size: 10px; }
.horizontal-chart { padding: 14px 15px; display: grid; gap: 13px; }
.horizontal-chart > div > header { margin-bottom: 6px; display: flex; justify-content: space-between; gap: 12px; font-size: 10px; }
.horizontal-chart > div > header strong { font-size: 10px; }
.horizontal-chart > div > div { height: 10px; border-radius: 2px; background: #e8ecee; overflow: hidden; }
.horizontal-chart > div > div > i { height: 100%; border-radius: 2px; display: block; background: var(--blue); }
.horizontal-chart i.green { background: var(--green); }
.horizontal-chart i.orange { background: var(--amber); }
.horizontal-chart i.violet { background: var(--violet); }
.horizontal-chart > div > small { display: block; margin-top: 4px; color: var(--muted); font-size: 8px; }
.trend-chart { height: 230px; padding: 28px 14px 12px; display: flex; align-items: flex-end; gap: 8px; direction: ltr; }
.trend-chart.large { height: 300px; padding-inline: 24px; }
.trend-column { height: 100%; min-width: 24px; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 5px; }
.trend-column span, .trend-column small { color: var(--muted); font-size: 8px; }
.trend-column i { width: min(38px, 68%); min-height: 4px; border-radius: 3px 3px 0 0; background: var(--blue); }
.order-completion-table td { height: 62px; }
.order-completion-table .delayed-order { background: #fff8f6; }
.completion-cell { min-width: 145px; }
.completion-cell > span { display: block; margin-bottom: 6px; font-size: 10px; font-weight: 900; }
.completion-cell > div { height: 9px; border-radius: 2px; background: #e5e9eb; overflow: hidden; }
.completion-cell i { height: 100%; display: block; }
.completion-cell i.healthy { background: var(--green); }
.completion-cell i.info { background: var(--blue); }
.completion-cell i.warning { background: var(--amber); }
.compact-alert-list article { min-height: 58px; padding: 10px 12px; border-bottom: 1px solid var(--line); border-right: 4px solid var(--amber); display: flex; align-items: center; gap: 8px; }
.compact-alert-list article.critical { border-right-color: var(--red); background: #fff8f7; }
.compact-alert-list article div { min-width: 0; flex: 1; }
.compact-alert-list strong, .compact-alert-list small { display: block; }
.compact-alert-list small { margin-top: 3px; color: var(--muted); font-size: 8px; }
.compact-alert-list b { color: var(--red); font-size: 10px; white-space: nowrap; }
.production-chart-grid { margin-bottom: 12px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.daily-trend-panel, .order-progress-panel { margin-bottom: 12px; }
.inventory-widget-grid { margin-bottom: 12px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.low-stock-widget { grid-column: span 2; }
.stock-color { width: 10px; height: 10px; margin-left: 6px; border-radius: 50%; border: 1px solid rgba(0,0,0,.14); background: var(--stock-color); display: inline-block; }
.stock-alert-grid { padding: 11px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stock-alert-grid article { min-height: 118px; padding: 12px; border: 1px solid var(--line); border-top: 4px solid var(--amber); border-radius: 5px; }
.stock-alert-grid article.critical { border-top-color: var(--red); background: #fff8f7; }
.stock-alert-grid header { display: flex; align-items: center; gap: 6px; }
.stock-alert-grid header strong { min-width: 0; flex: 1; font-size: 10px; }
.stock-alert-grid header b { color: var(--red); font-size: 8px; }
.stock-alert-grid p { margin: 8px 0; font-size: 9px; line-height: 1.4; }
.stock-alert-grid > article > div { padding-top: 8px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; font-size: 10px; }
.status-healthy { background: var(--green-soft); color: var(--green); }
.status-warning { background: var(--amber-soft); color: var(--amber); }
.status-critical { background: var(--red-soft); color: var(--red); }
.machine-control-table.refined { min-width: 1020px; }
.machine-mobile-list { display: none; }
.machine-mobile-card { border: 1px solid var(--line); border-right: 5px solid var(--amber); border-radius: 6px; background: white; overflow: hidden; }
.machine-mobile-card.running { border-right-color: var(--green); }
.machine-mobile-card.stopped { border-right-color: var(--red); }
.machine-mobile-card.fault { border-right-color: #22292d; }
.machine-mobile-card > header { min-height: 58px; padding: 10px 12px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.machine-mobile-card > header strong, .machine-mobile-card > header small { display: block; }
.machine-mobile-card > header small { margin-top: 3px; color: var(--muted); font-size: 8px; }
.machine-mobile-card > header > span { font-size: 9px; font-weight: 900; }
.mobile-machine-order { padding: 12px; display: flex; justify-content: space-between; gap: 10px; }
.mobile-machine-order span { color: var(--muted); font-size: 9px; }
.mobile-machine-order strong { color: var(--blue); font-size: 11px; }
.machine-mobile-card dl { margin: 0; padding: 0 12px 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.machine-mobile-card dl div { padding: 8px; background: var(--surface-soft); }
.machine-mobile-card dt { color: var(--muted); font-size: 8px; }
.machine-mobile-card dd { margin: 4px 0 0; font-size: 10px; font-weight: 800; }
.machine-mobile-card > footer { padding: 10px 12px; border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; }

@media (max-width: 1200px) {
    .executive-dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .executive-dashboard-grid > .span-2-panel { grid-column: span 2; }
    .executive-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
    .executive-header { align-items: flex-start; flex-direction: column; }
    .live-shift { width: 100%; }
    .executive-kpi-grid, .executive-kpi-grid.four, .executive-kpi-grid.machine-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
    .executive-kpi { min-height: 126px; padding: 12px; grid-template-columns: 32px 1fr; gap: 7px 9px; }
    .kpi-symbol { width: 32px; height: 32px; font-size: 12px; }
    .executive-kpi strong { font-size: 26px; }
    .executive-status-strip { grid-template-columns: repeat(2, 1fr); }
    .executive-status-strip article { border-bottom: 1px solid var(--line); }
    .executive-dashboard-grid { grid-template-columns: 1fr; }
    .executive-dashboard-grid > .span-2-panel { grid-column: auto; }
    .machine-visual-strip { grid-template-columns: 1fr 1fr; }
    .production-chart-grid, .inventory-widget-grid { grid-template-columns: 1fr; }
    .low-stock-widget { grid-column: auto; }
    .stock-alert-grid { grid-template-columns: 1fr; }
    .trend-chart { height: 210px; padding-inline: 6px; }
    .trend-chart.large { height: 240px; padding-inline: 8px; }
    .order-completion-table { min-width: 650px; }
    .machine-control-panel { display: none; }
    .machine-mobile-list { display: grid; gap: 9px; }
}
@media (max-width: 420px) {
    .machine-visual-strip { grid-template-columns: 1fr; }
    .executive-kpi strong { font-size: 23px; }
}


/* Phase 3 factory reality integration */
.door-capacity-list { display: grid; }
.door-capacity-list article { min-height: 58px; padding: 10px 14px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 9px; }
.door-capacity-list article:last-child { border-bottom: 0; }
.door-capacity-list article > div { min-width: 0; flex: 1; }
.door-capacity-list strong, .door-capacity-list small { display: block; }
.door-capacity-list small { margin-top: 3px; color: var(--muted); font-size: 8px; }
.door-capacity-list b { color: var(--green); font-size: 12px; white-space: nowrap; }
.door-capacity-list.compact article { min-height: 48px; }
@media (max-width: 760px) { .door-capacity-panel { grid-column: auto; } }


/* Phase 4 factory reality consolidation */
.setup-kpi-grid { margin-bottom: 12px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.setup-kpi-grid article { min-height: 120px; padding: 16px; border: 1px solid var(--line); border-top: 4px solid var(--blue); border-radius: 6px; background: white; display: grid; align-content: center; }
.setup-kpi-grid span { color: var(--muted); font-size: 10px; }
.setup-kpi-grid strong { margin: 8px 0; font-size: 30px; }
.setup-kpi-grid a { color: var(--blue); font-size: 10px; font-weight: 800; }
.setup-table, .setup-matrix { margin-bottom: 12px; }
.profile-definition-grid { padding: 12px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.profile-definition-grid article { min-height: 100px; padding: 13px; border: 1px solid var(--line); border-right: 4px solid var(--green); border-radius: 5px; display: grid; align-content: center; }
.profile-definition-grid strong, .profile-definition-grid span, .profile-definition-grid b { display: block; }
.profile-definition-grid span { margin: 4px 0 10px; color: var(--muted); font-size: 9px; }
.profile-definition-grid b { font-size: 11px; }
.weight-rule-band { margin-bottom: 14px; min-height: 72px; padding: 13px 16px; border: 1px solid #a9d6c3; border-right: 5px solid var(--green); background: var(--green-soft); display: grid; grid-template-columns: 1fr auto; align-items: center; }
.weight-rule-band span, .weight-rule-band small { color: var(--muted); font-size: 9px; }
.weight-rule-band strong { font-size: 18px; }
.weight-rule-band small { grid-column: 1 / -1; }
.measurement-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 900px) { .setup-kpi-grid, .profile-definition-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .setup-kpi-grid, .profile-definition-grid, .measurement-grid { grid-template-columns: 1fr; } }


/* Phase 5 initialization and raw-material warehouse */
.button-row { display: flex; flex-wrap: wrap; gap: 8px; }
.button.danger { background: var(--red); color: white; border-color: var(--red); }
.form-action-bar.danger { border-color: #f0b7b7; background: #fff5f5; }
.reset-warning-panel { margin-bottom: 12px; border-right: 5px solid var(--red); }
.warning-list { padding: 14px 18px; display: grid; gap: 8px; color: var(--ink); }
.warning-list p { margin: 0; }
.activity-list { display: grid; }
.activity-list a { min-height: 52px; padding: 10px 14px; border-bottom: 1px solid var(--line); display: grid; gap: 3px; color: inherit; text-decoration: none; }
.activity-list a:last-child { border-bottom: 0; }
.activity-list strong { font-size: 11px; }
.activity-list small { color: var(--muted); font-size: 9px; }
.status-negative, .status-critical { color: var(--red); }
.status-warning { color: var(--amber); }
.status-healthy { color: var(--green); }
.stock-alert-grid article.negative { border-right-color: var(--red); background: #fff5f5; }
.stock-alert-grid article.critical { border-right-color: var(--red); }
.stock-alert-grid article.warning { border-right-color: var(--amber); }
.stock-alert-grid article.healthy { border-right-color: var(--green); }
@media (max-width: 760px) { .button-row { width: 100%; } .button-row .button { flex: 1; justify-content: center; } }


/* User manual */
.manual-header p { max-width: 820px; }
.manual-screenshot-grid { margin-bottom: 12px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.manual-screenshot-grid article { border: 1px solid var(--line); border-radius: 6px; background: white; overflow: hidden; }
.manual-screenshot-grid img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; background: var(--surface-soft); }
.manual-screenshot-grid strong { min-height: 36px; padding: 9px 11px; display: block; font-size: 10px; }
.manual-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 12px; align-items: start; }
.manual-toc { position: sticky; top: 78px; overflow: hidden; }
.manual-toc a { min-height: 38px; padding: 10px 13px; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; display: block; font-size: 10px; font-weight: 800; }
.manual-toc a:last-child { border-bottom: 0; }
.manual-section { margin-bottom: 12px; overflow: hidden; }
.manual-section > p { margin: 0; padding: 14px 16px; line-height: 1.8; }
.manual-steps { margin: 0; padding: 14px 32px 16px 14px; display: grid; gap: 9px; }
.manual-steps li { padding: 10px 12px; border: 1px solid var(--line); border-right: 4px solid var(--blue); border-radius: 5px; background: var(--surface-soft); line-height: 1.7; }
.manual-role-grid { padding: 12px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.manual-role-grid article { min-height: 116px; padding: 13px; border: 1px solid var(--line); border-top: 4px solid var(--green); border-radius: 5px; background: white; }
.manual-role-grid strong, .manual-role-grid span { display: block; }
.manual-role-grid strong { margin-bottom: 8px; font-size: 11px; }
.manual-role-grid span { color: var(--muted); line-height: 1.7; font-size: 10px; }
.manual-callout { margin: 12px; padding: 13px 16px; border: 1px solid #a9d6c3; border-right: 5px solid var(--green); background: var(--green-soft); display: grid; gap: 6px; }
.manual-callout strong { font-size: 12px; }
.manual-callout span { color: var(--muted); line-height: 1.7; font-size: 10px; }
.manual-screen-table { min-width: 1100px; }
.manual-rules { margin: 0; padding: 16px 34px 16px 16px; display: grid; gap: 8px; }
.manual-rules li { line-height: 1.7; }
@media (max-width: 1200px) { .manual-screenshot-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .manual-layout { grid-template-columns: 1fr; } .manual-toc { position: static; } }
@media (max-width: 760px) { .manual-screenshot-grid, .manual-role-grid { grid-template-columns: 1fr; } .manual-steps { padding-inline: 14px; } }

@supports (padding-bottom: env(safe-area-inset-bottom)) {
    @media (max-width: 720px) {
        body.has-app-shell { padding-bottom: env(safe-area-inset-bottom); }
        .form-action-bar, .structured-form, .data-panel, .machine-mobile-list, .manual-section { scroll-margin-bottom: calc(var(--mobile-nav-height) + var(--mobile-safe-bottom) + 18px); }
        .button, .nav-link, .icon-command { touch-action: manipulation; }
    }
}

/* Factory ERP Android professional mobile shell */
@media (max-width: 720px) {
    body.has-app-shell { overflow-x: hidden; }
    body.android-app { overscroll-behavior-y: contain; }
    body.android-app .app-shell {
        padding-bottom: calc(var(--mobile-nav-height) + var(--mobile-safe-bottom) + 32px);
    }
    body.android-app .page {
        padding: 14px 10px calc(var(--mobile-nav-height) + var(--mobile-safe-bottom) + 34px);
    }
    body.android-app .sidebar {
        bottom: 0;
        min-height: calc(var(--mobile-nav-height) + var(--mobile-safe-bottom));
        box-shadow: 0 -8px 24px rgba(15, 23, 42, .18);
    }
    body.android-app .nav-link {
        min-width: 82px;
        min-height: 58px;
        font-size: 10px;
    }
    body.android-app .nav-link.active {
        background: #233a33;
        color: #fff;
    }
    body.android-app .button,
    body.android-app button,
    body.android-app input,
    body.android-app select,
    body.android-app textarea {
        min-height: 46px;
    }
    body.android-app input,
    body.android-app select,
    body.android-app textarea {
        font-size: 16px;
    }
    body.android-app .form-action-bar {
        position: sticky;
        bottom: calc(var(--mobile-nav-height) + var(--mobile-safe-bottom));
        z-index: 12;
        padding-bottom: 10px;
        box-shadow: 0 -8px 20px rgba(23, 32, 38, .1);
    }
    body.android-app .table-wrap {
        overflow-x: auto;
        overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
    }

    body.android-app .filter-bar,
    body.android-app .detail-grid {
        grid-template-columns: 1fr;
    }
    body.android-app .factory-input-form .table-wrap {
        max-width: calc(100vw - 22px);
    }
    body.android-app table th,
    body.android-app table td {
        padding-block: 11px;
    }
    body.android-app .executive-kpi,
    body.android-app .command-kpi,
    body.android-app .dashboard-kpi {
        border-radius: 7px;
    }
    body.android-app .machine-mobile-card,
    body.android-app .data-panel,
    body.android-app .structured-form {
        scroll-margin-bottom: calc(var(--mobile-nav-height) + var(--mobile-safe-bottom) + 28px);
    }
}


/* Android/PWA top safe-area correction */
@media (max-width: 720px) {
    body.has-app-shell:not(.android-app) .topbar {
        height: calc(58px + var(--mobile-safe-top));
        padding-top: var(--mobile-safe-top);
    }
    body.auth-page:not(.android-app) {
        padding-top: var(--mobile-safe-top);
    }
    body.android-app {
        --mobile-safe-top: 0px;
    }
    body.android-app .topbar {
        top: 0;
    }
}


.topbar-search{display:flex;align-items:center;gap:6px;min-width:280px;max-width:460px;flex:1}.topbar-search input,.toolbar-search input,.filter-bar input,.filter-bar select,.inline-note-form input{width:100%;min-height:40px;border:1px solid var(--line,#d8dee2);border-radius:8px;padding:0 12px;background:#fff;color:#172026}.topbar-search button{min-height:40px;border:0;border-radius:8px;background:#176b4d;color:#fff;font-weight:700;padding:0 14px}.toolbar-search.large{display:flex;gap:10px}.filter-bar{display:flex;flex-wrap:wrap;gap:10px;margin-bottom:14px}.row-highlight{background:#fff8e6}.chatter-grid{display:grid;grid-template-columns:1.2fr .8fr;gap:18px}.timeline-item,.attachment-row,.release-card{border:1px solid var(--line,#d8dee2);border-radius:8px;background:#fff;padding:12px;margin-bottom:10px}.timeline-item span,.attachment-row span{display:block;color:#66727a;font-size:12px;margin-top:4px}.inline-note-form{display:flex;gap:8px;margin:0 0 16px}.release-card h2{margin:0 0 6px;font-size:18px}.release-card ul{margin:10px 18px}.foundation-grid{margin-bottom:18px}.status-danger{background:#fee2e2;color:#991b1b}.status-info{background:#dbeafe;color:#1e40af}.button.danger,.row-action.danger{background:#b42318;color:#fff}.checkbox-line{display:flex;align-items:center;gap:8px}
@media (max-width: 760px){.topbar{gap:8px}.topbar-search{order:3;min-width:100%;max-width:none}.chatter-grid{grid-template-columns:1fr}.toolbar-search.large{flex-direction:column}.inline-note-form{flex-direction:column}}


/* 2026-07 mobile ERP redesign overrides */
.mobile-menu-button,
.mobile-drawer-backdrop,
.mobile-card-list { display: none; }
.disabled-action { pointer-events: none; opacity: .68; }
.button, .row-action, .quick-action, .worker-action { min-height: 44px; }
.button.warning { background: var(--amber); color: #fff; border-color: var(--amber); }

@media (max-width: 720px) {
    html, body { width: 100%; max-width: 100%; overflow-x: hidden; }
    body.has-app-shell { padding-bottom: 0 !important; }
    .app-shell,
    body.android-app .app-shell {
        display: block;
        min-width: 0;
        padding-bottom: 0 !important;
    }
    .workspace { min-width: 0; width: 100%; min-height: 100dvh; }
    .page,
    body.android-app .page {
        width: 100%;
        max-width: 100vw;
        padding: 14px 12px 28px !important;
        overflow-x: clip;
    }
    .topbar {
        min-height: 62px;
        height: auto;
        padding: calc(8px + var(--mobile-safe-top)) 10px 8px;
        gap: 8px;
        flex-wrap: wrap;
        align-items: center;
    }
    .mobile-menu-button {
        width: 46px;
        height: 46px;
        padding: 0;
        border: 1px solid var(--line-strong);
        border-radius: 8px;
        background: #fff;
        display: inline-grid;
        place-content: center;
        gap: 5px;
        flex: 0 0 auto;
    }
    .mobile-menu-button span { width: 21px; height: 2px; border-radius: 2px; background: var(--ink); display: block; }
    .topbar-context { min-width: 0; flex: 1; }
    .topbar-context strong { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .topbar-search { order: 5; min-width: 100%; max-width: none; flex-basis: 100%; }
    .topbar-user { margin-right: auto; gap: 6px; }
    .user-avatar { width: 36px; height: 36px; }
    .user-identity strong { max-width: 92px; font-size: 12px; }
    .icon-command { width: 40px; height: 40px; }

    .mobile-drawer-backdrop {
        position: fixed;
        inset: 0;
        z-index: 39;
        background: rgba(8, 14, 18, .48);
        display: block;
    }
    .mobile-drawer-backdrop[hidden] { display: none; }
    .sidebar,
    body.android-app .sidebar {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: auto;
        width: min(86vw, 330px);
        height: 100dvh;
        min-height: 100dvh;
        padding: calc(16px + var(--mobile-safe-top)) 14px calc(16px + var(--mobile-safe-bottom));
        display: flex;
        transform: translateX(105%);
        transition: transform 180ms ease;
        border-top: 0;
        box-shadow: -16px 0 36px rgba(0,0,0,.24);
        z-index: 40;
        overflow: hidden;
    }
    body.mobile-nav-open .sidebar { transform: translateX(0); }
    body.mobile-nav-open { overflow: hidden; }
    .sidebar .brand { display: flex; justify-content: flex-start; padding-bottom: 14px; }
    .brand > span:last-child,
    .nav-section-label,
    .nav-link > span:last-child,
    .sidebar-footer .environment-label { display: block; }
    .nav-section-label { padding: 14px 8px 8px; }
    .primary-nav,
    body.android-app .primary-nav {
        height: auto;
        min-height: 0;
        display: grid;
        grid-template-columns: 1fr;
        gap: 5px;
        overflow-y: auto;
        overflow-x: hidden;
        padding-bottom: 12px;
    }
    .nav-link,
    body.android-app .nav-link {
        min-width: 0;
        min-height: 48px;
        padding: 9px 10px;
        border-top: 0;
        border-right: 3px solid transparent;
        border-radius: 7px;
        flex-direction: row;
        justify-content: flex-start;
        text-align: right;
        gap: 10px;
        font-size: 12px;
    }
    .nav-link.active,
    body.android-app .nav-link.active { border-top: 0; border-right-color: #72c6a3; }
    .nav-mark { width: 25px; font-size: 10px; }
    .sidebar-footer { display: grid; }
    .system-state { font-size: 12px; }

    .page-header,
    .executive-header,
    .dashboard-header {
        min-height: 0;
        margin-bottom: 14px;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    h1 { font-size: 22px; line-height: 1.3; overflow-wrap: anywhere; }
    p { font-size: 14px; line-height: 1.65; }
    .page-actions, .form-actions, .button-row { width: 100%; flex-wrap: wrap; align-items: stretch; }
    .page-actions .button, .button-row .button, .form-actions .button { flex: 1 1 132px; min-height: 46px; }
    .button, .row-action { min-height: 46px; padding: 10px 14px; border-radius: 8px; font-size: 14px; }

    .metric-strip, .dashboard-kpis, .command-kpis, .command-kpis.four,
    .executive-kpi-grid, .executive-kpi-grid.four, .executive-kpi-grid.machine-kpis,
    .supervisor-kpi-grid, .kpi-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .metric-cell, .dashboard-kpi, .command-kpi, .executive-kpi, .supervisor-kpi { min-height: 96px; padding: 12px; }
    .metric-cell strong, .dashboard-kpi strong, .command-kpi strong, .executive-kpi strong, .supervisor-kpi strong { font-size: 24px; }

    .panel-toolbar { min-height: 0; padding: 12px; display: grid; gap: 10px; }
    .table-filters, .filter-bar, .toolbar-search.large { width: 100%; display: grid; grid-template-columns: 1fr; gap: 9px; }
    .search-control input, .filter-control select { width: 100%; }
    .data-panel, .structured-form { max-width: 100%; border-radius: 8px; overflow: hidden; }
    .form-section { padding: 16px 12px; }
    .form-grid, .form-grid.three-columns, .measurement-grid, .detail-grid, .filter-bar { grid-template-columns: 1fr !important; }
    .span-2 { grid-column: auto; }
    label { font-size: 13px; }
    input, select, textarea,
    body.android-app input, body.android-app select, body.android-app textarea {
        min-height: 48px;
        font-size: 16px;
        border-radius: 8px;
    }
    textarea { min-height: 104px; }
    .errorlist, .form-errors { font-size: 12px; }
    .form-action-bar,
    body.android-app .form-action-bar {
        position: static;
        min-height: 0;
        padding: 12px;
        display: grid;
        gap: 10px;
        box-shadow: none;
    }

    .table-wrap { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    table:not(.operations-table) { min-width: 680px; }
    th, td { padding: 12px; font-size: 13px; }
    th { font-size: 11px; }
    .desktop-table-wrap { display: none; }
    .mobile-card-list { display: grid; gap: 10px; padding: 10px; }
    .mobile-card-list.always { display: grid; }
    .mobile-record-card {
        border: 1px solid var(--line);
        border-right: 5px solid var(--blue);
        border-radius: 8px;
        background: #fff;
        padding: 12px;
        display: grid;
        gap: 11px;
        box-shadow: 0 4px 14px rgba(23,32,38,.05);
    }
    .mobile-record-card[hidden] { display: none !important; }
    .mobile-record-card > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
    .mobile-record-card header span, .mobile-record-card dt { color: var(--muted); font-size: 11px; font-weight: 700; }
    .mobile-record-card header strong { margin-top: 3px; display: block; font-size: 17px; }
    .mobile-record-grid { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
    .mobile-record-grid div { min-width: 0; padding: 9px; border-radius: 7px; background: var(--surface-soft); }
    .mobile-record-grid dd { margin: 4px 0 0; font-size: 13px; font-weight: 800; overflow-wrap: anywhere; }
    .mobile-progress { display: grid; gap: 7px; }
    .mobile-progress > div:first-child { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
    .mobile-details { border-top: 1px solid var(--line); padding-top: 8px; }
    .mobile-details summary { min-height: 38px; cursor: pointer; font-weight: 800; color: var(--blue); }
    .mobile-details div { padding: 5px 0; display: flex; justify-content: space-between; gap: 10px; font-size: 12px; }
    .mobile-details span { color: var(--muted); }
    .mobile-main-action { min-height: 52px; font-size: 15px; }
    .status-accent-released, .status-accent-active, .status-accent-in_production { border-right-color: var(--green); }
    .status-accent-partially_completed, .status-accent-completion_pending, .status-accent-warning { border-right-color: var(--amber); }
    .status-accent-cancelled, .status-accent-danger { border-right-color: var(--red); }
    .status-accent-completed, .status-accent-approved { border-right-color: var(--blue); }

    .worker-mobile-screen, .supervisor-panels, .statement-grid { display: grid; gap: 12px; }
    .worker-current-card { border: 1px solid var(--line); border-right: 5px solid var(--green); border-radius: 8px; background: #fff; padding: 12px; display: grid; gap: 10px; }
    .worker-current-card > header { display: flex; justify-content: space-between; gap: 10px; }
    .worker-current-card header span { color: var(--muted); font-size: 11px; }
    .worker-current-card header strong { display: block; margin-top: 4px; font-size: 18px; }
    .worker-action-grid, .supervisor-action-grid { display: grid; grid-template-columns: 1fr; gap: 9px; }
    .worker-action {
        min-height: 64px;
        padding: 12px 14px;
        border: 1px solid var(--line);
        border-right: 5px solid var(--blue);
        border-radius: 9px;
        background: #fff;
        display: grid;
        align-content: center;
        gap: 4px;
    }
    .worker-action.primary { border-right-color: var(--green); background: var(--green-soft); }
    .worker-action.warning { border-right-color: var(--amber); background: var(--amber-soft); }
    .worker-action.danger { border-right-color: var(--red); background: var(--red-soft); }
    .worker-action b { font-size: 15px; }
    .worker-action span { color: var(--muted); font-size: 12px; }
    .worker-end-shift .button { min-height: 54px; }
    .supervisor-kpi-grid { display: grid; }
    .supervisor-kpi { border: 1px solid var(--line); border-top: 4px solid var(--blue); border-radius: 8px; background: #fff; display: grid; align-content: center; }
    .supervisor-kpi.success { border-top-color: var(--green); }
    .supervisor-kpi.warning { border-top-color: var(--amber); }
    .supervisor-kpi.danger { border-top-color: var(--red); }
    .supervisor-kpi.info { border-top-color: var(--blue); }
    .supervisor-kpi span, .supervisor-kpi small { color: var(--muted); font-size: 11px; }
    .supervisor-kpi strong { margin: 7px 0; display: block; }
    .formset-mobile-card { margin-bottom: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); }
    .mobile-note-panel { margin-bottom: 12px; padding: 12px; border: 1px solid #d9c293; border-right: 5px solid var(--amber); border-radius: 8px; background: var(--amber-soft); display: grid; gap: 5px; }
    .mobile-note-panel span { color: var(--muted); line-height: 1.6; }
    .qr-scan-panel { padding: 12px; display: grid; gap: 12px; }
    .qr-preview { width: 100%; aspect-ratio: 3 / 4; max-height: 58dvh; border-radius: 8px; background: #111; object-fit: cover; }
    .mobile-inline-form { display: grid; gap: 9px; }

    .login-workspace { width: 100%; min-height: auto; border: 0; grid-template-columns: 1fr; box-shadow: none; }
    .auth-main { min-height: 100dvh; padding: max(14px, var(--mobile-safe-top)) 12px max(18px, var(--mobile-safe-bottom)); place-items: start center; }
    .login-identity { min-height: auto; padding: 20px; border-radius: 10px 10px 0 0; }
    .login-context { margin: 22px 0 12px; }
    .login-context h1 { font-size: 25px; }
    .login-form-zone { padding: 20px 14px; border: 1px solid var(--line); border-top: 0; border-radius: 0 0 10px 10px; background: #fff; }
    .login-submit { min-height: 52px; justify-content: center; }
}

@media (max-width: 380px) {
    .page, body.android-app .page { padding-inline: 9px !important; }
    .metric-strip, .dashboard-kpis, .command-kpis, .command-kpis.four,
    .executive-kpi-grid, .executive-kpi-grid.four, .executive-kpi-grid.machine-kpis,
    .supervisor-kpi-grid, .kpi-grid, .mobile-record-grid { grid-template-columns: 1fr; }
    .topbar-user .user-identity { display: none; }
    .sidebar { width: min(90vw, 310px); }
}

@media (min-width: 721px) {
    .desktop-table-wrap { display: block; }
    .production-order-cards { display: none; }
    .supervisor-kpi-grid { margin-bottom: 12px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
    .supervisor-kpi { min-height: 118px; padding: 15px; border: 1px solid var(--line); border-top: 4px solid var(--blue); background: #fff; box-shadow: var(--shadow); }
    .supervisor-kpi.success { border-top-color: var(--green); }
    .supervisor-kpi.warning { border-top-color: var(--amber); }
    .supervisor-kpi.danger { border-top-color: var(--red); }
    .supervisor-panels, .statement-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .worker-action-grid, .supervisor-action-grid { margin-bottom: 12px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
    .worker-action { min-height: 88px; padding: 14px; border: 1px solid var(--line); border-right: 4px solid var(--blue); background: #fff; display: grid; align-content: center; gap: 4px; }
    .worker-current-card { margin-bottom: 12px; padding: 16px; border: 1px solid var(--line); border-right: 5px solid var(--green); background: #fff; }
}


/* 2026-07 Android WebView hard layout fix */
body.android-app,
body.android-app * ,
body.android-app *::before,
body.android-app *::after { box-sizing: border-box; }
html.android-app,
html:has(body.android-app),
body.android-app {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    overflow-x: hidden !important;
    direction: rtl;
}
body.android-app .app-shell,
body.android-app .workspace,
body.android-app main,
body.android-app .page,
body.android-app .page > *,
body.android-app .data-panel,
body.android-app .structured-form,
body.android-app .production-orders-panel,
body.android-app .production-order-cards,
body.android-app .mobile-card-list,
body.android-app .mobile-record-card,
body.android-app .order-mobile-card {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    transform: none;
}
body.android-app .app-shell {
    display: block !important;
    grid-template-columns: none !important;
    padding: 0 !important;
    overflow-x: hidden !important;
}
body.android-app .workspace {
    display: block !important;
    min-height: 100dvh;
    overflow-x: hidden !important;
}
body.android-app .page {
    display: block !important;
    padding: 14px 10px 28px !important;
    overflow-x: hidden !important;
}
body.android-app .topbar {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    width: 100% !important;
    max-width: 100vw !important;
    min-height: 62px;
    height: auto;
    padding: 8px 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
body.android-app .mobile-menu-button { display: inline-grid !important; }
body.android-app .topbar-context { min-width: 0 !important; flex: 1 1 auto; }
body.android-app .topbar-context strong { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.android-app .topbar-search { order: 5; flex: 1 0 100%; min-width: 0 !important; max-width: none !important; width: 100% !important; }
body.android-app .topbar-user { min-width: 0 !important; }
body.android-app .user-identity strong { max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

body.android-app .sidebar {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    left: auto !important;
    width: min(86vw, 330px) !important;
    max-width: 86vw !important;
    height: 100dvh !important;
    min-height: 100dvh !important;
    padding: 16px 14px calc(16px + env(safe-area-inset-bottom, 0px)) !important;
    display: flex !important;
    flex-direction: column !important;
    transform: translate3d(110%, 0, 0) !important;
    transition: transform 180ms ease;
    border: 0 !important;
    overflow: hidden !important;
    z-index: 40 !important;
}
body.android-app.mobile-nav-open .sidebar { transform: translate3d(0, 0, 0) !important; }
body.android-app .brand { display: flex !important; justify-content: flex-start !important; }
body.android-app .nav-section-label,
body.android-app .brand > span:last-child,
body.android-app .nav-link > span:last-child,
body.android-app .sidebar-footer { display: block !important; }
body.android-app .primary-nav {
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 5px !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
}
body.android-app .nav-link {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 48px !important;
    padding: 9px 10px !important;
    display: flex !important;
    flex-direction: row !important;
    justify-content: flex-start !important;
    text-align: right !important;
    border-top: 0 !important;
    border-right: 3px solid transparent !important;
    border-radius: 7px !important;
    font-size: 12px !important;
}
body.android-app .nav-link.active { border-right-color: #72c6a3 !important; }
body.android-app .mobile-drawer-backdrop { position: fixed; inset: 0; width: 100vw; max-width: 100vw; }

body.android-app .desktop-table-wrap,
body.android-app .operations-table { display: none !important; }
body.android-app .production-order-cards {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 10px !important;
    padding: 10px !important;
    overflow-x: hidden !important;
}
body.android-app .mobile-record-card,
body.android-app .order-mobile-card {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 11px !important;
    padding: 12px !important;
    overflow: hidden !important;
}
body.android-app .mobile-record-card > header,
body.android-app .order-mobile-card > header,
body.android-app .page-header,
body.android-app .panel-toolbar,
body.android-app .page-actions,
body.android-app .button-row,
body.android-app .form-action-bar {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
}
body.android-app .mobile-record-card > header,
body.android-app .order-mobile-card > header {
    display: flex !important;
    align-items: flex-start !important;
    justify-content: space-between !important;
    gap: 8px !important;
}
body.android-app .mobile-record-card header > div,
body.android-app .order-mobile-card header > div,
body.android-app .mobile-record-card strong,
body.android-app .mobile-record-card span,
body.android-app .mobile-record-card dd,
body.android-app .mobile-record-card dt,
body.android-app .mobile-details,
body.android-app .mobile-details * {
    min-width: 0 !important;
    max-width: 100% !important;
    overflow-wrap: anywhere !important;
    word-break: break-word;
}
body.android-app .mobile-record-grid {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
}
body.android-app .mobile-record-grid > div {
    min-width: 0 !important;
    max-width: 100% !important;
    overflow: hidden !important;
}
body.android-app .mobile-progress,
body.android-app .progress-track,
body.android-app .table-progress,
body.android-app .mobile-main-action,
body.android-app .row-action,
body.android-app .button,
body.android-app input,
body.android-app select,
body.android-app textarea {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
}
body.android-app .progress-track,
body.android-app .table-progress > div { overflow: hidden !important; }
body.android-app .progress-track i,
body.android-app .table-progress i { max-width: 100% !important; }
body.android-app .button,
body.android-app .row-action { min-height: 48px !important; white-space: normal !important; text-align: center !important; }
body.android-app .form-grid,
body.android-app .form-grid.three-columns,
body.android-app .measurement-grid,
body.android-app .detail-grid,
body.android-app .filter-bar,
body.android-app .table-filters,
body.android-app .supervisor-kpi-grid,
body.android-app .dashboard-kpis,
body.android-app .executive-kpi-grid,
body.android-app .command-kpis {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    width: 100% !important;
    max-width: 100% !important;
}
body.android-app table { max-width: 100% !important; }
body.android-app .table-wrap { width: 100% !important; max-width: 100% !important; overflow-x: auto !important; }
body.android-app .bottom-nav,
body.android-app .mobile-bottom-nav {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
    display: grid !important;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    overflow: hidden !important;
}
@media (max-width: 380px) {
    body.android-app .mobile-record-grid { grid-template-columns: minmax(0, 1fr) !important; }
    body.android-app .page { padding-inline: 8px !important; }
    body.android-app .user-identity { display: none !important; }
}


/* 2026-07 Android WebView document scrolling fix */
html.android-app,
html:has(body.android-app),
body.android-app {
    height: auto !important;
    min-height: 100% !important;
    max-height: none !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior-y: auto !important;
}
html.mobile-nav-open,
body.android-app.mobile-nav-open {
    overflow: hidden !important;
}
body.android-app:not(.mobile-nav-open) {
    position: static !important;
    overflow-y: auto !important;
    touch-action: pan-y;
}
body.android-app .app-shell,
body.android-app .workspace,
body.android-app main,
body.android-app .page {
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow-y: visible !important;
}
body.android-app .page {
    padding-bottom: calc(112px + env(safe-area-inset-bottom, 0px)) !important;
}
body.android-app .executive-header,
body.android-app .executive-rankings,
body.android-app .executive-kpi-grid,
body.android-app .executive-status-strip,
body.android-app .executive-dashboard-grid,
body.android-app .executive-dashboard-grid > *,
body.android-app .foundation-grid,
body.android-app .machine-visual-strip,
body.android-app .horizontal-chart,
body.android-app .trend-chart,
body.android-app .order-progress-panel,
body.android-app .alert-panel,
body.android-app .door-capacity-panel,
body.android-app .inventory-alert-panel,
body.android-app .data-panel,
body.android-app .structured-form,
body.android-app .notification-list {
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow-y: visible !important;
}
body.android-app .sidebar {
    height: 100dvh !important;
    max-height: 100dvh !important;
    overflow: hidden !important;
}
body.android-app .primary-nav {
    min-height: 0 !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
}
body.android-app .mobile-drawer-backdrop[hidden] {
    display: none !important;
    pointer-events: none !important;
}
