:root {
    color-scheme: light;
    --bg: #f3f6f6;
    --surface: #ffffff;
    --surface-soft: #f7f9f9;
    --surface-ivory: #fbf4e9;
    --text: #172126;
    --muted: #667278;
    --border: #dbe3e4;
    --brand: #176b73;
    --brand-strong: #10545b;
    --brand-soft: #dff0f0;
    --blue: #2f6f98;
    --green: #25875b;
    --orange: #d47a24;
    --danger: #bd3c43;
    --shadow: 0 10px 30px rgba(25, 46, 52, 0.08);
    --radius: 8px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #111719;
    --surface: #192124;
    --surface-soft: #202a2d;
    --surface-ivory: #29261f;
    --text: #f2f5f4;
    --muted: #9caaad;
    --border: #303c40;
    --brand: #38b6b4;
    --brand-strong: #64cfcc;
    --brand-soft: #173a3d;
    --blue: #6aa8d1;
    --green: #55bb82;
    --orange: #efa257;
    --danger: #ef747a;
    --shadow: 0 14px 38px rgba(0, 0, 0, 0.24);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
svg { width: 19px; height: 19px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 204px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 22px 14px 16px; z-index: 20; }
.brand-wrap { min-height: 68px; display: flex; align-items: center; padding: 0 10px 18px; }
.brand-logo { display: block; width: 122px; height: 46px; object-fit: contain; object-position: left center; mix-blend-mode: multiply; }
:root[data-theme="dark"] .brand-logo { background: #f8f0e4; border-radius: 6px; padding: 4px 8px; mix-blend-mode: normal; }
.primary-nav { display: grid; gap: 5px; }
.nav-item { width: 100%; min-height: 44px; border: 0; border-radius: 6px; background: transparent; display: flex; align-items: center; gap: 12px; padding: 0 12px; cursor: pointer; text-align: left; }
.nav-item:hover { background: var(--surface-soft); }
.nav-item.active { background: var(--brand-soft); color: var(--brand-strong); font-weight: 700; box-shadow: inset 3px 0 var(--brand); }
.sidebar-footer { margin-top: auto; border-top: 1px solid var(--border); padding: 16px 10px 0; display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); }
.sidebar-footer a { color: var(--brand); text-decoration: none; font-weight: 700; }

.main-shell { min-width: 0; }
.topbar { min-height: 70px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 12px 30px; position: sticky; top: 0; z-index: 10; }
.search-box { width: min(500px, 60vw); height: 42px; display: flex; align-items: center; gap: 10px; padding: 0 13px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-soft); color: var(--muted); }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.icon-button { width: 40px; height: 40px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); display: inline-grid; place-items: center; cursor: pointer; }
.icon-button:hover { color: var(--brand); border-color: var(--brand); }
.icon-button.small { width: 34px; height: 34px; border: 0; background: transparent; }
.account-avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-strong); display: grid; place-items: center; font-weight: 800; }

.view { display: none; padding: 30px; max-width: 1400px; margin: 0 auto; }
.view.active { display: block; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.eyebrow { margin: 0 0 5px; color: var(--brand); font-size: 12px; line-height: 1.2; font-weight: 800; text-transform: uppercase; }
h1, h2, h3, p { letter-spacing: 0; }
h1 { margin: 0; font-size: 30px; line-height: 1.15; }
h2 { margin: 0; font-size: 18px; }
h3 { margin: 0; font-size: 17px; }

.button { min-height: 40px; border: 1px solid transparent; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; padding: 0 16px; font-weight: 750; cursor: pointer; }
.button.primary { color: white; background: var(--brand); }
.button.primary:hover { background: var(--brand-strong); }
.button.full { width: 100%; }
.text-button { border: 0; padding: 5px; background: transparent; color: var(--brand); font-weight: 750; cursor: pointer; }

.metric-grid { display: grid; gap: 14px; }
.metric-grid.compact { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric-grid.financial { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 14px; }
.metric { min-height: 105px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; display: flex; align-items: center; gap: 14px; box-shadow: 0 1px 0 rgba(12, 35, 39, 0.02); }
.metric.money { min-height: 114px; }
.metric small { display: block; color: var(--muted); margin-bottom: 5px; }
.metric strong { display: block; font-size: 25px; line-height: 1.1; }
.metric-icon { flex: 0 0 42px; width: 42px; height: 42px; border-radius: 6px; display: grid; place-items: center; }
.metric-icon.teal { background: var(--brand-soft); color: var(--brand); }
.metric-icon.blue { background: color-mix(in srgb, var(--blue) 13%, transparent); color: var(--blue); }
.metric-icon.green { background: color-mix(in srgb, var(--green) 13%, transparent); color: var(--green); }
.metric-icon.orange { background: color-mix(in srgb, var(--orange) 14%, transparent); color: var(--orange); }

.data-section { margin-top: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.section-heading { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 0 18px; border-bottom: 1px solid var(--border); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th { height: 44px; background: var(--surface-soft); color: var(--muted); font-size: 12px; text-transform: uppercase; text-align: left; padding: 0 16px; }
td { height: 62px; border-top: 1px solid var(--border); padding: 8px 16px; }
td small { display: block; color: var(--muted); margin-top: 3px; }
.status { display: inline-flex; align-items: center; min-height: 27px; border-radius: 999px; padding: 0 10px; font-size: 12px; font-weight: 800; }
.status-orcamento { color: var(--muted); background: var(--surface-soft); }
.status-aceite, .status-em_producao { color: var(--blue); background: color-mix(in srgb, var(--blue) 12%, transparent); }
.status-pronto, .status-entregue { color: var(--green); background: color-mix(in srgb, var(--green) 12%, transparent); }
.status-cancelado { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }

.empty-state { min-height: 310px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 40px 20px; }
.empty-state p { max-width: 460px; margin: 8px 0 20px; color: var(--muted); }
.empty-icon { width: 54px; height: 54px; border-radius: 8px; display: grid; place-items: center; color: var(--brand); background: var(--brand-soft); margin-bottom: 15px; }
.empty-icon svg { width: 26px; height: 26px; }
.placeholder-view .empty-state { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }

.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(135deg, var(--bg), var(--surface-ivory)); }
.auth-shell { width: min(440px, 100%); }
.auth-panel { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); padding: 30px; }
.auth-logo { width: 88px; height: 88px; object-fit: contain; border-radius: 50%; margin-bottom: 18px; }
.auth-panel h1 { margin-bottom: 8px; }
.auth-copy { color: var(--muted); line-height: 1.55; margin: 0 0 22px; }
.auth-remember { display: flex !important; grid-template-columns: none; align-items: center; gap: 9px !important; min-height: 38px; color: var(--text) !important; font-weight: 600 !important; cursor: pointer; }
.auth-remember input { width: 17px; height: 17px; min-height: 0; accent-color: var(--brand); }
.form-stack { display: grid; gap: 15px; }
.form-stack label { display: grid; gap: 7px; font-size: 13px; font-weight: 700; }
input, select, textarea { min-height: 42px; border: 1px solid var(--border); border-radius: 6px; padding: 9px 11px; background: var(--surface); color: var(--text); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.form-message { border-radius: 6px; padding: 11px 13px; font-size: 14px; }
.form-message.error { color: var(--danger); background: color-mix(in srgb, var(--danger) 11%, transparent); }
.toast { position: fixed; right: 24px; bottom: 24px; max-width: 360px; padding: 13px 16px; border-radius: 6px; background: var(--text); color: var(--surface); box-shadow: var(--shadow); z-index: 100; }

.toolbar { min-height: 64px; display: flex; align-items: end; gap: 12px; padding: 10px 12px; margin-bottom: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.toolbar > label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 700; }
.toolbar select { min-width: 150px; }
.filter-search { flex: 1; min-width: 230px; position: relative; }
.filter-search svg { position: absolute; left: 12px; bottom: 12px; width: 17px; height: 17px; }
.filter-search input { width: 100%; padding-left: 38px; }
.orders-section { margin-top: 0; }
.loading-area { min-height: 180px; display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); }
.loader { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--brand); border-radius: 50%; animation: spin 0.75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.segmented { display: inline-flex; gap: 3px; padding: 3px; margin-bottom: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 7px; }
.segmented button { min-height: 36px; border: 0; border-radius: 5px; padding: 0 15px; background: transparent; cursor: pointer; }
.segmented button.active { background: var(--brand); color: white; font-weight: 750; }
.production-list { display: grid; gap: 10px; }
.production-row { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 15px 16px; display: grid; grid-template-columns: minmax(180px, 1.2fr) minmax(160px, 1fr) minmax(150px, .9fr) auto; align-items: center; gap: 18px; cursor: pointer; }
.production-row:hover { border-color: var(--brand); }
.production-row strong, .production-row small { display: block; }
.production-row small { margin-top: 4px; color: var(--muted); }
.progress-track { width: 100%; height: 7px; overflow: hidden; border-radius: 999px; background: var(--surface-soft); }
.progress-track span { display: block; height: 100%; background: var(--brand); }

.split-layout { display: grid; grid-template-columns: minmax(300px, .8fr) minmax(450px, 1.3fr); gap: 16px; align-items: start; }
.form-panel, .settings-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.data-section.no-margin { margin-top: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.form-grid.padded, .padded { padding: 18px; }
.form-grid label, .settings-grid label, .compact-grid label { min-width: 0; display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 750; }
.form-grid input, .form-grid select, .form-grid textarea, .settings-grid input, .settings-grid select { width: 100%; }
.span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; margin-top: 4px; }
.expense-row { display: grid; grid-template-columns: 110px minmax(180px, 1fr) 110px 110px 40px; align-items: center; gap: 12px; min-height: 56px; padding: 8px 16px; border-top: 1px solid var(--border); }
.expense-row:first-child { border-top: 0; }
.expense-row small { color: var(--muted); }
.expense-row > div { min-width: 0; }
.expense-row > div strong { display: block; overflow-wrap: anywhere; }
.expense-row > div small { display: block; margin-top: 3px; overflow-wrap: anywhere; }
.expense-row > strong { text-align: right; }

.info-banner { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 16px; padding: 12px 14px; border: 1px solid color-mix(in srgb, var(--blue) 28%, var(--border)); border-radius: 6px; background: color-mix(in srgb, var(--blue) 7%, var(--surface)); color: var(--muted); font-size: 13px; line-height: 1.45; }
.info-banner svg { flex: 0 0 auto; color: var(--blue); }
.settings-section { margin-bottom: 16px; overflow: hidden; }
.settings-section .section-heading > div p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.settings-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.input-unit { min-height: 42px; display: flex; align-items: stretch; }
.input-unit input { min-width: 0; border-radius: 6px 0 0 6px; }
.input-unit span { min-width: 54px; display: grid; place-items: center; padding: 0 9px; border: 1px solid var(--border); border-left: 0; border-radius: 0 6px 6px 0; background: var(--surface-soft); color: var(--muted); font-size: 12px; white-space: nowrap; }
.toggle-label { align-content: end; }
.toggle-row { min-height: 42px; display: flex; align-items: center; gap: 9px; padding: 0 11px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-soft); color: var(--text); font-size: 13px; }
.toggle-row input { width: 17px; height: 17px; min-height: 0; accent-color: var(--brand); }
.panel-actions { display: flex; justify-content: flex-end; padding: 0 18px 18px; }
.settings-columns { display: grid; grid-template-columns: 1.15fr .85fr; gap: 16px; align-items: start; }
.settings-list { display: grid; }
.settings-row { min-height: 66px; display: grid; grid-template-columns: minmax(140px, 1fr) minmax(90px, .6fr) minmax(80px, .45fr) 74px; align-items: center; gap: 12px; padding: 9px 16px; border-top: 1px solid var(--border); }
.settings-row:first-child { border-top: 0; }
.settings-row small { display: block; color: var(--muted); margin-top: 3px; }
.settings-row-actions { display: flex; justify-content: flex-end; gap: 2px; }
.settings-row.machine { grid-template-columns: minmax(140px, 1fr) minmax(100px, .7fr) 74px; }
.import-settings .section-heading { align-items: center; }
.import-history-row { min-height: 64px; display: grid; grid-template-columns: minmax(180px, 1fr) auto auto; align-items: center; gap: 14px; padding: 9px 16px; border-top: 1px solid var(--border); }
.import-history-row:first-child { border-top: 0; }
.import-history-row div { min-width: 0; }
.import-history-row strong, .import-history-row small { display: block; overflow-wrap: anywhere; }
.import-history-row small, .import-history-row > span { margin-top: 3px; color: var(--muted); font-size: 12px; }

.app-dialog { width: min(1180px, calc(100vw - 30px)); max-height: calc(100vh - 30px); padding: 0; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); box-shadow: 0 30px 90px rgba(0, 0, 0, .28); }
.app-dialog::backdrop { background: rgba(10, 20, 23, .52); backdrop-filter: blur(2px); }
.dialog-shell { max-height: calc(100vh - 32px); display: flex; flex-direction: column; margin: 0; }
.dialog-header { flex: 0 0 auto; min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.dialog-header h2 { font-size: 21px; }
.dialog-body { overflow-y: auto; }
.dialog-footer { flex: 0 0 auto; min-height: 70px; display: flex; justify-content: flex-end; align-items: center; gap: 10px; padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface); }
.order-form-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; align-items: start; }
.order-form-main { padding: 18px; display: grid; gap: 15px; }
.form-section { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.form-section-title { min-height: 50px; display: flex; align-items: center; gap: 9px; padding: 8px 14px; border-bottom: 1px solid var(--border); background: var(--surface-soft); }
.form-section-title > span, .form-section-title > div > span { width: 25px; height: 25px; display: inline-grid; place-items: center; border-radius: 50%; background: var(--brand); color: white; font-size: 12px; font-weight: 800; }
.form-section-title.with-action { justify-content: space-between; }
.form-section-title.with-action > div { display: flex; align-items: center; gap: 9px; }
.button.secondary { border-color: var(--border); background: var(--surface); color: var(--text); }
.button.secondary:hover { border-color: var(--brand); color: var(--brand); }
.button.danger { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); background: var(--surface); color: var(--danger); }
.button.danger:hover { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 7%, var(--surface)); }
.template-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.template-toolbar select { min-width: 190px; flex: 1; }
.order-preview { position: sticky; top: 0; min-height: 100%; padding: 22px 20px; border-left: 1px solid var(--border); background: var(--surface-soft); }
.order-preview h3 { margin-bottom: 18px; }
.order-preview dl { margin: 0; }
.order-preview dl div { min-height: 38px; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--border); }
.order-preview dt { color: var(--muted); font-size: 13px; }
.order-preview dd { margin: 0; font-weight: 750; }
.order-preview .preview-total { margin-top: 8px; border-top: 1px solid var(--text); }
.order-preview .preview-total dt, .order-preview .preview-total dd { color: var(--text); font-weight: 850; }
.order-preview .preview-profit dt, .order-preview .preview-profit dd { color: var(--green); font-weight: 850; }
.helper { color: var(--muted); font-size: 12px; line-height: 1.55; }
.advanced-values { margin: 0 18px 18px; border: 1px solid var(--border); border-radius: 6px; }
.advanced-values summary { min-height: 44px; display: flex; align-items: center; padding: 0 13px; cursor: pointer; color: var(--brand); font-weight: 750; font-size: 13px; }
.details-grid { border-top: 1px solid var(--border); }
.order-items { padding: 14px; display: grid; gap: 12px; }
.order-item-card { border: 1px solid var(--border); border-radius: 7px; overflow: hidden; }
.order-item-card > header, .operation-card > header, .operations-header { min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 12px; background: var(--surface-soft); border-bottom: 1px solid var(--border); }
.compact-grid { padding: 13px; }
.operations-wrap { border-top: 1px solid var(--border); }
.operations-header { background: var(--surface); border-bottom: 0; }
.operations-list { display: grid; gap: 10px; padding: 0 12px 12px; }
.operation-card { border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.operation-title { display: flex; align-items: center; gap: 8px; font-weight: 750; }
.operation-fields { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.steps-fieldset { margin: 0 13px 13px; padding: 11px 12px; border: 1px solid var(--border); border-radius: 6px; }
.steps-fieldset legend { padding: 0 6px; color: var(--muted); font-size: 12px; font-weight: 750; }
.steps-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.steps-grid label { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.steps-grid input { min-height: 0; width: 16px; height: 16px; accent-color: var(--brand); }
.side-dialog-shell { width: min(620px, 100%); margin-left: auto; }
.order-detail-dialog { width: min(620px, calc(100vw - 20px)); margin-right: 0; height: 100vh; max-height: 100vh; border-radius: 8px 0 0 8px; }
.order-detail-dialog .dialog-shell { max-height: 100vh; height: 100vh; }
.small-dialog { width: min(540px, calc(100vw - 30px)); }
.import-dialog { width: min(1060px, calc(100vw - 30px)); }
.import-preview { padding: 18px; background: var(--surface-soft); }
.import-preview-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.import-preview-heading strong, .import-preview-heading small { display: block; }
.import-preview-heading small { color: var(--muted); }
.import-group { margin-top: 18px; }
.import-group > h3 { margin-bottom: 9px; font-size: 15px; }
.import-order-list, .import-expense-list { display: grid; gap: 10px; }
.import-row, .import-expense-row { border: 1px solid var(--border); border-radius: 7px; background: var(--surface); overflow: hidden; }
.import-row > header { min-height: 45px; display: grid; grid-template-columns: 110px minmax(0, 1fr); align-items: center; gap: 12px; padding: 7px 12px; border-bottom: 1px solid var(--border); background: var(--surface-soft); }
.import-row > header strong { min-width: 0; overflow-wrap: anywhere; }
.import-check { display: flex !important; align-items: center; gap: 7px !important; color: var(--text) !important; cursor: pointer; }
.import-check input { width: 17px !important; height: 17px; min-height: 0; accent-color: var(--brand); }
.import-core-grid, .import-cost-grid, .import-steps-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 11px; padding: 12px; }
.import-core-grid label, .import-cost-grid label, .import-steps-grid label, .import-expense-row > label:not(.import-check) { min-width: 0; display: grid; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 750; }
.import-core-grid input, .import-core-grid select, .import-cost-grid input, .import-steps-grid select, .import-expense-row input { width: 100%; }
.import-details { border-top: 1px solid var(--border); }
.import-details summary { min-height: 40px; display: flex; align-items: center; padding: 0 12px; color: var(--brand); font-size: 12px; font-weight: 750; cursor: pointer; }
.import-cost-grid { padding-top: 2px; }
.import-steps-grid { border-top: 1px solid var(--border); }
.import-expense-row { display: grid; grid-template-columns: 100px minmax(220px, 1fr) 130px 160px; align-items: end; gap: 11px; padding: 12px; }
.import-selection { margin-right: auto; color: var(--muted); font-size: 13px; }

.detail-content { padding: 18px; display: grid; gap: 15px; }
.detail-summary { display: flex; justify-content: space-between; gap: 18px; }
.detail-summary p { margin: 4px 0 0; color: var(--muted); }
.detail-section { border-top: 1px solid var(--border); padding-top: 15px; }
.detail-section h3 { margin-bottom: 10px; }
.detail-item { margin-bottom: 12px; padding: 13px; border: 1px solid var(--border); border-radius: 6px; }
.detail-item > header { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.detail-item > header div { min-width: 0; }
.detail-item > header div strong, .detail-item > header div small { display: block; }
.detail-item > header div strong { overflow-wrap: anywhere; }
.detail-item > header div small { margin-top: 3px; color: var(--muted); }
.detail-operation { padding: 11px 0; border-top: 1px solid var(--border); }
.detail-operation:first-of-type { border-top: 0; }
.operation-meta { display: flex; flex-wrap: wrap; gap: 7px 14px; margin-top: 5px; color: var(--muted); font-size: 12px; }
.steps-list { display: grid; gap: 7px; margin-top: 10px; }
.step-row { display: grid; grid-template-columns: minmax(110px, 1fr) 145px; align-items: center; gap: 10px; }
.step-row select { min-height: 36px; }
.cost-list { margin: 0; }
.cost-list div { min-height: 34px; display: flex; justify-content: space-between; gap: 14px; align-items: center; border-bottom: 1px solid var(--border); }
.cost-list dt { color: var(--muted); }
.cost-list dd { margin: 0; font-weight: 750; }
.cost-list .total-row { margin-top: 7px; border-top: 1px solid var(--text); color: var(--text); font-weight: 850; }
.cost-list .profit-row { color: var(--green); font-weight: 850; }
.detail-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.detail-actions .button { flex: 1 1 auto; }
.detail-section details > summary { cursor: pointer; color: var(--brand); font-weight: 750; margin-bottom: 12px; }
.actual-operations { display: grid; gap: 10px; margin-bottom: 12px; }
.actual-operation { border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.actual-operation > header { min-height: 42px; display: flex; justify-content: space-between; gap: 12px; padding: 8px 11px; background: var(--surface-soft); }
.actual-operation > header span { color: var(--muted); font-size: 12px; white-space: nowrap; }
.actual-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 11px; }
.actual-grid label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 750; }
.attachment-row { display: grid; grid-template-columns: minmax(0, 1fr) repeat(3, 34px); align-items: center; gap: 5px; min-height: 48px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.attachment-row small { display: block; color: var(--muted); margin-top: 3px; }
.attachment-row > div { min-width: 0; overflow-wrap: anywhere; }
.upload-label { cursor: pointer; }
.upload-label input { display: none; }
.empty-inline { color: var(--muted); font-size: 13px; padding: 10px 0; }
.history-list { display: grid; }
.history-list > div { display: grid; gap: 3px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.history-list small, .muted-copy { color: var(--muted); }

.orders-mobile, .customers-mobile { display: none; }
.customer-card, .customer-order-row { width: 100%; border: 0; border-top: 1px solid var(--border); background: var(--surface); color: var(--text); text-align: left; cursor: pointer; }
.customer-order-row { min-height: 58px; display: grid; grid-template-columns: minmax(0, 1fr) auto 22px; align-items: center; gap: 10px; padding: 8px 16px; }
.customer-card span, .customer-order-row span { min-width: 0; }
.customer-card strong, .customer-card small, .customer-order-row strong, .customer-order-row small { display: block; }
.customer-card small, .customer-order-row small { margin-top: 3px; color: var(--muted); overflow-wrap: anywhere; }
.customer-detail-form { border-bottom: 1px solid var(--border); }
.customer-history .section-heading { border-top: 0; }

.reports-section { overflow: visible; }
.report-filters { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; }
.report-filters label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 750; }
.report-metric { box-shadow: none; }
.report-machines { border-top: 1px solid var(--border); }
.report-machine-row { min-height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 18px; border-top: 1px solid var(--border); }
.report-machine-row:first-of-type { border-top: 0; }
.report-machine-row span strong, .report-machine-row span small { display: block; }
.report-machine-row span small { margin-top: 3px; color: var(--muted); }
.settings-row.template-row { grid-template-columns: minmax(0, 1fr) 44px; }
.form-stack { display: grid; gap: 13px; }
.form-stack label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 750; }
.form-stack label small { color: var(--muted); font-weight: 500; line-height: 1.4; }
.account-subsection { border-top: 1px solid var(--border); }
.session-actions { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.session-actions strong, .session-actions small { display: block; }
.session-actions small { margin-top: 4px; color: var(--muted); }
[hidden] { display: none !important; }

@media (max-width: 1100px) {
    .settings-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .settings-columns { grid-template-columns: 1fr; }
    .order-form-layout { grid-template-columns: 1fr; }
    .order-preview { position: static; min-height: auto; border-left: 0; border-top: 1px solid var(--border); }
}

@media (max-width: 980px) {
    .metric-grid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .metric-grid.financial { grid-template-columns: 1fr; }
    .split-layout { grid-template-columns: 1fr; }
    .settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
    .app-shell { display: block; padding-bottom: 72px; }
    .sidebar { position: fixed; left: 0; right: 0; bottom: 0; top: auto; height: 68px; border: 0; border-top: 1px solid var(--border); padding: 5px 8px calc(5px + env(safe-area-inset-bottom)); }
    .brand-wrap, .sidebar-footer { display: none; }
    .primary-nav { display: grid; grid-template-columns: repeat(6, 1fr); gap: 1px; }
    .nav-item { min-width: 0; min-height: 56px; flex-direction: column; justify-content: center; gap: 3px; padding: 3px 1px; font-size: 9px; }
    .nav-item svg { width: 17px; height: 17px; }
    .nav-item.active { box-shadow: inset 0 3px var(--brand); }
    .topbar { min-height: 62px; padding: 10px 16px; }
    .search-box { width: auto; flex: 1; }
    .account-avatar { display: none; }
    .view { padding: 22px 16px; }
    .page-heading { align-items: flex-start; }
    .page-heading .button { width: 42px; padding: 0; font-size: 0; }
    .page-heading .button svg { width: 20px; height: 20px; }
    h1 { font-size: 26px; }
    .metric-grid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .metric { min-height: 90px; padding: 13px; gap: 10px; }
    .metric-icon { width: 36px; height: 36px; flex-basis: 36px; }
    .metric strong { font-size: 21px; }
    .metric-grid.financial { gap: 10px; }
    .metric.money { min-height: 90px; }
    .data-section { margin-top: 14px; }
    .toast { left: 16px; right: 16px; bottom: 84px; }
    .toolbar { align-items: stretch; flex-direction: column; }
    .toolbar select { width: 100%; }
    .filter-search { min-width: 0; }
    .production-row { grid-template-columns: 1fr auto; gap: 10px; }
    .production-row .progress-cell { grid-column: 1 / -1; }
    .expense-row { grid-template-columns: minmax(0, 1fr) auto 36px; gap: 4px 10px; padding: 10px 12px; }
    .expense-row .expense-category { display: none; }
    .expense-row > small:first-child { grid-column: 1; grid-row: 2; }
    .expense-row > div { grid-column: 1; grid-row: 1; }
    .expense-row > strong { grid-column: 2; grid-row: 1 / 3; white-space: nowrap; }
    .expense-row > button { grid-column: 3; grid-row: 1 / 3; }
    .orders-section .table-wrap, .customers-table { display: none; }
    .orders-mobile, .customers-mobile { display: grid; }
    .order-mobile-card { padding: 13px 14px; border-top: 1px solid var(--border); cursor: pointer; }
    .order-mobile-card:first-child, .customer-card:first-child { border-top: 0; }
    .order-mobile-card > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
    .order-mobile-card > header div { min-width: 0; }
    .order-mobile-card > header strong, .order-mobile-card > header small { display: block; overflow-wrap: anywhere; }
    .order-mobile-card > header small { margin-top: 4px; color: var(--muted); }
    .mobile-order-body { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; }
    .mobile-order-body small, .mobile-order-body strong { display: block; }
    .mobile-order-body small { color: var(--muted); margin-bottom: 3px; }
    .customer-card { min-height: 68px; display: grid; grid-template-columns: minmax(0, 1fr) auto 20px; align-items: center; gap: 10px; padding: 9px 14px; }
    .actual-grid { grid-template-columns: 1fr; }
    .session-actions { align-items: stretch; flex-direction: column; }
    .actual-operation > header { display: grid; }
    .report-filters > label { flex: 1 1 130px; }
    .report-filters .button { flex: 1 1 100%; }
    .reports-section .section-heading { align-items: flex-start; padding-top: 12px; padding-bottom: 12px; }
    .reports-section .section-heading .button { width: 42px; padding: 0; font-size: 0; }
    .settings-grid { grid-template-columns: 1fr; }
    .settings-row { grid-template-columns: 1fr 1fr 44px; }
    .settings-row .settings-unit { display: none; }
    .import-settings .section-heading { align-items: stretch; flex-direction: column; }
    .import-settings .section-heading .button { width: 100%; }
    .import-history-row { grid-template-columns: minmax(0, 1fr) auto; }
    .import-history-row > span { grid-column: 1; }
    .import-history-row > button { grid-column: 2; grid-row: 1 / 3; }
    .app-dialog { width: 100vw; max-width: 100vw; max-height: 100vh; height: 100vh; border-radius: 0; border: 0; }
    .dialog-shell { max-height: 100vh; height: 100vh; }
    .dialog-header { min-height: 64px; padding: 10px 14px; }
    .dialog-footer { padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); }
    .order-form-main { padding: 12px; }
    .form-grid, .operation-fields { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
    .form-section-title.with-action .button { width: 40px; padding: 0; font-size: 0; }
    .steps-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .order-detail-dialog { width: 100vw; height: 100vh; border-radius: 0; }
    .detail-controls { grid-template-columns: 1fr; }
    .import-preview { padding: 12px; }
    .import-preview-heading { align-items: flex-start; flex-direction: column; }
    .import-row > header { grid-template-columns: 100px minmax(0, 1fr); }
    .import-core-grid, .import-cost-grid, .import-steps-grid { grid-template-columns: 1fr 1fr; padding: 10px; }
    .import-expense-row { grid-template-columns: 1fr 1fr; }
    .import-expense-row .import-check { grid-column: 1 / -1; }
    .import-expense-row > label:nth-of-type(2) { grid-column: 1 / -1; }
    .import-selection { display: none; }
}

@media (max-width: 410px) {
    .metric-grid.compact { grid-template-columns: 1fr; }
    .metric { min-height: 78px; }
}
