:root {
    color-scheme: light;
    --red: #b40018;
    --red-bright: #d20825;
    --red-soft: #fff0f2;
    --ink: #17181b;
    --ink-soft: #555962;
    --muted: #797e88;
    --line: #e5e6e9;
    --line-strong: #d4d6db;
    --canvas: #f5f5f3;
    --surface: #ffffff;
    --surface-raised: #ffffff;
    --surface-subtle: #f8f8f7;
    --sidebar: #18191c;
    --sidebar-muted: #a8abb2;
    --shadow: 0 14px 40px rgba(25, 27, 31, .07);
    --radius: 14px;
    --radius-sm: 9px;
    --green: #18774a;
    --green-soft: #e9f7ef;
    --amber: #9b5d00;
    --amber-soft: #fff3d8;
    --blue: #2267a9;
    --blue-soft: #e9f3fc;
    --violet: #6b4caf;
    --violet-soft: #f0ebfc;
    --gray-soft: #eceef1;
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --red: #e11634;
    --red-bright: #f02643;
    --red-soft: #35151a;
    --ink: #f3f3f1;
    --ink-soft: #c5c6ca;
    --muted: #969aa3;
    --line: #303237;
    --line-strong: #42454b;
    --canvas: #111214;
    --surface: #1a1b1e;
    --surface-raised: #202125;
    --surface-subtle: #17181b;
    --sidebar: #0b0c0e;
    --sidebar-muted: #9699a1;
    --shadow: 0 18px 50px rgba(0, 0, 0, .3);
    --green: #72d19e;
    --green-soft: #173324;
    --amber: #f4be5c;
    --amber-soft: #3c2c10;
    --blue: #79b5ef;
    --blue-soft: #142c43;
    --violet: #b59aef;
    --violet-soft: #29213c;
    --gray-soft: #2b2d32;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--canvas); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--canvas); font-size: 15px; line-height: 1.5; }
button, input, select, textarea { font: inherit; }
a { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(2rem, 4vw, 3.1rem); line-height: 1.06; letter-spacing: -.045em; }
h2 { margin-bottom: 6px; font-size: 1.15rem; line-height: 1.25; letter-spacing: -.018em; }
.muted { color: var(--muted); }
.eyebrow { margin-bottom: 7px; color: var(--red); font-size: .7rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.field-note { color: var(--muted); font-size: .76rem; font-weight: 500; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; display: flex; width: 252px; flex-direction: column; padding: 28px 18px 20px; color: #f4f4f2; background: var(--sidebar); }
.brand { display: flex; align-items: center; gap: 12px; margin: 0 8px 42px; color: inherit; text-decoration: none; }
.brand > span:last-child { display: flex; flex-direction: column; }
.brand strong { font-size: .93rem; }
.brand small { color: var(--sidebar-muted); font-size: .73rem; }
.brand-mark { display: grid; width: 72px; height: 45px; place-items: center; color: #fff; background: var(--red); font-weight: 900; letter-spacing: .1em; }
.brand-mark--small { width: 47px; height: 31px; flex: 0 0 auto; font-size: .7rem; }
.nav { display: flex; flex: 1; flex-direction: column; gap: 6px; }
.nav-link { display: flex; align-items: center; gap: 13px; padding: 10px 12px; border-radius: 8px; color: var(--sidebar-muted); font-size: .88rem; font-weight: 650; text-decoration: none; transition: .18s ease; }
.nav-link span { display: grid; width: 22px; place-items: center; color: #dadbe0; font-size: 1.15rem; }
.nav-link:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav-link.is-active { color: #fff; background: var(--red); }
.sidebar-footer { border-top: 1px solid rgba(255,255,255,.1); padding-top: 14px; }
.theme-toggle { display: flex; width: 100%; align-items: center; gap: 11px; border: 0; padding: 9px 10px; color: var(--sidebar-muted); background: transparent; cursor: pointer; text-align: left; }
.theme-toggle:hover { color: #fff; }
.theme-icon { display: inline-grid; width: 24px; place-items: center; font-size: 1.15rem; }
.profile { display: grid; grid-template-columns: 36px 1fr 28px; align-items: center; gap: 10px; margin-top: 10px; padding: 12px 8px 0; border-top: 1px solid rgba(255,255,255,.08); }
.profile > span:nth-child(2) { display: flex; min-width: 0; flex-direction: column; }
.profile strong { overflow: hidden; font-size: .8rem; text-overflow: ellipsis; white-space: nowrap; }
.profile small { color: var(--sidebar-muted); font-size: .68rem; }
.avatar { display: inline-grid; width: 36px; height: 36px; flex: 0 0 auto; place-items: center; border-radius: 50%; color: #fff; background: #5b5e67; font-size: .78rem; font-weight: 800; }
.icon-button { border: 0; padding: 4px; color: var(--sidebar-muted); background: transparent; cursor: pointer; font-size: 1rem; }
.main-column { display: flex; width: calc(100% - 252px); min-height: 100vh; flex-direction: column; margin-left: 252px; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; height: 76px; align-items: center; justify-content: space-between; gap: 20px; padding: 0 42px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--canvas) 91%, transparent); backdrop-filter: blur(16px); }
.topbar-title { display: flex; flex-direction: column; }
.topbar-title .eyebrow { margin: 0; font-size: .57rem; }
.topbar-title strong { font-size: .93rem; }
.quick-search { display: flex; width: min(310px, 34vw); align-items: center; gap: 10px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); background: var(--surface); text-decoration: none; }
.quick-search span:nth-child(2) { flex: 1; font-size: .8rem; }
kbd { padding: 1px 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; color: var(--muted); background: var(--surface-subtle); font-size: .67rem; }
.menu-button { display: none; border: 0; color: var(--ink); background: transparent; font-size: 1.25rem; }
.main-content { width: 100%; max-width: 1520px; flex: 1; margin: 0 auto; padding: 44px 46px 64px; }
.footer { padding: 18px 46px; border-top: 1px solid var(--line); color: var(--muted); font-size: .72rem; }
.sidebar-scrim { display: none; }

.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; margin-bottom: 30px; }
.page-heading > div:first-child > p:last-child { margin: 0; color: var(--muted); }
.page-heading--hero { align-items: center; margin-bottom: 34px; }
.page-heading--hero h1 { font-size: clamp(2.1rem, 4vw, 3.45rem); }
.heading-actions { display: flex; gap: 10px; }
.back-link { display: inline-block; margin-bottom: 16px; color: var(--muted); font-size: .79rem; font-weight: 650; text-decoration: none; }
.back-link:hover, .text-link:hover { color: var(--red); }

.button { display: inline-flex; min-height: 41px; align-items: center; justify-content: center; gap: 9px; border: 1px solid transparent; border-radius: 8px; padding: 9px 16px; font-size: .8rem; font-weight: 750; text-decoration: none; cursor: pointer; transition: transform .15s ease, background .15s ease, border-color .15s ease; }
.button:hover { transform: translateY(-1px); }
.button--primary { color: #fff; background: var(--red); }
.button--primary:hover { background: var(--red-bright); }
.button--secondary { border-color: var(--line-strong); color: var(--ink); background: var(--surface); }
.button--ghost { border-color: transparent; color: var(--ink-soft); background: transparent; }
.button--danger { border-color: color-mix(in srgb, var(--red) 35%, var(--line)); color: var(--red); background: var(--surface); }
.button--full { width: 100%; }

.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 24px 26px 17px; }
.panel-header h2 { margin: 0; }
.panel-header .eyebrow { margin-bottom: 4px; }
.text-link { color: var(--ink-soft); font-size: .75rem; font-weight: 750; text-decoration: none; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; margin-bottom: 20px; }
.stat-card { position: relative; display: grid; min-height: 170px; grid-template-columns: 1fr auto; padding: 23px; border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); background: var(--surface); box-shadow: var(--shadow); text-decoration: none; transition: transform .2s ease, border-color .2s ease; }
.stat-card:hover { transform: translateY(-3px); border-color: var(--line-strong); }
.stat-card--primary { color: #fff; border-color: var(--red); background: var(--red); }
.stat-icon { display: grid; width: 36px; height: 36px; grid-column: 2; grid-row: 1 / span 2; place-items: center; border-radius: 10px; color: var(--red); background: var(--red-soft); font-size: 1.05rem; font-weight: 800; }
.stat-card--primary .stat-icon { color: #fff; background: rgba(255,255,255,.16); }
.stat-icon--amber { color: var(--amber); background: var(--amber-soft); }
.stat-icon--green { color: var(--green); background: var(--green-soft); }
.stat-icon--blue { color: var(--blue); background: var(--blue-soft); }
.stat-value { align-self: end; font-size: 2.4rem; font-weight: 790; letter-spacing: -.055em; line-height: 1; }
.stat-label { align-self: start; margin-top: 5px; font-size: .8rem; font-weight: 720; }
.stat-card small { grid-column: 1 / -1; align-self: end; color: var(--muted); font-size: .69rem; }
.stat-card--primary small { color: rgba(255,255,255,.76); }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(275px, .7fr); gap: 20px; }
.compact-list { padding: 0 14px 14px; }
.compact-row { display: grid; grid-template-columns: 58px minmax(130px, 1fr) auto 18px; align-items: center; gap: 13px; padding: 13px 12px; border-top: 1px solid var(--line); text-decoration: none; }
.compact-row:hover { border-radius: 8px; background: var(--surface-subtle); }
.machine-number { color: var(--red); font-size: .77rem; font-weight: 800; white-space: nowrap; }
.machine-main { display: flex; min-width: 0; flex-direction: column; }
.machine-main strong { overflow: hidden; font-size: .82rem; text-overflow: ellipsis; white-space: nowrap; }
.machine-main small, .table-subline { color: var(--muted); font-size: .68rem; }
.row-arrow { color: var(--muted); font-size: 1.2rem; }
.status { display: inline-flex; width: max-content; align-items: center; gap: 5px; border-radius: 99px; padding: 4px 8px; color: var(--muted); background: var(--gray-soft); font-size: .64rem; font-weight: 750; white-space: nowrap; }
.status::before { width: 5px; height: 5px; border-radius: 50%; background: currentColor; content: ""; }
.status--received { color: var(--amber); background: var(--amber-soft); }
.status--ready { color: var(--green); background: var(--green-soft); }
.status--dispatched { color: var(--blue); background: var(--blue-soft); }
.status--direct { color: var(--violet); background: var(--violet-soft); }
.status--scrapped, .status--untracked { color: var(--muted); background: var(--gray-soft); }
.side-summary { padding-bottom: 16px; }
.summary-item { display: grid; grid-template-columns: 10px 1fr 20px; align-items: center; gap: 11px; margin: 0 24px; padding: 16px 0; border-top: 1px solid var(--line); }
.summary-item > div { display: flex; flex-direction: column; }
.summary-item strong { font-size: .78rem; }
.summary-item small { color: var(--muted); font-size: .67rem; }
.summary-item a { color: var(--muted); font-size: 1.1rem; text-align: right; text-decoration: none; }
.summary-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.summary-dot--violet { background: var(--violet); }.summary-dot--amber { background: var(--amber); }.summary-dot--gray { background: var(--muted); }
.import-note { display: flex; flex-direction: column; gap: 2px; margin: 14px 20px 0; padding: 16px; border-radius: 10px; background: var(--surface-subtle); }
.import-note span { color: var(--red); font-size: .62rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.import-note strong { overflow: hidden; font-size: .75rem; text-overflow: ellipsis; white-space: nowrap; }
.import-note small { color: var(--muted); font-size: .63rem; }

.filter-bar { display: flex; align-items: end; gap: 10px; padding: 18px 20px 8px; }
.search-field { display: flex; min-width: 250px; flex: 1; flex-direction: row; align-items: center; gap: 9px; border: 1px solid var(--line-strong); border-radius: 8px; padding: 0 11px; background: var(--surface-subtle); }
.search-field:focus-within { border-color: var(--red); box-shadow: 0 0 0 3px color-mix(in srgb, var(--red) 12%, transparent); }
.search-field input { width: 100%; border: 0; padding: 9px 0; outline: 0; background: transparent; }
.select-label { display: flex; flex-direction: column; gap: 3px; color: var(--muted); font-size: .65rem; font-weight: 750; }
.select-label select { min-width: 140px; border: 1px solid var(--line-strong); border-radius: 8px; padding: 9px 32px 9px 10px; color: var(--ink); background: var(--surface); }
.clear-filter { padding: 10px 4px; color: var(--red); font-size: .7rem; font-weight: 700; }
.search-hint { margin: 0; padding: 0 21px 13px; color: var(--muted); font-size: .67rem; }
code { border-radius: 4px; padding: 2px 5px; color: var(--ink-soft); background: var(--surface-subtle); font-family: "SFMono-Regular", Consolas, monospace; font-size: .75em; }
.table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 10px 13px; color: var(--muted); background: var(--surface-subtle); font-size: .62rem; font-weight: 800; letter-spacing: .055em; text-align: left; text-transform: uppercase; white-space: nowrap; }
.data-table td { border-bottom: 1px solid var(--line); padding: 12px 13px; color: var(--ink-soft); font-size: .74rem; vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: color-mix(in srgb, var(--surface-subtle) 70%, transparent); }
.data-table td strong { color: var(--ink); font-size: .76rem; }
.inventory-panel .data-table th:nth-child(2), .inventory-panel .data-table td:nth-child(2) { min-width: 90px; }
.kam-number { display: inline-block; white-space: nowrap; }
.table-subline { display: block; margin-top: 2px; }
.info-cell { display: inline-block; max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions-cell { text-align: right !important; }
.table-action { color: var(--red); font-size: .7rem; font-weight: 750; text-decoration: none; }
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: .72rem; }
.pagination a { color: var(--ink-soft); font-weight: 700; text-decoration: none; }
.pagination a.is-disabled { pointer-events: none; opacity: .35; }
.empty-state { padding: 44px 20px; color: var(--muted); text-align: center; }
.empty-state strong { display: block; margin-bottom: 5px; color: var(--ink); }
.empty-state p { margin: 0; font-size: .8rem; }

.form-layout { display: grid; gap: 16px; max-width: 1000px; }
.form-layout--narrow { max-width: 780px; }
.form-panel { padding-bottom: 26px; }
.step-badge { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 50%; color: var(--red); background: var(--red-soft); font-size: .66rem; font-weight: 800; }
.form-grid { display: grid; gap: 18px; }
.form-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-panel > .form-grid, .form-panel > label { margin: 6px 26px 0; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: 1 / -1; }
.notes-grid { align-items: stretch; }
.notes-grid label { height: 100%; }
.notes-grid textarea { min-height: 150px; flex: 1; }
label { display: flex; flex-direction: column; gap: 7px; color: var(--ink-soft); font-size: .72rem; font-weight: 720; }
input, select, textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: 8px; padding: 10px 11px; color: var(--ink); background: var(--surface-subtle); outline: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--red); box-shadow: 0 0 0 3px color-mix(in srgb, var(--red) 12%, transparent); }
textarea { resize: vertical; }
label small { color: var(--muted); font-size: .64rem; font-weight: 500; }
.date-flow { position: relative; }
.date-label { display: flex; align-items: center; gap: 8px; }
.date-label i { display: inline-grid; width: 20px; height: 20px; place-items: center; border-radius: 50%; color: #fff; background: var(--ink); font-size: .58rem; font-style: normal; }
.form-actions { display: flex; align-items: center; gap: 9px; padding-top: 4px; }
.form-spacer { flex: 1; }

.machine-files-panel { overflow: hidden; padding-bottom: 24px; }
.file-panel-header { align-items: flex-start; }
.file-panel-header p:last-child { margin: 4px 0 0; color: var(--muted); font-size: .72rem; }
.machine-file-drop { display: grid; min-height: 112px; grid-template-columns: auto 1fr auto; align-items: center; gap: 16px; margin: 4px 26px 22px; border: 1.5px dashed var(--line-strong); border-radius: 12px; padding: 20px; background: var(--surface-subtle); cursor: pointer; transition: border-color .18s ease, background .18s ease, transform .18s ease; }
.machine-file-drop:hover, .machine-file-drop:focus-visible, .machine-file-drop.is-dragover { border-color: var(--red); background: var(--red-soft); outline: 0; transform: translateY(-1px); }
.machine-file-drop-icon { display: grid; width: 48px; height: 48px; place-items: center; border-radius: 12px; color: #fff; background: var(--red); box-shadow: 0 8px 20px color-mix(in srgb, var(--red) 22%, transparent); font-size: 1.4rem; font-weight: 800; }
.machine-file-drop-copy { display: flex; min-width: 0; flex-direction: column; }
.machine-file-drop-copy strong { color: var(--ink); font-size: .84rem; }
.machine-file-drop-copy small { color: var(--muted); font-size: .68rem; font-weight: 560; }
.file-upload-notice { min-height: 0; margin: 0 26px; border-radius: 8px; color: var(--muted); font-size: .7rem; }
.file-upload-notice:not(:empty) { margin-bottom: 12px; padding: 9px 11px; background: var(--surface-subtle); }
.file-upload-notice.is-error { color: var(--red); background: var(--red-soft); }
.file-upload-notice.is-success { color: var(--green); background: var(--green-soft); }
.file-upload-queue { display: grid; gap: 8px; margin: 0 26px 14px; }
.file-upload-item { display: grid; grid-template-columns: minmax(0, 1fr) 70px; gap: 7px 14px; align-items: center; border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; background: var(--surface-subtle); }
.file-upload-item strong { overflow: hidden; color: var(--ink); font-size: .72rem; text-overflow: ellipsis; white-space: nowrap; }
.file-upload-item span { color: var(--muted); font-size: .65rem; text-align: right; }
.file-upload-progress { grid-column: 1 / -1; height: 5px; overflow: hidden; border-radius: 9px; background: var(--line); }
.file-upload-progress i { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--red); transition: width .15s ease; }
.file-upload-item.is-complete .file-upload-progress i { background: var(--green); }
.file-upload-item.is-error { border-color: color-mix(in srgb, var(--red) 45%, var(--line)); }
.file-upload-item.is-error span { color: var(--red); }
.machine-file-list { margin-top: 4px; border-top: 1px solid var(--line); }
.machine-file-empty { display: none; padding: 42px 24px 24px; color: var(--muted); text-align: center; }
.machine-file-list.is-empty .machine-file-empty { display: block; }
.machine-file-empty > span { display: grid; width: 48px; height: 48px; margin: 0 auto 11px; place-items: center; border-radius: 50%; color: var(--red); background: var(--red-soft); font-size: 1.35rem; }
.machine-file-empty strong { display: block; color: var(--ink); font-size: .8rem; }
.machine-file-empty p { margin: 3px 0 0; font-size: .69rem; }
.machine-file-card { display: grid; grid-template-columns: minmax(240px, 1.5fr) minmax(145px, .7fr) minmax(145px, .7fr) auto; align-items: center; gap: 18px; padding: 13px 26px; border-bottom: 1px solid var(--line); transition: background .15s ease, opacity .18s ease, transform .18s ease; }
.machine-file-card:last-child { border-bottom: 0; }
.machine-file-card:hover { background: var(--surface-subtle); }
.machine-file-card.is-removing { opacity: 0; transform: translateX(14px); }
.machine-file-open { display: grid; min-width: 0; grid-template-columns: 52px minmax(0, 1fr); align-items: center; gap: 12px; border: 0; padding: 0; color: inherit; background: transparent; cursor: pointer; text-align: left; }
.machine-file-thumb { display: grid; width: 52px; height: 52px; overflow: hidden; place-items: center; border-radius: 10px; color: var(--muted); background: var(--gray-soft); font-size: .58rem; font-weight: 900; letter-spacing: .04em; }
.machine-file-thumb--pdf { color: var(--red); background: var(--red-soft); }
.machine-file-thumb--video { color: var(--violet); background: var(--violet-soft); font-size: 1rem; }
.machine-file-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .2s ease; }
.machine-file-open:hover .machine-file-thumb img { transform: scale(1.05); }
.machine-file-name { display: flex; min-width: 0; flex-direction: column; }
.machine-file-name strong { overflow: hidden; color: var(--ink); font-size: .75rem; text-overflow: ellipsis; white-space: nowrap; }
.machine-file-name small { color: var(--muted); font-size: .62rem; font-weight: 560; }
.machine-file-meta { display: flex; min-width: 0; flex-direction: column; }
.machine-file-meta small { color: var(--muted); font-size: .58rem; font-weight: 650; }
.machine-file-meta strong { display: flex; min-width: 0; align-items: center; gap: 7px; overflow: hidden; color: var(--ink-soft); font-size: .68rem; text-overflow: ellipsis; white-space: nowrap; }
.machine-file-meta i { display: inline-grid; width: 23px; height: 23px; flex: 0 0 auto; place-items: center; border-radius: 50%; color: #fff; background: var(--ink); font-size: .55rem; font-style: normal; }
.machine-file-actions { display: flex; gap: 6px; }
.icon-action { display: inline-grid; width: 34px; height: 34px; place-items: center; border: 1px solid var(--line); border-radius: 8px; color: var(--ink-soft); background: var(--surface); cursor: pointer; font-size: .82rem; text-decoration: none; }
.icon-action:hover { border-color: var(--red); color: var(--red); background: var(--red-soft); }
.icon-action--danger { color: var(--red); }
.icon-action--danger:hover { border-color: var(--red); color: #fff; background: var(--red); }

.file-preview-dialog { width: min(1100px, calc(100vw - 36px)); max-width: none; height: min(820px, calc(100vh - 40px)); max-height: none; border: 1px solid var(--line); border-radius: 16px; padding: 0; color: var(--ink); background: var(--surface-raised); box-shadow: 0 30px 90px rgba(0, 0, 0, .35); }
.file-preview-dialog::backdrop { background: rgba(5, 6, 8, .72); backdrop-filter: blur(7px); }
.file-preview-shell { display: grid; height: 100%; grid-template-rows: auto minmax(0, 1fr) auto; }
.file-preview-header, .file-preview-footer { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 15px 18px; background: var(--surface); }
.file-preview-header { border-bottom: 1px solid var(--line); }
.file-preview-header > span { display: flex; min-width: 0; flex-direction: column; }
.file-preview-header small { color: var(--red); font-size: .56rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.file-preview-header strong { overflow: hidden; font-size: .82rem; text-overflow: ellipsis; white-space: nowrap; }
.file-preview-close { display: grid; width: 36px; height: 36px; flex: 0 0 auto; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--ink); background: var(--surface-subtle); cursor: pointer; font-size: 1.25rem; }
.file-preview-stage { display: grid; min-height: 0; overflow: auto; place-items: center; padding: 18px; background: #0d0e11; }
.file-preview-stage img, .file-preview-stage video { display: block; max-width: 100%; max-height: 100%; border-radius: 9px; box-shadow: 0 18px 55px rgba(0,0,0,.35); }
.file-preview-stage iframe { width: 100%; height: 100%; min-height: 520px; border: 0; border-radius: 9px; background: #fff; }
.file-preview-generic { display: flex; max-width: 430px; flex-direction: column; align-items: center; color: #d7d8dc; text-align: center; }
.file-preview-generic span { display: grid; width: 86px; height: 86px; margin-bottom: 18px; place-items: center; border-radius: 22px; color: #fff; background: #2a2c32; font-size: 1rem; font-weight: 850; }
.file-preview-generic strong { font-size: 1rem; }.file-preview-generic p { margin: 5px 0 0; color: #969aa3; font-size: .76rem; }
.file-preview-footer { border-top: 1px solid var(--line); }
.file-preview-footer > span { overflow: hidden; color: var(--muted); font-size: .68rem; text-overflow: ellipsis; white-space: nowrap; }

.file-delete-dialog { width: min(480px, calc(100vw - 32px)); max-width: none; border: 1px solid var(--line); border-radius: 16px; padding: 0; color: var(--ink); background: var(--surface-raised); box-shadow: 0 28px 80px rgba(0, 0, 0, .38); }
.file-delete-dialog::backdrop { background: rgba(5, 6, 8, .68); backdrop-filter: blur(6px); }
.file-delete-shell { display: grid; grid-template-columns: 46px minmax(0, 1fr); gap: 16px; padding: 24px; }
.file-delete-symbol { display: grid; width: 46px; height: 46px; place-items: center; border-radius: 50%; color: var(--red); background: var(--red-soft); font-size: 1.05rem; font-weight: 900; }
.file-delete-copy { min-width: 0; }
.file-delete-copy > small { color: var(--red); font-size: .57rem; font-weight: 850; letter-spacing: .12em; text-transform: uppercase; }
.file-delete-copy h3 { margin: 3px 0 7px; font-size: 1.08rem; }
.file-delete-copy p { margin: 0; color: var(--muted); font-size: .72rem; line-height: 1.55; }
.file-delete-copy p strong { color: var(--ink); overflow-wrap: anywhere; }
.file-delete-copy .file-delete-error { min-height: 0; margin-top: 0; color: var(--red); }
.file-delete-copy .file-delete-error:not(:empty) { margin-top: 10px; }
.file-delete-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 9px; padding-top: 6px; }
.file-delete-actions .button[disabled] { cursor: wait; opacity: .65; }

.alert { position: relative; margin-bottom: 20px; border: 1px solid var(--line); border-radius: 9px; padding: 12px 42px 12px 14px; color: var(--ink-soft); background: var(--surface); font-size: .78rem; box-shadow: var(--shadow); }
.alert--success { border-color: color-mix(in srgb, var(--green) 35%, var(--line)); color: var(--green); background: var(--green-soft); }
.alert--error { border-color: color-mix(in srgb, var(--red) 35%, var(--line)); color: var(--red); background: var(--red-soft); }
.alert button { position: absolute; top: 8px; right: 9px; border: 0; color: inherit; background: transparent; cursor: pointer; font-size: 1.1rem; }
.alert ul { margin: 6px 0 0; padding-left: 19px; }

.import-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, .7fr); gap: 20px; margin-bottom: 20px; }
.upload-panel, .instructions-panel { padding-bottom: 26px; }
.file-symbol { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 10px; color: var(--red); background: var(--red-soft); font-size: 1.1rem; }
.stack-form { display: flex; flex-direction: column; gap: 17px; }
.upload-panel .stack-form { margin: 4px 26px 0; }
.drop-zone { position: relative; display: flex; min-height: 160px; align-items: center; justify-content: center; gap: 5px; border: 1.5px dashed var(--line-strong); border-radius: 11px; background: var(--surface-subtle); cursor: pointer; text-align: center; }
.drop-zone:hover { border-color: var(--red); background: var(--red-soft); }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-zone strong { color: var(--ink); font-size: .82rem; }
.drop-zone small { color: var(--muted); }
.drop-icon { display: grid; width: 33px; height: 33px; margin-bottom: 4px; place-items: center; border-radius: 50%; color: #fff; background: var(--red); font-size: 1.1rem; }
.mode-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; border: 0; margin: 0; padding: 0; }
.mode-picker legend { margin-bottom: 8px; color: var(--ink-soft); font-size: .69rem; font-weight: 750; }
.mode-picker label { position: relative; display: block; }
.mode-picker input { position: absolute; opacity: 0; }
.mode-picker label span { display: flex; height: 100%; flex-direction: column; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.mode-picker input:checked + span { border-color: var(--red); background: var(--red-soft); box-shadow: inset 3px 0 var(--red); }
.mode-picker strong { color: var(--ink); font-size: .73rem; }
.mode-picker small { color: var(--muted); font-size: .61rem; font-weight: 500; }
.instructions-panel { padding: 26px; }
.column-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; margin: 22px 0; padding: 0; list-style: none; }
.column-list li { display: flex; align-items: center; gap: 9px; color: var(--ink-soft); font-size: .74rem; font-weight: 680; }
.column-list span { display: grid; width: 21px; height: 21px; place-items: center; border-radius: 50%; color: var(--red); background: var(--red-soft); font-size: .59rem; }
.tip { margin-top: 22px; padding: 14px; border-left: 3px solid var(--red); border-radius: 5px; background: var(--surface-subtle); }
.tip strong { font-size: .7rem; }
.tip p { margin: 3px 0 0; color: var(--muted); font-size: .67rem; }
.history-panel { overflow: hidden; }
.metric { display: inline-flex; border-radius: 5px; padding: 2px 5px; font-weight: 800; }.metric--green { color: var(--green); background: var(--green-soft); }

.person-cell { display: flex; align-items: center; gap: 10px; }
.person-cell > span:last-child { display: flex; flex-direction: column; }
.person-cell small { color: var(--muted); font-size: .65rem; }
.role { border-radius: 5px; padding: 4px 7px; color: var(--ink-soft); background: var(--gray-soft); font-size: .64rem; font-weight: 750; }
.role--superuser { color: var(--red); background: var(--red-soft); }.role--admin { color: var(--violet); background: var(--violet-soft); }.role--manager { color: var(--blue); background: var(--blue-soft); }
.active-state { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: .68rem; }
.active-state i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }.active-state.is-active { color: var(--green); }.active-state.is-active i { background: var(--green); }
.role-explainer { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 18px; }
.role-explainer div { padding: 15px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.role-explainer strong { font-size: .7rem; }.role-explainer p { margin: 4px 0 0; color: var(--muted); font-size: .64rem; }
.toggle-label { flex-direction: row; align-items: center; align-self: end; min-height: 42px; }
.toggle-label input { position: absolute; opacity: 0; }
.toggle { position: relative; width: 40px; height: 23px; flex: 0 0 auto; border-radius: 20px; background: var(--line-strong); transition: .2s; }
.toggle::after { position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); content: ""; transition: .2s; }
.toggle-label input:checked + .toggle { background: var(--green); }.toggle-label input:checked + .toggle::after { transform: translateX(17px); }
.toggle-label > span:last-child { display: flex; flex-direction: column; }.toggle-label strong { color: var(--ink); font-size: .71rem; }.toggle-label small { color: var(--muted); font-size: .61rem; }
.action-tag { border-radius: 4px; padding: 3px 6px; color: var(--blue); background: var(--blue-soft); font-size: .63rem; font-weight: 750; }
.error-page { max-width: 660px; margin: 10vh auto; padding: 50px; text-align: center; }.error-code { display: block; color: var(--line-strong); font-size: 5rem; font-weight: 900; letter-spacing: -.08em; line-height: 1; }.error-page p:not(.eyebrow) { color: var(--muted); }

.auth-page { overflow-x: hidden; background: var(--surface); }
.auth-main { display: grid; min-height: 100vh; grid-template-columns: minmax(420px, 1fr) minmax(470px, .9fr); }
.auth-brand { position: relative; display: flex; min-height: 100vh; flex-direction: column; justify-content: center; overflow: hidden; padding: 9vw; color: #fff; background: #151619; }
.auth-brand::before { position: absolute; right: -12vw; bottom: -20vw; width: 45vw; height: 45vw; border: 8vw solid rgba(180, 0, 24, .15); border-radius: 50%; content: ""; }
.auth-brand::after { position: absolute; top: -18vw; left: -18vw; width: 36vw; height: 36vw; border: 1px solid rgba(255,255,255,.08); border-radius: 50%; content: ""; }
.auth-brand > * { position: relative; z-index: 1; }
.auth-brand .brand-mark { margin-bottom: 56px; }
.auth-brand .eyebrow { color: #e4707f; }
.auth-brand h1 { max-width: 660px; margin-bottom: 24px; font-size: clamp(3rem, 5.5vw, 5.5rem); letter-spacing: -.06em; }
.auth-brand h1 span { color: #e31835; }
.auth-intro { max-width: 540px; margin-bottom: 45px; color: #aeb0b6; font-size: 1rem; }
.auth-feature { display: grid; max-width: 430px; grid-template-columns: 34px 1fr; gap: 13px; margin-top: 13px; }
.auth-feature > span { padding-top: 2px; color: #e31835; font-size: .64rem; font-weight: 800; }
.auth-feature p { display: flex; flex-direction: column; margin: 0; color: #888b93; font-size: .73rem; }.auth-feature strong { color: #f4f4f2; font-size: .79rem; }
.auth-panel { display: grid; min-height: 100vh; place-items: center; padding: 60px 7vw; background: var(--surface); }
.auth-card { width: min(100%, 410px); }
.auth-card--wide { width: min(100%, 570px); }
.auth-card h2 { margin-bottom: 9px; font-size: 2rem; letter-spacing: -.04em; }
.auth-card > .muted { margin-bottom: 30px; }
.auth-card .stack-form { gap: 18px; }
.auth-card input { min-height: 44px; }
.form-note { margin: 25px 0 0; color: var(--muted); font-size: .65rem; text-align: center; }
.theme-toggle--floating { position: fixed; top: 22px; right: 24px; z-index: 10; width: auto; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); background: var(--surface); box-shadow: var(--shadow); }
.theme-toggle--floating:hover { color: var(--ink); }

@media (max-width: 1180px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .filter-bar { flex-wrap: wrap; }.search-field { flex-basis: 100%; }
    .role-explainer { grid-template-columns: repeat(2, 1fr); }
    .auth-brand { padding: 7vw; }.auth-brand h1 { font-size: clamp(3rem, 6vw, 4.5rem); }
    .machine-file-card { grid-template-columns: minmax(240px, 1fr) minmax(150px, .6fr) auto; }.machine-file-card .machine-file-meta:nth-of-type(2) { display: none; }
}

@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); transition: transform .22s ease; }
    .menu-open .sidebar { transform: translateX(0); }
    .sidebar-scrim { position: fixed; inset: 0; z-index: 25; border: 0; background: rgba(0,0,0,.45); }
    .menu-open .sidebar-scrim { display: block; }
    .main-column { width: 100%; margin-left: 0; }
    .menu-button { display: block; }
    .topbar { padding: 0 24px; }
    .main-content { padding: 36px 24px 54px; }
    .dashboard-grid, .import-grid { grid-template-columns: 1fr; }
    .auth-main { grid-template-columns: 1fr; }
    .auth-brand { display: none; }
    .auth-panel { padding: 70px 24px 40px; }
    .file-preview-dialog { height: calc(100vh - 28px); }
}

@media (max-width: 690px) {
    body { font-size: 14px; }
    .topbar { height: 64px; }.topbar-title .eyebrow { display: none; }.quick-search { width: auto; border: 0; background: transparent; }.quick-search span:nth-child(2), .quick-search kbd { display: none; }
    .main-content { padding: 28px 15px 45px; }
    .page-heading { align-items: stretch; flex-direction: column; }.page-heading h1 { font-size: 2.35rem; }.heading-actions { width: 100%; }.heading-actions .button { flex: 1; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }.stat-card { min-height: 145px; padding: 17px; }.stat-value { font-size: 2rem; }.stat-card small { display: none; }
    .compact-row { grid-template-columns: 50px 1fr auto; }.compact-row .status { display: none; }
    .filter-bar { align-items: stretch; flex-direction: column; }.search-field { min-width: 0; }.select-label select { width: 100%; }.filter-bar .button { width: 100%; }
    .inventory-panel { border-right: 0; border-left: 0; border-radius: 0; margin-right: -15px; margin-left: -15px; }
    .inventory-panel .data-table thead { display: none; }.inventory-panel .data-table, .inventory-panel .data-table tbody, .inventory-panel .data-table tr, .inventory-panel .data-table td { display: block; width: 100%; }
    .inventory-panel .data-table tr { display: grid; grid-template-columns: 70px 1fr; padding: 13px 16px; border-bottom: 1px solid var(--line); }
    .inventory-panel .data-table td { display: grid; grid-template-columns: 74px minmax(0, 1fr); column-gap: 8px; border: 0; padding: 5px 0; }.inventory-panel .data-table td::before { color: var(--muted); font-size: .61rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; content: attr(data-label); }
    .inventory-panel .data-table td:first-child { grid-column: 1; grid-row: 1 / span 2; display: flex; flex-direction: column; gap: 3px; padding-right: 10px; }.inventory-panel .data-table td:nth-child(2) { grid-column: 2; grid-row: 1; display: flex; flex-direction: column; gap: 3px; }.inventory-panel .data-table td:nth-child(n+3) { grid-column: 1 / -1; }
    .inventory-panel .data-table .actions-cell { text-align: left !important; }
    .info-cell { max-width: 100%; white-space: normal; }
    .form-grid--2, .form-grid--3 { grid-template-columns: 1fr; }.span-2, .span-3 { grid-column: auto; }.form-panel > .form-grid, .form-panel > label { margin-right: 18px; margin-left: 18px; }.panel-header { padding-right: 18px; padding-left: 18px; }
    .form-actions { flex-wrap: wrap; }.form-actions .form-spacer { display: none; }.form-actions .button { flex: 1; }.form-actions .button--danger { flex-basis: 100%; order: 3; }
    .machine-file-drop { grid-template-columns: 44px 1fr; margin-right: 18px; margin-left: 18px; padding: 16px; }.machine-file-drop .button { grid-column: 1 / -1; width: 100%; }.machine-file-drop-icon { width: 44px; height: 44px; }.file-upload-notice, .file-upload-queue { margin-right: 18px; margin-left: 18px; }
    .machine-file-card { grid-template-columns: 1fr auto; gap: 10px; padding: 14px 18px; }.machine-file-open { grid-column: 1 / -1; }.machine-file-card .machine-file-meta { display: flex !important; }.machine-file-card .machine-file-meta:nth-of-type(2) { grid-column: 1; }.machine-file-actions { grid-column: 2; grid-row: 2 / span 2; }
    .file-preview-dialog { width: calc(100vw - 16px); height: calc(100vh - 16px); border-radius: 12px; }.file-preview-header, .file-preview-footer { padding: 12px; }.file-preview-stage { padding: 8px; }.file-preview-stage iframe { min-height: 420px; }.file-preview-footer > span { display: none; }
    .file-delete-shell { grid-template-columns: 40px minmax(0, 1fr); gap: 13px; padding: 20px; }.file-delete-symbol { width: 40px; height: 40px; }.file-delete-actions { flex-direction: column-reverse; }.file-delete-actions .button { width: 100%; }
    .mode-picker { grid-template-columns: 1fr; }
    .role-explainer { grid-template-columns: 1fr; }
    .auth-panel { align-items: start; }.auth-card h2 { font-size: 1.7rem; }
}

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