:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --panel: #fffefa;
  --panel-strong: #ffffff;
  --ink: #24211c;
  --muted: #706a61;
  --line: #ddd6ca;
  --accent: #205c4a;
  --accent-strong: #164536;
  --accent-soft: #dbe9e3;
  --rose: #9e3948;
  --amber: #b8791f;
  --blue: #2f5e88;
  --shadow: 0 18px 40px rgba(56, 48, 36, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(32, 92, 74, 0.07) 1px, transparent 1px),
    linear-gradient(rgba(32, 92, 74, 0.05) 1px, transparent 1px),
    var(--bg);
  background-size: 40px 40px;
  color: var(--ink);
}

body.auth-pending {
  background: var(--bg);
}

body.unauthenticated {
  min-height: 100vh;
  min-height: 100dvh;
}

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

button {
  cursor: pointer;
}

.auth-screen {
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  place-items: center;
  padding: 32px 20px;
}

.auth-card {
  display: grid;
  width: min(100%, 430px);
  gap: 18px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 254, 250, 0.94);
  box-shadow: var(--shadow);
}

.auth-card h1 {
  margin-bottom: 0;
  font-size: 42px;
  line-height: 1.02;
}

.auth-card input {
  height: 48px;
}

.auth-card .primary-action {
  width: fit-content;
  min-width: 116px;
  min-height: 48px;
}

.auth-brand {
  margin-bottom: 6px;
}

.auth-error {
  min-height: 18px;
  margin: -4px 0 0;
  color: var(--rose);
  font-size: 13px;
  font-weight: 750;
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 28px;
  height: 100vh;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: rgba(255, 254, 250, 0.88);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span,
.eyebrow,
.sidebar-note span,
.meta,
.table th {
  color: var(--muted);
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  border-color: var(--line);
  background: var(--panel-strong);
}

.nav-item.active {
  color: var(--accent-strong);
  font-weight: 700;
}

.icon {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  color: var(--accent);
  font-weight: 700;
}

.sidebar-note {
  margin-top: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.sidebar-note strong {
  display: block;
  margin-top: 4px;
}

.main {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.02;
}

h2 {
  margin-bottom: 0;
  font-size: 24px;
}

h3 {
  margin-bottom: 10px;
  font-size: 16px;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  width: min(100%, 760px);
}

.user-pill {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid rgba(32, 92, 74, 0.22);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.search {
  display: flex;
  flex: 1 1 240px;
  align-items: center;
  gap: 8px;
  min-width: 220px;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.search input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
}

.primary-action,
.secondary-action,
.icon-button,
.small-action {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 750;
}

.primary-action {
  padding: 0 16px;
  background: var(--accent);
  color: white;
}

.primary-action:hover {
  background: var(--accent-strong);
}

.secondary-action,
.small-action {
  padding: 0 14px;
  border-color: var(--line);
  background: var(--panel);
  color: var(--ink);
}

.danger-action {
  border-color: rgba(158, 57, 72, 0.34);
  background: #f7e5e7;
  color: #842638;
}

.danger-action:hover {
  border-color: rgba(158, 57, 72, 0.58);
  background: #f2d7da;
}

.icon-button {
  width: 40px;
  background: var(--panel);
  border-color: var(--line);
  font-size: 24px;
  line-height: 1;
}

.view {
  display: grid;
  gap: 18px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.stat,
.panel,
.client-card,
.order-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 254, 250, 0.94);
  box-shadow: var(--shadow);
}

.stat {
  padding: 16px;
}

.stat span,
.field-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 18px;
  align-items: start;
}

.panel {
  min-width: 0;
  padding: 18px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 14px;
}

.list {
  display: grid;
  gap: 14px;
}

.client-card,
.order-card {
  padding: 14px;
  box-shadow: none;
}

.order-card {
  border-width: 2px;
  border-color: #cfc6b7;
  background: rgba(255, 254, 250, 0.98);
  box-shadow: 0 10px 26px rgba(56, 48, 36, 0.08);
}

.order-card + .order-card {
  margin-top: 4px;
}

.interactive-card {
  cursor: pointer;
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.16s ease;
}

.interactive-card:hover {
  border-color: rgba(32, 92, 74, 0.34);
  box-shadow: 0 12px 28px rgba(56, 48, 36, 0.1);
  transform: translateY(-1px);
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.row > * {
  min-width: 0;
}

.meta {
  margin: 4px 0 0;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.tag,
.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
}

.tag {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.status {
  background: #eee8dd;
  color: var(--muted);
}

.status.done {
  background: #dcead5;
  color: #315c25;
}

.status.money {
  background: #f4e5c9;
  color: #744b12;
}

.status.late {
  background: #f2d7da;
  color: #842638;
}

.measure-grid,
.finance-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.measure,
.finance-cell {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.measure strong,
.finance-cell strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

.client-detail {
  display: grid;
  gap: 16px;
}

.client-profile-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.8fr);
  gap: 14px;
  align-items: start;
}

.detail-section {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
}

.detail-section h3 {
  margin-bottom: 0;
}

.back-action {
  margin-bottom: 10px;
}

.client-measure-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.compact-list {
  gap: 8px;
}

.compact-card {
  padding: 12px;
}

.timeline {
  display: grid;
  gap: 10px;
}

.status-flow {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin-top: 14px;
}

.status-step {
  display: grid;
  min-height: 34px;
  place-items: center;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-align: center;
}

.status-step.done {
  border-color: rgba(32, 92, 74, 0.24);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.status-step.active {
  background: var(--accent);
  color: white;
}

.order-stage-actions {
  margin-top: 10px;
}

.order-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.order-actions.inline-actions,
.order-actions.table-actions {
  margin-top: 0;
}

.order-actions.table-actions {
  min-width: 148px;
}

.segmented-control {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.segment {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--ink);
  font-weight: 750;
}

.segment strong {
  display: grid;
  min-width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 999px;
  background: #eee8dd;
  color: var(--muted);
  font-size: 12px;
}

.segment.active {
  border-color: rgba(32, 92, 74, 0.4);
  background: var(--accent);
  color: white;
}

.segment.active strong {
  background: rgba(255, 255, 255, 0.18);
  color: white;
}

.finance-period-picker {
  position: relative;
  justify-self: end;
}

.period-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.calendar-icon {
  position: relative;
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-radius: 5px;
}

.calendar-icon::before {
  position: absolute;
  top: 4px;
  right: 0;
  left: 0;
  height: 2px;
  background: currentColor;
  content: "";
}

.calendar-icon::after {
  position: absolute;
  top: -5px;
  left: 3px;
  width: 8px;
  height: 5px;
  border-right: 2px solid currentColor;
  border-left: 2px solid currentColor;
  content: "";
}

.period-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 70;
  display: grid;
  width: 190px;
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: 0 16px 34px rgba(36, 33, 28, 0.18);
}

.period-option {
  min-height: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-weight: 750;
  text-align: left;
}

.period-option:hover,
.period-option.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.order-finance-panel,
.variable-costs-panel,
.fixed-costs-panel {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
}

.rate-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.compact-form-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.finance-summary {
  margin-bottom: 14px;
}

.expense-list {
  display: grid;
  max-width: 440px;
  gap: 8px;
}

.expense-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(130px, 180px);
  gap: 12px;
  align-items: center;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.expense-row strong {
  color: var(--ink);
  font-size: 18px;
  text-align: right;
}

.expense-input-row input {
  height: 34px;
  text-align: right;
}

.expense-total {
  justify-self: start;
  min-height: 30px;
  margin-top: 4px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #f4e5c9;
  color: #744b12;
  font-size: 14px;
  font-weight: 800;
}

.checkpoint {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.checkpoint:last-child {
  border-bottom: 0;
}

.dot {
  width: 12px;
  height: 12px;
  border: 2px solid var(--accent);
  border-radius: 50%;
}

.dot.done {
  background: var(--accent);
}

.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}

.table th,
.table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.table th {
  text-transform: uppercase;
  letter-spacing: 0;
}

.dialog {
  width: min(760px, calc(100vw - 28px));
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.dialog::backdrop {
  background: rgba(36, 33, 28, 0.38);
}

.dialog-form {
  display: grid;
  gap: 16px;
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 20px;
}

.dialog-header,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  overflow: visible;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--ink);
  outline: 0;
}

input,
select {
  height: 40px;
  padding: 0 10px;
}

textarea {
  min-height: 100px;
  resize: vertical;
  padding: 10px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(32, 92, 74, 0.14);
}

.product-search-field {
  position: relative;
  z-index: 10;
}

.product-search-field:focus-within {
  z-index: 40;
}

.product-suggestions {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  left: 0;
  z-index: 50;
  display: grid;
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: 0 16px 34px rgba(36, 33, 28, 0.18);
}

.product-suggestion {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 54px;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.product-suggestion:last-child {
  border-bottom: 0;
}

.product-suggestion:hover,
.product-suggestion.active {
  background: var(--accent-soft);
}

.product-suggestion strong,
.product-suggestion small {
  display: block;
}

.product-suggestion small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.product-suggestion-price {
  flex: 0 0 auto;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
}

.product-suggestion-empty {
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
}

.empty-state {
  padding: 28px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 254, 250, 0.68);
  color: var(--muted);
  text-align: center;
}

.calculation-block {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.form-calculation-block {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.52);
}

.calculation-strip,
.calculator-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.calculation-snapshot,
.calculation-lines,
.calculator-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
}

.calculation-snapshot {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.calculation-lines {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.cost-calculator {
  display: grid;
  gap: 14px;
}

.calculator-section {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.calculator-grid,
.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.calculator-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.calculator-grid label:last-child {
  grid-column: span 2;
}

.summary-grid.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.driver-list,
.manual-list {
  display: grid;
  gap: 8px;
}

.driver-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  gap: 10px;
  align-items: center;
  min-height: 54px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.driver-row.selected {
  border-color: rgba(32, 92, 74, 0.38);
  background: var(--accent-soft);
}

.driver-check {
  display: flex;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

.driver-check input[type="checkbox"] {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.driver-check small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.quantity-field {
  font-size: 12px;
}

.manual-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) 74px 120px minmax(150px, 1fr) 40px;
  gap: 8px;
  align-items: center;
}

.manual-row input,
.manual-row select {
  min-width: 0;
}

.compact-button {
  width: 40px;
  height: 40px;
  min-height: 40px;
  font-size: 22px;
}

.calculator-comments {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.calculator-comments textarea {
  min-height: 72px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 16px;
  }

  .nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .nav-item {
    justify-content: center;
  }

  .nav-item .icon,
  .sidebar-note {
    display: none;
  }

  .main {
    padding: 18px;
  }

  .topbar,
  .topbar-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
  }

  .search {
    min-width: 0;
  }

  .stats-grid,
  .content-grid,
  .client-profile-grid,
  .calculator-grid,
  .summary-grid,
  .summary-grid.compact,
  .rate-grid,
  .compact-form-grid {
    grid-template-columns: 1fr;
  }

  .calculator-grid label:last-child {
    grid-column: auto;
  }
}

@media (max-width: 760px) {
  body.authenticated {
    background-size: 32px 32px;
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    inset: auto 0 0;
    z-index: 80;
    height: auto;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    border-right: 0;
    background: rgba(255, 254, 250, 0.94);
  }

  .sidebar .brand,
  .sidebar-note {
    display: none;
  }

  .nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  body.finance-hidden .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nav-item {
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    min-height: 58px;
    padding: 6px 4px;
    font-size: 11px;
    line-height: 1.15;
    text-align: center;
  }

  .nav-item .icon {
    display: grid;
    width: 20px;
    height: 20px;
  }

  .main {
    padding: 14px 14px calc(92px + env(safe-area-inset-bottom));
  }

  .topbar {
    gap: 12px;
    margin-bottom: 14px;
  }

  .topbar h1 {
    font-size: 30px;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .search,
  .user-pill {
    grid-column: 1 / -1;
  }

  .user-pill {
    justify-content: center;
  }

  .topbar-actions .primary-action,
  .topbar-actions .secondary-action {
    min-width: 0;
    padding-inline: 10px;
  }

  .segmented-control {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .segment {
    width: 100%;
  }

  .finance-period-picker {
    justify-self: stretch;
  }

  .period-trigger {
    justify-content: center;
    width: 100%;
  }

  .period-menu {
    right: 0;
    left: 0;
    width: auto;
  }

  .panel,
  .client-card,
  .order-card,
  .stat {
    box-shadow: none;
  }

  .order-card {
    border-width: 2px;
    border-color: #c8bead;
    box-shadow: 0 8px 22px rgba(56, 48, 36, 0.1);
  }

  .panel {
    padding: 14px;
  }

  .detail-section {
    padding: 12px;
  }

  .stat {
    padding: 14px;
  }

  .stat strong {
    font-size: 24px;
  }

  .row {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .dialog {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .dialog-form {
    max-height: 100dvh;
    padding: 16px 16px calc(18px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 620px) {
  .auth-screen {
    align-items: start;
    padding: 16px;
  }

  .auth-card {
    gap: 14px;
    padding: 20px;
  }

  .auth-card h1 {
    font-size: 34px;
  }

  .auth-card .primary-action {
    width: 100%;
  }

  .nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  body.finance-hidden .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid,
  .measure-grid,
  .client-measure-grid,
  .finance-grid,
  .calculator-comments,
  .driver-row,
  .manual-row,
  .expense-row,
  .status-flow {
    grid-template-columns: 1fr;
  }

  .expense-row strong,
  .expense-input-row input {
    text-align: left;
  }

  .checkpoint {
    grid-template-columns: 18px minmax(0, 1fr);
  }

  .checkpoint .status {
    grid-column: 2;
    width: fit-content;
  }
}

@media (max-width: 420px) {
  .topbar-actions {
    grid-template-columns: 1fr;
  }

  .topbar h1 {
    font-size: 28px;
  }

  .panel-header,
  .dialog-header,
  .dialog-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .dialog-actions .primary-action,
  .dialog-actions .secondary-action {
    width: 100%;
  }
}
