:root {
  --bg: #f8f4ec;
  --surface: #fffdf8;
  --surface-strong: #eee3cf;
  --text: #2b2925;
  --muted: #746d62;
  --line: #d8c7a7;
  --brand: #ad8b4f;
  --brand-dark: #34312c;
  --gold: #b6975c;
  --sage: #7f927d;
  --danger: #8b5e54;
  --shadow: 0 14px 34px rgba(62, 52, 37, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

body.auth-pending .app-header,
body.auth-pending main,
body.auth-login .app-header,
body.auth-login main {
  display: none;
}

body.authenticated .auth-screen {
  display: none;
}

.auth-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.auth-card {
  display: grid;
  gap: 18px;
  width: min(100%, 420px);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}

.auth-card label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
  text-align: left;
}

.auth-card input {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf0;
  color: var(--text);
}

.auth-logo-frame {
  width: 138px;
  margin: 0 auto;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 50%;
}

.auth-logo-frame img {
  display: block;
  width: 102%;
  height: auto;
  margin-left: -1.5%;
  transform: translateY(-16%);
}

.auth-status {
  min-height: 1.3em;
  margin: 0;
  color: var(--danger);
  font-weight: 700;
}

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

.app-header {
  display: grid;
  grid-template-columns: minmax(92px, 1fr) auto minmax(44px, 1fr);
  align-items: center;
  gap: 18px;
  padding: 7px clamp(16px, 4vw, 46px);
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.user-menu {
  position: relative;
  justify-self: end;
}

.user-menu-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #eadfc9;
  color: var(--brand-dark);
  cursor: pointer;
  font-size: 1.05rem;
  box-shadow: 0 8px 18px rgba(62, 52, 37, 0.08);
}

.user-menu-button:hover {
  background: #dcc58f;
}

.user-menu-panel {
  position: absolute;
  z-index: 40;
  top: calc(100% + 9px);
  right: 0;
  width: min(78vw, 260px);
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.user-email {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

.user-menu-action {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eadfc9;
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
  text-align: center;
}

.user-menu-action:hover {
  background: #dcc58f;
}

.work-logo-frame {
  justify-self: center;
  width: clamp(58px, 9vw, 78px);
  flex: 0 0 auto;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 50%;
}

.work-logo-frame img {
  display: block;
  width: 102%;
  height: auto;
  margin-left: -1.5%;
  transform: translateY(-16%);
}

.app-header .tabs {
  position: static;
  padding: 0;
  border: 0;
  background: transparent;
  backdrop-filter: none;
  overflow: visible;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-family: Arial, Helvetica, sans-serif;
  font-size: clamp(2rem, 5vw, 3.8rem);
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.2rem, 2.5vw, 1.55rem);
}

h3 {
  margin-bottom: 8px;
  font-size: 1rem;
}

.header-stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.header-stats span {
  min-width: 110px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 20px rgba(62, 52, 37, 0.08);
  color: var(--muted);
}

.header-stats strong {
  display: block;
  color: var(--brand);
  font-size: 1.45rem;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 8px;
  padding: 10px clamp(16px, 4vw, 46px);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgba(248, 244, 236, 0.95);
  backdrop-filter: blur(16px);
  overflow-x: auto;
}

.tabs.home-nav-hidden {
  display: none;
}

.tab-button,
.ghost-button,
.primary-button,
.small-button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.tab-button {
  min-width: 108px;
  padding: 11px 16px;
  border: 1px solid var(--line);
  background: #eadfc9;
  color: var(--text);
  font-weight: 700;
}

.tab-button.active {
  background: #d9c18f;
  color: var(--brand-dark);
}

.tab-button:hover,
.ghost-button:hover,
.primary-button:hover,
.small-button:hover {
  transform: translateY(-1px);
}

main {
  padding: 24px clamp(16px, 4vw, 46px) 42px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.home-active main {
  padding-top: 16px;
}

.home-brand-lockup {
  display: grid;
  justify-items: center;
  width: auto;
  margin: 0 auto 16px;
  text-align: center;
}

.home-logo-frame {
  width: clamp(150px, 22vw, 250px);
  aspect-ratio: 1;
  overflow: hidden;
  border: 0;
  border-radius: 50%;
  background: transparent;
  box-shadow: none;
}

.home-logo-frame img {
  display: block;
  width: 102%;
  height: auto;
  margin-left: -1.5%;
  transform: translateY(-16%);
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  width: min(100%, 560px);
  margin: 0 auto;
}

.home-module-card {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 165px;
  padding: 20px;
  border: 1px solid #b6975c;
  border-radius: 8px;
  background: #eadfc9;
  box-shadow: 0 10px 24px rgba(62, 52, 37, 0.1);
  color: #242320;
  cursor: pointer;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 1.18rem;
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
  transition: transform 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.home-status-card {
  gap: 8px;
}

.home-card-title {
  display: block;
}

.home-card-count {
  display: block;
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1;
}

.home-status-pending .home-card-count {
  color: #b8860b;
}

.home-status-prepared .home-card-count {
  color: #52735a;
}

.home-status-completed .home-card-count {
  color: #242320;
}

.home-module-card:hover {
  transform: translateY(-3px);
  background: #dfcda8;
  box-shadow: 0 16px 32px rgba(62, 52, 37, 0.14);
}

.backup-module-card {
  gap: 8px;
  border-color: #b6975c;
  background: #592532;
  color: #fff9ed;
  box-shadow: 0 10px 24px rgba(64, 27, 37, 0.18);
}

.backup-module-card:hover {
  background: #6b2d3c;
  box-shadow: 0 16px 32px rgba(64, 27, 37, 0.24);
}

.home-card-icon {
  font-size: 1.55rem;
  line-height: 1;
}

.module-grid {
  display: grid;
  grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.form-page {
  width: min(100%, 620px);
  margin: 0 auto;
}

.form-page .form-panel {
  position: static;
}

.form-panel,
.list-panel,
.calendar-day {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.form-panel,
.list-panel {
  padding: 18px;
}

.form-panel {
  position: sticky;
  top: 74px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.section-heading.wide {
  align-items: end;
}

.order-count {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 8px 0 0;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.order-count strong {
  color: var(--brand-dark);
  font-size: 0.95rem;
}

.search-result-count {
  margin: 6px 0 0;
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 700;
}

label {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 400;
}

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

input,
select {
  min-height: 42px;
  padding: 9px 11px;
}

textarea {
  resize: vertical;
  padding: 10px 11px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(173, 139, 79, 0.16);
}

input[readonly] {
  background: #f2eadc;
  color: var(--brand-dark);
  font-weight: 800;
}

.field-warning {
  color: var(--danger);
  font-weight: 700;
}

.price-settings {
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.price-settings-title {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.price-settings-title h3 {
  margin-bottom: 4px;
  color: var(--brand);
}

.price-table-wrap {
  padding: 0 14px 14px;
  overflow-x: auto;
}

.price-table {
  width: 100%;
  border-collapse: collapse;
}

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

.price-table th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.price-table td:first-child {
  font-weight: 700;
}

.price-table th:last-child,
.price-table td:last-child {
  width: 155px;
}

.price-input {
  display: grid;
  grid-template-columns: minmax(80px, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.price-input input {
  text-align: right;
}

.price-input span {
  color: var(--brand);
  font-weight: 800;
}

.two-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.time-select-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.order-products-section {
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.order-products-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.order-items {
  display: grid;
  gap: 10px;
}

.order-item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 90px 130px auto;
  gap: 10px;
  align-items: end;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.order-item-calculation {
  display: grid;
  gap: 4px;
  min-height: 42px;
  align-content: center;
  color: var(--muted);
  font-size: 0.76rem;
}

.order-item-calculation strong {
  color: var(--brand);
  font-size: 0.9rem;
}

.order-item-row:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.order-item-row label {
  margin-bottom: 0;
}

.remove-order-item {
  min-height: 42px;
}

.add-product-button {
  display: block !important;
  visibility: visible !important;
  position: static !important;
  opacity: 1 !important;
  width: 100%;
  min-height: 42px;
  margin: 0 0 14px;
  border: 1px solid var(--brand);
  border-radius: 8px;
  background: var(--surface);
  color: var(--brand-dark);
  cursor: pointer;
  font-weight: 800;
}

.add-product-button:hover {
  background: #e2d1ae;
  color: var(--brand-dark);
}

.primary-button {
  width: 100%;
  min-height: 46px;
  padding: 12px 16px;
  background: #d9c18f;
  color: var(--brand-dark);
  font-weight: 800;
}

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

.editing-order-notice {
  margin: 4px 0 10px;
  color: var(--muted);
  font-size: 0.84rem;
  text-align: right;
}

.editing-order-notice strong {
  color: var(--brand);
}

.order-form-actions .ghost-button {
  min-height: 46px;
}

.whatsapp-button {
  border-color: #b9a982;
  background: #f3ecdc;
  color: var(--brand-dark);
}

.whatsapp-button:hover {
  background: #e5d6b8;
}

.order-saved-action.is-disabled,
.order-saved-action.is-disabled:hover {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  background: #f3ecdc;
}

.ghost-button {
  padding: 9px 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--brand-dark);
  font-size: 0.86rem;
  font-weight: 800;
}

.small-button {
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--brand-dark);
  font-size: 0.84rem;
  font-weight: 800;
}

.small-button.danger {
  color: var(--danger);
}

.ghost-button.danger {
  border-color: rgba(139, 94, 84, 0.45);
  color: var(--danger);
}

.ghost-button.danger:hover {
  border-color: var(--danger);
  background: #f7eeea;
}

.edit-order-button {
  border-color: var(--gold);
}

.search-input {
  width: min(100%, 360px);
  max-width: 360px;
}

.criteria-search {
  display: grid;
  gap: 8px;
  width: min(100%, 360px);
}

.criteria-search .search-input {
  width: 100%;
  max-width: none;
}

.search-criteria {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
  padding: 3px;
  border: 1px solid #ddc9a8;
  border-radius: 8px;
  background: #f5eee1;
  box-shadow: inset 0 1px 2px rgba(62, 47, 29, 0.05);
}

.search-criterion-button {
  min-width: 0;
  min-height: 36px;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #51483f;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 750;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, box-shadow 150ms ease, color 150ms ease;
}

.search-criterion-button:hover {
  border-color: #d3b985;
  background: #fbf7ef;
}

.search-criterion-button.active,
.search-criterion-button.active:hover {
  border-color: #b68b45;
  background: #d7bd8a;
  color: #2f2923;
  box-shadow: 0 2px 6px rgba(76, 56, 28, 0.16);
}

.search-criterion-button:focus-visible {
  outline: 2px solid #9f7839;
  outline-offset: 2px;
}

.delivered-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.delivered-toolbar .primary-button {
  width: auto;
  min-height: 42px;
  white-space: nowrap;
}

.delivered-history {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.delivered-history h3 {
  margin: 0 0 12px;
  color: var(--brand);
  font-size: 1rem;
}

.cards-list {
  display: grid;
  gap: 12px;
}

.data-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.card-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.card-title {
  margin-bottom: 4px;
  font-weight: 800;
}

.record-code {
  color: var(--brand);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.order-code-display {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  width: fit-content;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.order-code-display strong {
  color: var(--brand);
  font-size: 1rem;
}

.calendar-client {
  display: grid;
  gap: 0.2rem;
}

.card-subtitle,
.muted {
  color: var(--muted);
}

.card-subtitle {
  margin: 0;
  font-size: 0.9rem;
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0;
}

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

.client-history {
  margin: 14px 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.client-history h3 {
  margin: 0 0 10px;
  color: var(--brand);
  font-size: 0.9rem;
}

.client-history-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.product-summary {
  margin: 12px 0;
  padding: 11px 12px;
  border-left: 3px solid var(--gold);
  background: #f5eee2;
}

.product-summary > strong {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
}

.product-summary ul {
  display: grid;
  gap: 4px;
  margin: 0;
  padding-left: 18px;
}

.product-price-line {
  line-height: 1.55;
}

.product-unit-price {
  color: var(--muted);
}

.product-price-line > strong {
  color: var(--brand);
}

.product-summary.compact {
  margin: 0;
  padding: 0;
  border-left: 0;
  background: transparent;
}

.detail {
  padding: 10px;
  border-radius: 8px;
  background: #f5eee2;
}

.detail span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.order-details {
  display: grid;
  gap: 10px;
  margin: 12px 0;
}

.order-detail-row {
  display: grid;
  gap: 10px;
}

.order-date-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.order-financial-row {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.55fr);
}

.order-context-row {
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
}

.order-context-row.with-client-notes {
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.6fr) minmax(0, 1.6fr);
}

.amount-value {
  font-size: 1rem;
}

.pending-payment {
  border: 1px solid var(--brand);
  background: #eadfc9;
  box-shadow: 0 7px 18px rgba(62, 52, 37, 0.1);
}

.pending-payment span {
  color: var(--brand);
}

.pending-payment strong {
  color: var(--brand-dark);
  font-size: 1.3rem;
}

.card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  align-items: end;
}

.status-control {
  width: min(240px, 100%);
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  margin-bottom: 0;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 999px;
  background: #e7c96f;
  color: #594817;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.status.pendiente {
  background: #e7c96f;
  color: #594817;
}

.status.listo {
  background: #9eb99b;
  color: #2f4930;
}

.status.entregado {
  background: #66645f;
  color: #fffaf0;
}

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

.calendar-legend {
  display: flex;
  gap: 10px 18px;
  align-items: center;
  flex-wrap: wrap;
  margin: -4px 0 14px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.78);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.calendar-legend span {
  display: inline-flex;
  gap: 7px;
  align-items: center;
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border: 1px solid rgba(54, 50, 43, 0.18);
  border-radius: 50%;
}

.legend-swatch.pendiente {
  background: #e7c96f;
}

.legend-swatch.listo {
  background: #9eb99b;
}

.legend-swatch.entregado {
  background: #66645f;
}

.calendar-day {
  overflow: hidden;
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #e4d5b9;
  color: var(--text);
}

.calendar-header h3 {
  margin: 0;
}

.calendar-count {
  padding: 5px 10px;
  border: 1px solid rgba(91, 74, 43, 0.2);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.55);
  white-space: nowrap;
}

.calendar-orders {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.calendar-row {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(180px, 1.5fr) minmax(210px, auto) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.calendar-row.calendar-pendiente {
  border-color: #d2b45d;
  background: #fff4cf;
}

.calendar-row.calendar-listo {
  border-color: #9db49a;
  background: #e7f0e5;
}

.calendar-row.calendar-entregado {
  border-color: #88857f;
  background: #e7e5e1;
}

.calendar-row.calendar-pendiente .status {
  background: #e7c96f;
  color: #594817;
}

.calendar-row.calendar-listo .status {
  background: #9eb99b;
  color: #2f4930;
}

.calendar-row.calendar-entregado .status {
  background: #66645f;
  color: #fffaf0;
}

.calendar-amounts {
  display: grid;
  gap: 5px;
}

.calendar-amounts div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  white-space: nowrap;
}

.calendar-amounts span {
  color: var(--muted);
  font-size: 0.78rem;
}

.calendar-amounts strong {
  color: var(--text);
  font-size: 0.84rem;
}

.billing-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.billing-block {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.billing-block h3 {
  margin: 0;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #e4d5b9;
  color: var(--text);
}

.billing-list {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.billing-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.billing-row > div {
  display: grid;
  gap: 3px;
}

.billing-row span {
  color: var(--muted);
  font-size: 0.78rem;
}

.billing-amount {
  color: var(--brand);
  white-space: nowrap;
}

.billing-total {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  border-top: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 0.86rem;
}

.billing-total strong {
  color: var(--brand-dark);
}

.billing-empty {
  padding: 20px 10px;
  color: var(--muted);
  text-align: center;
}

.backup-block {
  display: grid;
  gap: 18px;
  margin-top: 20px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.backup-page {
  width: min(100%, 980px);
  margin: 0 auto;
}

.backup-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.backup-block h3 {
  margin-bottom: 6px;
}

.backup-block p {
  margin-bottom: 0;
}

.backup-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.backup-actions .primary-button,
.backup-actions .ghost-button {
  width: auto;
  min-height: 42px;
}

.backup-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.backup-fallback {
  display: grid;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.backup-fallback label {
  margin-bottom: 0;
  font-weight: 800;
}

.backup-fallback textarea {
  min-height: 220px;
  resize: vertical;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.78rem;
  line-height: 1.45;
}

.backup-copy-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

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

.hidden {
  display: none;
}

@media (max-width: 920px) {
  .module-grid {
    grid-template-columns: 1fr;
  }

  .form-panel {
    position: static;
  }

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

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

  .billing-grid {
    grid-template-columns: 1fr;
  }

}

@media (max-width: 650px) {
  .order-form-actions {
    grid-template-columns: 1fr;
  }

  .home-active main {
    padding-top: 6px;
  }

  .home-brand-lockup {
    margin-bottom: 12px;
  }

  .home-logo-frame {
    width: clamp(110px, 32vw, 140px);
  }

  .home-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 0;
  }

  .home-module-card {
    min-height: 92px;
    padding: 12px;
    font-size: 0.9rem;
    overflow-wrap: anywhere;
  }

  .app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .header-stats {
    justify-content: start;
  }

  .section-heading,
  .section-heading.wide,
  .card-top {
    align-items: stretch;
    flex-direction: column;
  }

  .search-input {
    max-width: none;
  }

  .delivered-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .delivered-toolbar .primary-button {
    width: 100%;
  }

  .two-columns,
  .price-grid,
  .order-item-row,
  .order-date-row,
  .order-financial-row,
  .order-context-row,
  .details-grid,
  .details-grid.compact,
  .client-history-grid,
  .calendar-row {
    grid-template-columns: 1fr;
  }

  .order-context-row.with-client-notes {
    grid-template-columns: 1fr;
  }

  .order-products-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .card-actions {
    justify-content: stretch;
  }

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

  .backup-actions .primary-button,
  .backup-actions .ghost-button {
    width: 100%;
  }

  .small-button,
  .ghost-button,
  .status-control {
    width: 100%;
  }
}
