:root {
  color-scheme: light;
  --ink: #30252a;
  --muted: #7a6c71;
  --paper: #fffaf7;
  --surface: #ffffff;
  --line: #eadfdc;
  --berry: #8a3d55;
  --berry-dark: #65283b;
  --berry-soft: #f7e8ed;
  --mint: #dcece3;
  --green: #327052;
  --shadow: 0 18px 50px rgba(75, 48, 57, 0.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--paper); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 3px solid #d589a0; outline-offset: 2px; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 248px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 28px 18px; background: #442332; color: white; display: flex; flex-direction: column; overflow-y: auto; }
.brand { color: white; text-decoration: none; display: flex; align-items: center; gap: 12px; padding: 0 10px 30px; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 14px; background: #ffd9df; color: var(--berry-dark); font-weight: 800; }
.brand strong, .brand small { display: block; }
.brand small { opacity: .65; margin-top: 2px; }
nav { display: grid; gap: 7px; }
nav a { color: rgba(255,255,255,.72); text-decoration: none; padding: 12px 14px; border-radius: 12px; }
nav a:hover, nav a.active { background: rgba(255,255,255,.12); color: white; }
.sidebar-action { margin-top: auto; color: white; border-color: rgba(255,255,255,.2) !important; }
.sidebar-close, .nav-backdrop { display: none; }
.nav-backdrop[hidden] { display: none; }
main { min-width: 0; }
.topbar { min-height: 104px; padding: 24px clamp(22px, 4vw, 56px); display: flex; align-items: center; gap: 18px; border-bottom: 1px solid var(--line); background: rgba(255,250,247,.9); position: sticky; top: 0; z-index: 5; backdrop-filter: blur(12px); }
.topbar h1 { margin: 2px 0 0; font-family: Georgia, serif; font-size: clamp(1.65rem, 3vw, 2.25rem); }
.eyebrow { margin: 0; color: var(--berry); text-transform: uppercase; font-weight: 750; letter-spacing: .12em; font-size: .7rem; }
.today { margin-left: auto; color: var(--muted); font-size: .9rem; }
.icon-button { display: none; border: 0; background: transparent; font-size: 1.4rem; }
.content { padding: 34px clamp(22px, 4vw, 56px) 70px; max-width: 1440px; }
.hero { padding: clamp(25px, 5vw, 48px); background: linear-gradient(135deg, #fff 0%, #f8e9ed 100%); border: 1px solid var(--line); border-radius: 26px; box-shadow: var(--shadow); display: flex; justify-content: space-between; gap: 30px; align-items: center; }
.hero h2 { max-width: 650px; font-family: Georgia, serif; font-size: clamp(2rem, 4vw, 3.6rem); line-height: 1.02; margin: 8px 0 16px; }
.hero p { color: var(--muted); max-width: 650px; line-height: 1.6; }
.hero-actions, .page-actions, .form-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; margin: 22px 0; }
.stat, .card { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 8px 28px rgba(75,48,57,.05); }
.stat { padding: 20px; }
.stat small { display: block; color: var(--muted); margin-bottom: 8px; }
.stat strong { font-family: Georgia, serif; font-size: 1.7rem; }
.stat .positive { color: var(--green); }
.card { padding: 24px; }
.card h2, .card h3 { margin-top: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.section-heading h2 { margin: 0; font-family: Georgia, serif; font-size: 2rem; }
.section-heading p { margin: 5px 0 0; color: var(--muted); }
.primary, .secondary, .ghost, .danger { padding: 11px 16px; border-radius: 11px; font-weight: 700; border: 1px solid transparent; }
.primary { background: var(--berry); color: white; }
.primary:hover { background: var(--berry-dark); }
.secondary { background: var(--berry-soft); color: var(--berry-dark); }
.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.danger { background: #fff0f0; color: #a33131; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; }
td.actions { text-align: right; }
.pill { display: inline-block; padding: 5px 9px; border-radius: 999px; background: var(--mint); color: var(--green); font-size: .78rem; font-weight: 750; }
.empty { text-align: center; padding: 55px 20px; color: var(--muted); }
.empty .empty-icon { display: block; font-size: 2rem; margin-bottom: 8px; }
dialog { border: 0; border-radius: 22px; padding: 0; width: min(680px, calc(100% - 30px)); max-height: 90vh; box-shadow: 0 30px 100px rgba(50,25,35,.3); }
dialog::backdrop { background: rgba(45,28,35,.48); backdrop-filter: blur(3px); }
.dialog-body { padding: 28px; overflow-y: auto; max-height: 90vh; }
.dialog-body h2 { margin: 0 0 5px; font-family: Georgia, serif; }
.dialog-body > p { margin: 0 0 22px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { min-width: 0; display: grid; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field[hidden] { display: none; }
label { font-size: .83rem; font-weight: 700; }
input, select, textarea { width: 100%; padding: 11px 12px; border: 1px solid #d9cdca; border-radius: 10px; background: white; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(138,61,85,.14); border-color: var(--berry); }
.form-actions { justify-content: flex-end; margin-top: 24px; }
.recipe-lines { display: grid; gap: 10px; }
.combo-items { list-style: none; padding: 0; margin: 16px 0; }
.combo-items li { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.combo-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.combo-line { display: grid; grid-template-columns: minmax(0, 1fr) 90px 40px; gap: 8px; align-items: end; }
.combo-line button { min-height: 42px; }
.combo-card .hero-actions { margin-top: 16px; }
.combo-card p { overflow-wrap: anywhere; }
@media (max-width: 600px) {
  .combo-line { grid-template-columns: minmax(0, 1fr) 72px 40px; }
  .combo-card .card-title-row { flex-wrap: wrap; }
}
.recipe-line { display: grid; grid-template-columns: minmax(0, 1fr) 110px 110px 40px; gap: 8px; align-items: end; }
.recipe-line button { height: 42px; border: 0; border-radius: 10px; background: #fff0f0; color: #a33131; }
.optional-box { background: #faf6f4; border-radius: 14px; padding: 16px; }
.optional-box h3 { font-size: 1rem; margin: 0 0 5px; }
.optional-box p { color: var(--muted); font-size: .84rem; margin: 0 0 14px; }
.cost-preview { padding: 16px; border-radius: 14px; background: var(--mint); display: flex; justify-content: space-between; gap: 15px; }
.toast { position: fixed; right: 24px; bottom: 24px; transform: translateY(130%); opacity: 0; background: #2f2529; color: white; padding: 13px 18px; border-radius: 12px; transition: .25s; z-index: 30; }
.toast.show { transform: translateY(0); opacity: 1; }
.muted { color: var(--muted); }
.warning { color: #8a5d10; background: #fff8e5; border: 1px solid #efdcaa; padding: 12px 14px; border-radius: 12px; }
.compact-button { padding: 7px 11px; font-size: .8rem; }
.card-title-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.production-preview { display: grid; gap: 12px; }
.production-row { cursor: pointer; }
.production-row:hover { background: #faf6f4; }
.production-name { border: 0; padding: 4px 0; background: transparent; color: var(--berry); font: inherit; font-weight: 750; text-align: left; cursor: pointer; }
.production-name small { display: block; margin-top: 3px; color: var(--muted); font-size: .72rem; font-weight: 500; }
.production-name:focus-visible { outline: 3px solid rgba(138,61,85,.3); border-radius: 4px; }
.breakdown { display: grid; gap: 5px; }
.breakdown h3 { margin: 20px 0 7px; font-size: 1rem; }
.breakdown-line { display: flex; justify-content: space-between; align-items: start; gap: 18px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.breakdown-line span { min-width: 0; }
.breakdown-line small { display: block; margin-top: 4px; color: var(--muted); font-size: .78rem; }
.breakdown-line strong { flex-shrink: 0; }
.breakdown-line.subtotal { font-weight: 700; }
.breakdown-line.total { margin-top: 12px; padding: 14px; border: 0; border-radius: 12px; background: var(--mint); font-weight: 800; }
.requirement-list { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.requirement { display: flex; justify-content: space-between; gap: 16px; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: .88rem; }
.requirement:last-child { border: 0; }
.requirement.enough span:last-child { color: var(--green); }
.requirement.missing span:last-child { color: #a33131; font-weight: 700; }
.row-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 7px; }
.stock-history { margin-top: 18px; }
.stock-history > p { margin-top: -5px; }
.history-note { display: block; margin-top: 4px; white-space: normal; }
.home-cost-field { margin-top: 12px; }
.home-cost-field label { color: var(--ink); }
.home-cost-field small { font-weight: 400; }
button:disabled { opacity: .45; cursor: not-allowed; }
.voided-row { opacity: .65; }
.client-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.client-card { display: grid; gap: 8px; }
.client-card h2 { margin: 6px 0 0; font-family: Georgia, serif; }
.client-card a { color: var(--berry); font-weight: 700; text-decoration: none; }
.client-avatar { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; background: var(--berry-soft); color: var(--berry-dark); font-weight: 850; }
.agenda { display: grid; gap: 20px; }
.agenda-day { display: grid; grid-template-columns: 170px 1fr; gap: 20px; }
.agenda-day > header { padding: 18px; border-radius: 16px; background: #442332; color: white; height: fit-content; }
.agenda-day > header span, .agenda-day > header strong { display: block; }
.agenda-day > header span { opacity: .7; font-size: .8rem; text-transform: capitalize; }
.agenda-day > header strong { margin-top: 4px; }
.agenda-day > div { display: grid; gap: 10px; }
.agenda-order { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 18px 20px; background: white; border: 1px solid var(--line); border-radius: 16px; }
.agenda-order h3 { margin: 8px 0 2px; }
.agenda-order p { margin: 0; color: var(--muted); }
.agenda-balance { display: grid; text-align: right; }
.agenda-balance small { color: var(--muted); }
.backup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
.backup-card { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: start; }
.backup-card h2 { margin: 2px 0 8px; font-family: Georgia, serif; }
.backup-card p { margin: 0; color: var(--muted); line-height: 1.55; }
.backup-card button { grid-column: 1 / -1; }
.backup-icon { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 14px; background: var(--berry-soft); color: var(--berry); font-size: 1.45rem; font-weight: 900; }
.data-summary > div { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 18px 0; }
.data-summary span { padding: 13px; border-radius: 12px; background: #faf6f4; text-align: center; }
.data-summary strong, .data-summary small { display: block; }
.data-summary strong { font-family: Georgia, serif; font-size: 1.4rem; }
.data-summary small { color: var(--muted); margin-top: 4px; }
.account-state { max-width: 680px; margin: 30px auto; text-align: center; display: grid; justify-items: center; gap: 14px; padding: clamp(30px, 6vw, 60px); }
.account-state h2, .account-state p { margin: 0; }
.account-state p { color: var(--muted); line-height: 1.6; }
.login-card { max-width: 470px; margin: 20px auto; }
.login-card form { display: grid; gap: 16px; }
.form-error { color: #a33131; min-height: 1.3em; margin: 0; }
.subscription-active, .subscription-grace { background: var(--mint); color: var(--green); }
.subscription-read_only { background: #fff0d5; color: #8a5d10; }
.subscription-suspended { background: #f3e8e8; color: #8a4545; }
.positive-text { color: var(--green) !important; font-weight: 700; }
.spinner { width: 40px; height: 40px; border: 4px solid var(--berry-soft); border-top-color: var(--berry); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.order-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 14px; align-items: end; margin: 0 0 18px; }
.filter-bar .field { min-width: min(220px, 100%); }
.filter-bar select, .filter-bar input { width: 100%; }
.pagination { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px; margin-top: 18px; }
.pagination span { color: var(--muted); font-size: .9rem; }
.order-card-head { display: flex; justify-content: space-between; gap: 18px; }
.order-card h2 { margin: 10px 0 3px; font-family: Georgia, serif; }
.order-card p { margin: 0; color: var(--muted); }
.order-card time { font-weight: 750; color: var(--berry); }
.status { display: inline-block; width: fit-content; padding: 5px 9px; border-radius: 999px; font-size: .72rem; font-weight: 800; background: #eee; color: #555; }
.status-confirmado, .status-listo { background: #e7edf9; color: #355a91; }
.status-produccion { background: #fff0d5; color: #8a5d10; }
.status-entregado { background: var(--mint); color: var(--green); }
.status-cancelado { background: #f3e8e8; color: #8a4545; }
.order-finance { margin: 22px 0; padding: 14px 0; display: grid; grid-template-columns: repeat(3, 1fr); border-block: 1px solid var(--line); }
.order-finance div { display: grid; gap: 4px; }
.order-finance small { color: var(--muted); }
.order-notes { padding: 12px; background: #faf6f4; border-radius: 10px; }
.order-actions { margin-top: 18px; display: flex; align-items: end; justify-content: space-between; gap: 12px; }
.order-actions label { display: grid; gap: 5px; }
.order-actions select { min-width: 155px; padding-block: 8px; }
.sale-linked { display: block; margin-top: 14px; color: var(--green); font-weight: 700; }
.order-list { display: grid; }
.order-row { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.order-row:last-child { border: 0; }
.order-row > div { display: grid; gap: 5px; }
.order-row > div:last-child { justify-items: end; }
.order-row small { color: var(--muted); }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; z-index: 20; width: min(320px, 86vw); height: 100dvh; overflow-y: auto; padding-top: 72px; transform: translateX(-102%); transition: transform .25s; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { position: absolute; top: 16px; right: 18px; display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid rgba(255,255,255,.3); border-radius: 12px; color: white; background: transparent; font-size: 1.8rem; }
  .nav-backdrop { position: fixed; inset: 0; display: block; z-index: 19; width: 100%; height: 100dvh; border: 0; background: rgba(26, 16, 22, .55); }
  body.menu-open { overflow: hidden; }
  .icon-button { display: grid; place-items: center; flex: 0 0 44px; width: 44px; height: 44px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .order-grid { grid-template-columns: 1fr; }
  .client-grid { grid-template-columns: 1fr 1fr; }
  .data-summary > div { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 600px) {
  .today { display: none; }
  .topbar { min-height: 78px; padding: 12px 18px; gap: 12px; }
  .topbar h1 { font-size: 1.65rem; }
  .content { padding: 20px 18px calc(72px + env(safe-area-inset-bottom)); }
  .section-heading { margin-bottom: 16px; }
  .section-heading h2 { display: none; }
  .card, .stat { padding: 16px; }
  .empty { padding: 32px 12px; }
  .primary, .secondary, .ghost, .danger { min-height: 44px; }
  .section-heading > button, .section-heading > .field, .hero-actions > button { width: 100%; }
  .hero { display: block; }
  .stats, .grid-2, .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .section-heading { align-items: stretch; flex-direction: column; }
  .table-wrap { overflow: visible; }
  .responsive-table, .responsive-table tbody, .responsive-table tr, .responsive-table td { display: block; width: 100%; }
  .responsive-table thead { display: none; }
  .responsive-table tbody { display: grid; gap: 12px; }
  .responsive-table tr { padding: 9px 14px; border: 1px solid var(--line); border-radius: 14px; }
  .responsive-table td { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 9px 0; border: 0; white-space: normal; text-align: right; overflow-wrap: anywhere; }
  .responsive-table td + td { border-top: 1px solid #f3ecea; }
  .responsive-table td::before { content: attr(data-label); flex: 0 0 42%; color: var(--muted); font-size: .72rem; font-weight: 750; text-align: left; text-transform: uppercase; letter-spacing: .04em; }
  .responsive-table td.actions { justify-content: flex-end; }
  .responsive-table td.actions::before { display: none; }
  .responsive-table td.actions button { min-width: 96px; }
  .responsive-table td.actions .row-actions { width: 100%; }
  .responsive-table td.actions .row-actions button { flex: 1 1 96px; min-width: 0; }
  .requirement { flex-direction: column; gap: 3px; }
  dialog { inset: 0; width: 100%; max-width: none; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
  .dialog-body { max-height: 100dvh; padding: 24px 18px calc(28px + env(safe-area-inset-bottom)); }
  .recipe-line { grid-template-columns: minmax(0, 1fr) 44px; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
  .recipe-line > .field:nth-child(2) { grid-column: 1; grid-row: 2; }
  .recipe-line > .field:nth-child(3) { grid-column: 1; grid-row: 3; }
  .recipe-line > button { grid-column: 2; grid-row: 1; min-height: 44px; }
  .client-grid { grid-template-columns: 1fr; }
  .agenda-day { grid-template-columns: 1fr; gap: 8px; }
  .agenda-day > header { border-radius: 12px; padding: 12px 16px; }
  .agenda-order, .order-card-head, .order-actions { flex-direction: column; align-items: stretch; }
  .agenda-balance { text-align: left; }
  .order-finance { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .order-finance > div:last-child { grid-column: 1 / -1; }
  .order-actions select { min-width: 0; }
  .filter-bar { display: grid; grid-template-columns: 1fr; }
  .pagination .row-actions { width: 100%; }
  .pagination button { flex: 1; }
  .backup-grid { grid-template-columns: 1fr; }
  .data-summary > div { grid-template-columns: repeat(2, 1fr); }
  .toast { left: 18px; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); text-align: center; }
}
