:root {
  --fm-blue: #002b4f;
  --fm-blue-deep: #001c33;
  --fm-blue-soft: #e6eef4;
  --white: #ffffff;
  --ink: #111111;
  --text: #1e2d38;
  --muted: #52616b;
  --surface: #f3f6f8;
  --surface-2: #e9eef2;
  --border: #d5dee6;
  --green: #147a52;
  --green-bg: #e7f5ef;
  --amber: #925e00;
  --amber-bg: #fff4d6;
  --red: #a52222;
  --red-bg: #fdecec;
  --shadow: 0 8px 24px rgba(0, 31, 57, 0.07);
  --radius: 12px;
  --sidebar: 244px;
}

*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: light; scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--surface); color: var(--text); font-family: Arial, Helvetica, sans-serif; font-size: 16px; line-height: 1.45; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--fm-blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; color: var(--fm-blue-deep); font-size: clamp(1.75rem, 3vw, 2.35rem); line-height: 1.12; letter-spacing: -0.035em; }
h2 { color: var(--fm-blue-deep); font-size: 1.08rem; line-height: 1.25; margin-bottom: 6px; }
small { color: var(--muted); }
code { font-family: Consolas, "Courier New", monospace; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid #58a6db; outline-offset: 2px; }
.skip-link { position: fixed; top: -100px; left: 16px; z-index: 1000; padding: 10px 14px; background: var(--white); color: var(--fm-blue); border-radius: 0 0 8px 8px; font-weight: 700; }
.skip-link:focus { top: 0; }
.brand-stripe { height: 10px; background: var(--fm-blue-deep); position: fixed; inset: 0 0 auto 0; z-index: 50; }
.connection-status { position: fixed; inset: 0 0 auto 0; z-index: 200; padding: 9px 20px; background: var(--amber-bg); border-bottom: 1px solid #e6c26b; color: #604000; text-align: center; font-size: 0.88rem; font-weight: 700; }
.connection-status:not([hidden]) ~ .brand-stripe { top: 39px; }
.connection-status:not([hidden]) ~ .topbar { top: 49px; }

.topbar { position: fixed; z-index: 40; top: 10px; right: 0; left: 0; height: 82px; display: flex; align-items: center; gap: 18px; padding: 0 26px; background: var(--white); border-bottom: 1px solid var(--border); }
.brand { width: 230px; flex: 0 0 auto; color: var(--fm-blue-deep); }
.brand:hover { text-decoration: none; }
.brand-lockup { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-lockup > img { width: 46px; height: 46px; flex: 0 0 46px; object-fit: contain; }
.brand-wordmark { min-width: 0; line-height: 1.05; }
.brand-wordmark strong, .brand-wordmark small { display: block; }
.brand-wordmark strong { color: var(--fm-blue-deep); font-size: .82rem; font-weight: 900; letter-spacing: -.015em; }
.brand-wordmark small { max-width: 260px; margin-top: 4px; color: var(--muted); font-size: .62rem; }
.topbar-context { padding-left: 18px; border-left: 1px solid var(--border); line-height: 1.2; }
.topbar-context strong { display: block; color: var(--fm-blue); font-size: 0.95rem; }
.debug-badge { display: inline-block; width: fit-content; margin-top: 4px; padding: 2px 7px; border: 1px solid #d29a20; border-radius: 999px; background: #fff6d9; color: #795600; font-size: .64rem; font-weight: 800; letter-spacing: .02em; }
.eyebrow { display: block; margin-bottom: 5px; color: #5a7181; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.11em; text-transform: uppercase; }
.user-menu { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--fm-blue); color: var(--white); font-weight: 800; }
.user-copy { min-width: 120px; line-height: 1.2; }
.user-copy strong, .user-copy span { display: block; }
.user-copy strong { font-size: 0.88rem; color: var(--fm-blue-deep); }
.user-copy span { margin-top: 3px; color: var(--muted); font-size: 0.73rem; }
.nav-toggle { display: none; border: 0; background: transparent; color: var(--fm-blue); font-size: 1.45rem; min-width: 44px; min-height: 44px; }

.app-shell { min-height: 100vh; padding-top: 92px; }
.sidebar { position: fixed; z-index: 35; left: 0; top: 92px; bottom: 0; width: var(--sidebar); display: flex; flex-direction: column; background: var(--fm-blue-deep); color: var(--white); overflow-y: auto; }
.sidebar nav { padding: 22px 12px; }
.nav-section { padding: 18px 12px 7px; color: #87a4b9; font-size: 0.66rem; font-weight: 800; letter-spacing: 0.13em; text-transform: uppercase; }
.nav-item { min-height: 46px; display: flex; align-items: center; gap: 11px; margin: 3px 0; padding: 9px 11px; border: 1px solid transparent; border-radius: 8px; color: #d8e5ee; font-size: 0.88rem; font-weight: 700; }
.nav-item:hover { background: rgba(255,255,255,0.07); color: var(--white); text-decoration: none; }
.nav-item.active { background: var(--white); color: var(--fm-blue-deep); }
.nav-item-primary { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.18); color: var(--white); }
.nav-icon { width: 28px; height: 28px; flex: 0 0 28px; display: grid; place-items: center; border: 1px solid currentColor; border-radius: 7px; font-size: 0.62rem; font-weight: 900; letter-spacing: -0.02em; }
.nav-badge { margin-left: auto; min-width: 22px; height: 22px; display: grid; place-items: center; padding: 0 5px; border-radius: 20px; background: var(--amber-bg); color: var(--amber); font-size: 0.7rem; }
.sidebar-footer { margin-top: auto; padding: 17px 18px; display: flex; align-items: center; gap: 10px; border-top: 1px solid rgba(255,255,255,0.1); background: rgba(0,0,0,0.11); }
.sidebar-footer strong, .sidebar-footer small { display: block; }
.sidebar-footer strong { font-size: 0.75rem; }
.sidebar-footer small { color: #8ca8ba; font-size: 0.68rem; }
.sidebar-footer a { color: #d8e5ee; }
.status-dot { width: 9px; height: 9px; display: inline-block; border-radius: 50%; background: #31c48d; box-shadow: 0 0 0 4px rgba(49,196,141,0.13); }

.main-content { min-height: calc(100vh - 92px); margin-left: var(--sidebar); padding: 34px clamp(22px, 3vw, 46px) 70px; }
.page-narrow { max-width: 940px; margin: 0 auto; }
.page-header { min-height: 72px; display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.page-header p { max-width: 720px; margin-bottom: 0; color: var(--muted); }
.header-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.top-gap { margin-top: 22px; }
.muted { color: var(--muted); }
.numeric { text-align: right; font-variant-numeric: tabular-nums; }

.card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.card-header h2 { margin-bottom: 0; }
.card-header > a { font-size: 0.8rem; font-weight: 800; }
.button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 16px; border: 1px solid transparent; border-radius: 7px; cursor: pointer; font-size: 0.86rem; font-weight: 800; line-height: 1.1; transition: background-color .15s, border-color .15s, transform .15s; }
.button:hover { text-decoration: none; transform: translateY(-1px); }
.button-primary { background: var(--fm-blue); border-color: var(--fm-blue); color: var(--white); }
.button-primary:hover { background: var(--fm-blue-deep); }
.button-secondary { background: var(--white); border-color: var(--fm-blue); color: var(--fm-blue); }
.button-secondary:hover { background: var(--fm-blue-soft); }
.button-ghost { background: transparent; border-color: var(--border); color: var(--muted); }
.button-ghost:hover { background: var(--surface); color: var(--fm-blue); }
.button-small { min-height: 36px; padding: 7px 10px; font-size: 0.76rem; }
.button-large { min-height: 50px; padding: 12px 22px; }
.button-full { width: 100%; }
.button-link { padding: 4px; border: 0; background: transparent; color: var(--fm-blue); cursor: pointer; font-size: 0.8rem; font-weight: 800; }
.button-link.danger { color: var(--red); }

.message-stack { position: fixed; z-index: 80; top: 108px; right: 22px; width: min(400px, calc(100vw - 44px)); display: grid; gap: 8px; }
.message { padding: 13px 16px; border: 1px solid var(--border); border-radius: 9px; background: var(--white); box-shadow: var(--shadow); font-size: 0.85rem; font-weight: 700; }
.message-success { background: var(--green-bg); border-color: #9bd9bf; color: #075d3c; }
.message-error { background: var(--red-bg); border-color: #e7abab; color: var(--red); }
.message-warning { background: var(--amber-bg); border-color: #ebca79; color: var(--amber); }
.toast { position: fixed; z-index: 300; right: 22px; bottom: 22px; max-width: 420px; padding: 14px 18px; border-radius: 9px; background: var(--fm-blue-deep); color: var(--white); box-shadow: 0 15px 40px rgba(0,0,0,.23); font-size: 0.87rem; font-weight: 700; }

.field { min-width: 0; }
.field label { display: block; margin-bottom: 6px; color: var(--fm-blue-deep); font-size: 0.78rem; font-weight: 800; }
.form-control { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid #b9c7d1; border-radius: 7px; background: var(--white); color: var(--ink); outline: none; }
textarea.form-control { min-height: 84px; resize: vertical; }
.form-control:hover { border-color: #8198a8; }
.form-control:focus { border-color: var(--fm-blue); box-shadow: 0 0 0 3px rgba(0,43,79,.12); }
.form-control:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
.field small { display: block; margin-top: 5px; color: var(--red); font-size: 0.74rem; }
.field-error .form-control { border-color: var(--red); }
.form-alert, .errorlist { margin: 0 0 18px; padding: 12px 14px; border: 1px solid #e8aaaa; border-radius: 8px; background: var(--red-bg); color: var(--red); font-size: 0.82rem; list-style: none; }
.form-stack { display: grid; gap: 17px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.field-wide { grid-column: 1 / -1; }
.form-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 22px; }
.confirmation-note { display: flex; align-items: flex-start; gap: 12px; padding: 15px; border-left: 4px solid var(--fm-blue); border-radius: 6px; background: var(--fm-blue-soft); color: var(--fm-blue-deep); }
.confirmation-note strong { white-space: nowrap; }
.confirmation-note span { color: var(--muted); font-size: 0.84rem; }

/* Access */
.auth-page { overflow-x: hidden; background: var(--white); }
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(420px, 45%) 1fr; }
.auth-shell-compact { grid-template-columns: minmax(420px, 560px); justify-content: center; background: linear-gradient(135deg, var(--surface), var(--white)); }
.auth-panel { align-self: center; width: min(440px, calc(100% - 48px)); margin: 30px auto; padding: 28px 0; }
.auth-brand { width: 100%; padding-bottom: 26px; margin-bottom: 34px; border-bottom: 4px solid var(--fm-blue); }
.brand-lockup-auth { gap: 16px; }
.brand-lockup-auth > img { width: 76px; height: 76px; flex-basis: 76px; }
.brand-lockup-auth .brand-wordmark strong { font-size: 1.05rem; }
.brand-lockup-auth .brand-wordmark small { margin-top: 6px; font-size: .72rem; }
.auth-heading { margin-bottom: 28px; }
.auth-heading h1 { font-size: 2.2rem; }
.auth-heading p { color: var(--muted); }
.auth-security { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 26px; color: var(--muted); font-size: 0.75rem; }
.recovery-link { display: block; margin-top: 18px; text-align: center; font-size: .8rem; font-weight: 700; }
.field-help { margin-top: 6px; color: var(--muted); font-size: .72rem; }
.field-help ul { margin: 5px 0; padding-left: 18px; }
.auth-visual { position: relative; min-height: 100vh; display: flex; align-items: flex-end; padding: 70px; overflow: hidden; background: var(--fm-blue-deep); color: var(--white); }
.auth-visual::before { content: "FM"; position: absolute; right: -50px; top: -80px; color: rgba(255,255,255,.035); font-size: min(33vw, 500px); font-weight: 900; line-height: 1; }
.auth-visual::after { content: ""; position: absolute; inset: auto -15% -35% 15%; height: 70%; border-radius: 50% 50% 0 0; background: linear-gradient(120deg, rgba(255,255,255,.04), rgba(255,255,255,.01)); transform: rotate(-8deg); }
.auth-visual-content { position: relative; z-index: 2; max-width: 620px; }
.auth-visual-content strong { display: block; max-width: 580px; margin-bottom: 18px; font-size: clamp(2.5rem, 5vw, 4.6rem); line-height: .98; letter-spacing: -.055em; }
.auth-visual-content p { max-width: 470px; color: #b8cbd8; font-size: 1.05rem; }
.visual-kicker { display: block; margin-bottom: 18px; color: #8eb1ca; font-size: 0.76rem; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
.visual-grid { position: absolute; inset: 0; opacity: .12; background-image: linear-gradient(rgba(255,255,255,.1) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.1) 1px, transparent 1px); background-size: 55px 55px; mask-image: linear-gradient(to bottom, transparent, black); }
.setup-card { padding: 30px; }
.setup-steps { padding-left: 22px; color: var(--muted); }
.setup-steps li { margin: 8px 0; }
.mfa-qr-card { display: grid; justify-items: center; gap: 12px; margin: 22px 0; text-align: center; }
.mfa-qr-card img { width: min(100%, 315px); height: auto; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.mfa-qr-card p { max-width: 440px; margin: 0; color: var(--muted); font-size: .84rem; }
.mfa-manual-setup { margin: 18px 0; padding: 14px 16px; border: 1px solid var(--border); border-radius: 8px; }
.mfa-manual-setup > summary { cursor: pointer; color: var(--fm-blue); font-weight: 800; }
.secret-box { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 18px 0; padding: 16px; border: 1px dashed #7b94a6; border-radius: 8px; background: var(--surface); }
.secret-box code { overflow-wrap: anywhere; color: var(--fm-blue-deep); font-weight: 800; letter-spacing: .08em; }
.uri-code { display: block; margin-top: 10px; padding: 10px; overflow-wrap: anywhere; background: var(--surface); font-size: .7rem; }

/* Dashboard */
.dashboard-header { align-items: center; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi-card { min-height: 136px; display: flex; flex-direction: column; padding: 19px; border: 1px solid var(--border); border-top: 4px solid #9eb1bd; border-radius: 10px; background: var(--white); box-shadow: var(--shadow); }
.kpi-card > span { color: var(--muted); font-size: .74rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.kpi-card strong { margin: auto 0 2px; color: var(--fm-blue-deep); font-size: 2rem; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi-card small { font-size: .73rem; }
.kpi-primary { border-top-color: var(--fm-blue); background: linear-gradient(150deg, var(--white), #edf4f8); }
.kpi-warning { border-top-color: #d79c25; background: linear-gradient(150deg, var(--white), var(--amber-bg)); }
.connection-word { font-size: 1.4rem !important; color: var(--green) !important; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(300px, .8fr); gap: 18px; margin-bottom: 18px; }
.dashboard-grid-lower { grid-template-columns: minmax(0, 1.5fr) minmax(300px, .75fr); }
.chart-card { min-height: 345px; }
.trend-chart { height: 240px; display: flex; align-items: flex-end; gap: clamp(4px, .7vw, 10px); padding: 20px 4px 24px; border-bottom: 1px solid var(--border); }
.chart-column { position: relative; height: 100%; flex: 1; display: flex; align-items: flex-end; justify-content: center; }
.chart-bar { width: min(28px, 72%); min-height: 3px; border-radius: 5px 5px 1px 1px; background: linear-gradient(180deg, #17659a, var(--fm-blue)); transition: height .4s ease; }
.chart-column small { position: absolute; top: calc(100% + 7px); left: 50%; transform: translateX(-50%); color: var(--muted); font-size: .62rem; }
.chart-column b { position: absolute; top: 0; left: 50%; transform: translateX(-50%); color: var(--fm-blue-deep); font-size: .62rem; opacity: 0; }
.chart-column:hover b { opacity: 1; }
.chart-h-5 { height: 5%; }.chart-h-10 { height: 10%; }.chart-h-15 { height: 15%; }.chart-h-20 { height: 20%; }
.chart-h-25 { height: 25%; }.chart-h-30 { height: 30%; }.chart-h-35 { height: 35%; }.chart-h-40 { height: 40%; }
.chart-h-45 { height: 45%; }.chart-h-50 { height: 50%; }.chart-h-55 { height: 55%; }.chart-h-60 { height: 60%; }
.chart-h-65 { height: 65%; }.chart-h-70 { height: 70%; }.chart-h-75 { height: 75%; }.chart-h-80 { height: 80%; }
.chart-h-85 { height: 85%; }.chart-h-90 { height: 90%; }.chart-h-95 { height: 95%; }.chart-h-100 { height: 100%; }
.connection-word.offline { color: var(--amber) !important; }
.is-hidden { display: none !important; }
.quick-actions { display: grid; gap: 8px; }
.quick-actions a { min-height: 62px; display: flex; align-items: center; gap: 11px; padding: 10px; border: 1px solid transparent; border-radius: 8px; color: var(--text); }
.quick-actions a:hover { border-color: var(--border); background: var(--surface); text-decoration: none; }
.quick-actions a > span { width: 32px; height: 32px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 7px; background: var(--fm-blue-soft); color: var(--fm-blue); font-size: .68rem; font-weight: 900; }
.quick-actions div { flex: 1; }
.quick-actions strong, .quick-actions small { display: block; }
.quick-actions strong { color: var(--fm-blue-deep); font-size: .82rem; }
.quick-actions small { font-size: .7rem; }
.quick-actions b { color: var(--fm-blue); }
.alert-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 11px; }
.alert-list li { display: flex; align-items: center; gap: 12px; padding: 11px; border: 1px solid #ead19a; border-radius: 8px; background: var(--amber-bg); }
.alert-mark { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: #d99a1f; color: var(--white); font-weight: 900; }
.alert-list strong, .alert-list small { display: block; }
.alert-list strong { font-size: .8rem; }
.alert-list small { font-size: .68rem; }

/* Tables and status */
.table-card { padding: 0; overflow: hidden; }
.table-card > .card-header { padding: 21px 22px 0; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .8rem; }
th { padding: 11px 14px; border-bottom: 1px solid var(--border); background: #edf2f5; color: #425967; text-align: left; font-size: .66rem; font-weight: 900; letter-spacing: .055em; text-transform: uppercase; white-space: nowrap; }
td { padding: 13px 14px; border-bottom: 1px solid #e6ebef; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8fafb; }
td strong, td small { display: block; }
td small { margin-top: 3px; font-size: .68rem; }
.table-link { font-weight: 800; white-space: nowrap; }
.status { display: inline-flex; align-items: center; min-height: 25px; padding: 4px 8px; border-radius: 20px; font-size: .67rem; font-weight: 900; white-space: nowrap; }
.status-confirmed, .status-approved, .status-active, .status-positive { background: var(--green-bg); color: var(--green); }
.status-correction_pending, .status-pending, .status-pending_approval, .status-warning, .status-draft { background: var(--amber-bg); color: var(--amber); }
.status-rejected, .status-observed, .status-negative, .status-retired { background: var(--red-bg); color: var(--red); }
.status-legacy { background: #e7edf1; color: var(--muted); }
.empty-state { padding: 50px 24px; text-align: center; color: var(--muted); }
.empty-state strong { display: block; margin-bottom: 5px; color: var(--fm-blue-deep); }
.empty-state p { margin-bottom: 0; font-size: .82rem; }
.empty-state.compact { padding: 30px 16px; }

/* Filters */
.filters-card { margin-bottom: 16px; padding: 16px 18px; }
.filter-form { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.filter-form .field { min-width: 160px; }
.filter-form .grow { flex: 1; min-width: 230px; }
.filter-form .form-control { min-height: 40px; padding: 7px 9px; }
.filter-form .button { min-height: 40px; }
.export-actions { display: flex; justify-content: flex-end; gap: 18px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.export-actions a { font-size: .75rem; font-weight: 800; }

/* Production capture */
.capture-progress { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin-bottom: 15px; }
.capture-progress span { padding: 9px 12px; border-radius: 6px; background: var(--surface-2); color: var(--muted); text-align: center; font-size: .7rem; font-weight: 800; }
.capture-progress span.active { background: var(--fm-blue); color: var(--white); }
.capture-form { display: grid; gap: 16px; }
.form-section { position: relative; padding: 26px 26px 26px 82px; }
.section-number { position: absolute; left: 24px; top: 27px; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 8px; background: var(--fm-blue); color: var(--white); font-size: .72rem; font-weight: 900; }
.section-heading { margin-bottom: 21px; }
.section-heading p { margin: 0; color: var(--muted); font-size: .82rem; }
.deviation-list { display: grid; gap: 12px; margin-bottom: 14px; }
.deviation-form { padding: 17px; border: 1px solid var(--border); border-radius: 9px; background: #f9fbfc; }
.deviation-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; color: var(--fm-blue-deep); font-size: .8rem; }
.deviation-grid { grid-template-columns: minmax(180px, 1.3fr) minmax(120px, .65fr) minmax(140px, .75fr); }
.deviation-grid .field:last-of-type { grid-column: 1 / -1; }
.confirmation-section { border-color: #9db8ca; }

/* Detail */
.detail-hero { display: grid; grid-template-columns: 1.2fr 1fr 1fr; margin-bottom: 18px; border-radius: var(--radius); overflow: hidden; background: var(--fm-blue-deep); color: var(--white); box-shadow: var(--shadow); }
.detail-hero > div { min-height: 155px; display: flex; flex-direction: column; justify-content: center; padding: 24px; border-right: 1px solid rgba(255,255,255,.13); }
.detail-hero > div:last-child { border-right: 0; }
.detail-hero span { color: #a9c0d0; font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.detail-hero strong { margin: 10px 0 5px; font-size: 2.15rem; line-height: 1; }
.detail-hero small { color: #a9c0d0; }
.detail-hero .detail-status, .detail-hero .detail-person { font-size: 1rem; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.detail-grid-single { grid-template-columns: minmax(0, 1fr); }
.deviation-summary { margin: 0; padding: 0; list-style: none; display: grid; gap: 12px; }
.deviation-summary li { display: flex; gap: 13px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.deviation-summary li:last-child { border-bottom: 0; }
.deviation-duration { width: 48px; height: 48px; flex: 0 0 48px; display: grid; place-items: center; align-content: center; border-radius: 8px; background: var(--amber-bg); color: var(--amber); font-weight: 900; }
.deviation-duration small { color: inherit; font-size: .56rem; }
.deviation-summary p { margin: 3px 0; color: var(--muted); font-size: .78rem; }
.timeline { display: grid; gap: 0; }
.timeline-item { display: flex; gap: 14px; min-height: 75px; }
.timeline-item > span { position: relative; width: 12px; height: 12px; margin-top: 3px; flex: 0 0 12px; border: 3px solid var(--fm-blue); border-radius: 50%; background: var(--white); }
.timeline-item > span::after { content: ""; position: absolute; left: 2px; top: 11px; width: 2px; height: 54px; background: var(--border); }
.timeline-item:last-child > span::after { display: none; }
.timeline-item p { margin: 3px 0; color: var(--muted); font-size: .8rem; }
.timeline-item small { font-size: .7rem; }
.comparison-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.comparison-grid-three { grid-template-columns: repeat(3, 1fr); }
.comparison-grid section { display: flex; flex-direction: column; gap: 8px; }
.comparison-grid span { color: var(--muted); font-size: .74rem; font-weight: 800; text-transform: uppercase; }
.comparison-grid strong { color: var(--fm-blue-deep); font-size: 2.25rem; }
.comparison-new { border-color: #7bb99f; background: var(--green-bg); }
.reason-copy { margin-bottom: 0; color: var(--muted); white-space: pre-wrap; }

/* Inventory */
.balance-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 13px; margin-bottom: 18px; }
.balance-card { min-height: 168px; padding: 17px; border-top: 4px solid var(--fm-blue); }
.balance-card > div { display: flex; align-items: center; justify-content: space-between; }
.balance-card > div span { color: var(--muted); font-size: .68rem; font-weight: 900; }
.balance-card > div b { padding: 3px 6px; border-radius: 10px; background: var(--amber-bg); color: var(--amber); font-size: .58rem; text-transform: uppercase; }
.balance-card > strong { display: block; margin-top: 15px; color: var(--fm-blue-deep); font-size: 1.8rem; line-height: 1; }
.balance-card > small { font-size: .68rem; }
.balance-card h2 { margin: auto 0 0; padding-top: 16px; font-size: .86rem; }
.balance-card.low-stock { border-top-color: #d59316; background: linear-gradient(160deg, var(--white), #fffaf0); }
.movement-quantity { font-size: .9rem; font-weight: 900; }
.movement-quantity.positive { color: var(--green); }
.movement-quantity.negative { color: var(--red); }
.movement-form { padding-left: 26px; }
.field-override_reason { grid-column: 1 / -1; }
.inline-create { margin-top: 6px; padding: 2px 0; border: 0; background: transparent; color: var(--fm-blue); cursor: pointer; font-size: .72rem; font-weight: 800; }
.inline-create:hover { text-decoration: underline; }
.quick-dialog { width: min(620px, calc(100vw - 28px)); padding: 26px; border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 24px 70px rgba(0, 28, 51, .28); }
.quick-dialog::backdrop { background: rgba(0, 28, 51, .58); }
.quick-dialog-close { position: absolute; top: 10px; right: 12px; }
.quick-dialog-close button { width: 38px; height: 38px; border: 0; border-radius: 50%; background: var(--surface); color: var(--muted); cursor: pointer; font-size: 1.4rem; }
.reference-section { margin-bottom: 18px; }

/* BOM, catalogs, outbox */
.bom-grid, .catalog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.bom-card { padding: 0; overflow: hidden; }
.bom-product { display: flex; align-items: flex-start; justify-content: space-between; padding: 20px; background: linear-gradient(145deg, var(--fm-blue-deep), var(--fm-blue)); color: var(--white); }
.bom-product span { color: #9db7c9; font-size: .68rem; font-weight: 900; }
.bom-product h2 { margin: 5px 0 2px; color: var(--white); }
.bom-product p { margin: 0; color: #afc4d2; font-size: .75rem; }
.bom-product > strong { font-size: 1.5rem; text-align: center; }
.bom-product > strong small { display: block; color: #afc4d2; font-size: .58rem; text-transform: uppercase; }
.bom-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 18px; border-bottom: 1px solid var(--border); color: var(--muted); font-size: .7rem; }
.bom-card ul { margin: 0; padding: 9px 18px 16px; list-style: none; }
.bom-card li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid #edf1f4; font-size: .75rem; }
.bom-card li:last-child { border-bottom: 0; }
.catalog-card { min-height: 158px; display: flex; flex-direction: column; color: var(--text); border-top: 4px solid var(--fm-blue); }
.catalog-card:hover { transform: translateY(-2px); text-decoration: none; box-shadow: 0 13px 30px rgba(0,31,57,.12); }
.catalog-card span { color: var(--muted); font-size: .75rem; font-weight: 800; text-transform: uppercase; }
.catalog-card strong { margin: auto 0 3px; color: var(--fm-blue-deep); font-size: 2.2rem; }
.catalog-card small { font-size: .72rem; }
.connection-explainer { display: flex; justify-content: space-between; gap: 25px; margin-bottom: 16px; padding: 15px 18px; border: 1px solid var(--border); border-radius: 9px; background: var(--white); }
.connection-explainer > div { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.connection-explainer p { margin: 0; max-width: 620px; color: var(--muted); font-size: .78rem; }
.loading-state { padding: 45px; text-align: center; color: var(--muted); }
.outbox-list { display: grid; gap: 10px; }
.outbox-item { display: flex; align-items: center; gap: 15px; padding: 14px; border: 1px solid var(--border); border-radius: 9px; background: var(--white); }
.outbox-item > span { width: 38px; height: 38px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 8px; background: var(--amber-bg); color: var(--amber); font-weight: 900; }
.outbox-item > div { flex: 1; }
.outbox-item strong, .outbox-item small { display: block; }
.outbox-item small { margin-top: 3px; font-size: .7rem; }

/* Feedback */
.feedback-launch { position: fixed; z-index: 44; right: 22px; bottom: 22px; min-height: 48px; display: inline-flex; align-items: center; gap: 9px; padding: 8px 16px 8px 9px; border: 0; border-radius: 999px; background: var(--fm-blue); color: var(--white); box-shadow: 0 10px 30px rgba(0,43,79,.28); cursor: pointer; }
.feedback-launch:hover { background: var(--fm-blue-deep); transform: translateY(-1px); }
.feedback-launch:focus-visible { outline: 3px solid rgba(245,166,35,.8); outline-offset: 3px; }
.feedback-launch:disabled { cursor: wait; opacity: .78; }
.feedback-launch > span { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: rgba(255,255,255,.16); font-size: 1.05rem; font-weight: 900; }
.feedback-launch > strong { font-size: .78rem; }
.feedback-dialog { width: min(650px, calc(100vw - 28px)); max-height: min(820px, calc(100vh - 28px)); padding: 0; overflow: auto; border: 1px solid var(--border); border-radius: 14px; background: var(--white); color: var(--ink); box-shadow: 0 24px 80px rgba(0,28,51,.34); }
.feedback-dialog::backdrop { background: rgba(0,28,51,.62); backdrop-filter: blur(2px); }
.feedback-dialog form { padding: 26px; }
.feedback-dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 21px; }
.feedback-dialog-header h2 { margin: 0; color: var(--fm-blue-deep); font-size: 1.45rem; }
.feedback-close { width: 44px; height: 44px; flex: 0 0 auto; border: 0; border-radius: 50%; background: var(--surface); color: var(--muted); cursor: pointer; font-size: 1.55rem; line-height: 1; }
.feedback-close:hover { background: var(--fm-blue-soft); color: var(--fm-blue); }
.feedback-kinds { margin: 0 0 19px; padding: 0; border: 0; }
.feedback-kinds legend { margin-bottom: 9px; color: var(--fm-blue-deep); font-size: .82rem; font-weight: 800; }
.feedback-kinds { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }
.feedback-kinds legend { grid-column: 1 / -1; }
.feedback-kinds label { position: relative; display: block; cursor: pointer; }
.feedback-kinds input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
.feedback-kinds label > span { min-height: 108px; display: flex; flex-direction: column; padding: 14px; border: 1px solid #b9c7d1; border-radius: 9px; background: var(--white); transition: border-color .15s ease, background .15s ease, box-shadow .15s ease; }
.feedback-kinds label:hover > span { border-color: var(--fm-blue); }
.feedback-kinds input:checked + span { border-color: var(--fm-blue); background: var(--fm-blue-soft); box-shadow: 0 0 0 2px rgba(0,43,79,.08); }
.feedback-kinds input:focus-visible + span { outline: 3px solid rgba(0,43,79,.18); outline-offset: 2px; }
.feedback-kinds strong { color: var(--fm-blue-deep); font-size: .78rem; line-height: 1.25; }
.feedback-kinds small { margin-top: 7px; color: var(--muted); font-size: .68rem; line-height: 1.35; }
.feedback-context { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 9px; margin: 0 0 18px; }
.feedback-context > div { min-width: 0; padding: 10px 12px; border-radius: 8px; background: var(--surface); }
.feedback-context dt { color: var(--muted); font-size: .66rem; font-weight: 800; text-transform: uppercase; }
.feedback-context dd { overflow: hidden; margin: 3px 0 0; color: var(--fm-blue-deep); font-size: .76rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.feedback-message-field { display: block; }
.feedback-message-field > strong { display: block; margin-bottom: 7px; color: var(--fm-blue-deep); font-size: .82rem; }
.feedback-message-field textarea { min-height: 122px; resize: vertical; }
.feedback-message-field > small { display: block; margin-top: 5px; color: var(--muted); text-align: right; font-size: .68rem; }
.feedback-capture-notice { display: flex; align-items: flex-start; gap: 10px; margin-top: 16px; padding: 12px 14px; border-radius: 9px; background: var(--amber-bg); color: #6f4d0c; }
.feedback-capture-notice > span { font-size: 1rem; }
.feedback-capture-notice p { margin: 0; font-size: .72rem; line-height: 1.45; }
.feedback-errors { margin-top: 14px; padding: 11px 13px; border: 1px solid #e8aaaa; border-radius: 8px; background: var(--red-bg); color: var(--red); font-size: .78rem; }
.feedback-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

.mobile-nav { display: none; }
.offline-screen, .error-page { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 30px; text-align: center; background: var(--surface); }
.offline-mark { width: 70px; height: 70px; display: grid; place-items: center; margin-bottom: 20px; border: 4px solid var(--fm-blue); border-radius: 50%; color: var(--fm-blue); font-size: 1.4rem; font-weight: 900; }
.offline-screen p, .error-page p { max-width: 520px; color: var(--muted); }
.work-order-section { margin: 0 0 26px; }
.work-order-section > .card-header { margin-bottom: 12px; }
.work-order-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(235px, 1fr)); gap: 12px; }
.work-order-card { padding: 18px; border: 1px solid var(--border); border-radius: 10px; background: var(--white); box-shadow: 0 5px 18px rgba(0,43,79,.05); }
.work-order-card > div:first-child { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.work-order-card h3 { margin: 12px 0 10px; color: var(--fm-blue-deep); font-size: 1rem; }
.work-order-card > small { display: block; margin-top: -5px; color: var(--muted); font-size: .7rem; }
.progress-track { height: 8px; overflow: hidden; border-radius: 99px; background: var(--surface); }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: var(--fm-blue); }
.work-order-card.completed .progress-track span { background: var(--green); }
.progress-p0 { width: 0; }
.progress-p5 { width: 5%; }
.progress-p10 { width: 10%; }
.progress-p15 { width: 15%; }
.progress-p20 { width: 20%; }
.progress-p25 { width: 25%; }
.progress-p30 { width: 30%; }
.progress-p35 { width: 35%; }
.progress-p40 { width: 40%; }
.progress-p45 { width: 45%; }
.progress-p50 { width: 50%; }
.progress-p55 { width: 55%; }
.progress-p60 { width: 60%; }
.progress-p65 { width: 65%; }
.progress-p70 { width: 70%; }
.progress-p75 { width: 75%; }
.progress-p80 { width: 80%; }
.progress-p85 { width: 85%; }
.progress-p90 { width: 90%; }
.progress-p95 { width: 95%; }
.progress-p100 { width: 100%; }
.work-order-card dl { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0 0; }
.work-order-card dl div { min-width: 0; }
.work-order-card dt { color: var(--muted); font-size: .7rem; }
.work-order-card dd { margin: 2px 0 0; color: var(--fm-blue-deep); font-weight: 800; }
.deviation-estimate output { min-height: 44px; display: flex; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); color: var(--fm-blue); font-weight: 800; }
.error-page > span { color: var(--fm-blue); font-size: 5rem; font-weight: 900; line-height: 1; opacity: .18; }

@media (max-width: 1120px) {
  :root { --sidebar: 215px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid, .dashboard-grid-lower { grid-template-columns: 1fr; }
  .topbar-context { display: none; }
}

@media (max-width: 820px) {
  body { padding-bottom: 70px; }
  button, input:not([type="hidden"]):not([type="radio"]):not([type="checkbox"]), select, .button, .button-small, .filter-form .button { min-height: 44px; }
  .brand-stripe { height: 7px; }
  .topbar { top: 7px; height: 66px; padding: 0 13px; gap: 10px; }
  .brand { width: 174px; }
  .brand-lockup > img { width: 39px; height: 39px; flex-basis: 39px; }
  .brand-wordmark strong { font-size: .72rem; }
  .nav-toggle { display: inline-grid; place-items: center; }
  .user-copy, .user-menu .button { display: none; }
  .user-avatar { width: 34px; height: 34px; }
  .app-shell { padding-top: 73px; }
  .sidebar { top: 73px; width: min(82vw, 290px); transform: translateX(-105%); transition: transform .2s ease; box-shadow: 8px 0 24px rgba(0,0,0,.18); }
  .sidebar.open { transform: translateX(0); }
  .main-content { min-height: calc(100vh - 73px); margin-left: 0; padding: 24px 16px 34px; }
  .mobile-nav { position: fixed; z-index: 45; left: 0; right: 0; bottom: 0; height: 68px; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding-bottom: env(safe-area-inset-bottom); border-top: 1px solid var(--border); background: rgba(255,255,255,.97); box-shadow: 0 -8px 24px rgba(0,31,57,.08); }
  .mobile-nav a { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: .62rem; font-weight: 800; }
  .mobile-nav a:hover { text-decoration: none; }
  .mobile-nav a > span { font-size: .7rem; font-weight: 900; }
  .mobile-nav a.active { color: var(--fm-blue); }
  .mobile-nav .mobile-primary { width: 60px; height: 60px; align-self: center; justify-self: center; margin-top: -16px; border: 4px solid var(--surface); border-radius: 50%; background: var(--fm-blue); color: var(--white); }
  .mobile-nav b { position: absolute; top: 5px; right: calc(50% - 25px); min-width: 18px; height: 18px; display: grid; place-items: center; border-radius: 20px; background: var(--red); color: var(--white); }
  .feedback-launch { right: 14px; bottom: calc(80px + env(safe-area-inset-bottom)); min-width: 48px; padding-right: 12px; }
  .page-header, .dashboard-header { align-items: stretch; flex-direction: column; gap: 14px; }
  .page-header .button { align-self: flex-start; }
  .header-actions { justify-content: flex-start; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-hero { grid-template-columns: 1fr 1fr; }
  .detail-hero > div:last-child { grid-column: 1 / -1; min-height: 110px; border-top: 1px solid rgba(255,255,255,.13); }
  .form-section { padding: 22px 18px; }
  .section-number { position: static; margin-bottom: 12px; }
  .deviation-grid { grid-template-columns: 1fr 1fr; }
  .deviation-grid .field:first-child, .deviation-grid .field:last-of-type { grid-column: 1 / -1; }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
  .auth-panel { width: min(430px, calc(100% - 36px)); }
}

@media (max-width: 600px) {
  h1 { font-size: 1.72rem; }
  .topbar { gap: 5px; }
  .brand { width: 150px; }
  .brand-wordmark strong { font-size: .66rem; }
  .user-menu { gap: 0; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .kpi-card { min-height: 120px; padding: 14px; }
  .kpi-card strong { font-size: 1.55rem; }
  .card { padding: 17px; }
  .table-card { padding: 0; }
  .form-grid, .deviation-grid { grid-template-columns: 1fr; }
  .deviation-grid .field { grid-column: auto !important; }
  .capture-progress span { padding: 8px 3px; font-size: .61rem; }
  .confirmation-note { flex-direction: column; gap: 4px; }
  .confirmation-note strong { white-space: normal; }
  .form-actions { align-items: stretch; flex-direction: column; }
  .form-actions .button { width: 100%; }
  .detail-hero { grid-template-columns: 1fr; }
  .detail-hero > div { min-height: 110px; border-right: 0; border-bottom: 1px solid rgba(255,255,255,.13); }
  .detail-hero > div:last-child { grid-column: auto; border-bottom: 0; }
  .comparison-grid, .comparison-grid-three { grid-template-columns: 1fr; }
  .balance-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .balance-card { min-height: 150px; }
  .balance-card > strong { font-size: 1.4rem; }
  .filter-form { align-items: stretch; flex-direction: column; }
  .filter-form .field, .filter-form .grow, .filter-form .button { width: 100%; min-width: 0; }
  .connection-explainer { flex-direction: column; gap: 9px; }
  .message-stack { top: 84px; right: 12px; width: calc(100vw - 24px); }
  .feedback-dialog form { padding: 20px 17px; }
  .feedback-kinds { grid-template-columns: 1fr; }
  .feedback-context { grid-template-columns: 1fr; }
  .feedback-kinds label > span { min-height: 72px; }
  .feedback-actions { align-items: stretch; flex-direction: column-reverse; }
  .feedback-actions .button { width: 100%; }
  table.responsive, table.responsive tbody, table.responsive tr, table.responsive td { display: block; }
}

@media (max-width: 410px) {
  .brand { width: 122px; }
  .brand-lockup { gap: 6px; }
  .brand-lockup > img { width: 34px; height: 34px; flex-basis: 34px; }
  .kpi-grid, .balance-grid { grid-template-columns: 1fr; }
  .kpi-card { min-height: 105px; }
}

@media print {
  .brand-stripe, .topbar, .sidebar, .mobile-nav, .feedback-launch, .feedback-dialog, .page-header .button, .filters-card, .message-stack { display: none !important; }
  .app-shell { padding: 0; }
  .main-content { margin: 0; padding: 12mm; }
  .card { box-shadow: none; break-inside: avoid; }
}
