:root {
  --ink: #172238;
  --muted: #657084;
  --line: #dfe4ec;
  --line-strong: #c9d0dc;
  --surface: #ffffff;
  --surface-soft: #f5f7fa;
  --canvas: #eef1f5;
  --nav: #172238;
  --nav-soft: #23314d;
  --accent: #e6532f;
  --accent-dark: #bd3d20;
  --green: #16784b;
  --green-soft: #e7f5ed;
  --red: #b83a3a;
  --red-soft: #fbeaea;
  --amber: #a86609;
  --amber-soft: #fff4dc;
  --blue-soft: #e9f1ff;
  --shadow: 0 14px 40px rgba(24, 34, 56, 0.12);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html, body, #app { min-height: 100%; margin: 0; }

body {
  min-width: 0;
  background: var(--canvas);
  font-size: 14px;
  line-height: 1.45;
}

button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }

button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(230, 83, 47, 0.2);
  outline-offset: 1px;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 4px; font-size: 26px; letter-spacing: -0.025em; }
h2 { margin-bottom: 12px; font-size: 18px; letter-spacing: -0.015em; }
h3 { margin-bottom: 8px; font-size: 15px; }

.review-banner {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 1000;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0 16px;
  background: #ffd24a;
  color: #3f3210;
  border-bottom: 1px solid #d4ab2f;
  font-size: 12px;
  font-weight: 850;
  line-height: 1.2;
  letter-spacing: 0.08em;
  text-align: center;
  white-space: nowrap;
}

.owner-test-banner {
  background: #dce8ff;
  color: #17315c;
  border-bottom-color: #91addc;
}

.review-banner + .app-shell { padding-top: 32px; }

.app-shell { display: grid; grid-template-columns: 244px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--nav), #111a2c);
  color: #f6f8fc;
  border-right: 1px solid #2b3852;
}

.review-banner + .app-shell .sidebar { top: 32px; height: calc(100vh - 32px); }

.brand { display: flex; align-items: center; gap: 12px; min-height: 78px; padding: 18px 20px; font-weight: 800; font-size: 18px; }
.brand small { display: block; margin-top: 2px; color: #9ba8bd; font-size: 11px; font-weight: 550; letter-spacing: 0.03em; }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 10px;
  color: white;
  background: var(--accent);
  font-size: 22px;
  font-weight: 900;
  box-shadow: 0 8px 22px rgba(230, 83, 47, 0.28);
}

.nav { padding: 5px 10px 18px; overflow-y: auto; }
.nav button {
  position: relative;
  width: 100%;
  min-height: 40px;
  display: grid;
  grid-template-columns: 8px 1fr auto;
  align-items: center;
  gap: 10px;
  margin: 2px 0;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  color: #b8c2d3;
  background: transparent;
  text-align: left;
}
.nav button:hover { color: white; background: rgba(255,255,255,0.06); }
.nav button.active { color: white; background: var(--nav-soft); box-shadow: inset 3px 0 var(--accent); }
.nav button small { color: #77859b; font-size: 9px; }
.nav .dot { width: 6px; height: 6px; border-radius: 50%; background: #526079; }
.nav button.active .dot { background: var(--accent); }

.sidebar-user { margin-top: auto; padding: 15px 18px 18px; border-top: 1px solid #2c3850; color: #aeb9ca; font-size: 12px; }
.sidebar-user strong { display: block; color: white; font-size: 13px; }
.sidebar-user > span { display: block; margin-top: 2px; }
.review-user-note { margin-top: 9px !important; color: #ffd24a; font-size: 10px; }
.logout { margin-top: 10px; padding: 0; border: 0; color: #d3daE5; background: none; text-decoration: underline; }

.workspace { min-width: 0; padding: 22px 26px 44px; }
.topbar { display: flex; justify-content: space-between; gap: 24px; align-items: flex-end; margin-bottom: 18px; }
.top-actions { display: flex; align-items: flex-end; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.eyebrow { margin-bottom: 5px; color: var(--accent-dark); font-size: 10px; font-weight: 850; letter-spacing: 0.1em; text-transform: uppercase; }
.subtle { color: var(--muted); font-size: 12px; }
.demo-ribbon { padding: 7px 9px; border: 1px solid #d6b64c; border-radius: 6px; color: #745e13; background: #fff8d8; font-size: 10px; font-weight: 750; }

.sheet {
  margin-bottom: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 2px 5px rgba(31, 44, 66, 0.04);
}
.sheet-toolbar, .section-title { display: flex; justify-content: space-between; align-items: center; gap: 15px; margin-bottom: 12px; }
.section-title > div { display: flex; align-items: center; gap: 9px; }
.section-title h2 { margin: 0; }
.section-index { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; color: white; background: var(--nav); font-size: 11px; font-weight: 800; }

.table-wrap, .drawer-table-wrap { overflow-x: auto; overflow-y: auto; border: 1px solid var(--line); border-radius: 7px; background: white; }
.drawer-table-wrap { min-width: 0; max-width: 100%; }
.drawer-table-wrap table { min-width: 620px; }
.drawer-table-wrap td:not(.money) { white-space: normal; overflow-wrap: anywhere; }
.drawer-table-wrap .money, .drawer-table-wrap .row-actions, .drawer-table-wrap .btn { white-space: nowrap; }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
.dense { font-size: 12px; }
.dense th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 8px 9px;
  color: #4e596d;
  background: #edf1f6;
  border-bottom: 1px solid var(--line-strong);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.025em;
  text-align: left;
  white-space: nowrap;
}
.dense td { padding: 8px 9px; border-bottom: 1px solid #e8ebf0; vertical-align: top; }
.dense tr:last-child td { border-bottom: 0; }
.dense tbody tr:hover > td { background: #f8fafc; }
.dense .sticky-col { position: sticky; left: 0; z-index: 1; background: white; box-shadow: 1px 0 var(--line); }
.dense th.sticky-col { z-index: 3; background: #edf1f6; }
.total-row td { font-weight: 800; background: #eef4ff !important; border-top: 1px solid #bdcbe1; }
.orders-table { min-width: 0; table-layout: fixed; }
.works-table { min-width: 0; }
.dds-table, .statement-table, .cash-table { min-width: 0; table-layout: fixed; }

.money, .num { text-align: right !important; white-space: nowrap; font-variant-numeric: tabular-nums; }
.works-table .money, .works-table .num { white-space: normal; line-height: 1.15; overflow-wrap: anywhere; }
.works-table td:not(.work-actions-cell), .works-table th { overflow-wrap: anywhere; }
.positive { color: var(--green); }
.negative { color: var(--red); }
.muted { color: var(--muted); }
.calculated { background: #f4f6f9; }
.calc-dot, .manual-dot { display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; }
.calc-dot { background: #668ad2; }
.manual-dot { background: var(--accent); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--ink);
  background: white;
  font-weight: 700;
  text-decoration: none;
}
.btn:hover { border-color: #9da8b9; background: #f7f8fa; }
.btn-primary { border-color: var(--nav); color: white; background: var(--nav); }
.btn-primary:hover { border-color: #273752; background: #273752; }
.btn-accent { border-color: var(--accent); color: white; background: var(--accent); }
.btn-accent:hover { border-color: var(--accent-dark); background: var(--accent-dark); }
.btn-danger { border-color: #e3b5b5; color: var(--red); background: #fff6f6; }
.btn:disabled, .btn[disabled] { cursor: not-allowed; opacity: 0.5; }
.btn-small { min-height: 28px; padding: 4px 8px; font-size: 11px; }
.btn.full { width: 100%; }
.icon-button { width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 7px; background: white; color: #5e6878; }
.link-button { padding: 0; border: 0; color: #275ca8; background: none; text-decoration: underline; text-underline-offset: 2px; }
.row-actions, .action-strip { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.selected-counter { align-self: end; padding: 7px 8px; border: 1px solid var(--line); border-radius: 6px; color: #4f5b70; background: #f8fafc; font-size: 11px; font-weight: 800; }
.selected-counter.all-done { color: var(--green); background: var(--green-soft); border-color: #bfe4cd; }
.plan-estimate-table input { width: 100%; min-width: 120px; }
.plan-estimate-table td:nth-child(3) { min-width: 140px; }
.drawer-action-strip { margin: 12px 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 7px; background: #fafbfc; }
.drawer-action-strip .subtle { flex: 1; min-width: 220px; }
.order-status-form { border-left: 3px solid var(--accent); }
.order-status-form h3 { margin: 0; }
.works-filter-empty { margin: 10px 0; border: 1px dashed var(--line-strong); border-radius: 7px; background: #fafbfc; }

label { display: grid; gap: 4px; color: #536074; font-size: 11px; font-weight: 700; }
input, select, textarea {
  min-height: 38px;
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #cbd2de;
  border-radius: 6px;
  color: var(--ink);
  background: white;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { margin: 0; -webkit-appearance: none; }
input[type="number"] { appearance: textfield; -moz-appearance: textfield; }
textarea { min-height: 74px; resize: vertical; }
.cell-select { min-width: 116px; height: 29px; min-height: 29px; padding: 3px 6px; font-size: 11px; }
.compact-label { min-width: 145px; }
.finance-period-label { min-width: 190px; }
.finance-period-label select { min-height: 44px; min-width: 180px; font-size: 14px; }
.form-stack { display: grid; gap: 12px; }
.form-grid, .drawer-form-grid { display: grid; grid-template-columns: repeat(3, minmax(150px, 1fr)); gap: 11px; }
.dds-form { display: grid; grid-template-columns: repeat(4, minmax(180px, 1fr)); gap: 12px; align-items: end; margin-top: 12px; }
.dds-form input, .dds-form select, .dds-form .btn { min-height: 44px; border-radius: 7px; font-size: 14px; }
.dds-form .checkbox-field { min-height: 44px; }
.dds-form [hidden] { display: none !important; }
.inline-form { display: flex; align-items: end; gap: 10px; flex-wrap: wrap; }
.inline-form label { min-width: 145px; }
.inline { display: inline-flex; gap: 6px; align-items: center; }
.checkbox-field, .demo-mode { display: flex; min-height: 34px; flex-direction: row; align-items: center; gap: 8px; }
.checkbox-field input, .demo-mode input, .order-picker input[type="checkbox"] { width: auto; min-height: auto; }
.wide { min-width: 290px !important; }
.full { grid-column: 1 / -1; }
.split-input { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.order-picker { display: grid; grid-template-columns: repeat(2, minmax(250px, 1fr)); gap: 7px; padding: 10px; border: 1px solid var(--line); border-radius: 7px; }
.order-picker legend { padding: 0 6px; color: #536074; font-size: 11px; font-weight: 750; }
.order-picker label { display: grid; grid-template-columns: auto minmax(170px, 1fr) 110px; align-items: center; gap: 7px; padding: 7px; border: 1px solid var(--line); border-radius: 6px; background: #fafbfc; }

.orders-filterbar { display: grid; grid-template-columns: minmax(250px, 1fr) 170px 150px 150px auto; gap: 9px; align-items: end; }
.order-search { position: relative; }
.filter-count { color: var(--muted); white-space: nowrap; font-size: 12px; }
.order-create-panel { border-left: 4px solid var(--accent); background: #edf7fc; }
.order-card-form { display: grid; gap: 14px; }
.order-card-form label { font-size: 12px; }
.order-card-form input, .order-card-form select, .order-card-form textarea { min-height: 42px; font-size: 14px; }
.order-form-section { min-width: 0; padding: 14px; border: 1px solid #cfdde7; border-radius: 9px; background: #fff; }
.order-form-section > h3, .order-items-head h3 { margin: 0 0 10px; font-size: 15px; }
.order-three-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; align-items: end; }
.order-header-grid, .order-production-grid { margin-top: 12px; }
.order-production-grid .order-comment { grid-column: 1 / -1; }
.order-items-block { margin-top: 0; }
.order-items-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.order-item-editor { display: grid; grid-template-columns: minmax(190px, 1.35fr) minmax(130px, .9fr) minmax(92px, .55fr) minmax(110px, .7fr) minmax(112px, .7fr) 34px; gap: 10px; align-items: end; margin-bottom: 8px; }
.order-item-editor select[data-item-field="name"] { min-height: 42px; }
.order-item-variant { margin-top: 6px; }
.order-form-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.order-form-actions > .subtle { margin-right: auto; }
.order-comment { display: grid; margin: 0; color: var(--muted); white-space: normal; }
.order-comment textarea { resize: vertical; }
.order-draft-total { display: flex; justify-content: flex-end; align-items: center; gap: 14px; margin-top: 10px; padding: 10px 12px; border-radius: 7px; color: var(--muted); background: #e8f2f8; }
.order-draft-total > span { margin-right: auto; }
.order-draft-total strong { color: var(--ink); font-size: 18px; font-variant-numeric: tabular-nums; }
.order-payment-block { border-color: #a8c9da; }
.order-payment-tax { margin-top: 10px; }
.order-payment-balance { margin-top: 8px; color: var(--muted); text-align: right; }
.order-payment-balance strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.finance-revenue-note { margin-top: 12px; }

.badge, .demo-tag, .decision-tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 7px;
  border-radius: 999px;
  color: #41506a;
  background: #e9edf3;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}
.badge.READY, .badge.CLOSED, .badge.PAID, .badge.POSTED, .badge.ACCEPTED, .badge.FREE { color: var(--green); background: var(--green-soft); }
.badge.IN_PROGRESS, .badge.ASSIGNED, .badge.PARTIAL { color: #315f9d; background: var(--blue-soft); }
.badge.CANCELLED, .badge.REVERSED { color: var(--red); background: var(--red-soft); }
.badge.WARNING, .decision-tag { color: var(--amber); background: var(--amber-soft); }
.demo-tag { color: #6e5610; background: #fff2b8; }
.demo-row > td, .batch-card.demo-row { background: #fffdf4; }
.deadline-pill { display: inline-flex; align-items: center; min-height: 22px; padding: 3px 7px; border-radius: 999px; color: #41506a; background: #edf1f6; font-size: 10px; font-weight: 850; white-space: nowrap; }

.drawer {
  position: fixed;
  z-index: 900;
  inset: 32px 0 0 auto;
  width: min(760px, 65vw);
  overflow: auto;
  padding: 19px;
  border-left: 1px solid var(--line-strong);
  background: var(--surface-soft);
  box-shadow: -18px 0 50px rgba(20, 30, 48, 0.19);
}
.drawer-head { position: sticky; top: -19px; z-index: 4; display: flex; justify-content: space-between; align-items: start; gap: 15px; margin: -19px -19px 14px; padding: 17px 19px 13px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,0.97); }
.drawer-head h2 { margin: 0; }
.drawer-tabs { display: flex; gap: 5px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.drawer-tabs button { padding: 8px 10px; border: 0; border-bottom: 2px solid transparent; color: var(--muted); background: transparent; font-weight: 700; }
.drawer-tabs button.active { color: var(--ink); border-bottom-color: var(--accent); }
.drawer-tab-content { display: grid; gap: 12px; }
.drawer-metrics, .drawer-summary { display: flex; gap: 9px; flex-wrap: wrap; }
.drawer-metrics > span, .drawer-summary > span { min-width: 150px; flex: 1; padding: 10px 11px; border: 1px solid var(--line); border-radius: 7px; color: var(--muted); background: white; font-size: 11px; }
.drawer-metrics strong, .drawer-summary strong { display: block; margin-top: 3px; color: var(--ink); font-size: 15px; font-variant-numeric: tabular-nums; }
.orders-table th, .orders-table td,
.dds-table th, .dds-table td,
.cash-table th, .cash-table td,
.statement-table th, .statement-table td {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.orders-table .money, .orders-table .num,
.dds-table .money, .cash-table .money, .statement-table .money { white-space: nowrap; }
.orders-table .group-head { display: none; }
.orders-table th:nth-child(1), .orders-table td:nth-child(1) { width: 70px; }
.orders-table th:nth-child(3), .orders-table td:nth-child(3) { width: 95px; }
.orders-table th:nth-child(4), .orders-table td:nth-child(4) { width: 100px; }
.orders-table th:nth-child(5), .orders-table td:nth-child(5) { width: 110px; }
.orders-table th:nth-child(6), .orders-table td:nth-child(6) { width: 50px; }
.orders-table th:nth-child(8), .orders-table td:nth-child(8),
.orders-table th:nth-child(11), .orders-table td:nth-child(11),
.orders-table th:nth-child(12), .orders-table td:nth-child(12),
.orders-table th:nth-child(16), .orders-table td:nth-child(16),
.orders-table th:nth-child(17), .orders-table td:nth-child(17) { width: 80px; }
.orders-table th:nth-child(18), .orders-table td:nth-child(18) { width: 96px; }
.orders-table th:nth-child(26), .orders-table td:nth-child(26) { width: 80px; }
.orders-table th:nth-child(2), .orders-table td:nth-child(2),
.orders-table th:nth-child(7), .orders-table td:nth-child(7),
.orders-table th:nth-child(9), .orders-table td:nth-child(9),
.orders-table th:nth-child(10), .orders-table td:nth-child(10),
.orders-table th:nth-child(13), .orders-table td:nth-child(13),
.orders-table th:nth-child(14), .orders-table td:nth-child(14),
.orders-table th:nth-child(15), .orders-table td:nth-child(15),
.orders-table th:nth-child(19), .orders-table td:nth-child(19),
.orders-table th:nth-child(20), .orders-table td:nth-child(20),
.orders-table th:nth-child(21), .orders-table td:nth-child(21),
.orders-table th:nth-child(22), .orders-table td:nth-child(22),
.orders-table th:nth-child(23), .orders-table td:nth-child(23),
.orders-table th:nth-child(24), .orders-table td:nth-child(24),
.orders-table th:nth-child(25), .orders-table td:nth-child(25) { display: none; }
.dds-table th:nth-child(1), .dds-table td:nth-child(1) { width: 78px; }
.dds-table th:nth-child(2), .dds-table td:nth-child(2) { width: 92px; }
.dds-table th:nth-child(3), .dds-table td:nth-child(3) { width: 138px; }
.dds-table th:nth-child(4), .dds-table td:nth-child(4) { width: 138px; }
.dds-table th:nth-child(5), .dds-table td:nth-child(5) { width: 78px; }
.dds-table th:nth-child(7), .dds-table td:nth-child(7) { width: 104px; }
.dds-table th:nth-child(9), .dds-table td:nth-child(9) { width: 124px; }
.dds-table th:nth-child(11), .dds-table td:nth-child(11) { width: 134px; }
.dds-table th:nth-child(6), .dds-table td:nth-child(6),
.dds-table th:nth-child(8), .dds-table td:nth-child(8),
.dds-table th:nth-child(10), .dds-table td:nth-child(10) { display: none; }
.cash-table th:nth-child(1), .cash-table td:nth-child(1) { width: 135px; }
.cash-table th:nth-child(8), .cash-table td:nth-child(8),
.cash-table th:nth-child(9), .cash-table td:nth-child(9),
.cash-table th:nth-child(10), .cash-table td:nth-child(10) { width: 118px; }
.statement-table th:nth-child(1), .statement-table td:nth-child(1) { width: 170px; }
.statement-table th:nth-child(3), .statement-table td:nth-child(3),
.statement-table th:nth-child(4), .statement-table td:nth-child(4),
.statement-table th:nth-child(5), .statement-table td:nth-child(5),
.statement-table th:nth-child(6), .statement-table td:nth-child(6) { width: 116px; }
.statement-table th:nth-child(7), .statement-table td:nth-child(7),
.statement-table th:nth-child(8), .statement-table td:nth-child(8) { display: none; }
.finance-summary > span { min-width: 0; }
.finance-overview { margin-bottom: 16px; }
.finance-overview-panel { padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: white; box-shadow: 0 2px 5px rgba(31, 44, 66, 0.04); }
.finance-month { margin-bottom: 12px; color: var(--muted); font-size: 12px; font-weight: 850; }
.finance-result-grid, .finance-card-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.finance-card { position: relative; min-width: 0; min-height: 88px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.finance-card span { display: block; color: var(--muted); font-size: 11px; font-weight: 800; }
.finance-card strong { display: block; margin-top: 8px; color: var(--ink); font-size: 19px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.finance-card small { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.finance-pair { min-height: 106px; }
.finance-card-line { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-top: 10px; }
.finance-card-line small, .finance-card-line strong { margin: 0; }
.finance-card-line strong { text-align: right; font-size: 17px; }
.finance-card-value { min-width: 0; text-align: right; }
.finance-card-value > strong > small { display: block; margin-top: 3px; font-size: 10px; font-weight: 700; white-space: normal; }
.finance-summary > span { position: relative; }
.finance-breakdown { display: inline-block !important; position: static; color: inherit !important; font-size: inherit !important; }
.finance-breakdown-trigger { display: inline-block; padding: 0; border: 0; color: inherit; background: transparent; cursor: help; font: inherit; text-align: right; }
.finance-breakdown-trigger strong { display: block; margin: 0; color: inherit; font: inherit; font-size: 17px; font-weight: 850; font-variant-numeric: tabular-nums; white-space: nowrap; }
.finance-summary .finance-breakdown-trigger strong { margin-top: 4px; font-size: 16px; }
.finance-breakdown-trigger:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; border-radius: 3px; }
.finance-breakdown-popover {
  display: block !important;
  position: absolute;
  z-index: 80;
  top: calc(100% + 8px);
  right: 0;
  width: min(640px, calc(100vw - 64px));
  max-height: min(520px, 70vh);
  padding: 14px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink) !important;
  background: white;
  box-shadow: 0 18px 44px rgba(23, 34, 56, 0.2);
  font-size: 12px !important;
  text-align: left;
  visibility: hidden;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity .12s ease, transform .12s ease, visibility .12s;
}
.finance-breakdown:hover .finance-breakdown-popover,
.finance-breakdown.is-pinned .finance-breakdown-popover { visibility: visible; opacity: 1; transform: translateY(0); pointer-events: auto; }
.finance-breakdown.is-dismissed .finance-breakdown-popover { visibility: hidden; opacity: 0; transform: translateY(-4px); pointer-events: none; }
.finance-result-grid .finance-card:nth-child(-n+2) .finance-breakdown-popover,
.finance-summary > span:first-child .finance-breakdown-popover { left: 0; right: auto; }
.finance-breakdown-body table { width: 100%; table-layout: auto; }
.finance-breakdown-body th, .finance-breakdown-body td { white-space: normal; }
.finance-breakdown-total { display: flex; justify-content: space-between; gap: 18px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); font-weight: 850; }
.finance-cost-order { padding: 7px 0; border-bottom: 1px solid var(--line); }
.finance-cost-order summary { display: flex; justify-content: space-between; gap: 12px; cursor: pointer; font-weight: 800; }
.finance-cost-order table { margin-top: 8px; }
.finance-profit-lines > div { display: flex; justify-content: space-between; gap: 18px; padding: 6px 0; }
.finance-profit-lines span { color: var(--ink); font-size: 12px; font-weight: 750; }
.finance-profit-lines small { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; font-weight: 650; }
.finance-profit-lines strong { margin: 0; font-size: 13px; white-space: nowrap; }
.finance-ready-profit-breakdown > table { margin-top: 12px; border-top: 1px solid var(--line); }
.finance-margin { margin-top: 12px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 7px; color: var(--muted); background: #fafbfc; }
.finance-margin strong { color: var(--ink); }
.finance-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.finance-grid .sheet { margin-bottom: 0; }
.finance-fund-card, .finance-cash-card, .finance-withdraw-detail { grid-column: 1 / -1; }
.finance-orders-result { overflow: visible; }
.finance-orders-result-layout { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 24px; align-items: center; }
.finance-orders-result-lines { display: grid; gap: 8px; max-width: 620px; }
.finance-orders-result-lines > div { display: flex; position: relative; align-items: baseline; justify-content: space-between; gap: 24px; min-width: 0; padding: 9px 0; border-bottom: 1px solid var(--line); }
.finance-orders-result-lines > div > span:first-child { color: var(--muted); font-weight: 750; }
.finance-orders-result-lines .finance-breakdown-trigger strong { font-size: 18px; }
.finance-withdraw-card { display: grid; position: relative; align-content: center; justify-items: start; width: 240px; min-height: 80px; padding: 13px 18px; border: 0; border-radius: 9px; color: white; background: var(--nav); box-shadow: 0 8px 20px rgba(23, 34, 56, 0.16); text-align: left; }
.finance-withdraw-card span { color: #cbd5e1; font-size: 12px; font-weight: 850; }
.finance-withdraw-card strong { margin-top: 5px; max-width: 170px; font-size: 21px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.finance-withdraw-card b { position: absolute; right: 18px; bottom: 17px; font-size: 22px; }
.fund-kpis, .fund-buckets { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 10px; }
.fund-kpis { margin-bottom: 12px; }
.fund-kpis span, .fund-bucket { padding: 11px; border: 1px solid var(--line); border-radius: 8px; background: #fafbfc; color: var(--muted); font-size: 11px; font-weight: 750; }
.fund-kpis strong, .fund-bucket strong { display: block; margin-top: 4px; color: var(--ink); font-size: 16px; font-variant-numeric: tabular-nums; }
.fund-bucket small { display: block; margin-top: 5px; color: var(--muted); }
.fund-progress { display: block; width: 100%; height: 7px; margin-top: 8px; overflow: hidden; appearance: none; border: 0; border-radius: 999px; background: #e5eaf1; }
.fund-progress::-webkit-progress-bar { border-radius: 999px; background: #e5eaf1; }
.fund-progress::-webkit-progress-value { border-radius: 999px; background: var(--green); }
.fund-progress::-moz-progress-bar { border-radius: 999px; background: var(--green); }
.finance-mini-table td { padding: 9px 10px; }
.compact-settings { padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; background: #fafbfc; }
.compact-settings summary { cursor: pointer; font-weight: 800; color: var(--ink); }
.drawer-dates, .detail-grid { display: grid; grid-template-columns: repeat(3, minmax(130px, 1fr)); gap: 9px; }
.drawer-form { padding: 12px; border: 1px solid var(--line); border-radius: 7px; background: white; }

.batch-layout { display: grid; grid-template-columns: minmax(400px, 1.2fr) minmax(330px, 0.8fr); gap: 16px; }
.batch-list { display: grid; gap: 10px; }
.batch-card { padding: 13px; border: 1px solid var(--line); border-radius: 8px; background: white; }
.batch-card .group-head { display: flex; justify-content: space-between; gap: 12px; }
.batch-details { margin-top: 10px; }
.statement-detail td { padding: 0 !important; background: var(--surface-soft) !important; }
.statement-detail[hidden] { display: none; }
.statement-detail > td > div { padding: 12px; }
.statement-detail .detail-grid { grid-template-columns: minmax(0, 1.2fr) minmax(0, .8fr); gap: 12px; }
.statement-detail .detail-grid > div { min-width: 0; }
.statement-accruals, .statement-payments { width: 100%; table-layout: fixed; }
.statement-accruals th:nth-child(1) { width: 15%; }
.statement-accruals th:nth-child(2) { width: 24%; }
.statement-accruals th:nth-child(3) { width: 11%; }
.statement-accruals th:nth-child(4), .statement-accruals th:nth-child(5) { width: 17%; }
.statement-accruals th:nth-child(6) { width: 16%; }
.statement-accruals td { overflow-wrap: anywhere; }
.statement-accruals td:first-child, .statement-accruals td:last-child { white-space: nowrap; }
.work-order-list { display: grid; gap: 14px; }
.work-order-block { display: grid; gap: 8px; }
.work-order-head {
  display: grid;
  grid-template-columns: minmax(80px, .55fr) minmax(120px, .9fr) minmax(160px, 1.25fr) minmax(82px, .62fr) minmax(100px, .75fr) minmax(88px, .64fr);
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fbff;
}
.work-order-head span { min-width: 0; }
.work-order-head small { display: block; margin-bottom: 2px; color: var(--muted); font-size: 10px; font-weight: 850; }
.work-order-head strong {
  display: block;
  min-width: 0;
  overflow: visible;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}
.works-table-wrap { overflow-x: auto; }
.works-table {
  width: 100%;
  min-width: 920px;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
}
.works-table th:nth-child(1) { width: 14%; }
.works-table th:nth-child(2) { width: 11%; }
.works-table th:nth-child(3) { width: 9%; }
.works-table th:nth-child(4) { width: 9%; }
.works-table th:nth-child(5) { width: 12%; }
.works-table th:nth-child(6) { width: 12%; }
.works-table th:nth-child(7) { width: 12%; }
.works-table th:nth-child(8) { width: 14%; }
.works-table th:nth-child(9) { width: 7%; text-align: center; }
.works-table th { padding: 6px 6px; }
.works-table td {
  padding: 6px 6px;
  min-width: 0;
  vertical-align: middle;
  background: white;
}
.works-table tr.work-editing-row > td { background: #f3f8ff; }
.works-table input, .works-table select { width: 100%; min-width: 0; min-height: 28px; padding: 3px 6px; }
.works-table input[type="checkbox"] { width: 18px; min-width: 18px; height: 18px; min-height: 18px; padding: 0; }
.works-table input[type="number"]::-webkit-outer-spin-button, .works-table input[type="number"]::-webkit-inner-spin-button { appearance: none; margin: 0; }
.works-table .btn-small { min-height: 26px; padding: 4px 7px; font-size: 11px; }
.works-table .row-actions { gap: 5px; align-items: center; justify-content: flex-end; flex-wrap: nowrap; }
.works-table .badge { max-width: 100%; justify-content: center; line-height: 1.1; white-space: normal; text-align: center; }
.work-title-line { display: grid; grid-template-columns: auto minmax(0,1fr); gap: 8px; align-items: start; }
.work-name { color: var(--ink); font-size: 13px; font-weight: 850; line-height: 1.15; }
.work-formula { color: #22314c; font-weight: 750; }
.work-manual-value { color: #22314c; font-weight: 750; }
.work-contractor-inline { display: grid; gap: 3px; min-width: 0; }
.work-contractor-inline small { min-height: 12px; color: var(--muted); font-size: 9px; line-height: 1.2; white-space: normal; }
.work-contractor-inline small.error { color: var(--danger); }
.design-manual-inline { display: grid; gap: 3px; min-width: 120px; }
.design-manual-inline small { min-height: 12px; color: var(--muted); font-size: 9px; line-height: 1.2; white-space: normal; }
.design-manual-inline small.error { color: var(--red); }
.work-edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 5px; }
.work-edit-grid label, .work-inline-field { display: grid; gap: 3px; color: var(--muted); font-size: 10px; font-weight: 850; }
.works-table td.money input { text-align: right; }
.works-table td.money small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; text-align: left; white-space: normal; }
.dds-table th:first-child, .dds-table td:first-child {
  position: static;
  box-shadow: none;
}
.dds-table thead th:first-child {
  background: #edf1f6;
}
.dds-table th:last-child, .dds-table td:last-child {
  position: sticky;
  right: 0;
  z-index: 3;
  width: 58px;
  min-width: 58px;
  max-width: 58px;
  overflow: visible;
  background: white;
  box-shadow: -10px 0 14px rgba(18, 29, 49, 0.08);
}
.dds-table thead th:last-child { z-index: 5; background: #edf1f6; }
.dds-actions-cell { text-align: center; }
.dds-action-menu { right: 6px; left: auto; text-align: left; }
.works-table .demo-row, .dds-table .demo-row td:first-child { background: #fffdf4; }
.works-table .money-input { text-align: right; font-variant-numeric: tabular-nums; }
.works-table .work-payout { color: #172236; background: #fafcff; font-weight: 850; }
.works-table .work-row-marker { display: inline-flex; width: 18px; height: 18px; align-items: center; justify-content: center; border-radius: 999px; color: #4f5b70; background: #eef1f6; font-size: 10px; font-weight: 800; text-align: center; }
.works-table .work-accepted-row { background: #fbfcfe; }
.works-table th:last-child, .works-table .work-actions-cell {
  position: sticky;
  right: 0;
  z-index: 4;
  min-width: 86px;
  overflow: visible;
  background: white;
  box-shadow: -8px 0 12px rgba(18, 29, 49, 0.07);
  text-align: right !important;
}
.works-table th:last-child { z-index: 6; background: #edf1f6; text-align: center !important; }
.works-table tr[data-stage-row].work-editing-row td.work-actions-cell > .row-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  flex-wrap: nowrap;
}
.works-table tr[data-stage-row].work-editing-row td.work-actions-cell .btn-small { width: 100%; padding-inline: 5px; }
.work-edit-actions { display: grid; width: 100%; gap: 5px; }
.work-edit-actions .btn-small { width: 100%; }
.work-menu-trigger {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: #334155;
  background: white;
  font-size: 18px;
  font-weight: 850;
  line-height: 1;
}
.work-menu-trigger:hover { border-color: #9da8b9; background: #f7f8fa; }
.work-action-menu {
  position: absolute;
  right: 6px;
  top: 34px;
  z-index: 8;
  display: grid;
  min-width: 118px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: 0 12px 28px rgba(18, 29, 49, 0.16);
}
.work-action-menu.is-floating {
  position: fixed;
  right: auto;
  top: auto;
  z-index: 1400;
}
.work-action-menu[hidden] { display: none; }
.work-action-menu button {
  min-height: 28px;
  padding: 5px 8px;
  border: 0;
  border-radius: 6px;
  color: var(--ink);
  background: transparent;
  font-size: 12px;
  font-weight: 800;
  text-align: left;
}
.work-action-menu button:hover { background: #f3f6fa; }
.work-action-menu button.danger { color: var(--red); }
.work-action-menu button:disabled { cursor: not-allowed; opacity: 0.45; }
.handoff-panel { display: grid; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 7px; background: white; }
.handoff-grid { display: grid; grid-template-columns: repeat(4, minmax(160px, 1fr)); gap: 10px; align-items: end; }
.handoff-grid .wide { grid-column: span 2; }
.handoff-act { display: grid; grid-template-columns: auto auto repeat(4, minmax(150px, 1fr)); gap: 10px; align-items: end; padding-top: 10px; border-top: 1px solid var(--line); }
.handoff-act strong { align-self: center; }
.handoff-panel .checkbox-field input { width: 22px; min-width: 22px; height: 22px; min-height: 22px; }
.handoff-mini { margin-top: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 7px; background: #fafbfc; color: var(--muted); }

.source-details { margin-top: 12px; border: 1px solid var(--line); border-radius: 7px; background: #fbfcfd; }
.source-details summary { padding: 9px 11px; color: #45536a; font-weight: 750; }
.source-details table { border-top: 1px solid var(--line); }
.alert, .hint, .explain-note, .locked-note { padding: 10px 12px; border-radius: 7px; color: #445166; background: var(--blue-soft); border-left: 3px solid #668ad2; }
.alert { margin-bottom: 12px; }
.hint { margin-bottom: 14px; }
.locked-note { background: var(--amber-soft); border-left-color: #d4972a; }
.legend { display: flex; gap: 14px; color: var(--muted); font-size: 11px; }
.empty { padding: 25px !important; color: var(--muted); text-align: center !important; }

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(350px, 1fr)); gap: 16px; }
.reference-list { display: flex; flex-wrap: wrap; gap: 7px; }
.reference-list span { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fafbfc; font-size: 12px; }
.future-panel { min-height: 270px; display: flex; align-items: center; justify-content: center; gap: 20px; padding: 35px; border: 1px dashed #b9c2d0; border-radius: 10px; background: rgba(255,255,255,0.6); }
.future-icon { display: grid; place-items: center; width: 55px; height: 55px; border-radius: 50%; color: white; background: var(--accent); font-size: 27px; }

.login { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 0.95fr; background: white; }
.review-banner + .login { padding-top: 32px; }
.login-brand { display: flex; flex-direction: column; justify-content: space-between; padding: 8vh 8vw 6vh; color: white; background: radial-gradient(circle at 20% 20%, #2a4168, var(--nav) 58%, #10182a); }
.login-brand h1 { margin: 24px 0 18px; font-size: clamp(42px, 5vw, 70px); line-height: 0.98; }
.login-brand p { max-width: 520px; color: #c1cad9; font-size: 18px; }
.login-panel { display: grid; place-items: center; padding: 40px; background: var(--surface-soft); }
.login-card { width: min(420px, 100%); padding: 32px; border: 1px solid var(--line); border-radius: 12px; background: white; box-shadow: var(--shadow); }

.toast { position: fixed; z-index: 1200; right: 22px; bottom: 22px; max-width: 420px; padding: 12px 15px; border-radius: 8px; color: white; background: var(--green); box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: 0.18s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--red); }
.skeleton, .startup-error { display: grid; place-items: center; min-height: 100vh; color: var(--muted); }
.startup-error { align-content: center; padding: 30px; text-align: center; }

@media (max-width: 1300px) {
  .app-shell { grid-template-columns: 216px minmax(0, 1fr); }
  .workspace { padding-inline: 18px; }
  .batch-layout { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .dds-form { grid-template-columns: repeat(3, minmax(160px, 1fr)); }
  .fund-kpis, .fund-buckets { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .finance-grid { grid-template-columns: 1fr; }
  .orders-filterbar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .orders-filterbar .filter-count, .orders-filterbar .legend { align-self: center; }
  .orders-table th:nth-child(11), .orders-table td:nth-child(11),
  .orders-table th:nth-child(12), .orders-table td:nth-child(12),
  .orders-table th:nth-child(16), .orders-table td:nth-child(16),
  .orders-table th:nth-child(26), .orders-table td:nth-child(26) { display: none; }
  .dds-table th:nth-child(9), .dds-table td:nth-child(9),
  .dds-table th:nth-child(11), .dds-table td:nth-child(11) { display: none; }
  .orders-table th, .orders-table td,
  .dds-table th, .dds-table td { padding-inline: 6px; }
}

@media (max-width: 1100px) {
  .finance-result-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1100px) {
  .works-table th:nth-child(1) { width: 14%; }
  .works-table th:nth-child(2) { width: 10%; }
  .works-table th:nth-child(3) { width: 8%; }
  .works-table th:nth-child(4) { width: 8%; }
  .works-table th:nth-child(5) { width: 11%; }
  .works-table th:nth-child(6) { width: 12%; }
  .works-table th:nth-child(7) { width: 11%; }
  .works-table th:nth-child(8) { width: 14%; }
  .works-table th:nth-child(9) { width: 12%; }
  .works-table th, .works-table td { padding: 5px 5px; }
  .work-title-line { gap: 5px; }
  .work-edit-actions { gap: 4px; }
  .handoff-grid, .handoff-act { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .handoff-grid .wide, .handoff-act .wide { grid-column: 1 / -1; min-width: 0 !important; }
  .handoff-act strong { grid-column: 1 / -1; }
  .handoff-panel label { min-width: 0; }
}

@media print {
  body { min-width: 0; background: white; }
  .review-banner, .sidebar, .top-actions, .btn, .drawer { display: none !important; }
  .app-shell { display: block; }
  .workspace { padding: 0; }
  .sheet { break-inside: avoid; box-shadow: none; }
}

/* Approved spreadsheet-style workspaces: keep every accounting column available via horizontal scroll. */
.workspace, .sheet, .topbar, .top-actions,
.finance-hero, .finance-grid, .cash-secondary-grid, .batch-layout, .settings-grid,
.form-grid, .drawer-form-grid, .order-card-form, .order-header-grid, .order-main-grid,
.order-item-editor, .orders-filterbar, .dds-form, .work-order-block, .source-details {
  min-width: 0;
}
.topbar > *, .top-actions > *, .finance-hero > *, .finance-grid > *, .cash-secondary-grid > *,
.batch-layout > *, .settings-grid > *, .form-grid > *, .drawer-form-grid > *,
.order-header-grid > *, .order-main-grid > *, .order-item-editor > *, .orders-filterbar > *,
.dds-form > * { min-width: 0; }
fieldset { min-inline-size: 0; }
.table-wrap { max-width: 100%; overflow-x: auto; }
.source-details, .detail-grid > div { max-width: 100%; overflow-x: auto; }
.orders-table { min-width: 2320px; table-layout: auto; }
.orders-table .group-head { display: table-row; }
.orders-table th, .orders-table td { display: table-cell !important; width: auto !important; max-width: 220px; }
.orders-table .sticky-col { min-width: 76px; }
.orders-table .order-money-column { width: 112px !important; min-width: 112px; max-width: 112px; }
.orders-table th.order-money-column { white-space: normal; line-height: 1.2; text-align: right; }
.orders-table tbody tr.order-status-in_progress > td { background: #fffbea !important; }
.orders-table tbody tr.order-status-ready > td { background: #eefaf2 !important; }
.orders-table tbody tr.order-status-cancelled > td { background: #fff1f1 !important; }
.orders-table tbody tr.order-status-awaiting_prepayment > td,
.orders-table tbody tr.order-status-contract > td { background: #eef7ff !important; }
.orders-table tbody tr.order-status-draft > td,
.orders-table tbody tr.order-status-agreement > td { background: #f5f6f8 !important; }
.orders-table tbody tr.order-status-in_progress:hover > td { background: #fff6d2 !important; }
.orders-table tbody tr.order-status-ready:hover > td { background: #e2f6e9 !important; }
.orders-table tbody tr.order-status-cancelled:hover > td { background: #ffe5e5 !important; }
.orders-table tbody tr.order-status-awaiting_prepayment:hover > td,
.orders-table tbody tr.order-status-contract:hover > td { background: #e0f0ff !important; }
.orders-table tbody tr.order-status-draft:hover > td,
.orders-table tbody tr.order-status-agreement:hover > td { background: #e9ebef !important; }
.orders-table tbody tr > td.order-deadline-cell { min-width: 132px; color: #26364c; vertical-align: middle; }
.orders-table tbody tr > td.order-deadline-cell.deadline-safe { color: #245b35; background: #edf8f0 !important; }
.orders-table tbody tr > td.order-deadline-cell.deadline-attention { color: #695300; background: #fff8d9 !important; }
.orders-table tbody tr > td.order-deadline-cell.deadline-soon { color: #784300; background: #fff0dd !important; }
.orders-table tbody tr > td.order-deadline-cell.deadline-urgent { color: #862929; background: #fde8e8 !important; }
.order-deadline-cell .deadline-date { display: block; font-weight: 800; white-space: nowrap; }
.order-deadline-cell small { display: block; margin-top: 2px; color: inherit; font-size: 10px; font-weight: 750; line-height: 1.15; white-space: nowrap; }
.orders-table th:last-child, .orders-table td:last-child { min-width: 285px; max-width: none; overflow: visible; }
.order-row-actions { min-width: max-content; flex-wrap: nowrap; }
.dds-table { min-width: 2050px; table-layout: auto; }
.dds-table th, .dds-table td { display: table-cell !important; width: auto !important; max-width: 240px; }
.statement-table { min-width: 1180px; table-layout: auto; }
.statement-table th, .statement-table td { display: table-cell !important; width: auto !important; }
.cash-table { min-width: 1320px; table-layout: auto; }

.cash-kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.cash-kpi {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: white;
  box-shadow: 0 2px 5px rgba(31, 44, 66, 0.04);
}
.cash-kpi span, .cash-kpi small { display: block; color: var(--muted); font-size: 10px; font-weight: 800; }
.cash-kpi strong { display: block; margin: 7px 0 4px; font-size: 19px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cash-secondary-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr); gap: 16px; }
.cash-secondary-grid .sheet { margin-bottom: 16px; }

.finance-matrix-sheet { overflow: visible; }
.finance-matrix { min-width: 760px; }
.finance-matrix th:not(:first-child), .finance-matrix td:not(:first-child) { text-align: right; }
.finance-matrix .matrix-group td { color: #344258; background: #e9eef6; font-size: 10px; font-weight: 900; letter-spacing: .04em; text-transform: uppercase; }
.report-switches { display: flex; gap: 6px; flex-wrap: wrap; }
.finance-drilldowns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.finance-expenses-card { grid-column: 1 / -1; }

@media (max-width: 1450px) {
  .cash-kpis { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
}

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 196px minmax(0, 1fr); }
  .workspace { padding-inline: 14px; }
  .cash-secondary-grid { grid-template-columns: minmax(0, 1fr); }
  .statement-detail .detail-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 1000px) {
  .cash-kpis { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
  .cash-secondary-grid, .finance-drilldowns { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar, .review-banner + .app-shell .sidebar { position: static; top: auto; height: auto; }
  .nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); overflow: visible; }
  .nav button { min-width: 0; }
  .sidebar-user { margin-top: 0; }
  .workspace { padding: 14px; }
  .dds-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cash-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .review-banner { position: static; height: auto; min-height: 32px; white-space: normal; overflow-wrap: anywhere; }
  .review-banner + .app-shell { padding-top: 0; }
  .topbar, .sheet-toolbar, .section-title { align-items: stretch; flex-direction: column; }
  .top-actions { justify-content: flex-start; }
  .dds-form, .form-grid, .drawer-form-grid, .order-three-grid,
  .order-item-editor, .orders-filterbar, .order-picker, .cash-kpis, .finance-result-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .order-production-grid .order-comment { grid-column: auto; }
  .order-draft-total { align-items: stretch; flex-direction: column; }
  .order-draft-total > span { margin-right: 0; }
  .finance-orders-result-layout { grid-template-columns: minmax(0, 1fr); }
  .finance-withdraw-card { width: min(240px, 100%); }
  .wide, .compact-label, .finance-period-label { width: 100%; min-width: 0 !important; }
  .finance-period-label select { min-width: 0; }
  .order-form-actions { align-items: stretch; flex-direction: column; }
  .drawer { inset: 32px 0 0; width: 100%; }
}
