:root {
  color-scheme: light;
  --wine: #431c29;
  --wine-dark: #32141f;
  --rose: #f4e8ec;
  --cream: #fbf7f1;
  --paper: #fffdfa;
  --gold: #c79452;
  --ink: #31262a;
  --muted: #695e60;
  --line: #e9dfd7;
  --green: #2b624b;
  --green-bg: #e7f2e9;
  --red: #8f3341;
  --red-bg: #faeaeb;
  --font: 'DM Sans', system-ui, sans-serif;
  --display: 'Playfair Display', Georgia, serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--cream); color: var(--ink); font: 15px/1.5 var(--font); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: default; }
a { color: inherit; }
:focus-visible { outline: 2px solid #ae702a; outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h1, h2 { color: var(--wine); font-family: var(--display); font-weight: 600; line-height: 1.15; }
h1 { font-size: clamp(2rem, 4vw, 3rem); letter-spacing: -.045em; }
h2 { font-size: 1.55rem; letter-spacing: -.025em; }
h3 { font-size: .98rem; }
.muted { color: var(--muted); }
.small { font-size: .83rem; }
.align-right { text-align: right; }
.nowrap { white-space: nowrap; }
.positive { color: var(--green); }
.negative { color: var(--red); }

.sign-in { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: radial-gradient(ellipse at 52% 6%, #793c4f, var(--wine) 42%, var(--wine-dark) 86%); }
.sign-card { width: min(100%, 420px); padding: clamp(25px, 7vw, 42px); border: 1px solid var(--line); border-radius: 20px; background: var(--paper); box-shadow: 0 22px 70px #210c1560; }
.sign-brand { display: inline-flex; align-items: center; gap: 9px; margin-bottom: 26px; color: var(--wine); font-family: var(--display); font-size: 1.1rem; text-decoration: none; }
.sign-brand img { border-radius: 7px; }
.sign-card h1 { font-size: clamp(2rem, 7vw, 2.65rem); }
.sign-card p { margin-top: 10px; color: var(--muted); }
.sign-card form { margin-top: 24px; }
.sign-card .button { width: 100%; margin-top: 15px; }
.back-link { display: inline-block; margin-top: 23px; color: var(--wine); font-size: .86rem; }

.app { display: grid; min-height: 100vh; grid-template-columns: 235px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; display: flex; align-self: start; height: 100dvh; flex-direction: column; padding: 27px 16px 17px; background: var(--wine); color: #f9eaf0; }
.brand { display: flex; align-items: center; gap: 11px; margin: 0 7px 37px; text-decoration: none; }
.brand-logo { width: 52px; height: 45px; flex: 0 0 auto; padding: 3px; object-fit: contain; background: #fffdf9; border-radius: 8px; }
.brand strong, .brand small { display: block; }
.brand strong { color: #fff7f2; font: 600 1.12rem/1.2 var(--display); overflow-wrap: anywhere; }
.brand small { margin-top: 4px; color: #ead0d9; font-size: .72rem; }
.sidebar nav, .sidebar-footer { display: grid; gap: 4px; }
.sidebar nav a, .sidebar-footer a, .sidebar-footer button { display: flex; width: 100%; min-height: 43px; align-items: center; gap: 10px; padding: 8px 11px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: inherit; font-size: .89rem; font-weight: 600; text-align: left; text-decoration: none; white-space: nowrap; }
.sidebar a:hover, .sidebar-footer button:hover { background: #ffffff12; }
.sidebar nav a[aria-current="page"] { border-color: #fff2; background: #ffffff18; color: #fff; }
.sidebar-footer { margin-top: auto; padding-top: 13px; border-top: 1px solid #fff2; }
.sidebar svg { display: block; width: 17px; height: 17px; stroke: #edd2c0; }
.main { min-width: 0; }
.topbar { display: flex; min-height: 62px; align-items: center; justify-content: space-between; gap: 10px; padding: 0 clamp(18px, 4vw, 46px); border-bottom: 1px solid var(--line); background: var(--paper); color: var(--muted); font-size: .84rem; }
.topbar span { color: var(--wine); font-weight: 700; }
.topbar div::first-letter { text-transform: uppercase; }
.view { max-width: 1440px; min-height: 55vh; margin-inline: auto; padding: 36px clamp(18px, 4vw, 46px) 54px; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 17px; margin-bottom: 23px; }
.page-head p { max-width: 57ch; margin-top: 8px; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.button { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; gap: 6px; padding: 8px 13px; border: 1px solid transparent; border-radius: 7px; background: transparent; color: var(--wine); font-weight: 700; line-height: 1.3; text-decoration: none; }
.button.primary { border-color: var(--wine); background: var(--wine); color: #fff; }
.button.primary:hover:enabled, a.button.primary:hover { background: #613244; }
.button.secondary { border-color: var(--line); background: var(--paper); }
.button.secondary:hover:enabled, a.button.secondary:hover { border-color: #bc9c83; }
.button.danger { border-color: var(--red); background: var(--red); color: #fff; }
.button.quiet { padding-inline: 7px; }
.button.quiet:hover:enabled { background: var(--rose); }
.button.danger-text { color: var(--red); }
.button.compact { min-height: 34px; padding: 6px 9px; font-size: .83rem; }
.panel { min-width: 0; padding: 19px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
.panel + .panel { margin-top: 16px; }
.panel-head { display: flex; align-items: start; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.panel-head p { margin-top: 5px; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.metric { padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); }
.metric span { display: block; color: var(--muted); font-size: .83rem; }
.metric strong { display: block; margin-top: 7px; color: var(--wine); font: 600 clamp(1.22rem, 3vw, 1.85rem)/1.2 var(--display); overflow-wrap: anywhere; }
.quick-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.quick-actions a { display: flex; min-height: 97px; align-items: center; justify-content: space-between; gap: 12px; padding: 15px; border: 1px solid var(--line); border-radius: 9px; text-decoration: none; }
.quick-actions a:hover { border-color: #bc9c83; }
.quick-actions strong, .quick-actions small { display: block; }
.quick-actions strong { color: var(--wine); }
.quick-actions small { margin-top: 4px; color: var(--muted); }
.pill { display: inline-block; padding: 3px 8px; border-radius: 20px; background: var(--rose); color: var(--wine); font-size: .75rem; font-weight: 700; white-space: nowrap; }
.pill.green { background: var(--green-bg); color: var(--green); }
.pill.red { background: var(--red-bg); color: var(--red); }
.notice { padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--cream); color: var(--muted); font-size: .88rem; }
.empty { padding: 24px 10px; color: var(--muted); text-align: center; }
.stack { display: grid; gap: 11px; }
.split { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 15px; align-items: start; }
.split > .panel { margin: 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 11px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: .75rem; font-weight: 700; }
td { font-size: .88rem; }
th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
tbody tr:last-child td { border-bottom: 0; }
td .actions { justify-content: end; flex-wrap: nowrap; }
.product-cell { display: flex; min-width: 135px; align-items: center; gap: 9px; }
.product-cell strong { display: block; }
.thumb { display: grid; width: 37px; height: 37px; flex: 0 0 auto; place-items: center; border-radius: 6px; background: var(--rose); color: var(--wine); object-fit: cover; }
.thumb svg { width: 17px; }
.paginate { display: flex; justify-content: center; margin-top: 13px; }

.search-bar { display: flex; align-items: end; gap: 8px; margin-bottom: 12px; }
.search-bar label { flex: 1; }
label, .field-title { display: grid; gap: 5px; color: var(--ink); font-size: .88rem; font-weight: 700; }
input:not([type="checkbox"]), select, textarea { width: 100%; min-height: 39px; padding: 8px 10px; border: 1px solid #d9ccc4; border-radius: 7px; background: #fff; color: var(--ink); font-size: .91rem; font-weight: 500; }
textarea { resize: vertical; }
input[type="checkbox"] { width: 17px; height: 17px; margin: 0; accent-color: var(--wine); }
label.checkbox { display: flex; min-height: 34px; align-items: center; gap: 8px; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.fields > .wide { grid-column: 1 / -1; }
.form-actions { display: flex; flex-wrap: wrap; justify-content: end; gap: 8px; margin-top: 18px; }
.form-error { margin-top: 11px; color: var(--red) !important; font-size: .87rem; }
.settings-form { max-width: 925px; }
.settings-form > .form-actions { justify-content: start; }
.settings-form .panel h2 { margin-bottom: 15px; }
.photo-field { min-width: 0; margin: 0; padding: 10px; border: 1px solid var(--line); border-radius: 8px; }
.photo-field legend { padding: 0 4px; color: var(--ink); font-weight: 700; }
.photo-field input { margin: 6px 0; }
.photo-preview { width: 100%; max-height: 165px; margin-bottom: 4px; border-radius: 6px; background: var(--cream); object-fit: contain; }
.photo-field .button { display: block; padding-inline: 0; }

.register-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 15px; padding: 13px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); }
.register-bar p { margin-top: 4px; }
.register-history { margin-top: 17px !important; }
.pos-product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 140px), 1fr)); gap: 8px; }
.pos-product { display: flex; min-width: 0; flex-direction: column; gap: 5px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--wine); text-align: left; }
.pos-product:hover:enabled { border-color: var(--gold); background: var(--cream); }
.pos-product-photo { display: grid; width: 100%; height: 72px; flex: 0 0 auto; place-items: center; border-radius: 5px; background: var(--cream); color: var(--muted); }
.pos-product-photo img { display: block; width: 100%; height: 72px; padding: 3px; object-fit: contain; }
.pos-product-photo svg { width: 20px; height: 20px; }
.pos-product strong { line-height: 1.3; overflow-wrap: anywhere; }
.pos-product small { margin-top: auto; color: var(--muted); }
.table-map { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.table-card { display: flex; min-width: 0; min-height: 115px; flex-direction: column; align-items: flex-start; gap: 6px; padding: 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--wine); text-align: left; }
.table-card:hover { border-color: var(--gold); }
.table-card.is-open { background: #f7ecf0; border-color: #e5ccd5; }
.table-card.is-selected { border-color: var(--wine); box-shadow: inset 0 0 0 1px var(--wine); }
.table-card-number { font: 600 1.25rem/1.2 var(--display); }
.table-card .muted { overflow-wrap: anywhere; }
.table-detail-header { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.table-detail-header h2 + p { margin-top: 5px; }
.table-detail-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.table-kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
.table-kpis .metric { padding: 10px 12px; }
.table-lines, .table-payments { display: grid; gap: 8px; margin: 10px 0 0; padding: 0; list-style: none; }
.table-line, .table-payment { display: flex; min-width: 0; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.table-line:last-child, .table-payment:last-child { border-bottom: 0; }
.table-line-info, .table-payment > div { min-width: 0; overflow-wrap: anywhere; }
.table-line-info > strong, .table-line-info > small { display: block; }
.table-line-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: end; gap: 6px; }
.table-product-list, .table-split-items { display: grid; gap: 7px; max-height: 290px; margin: 8px 0; overflow-y: auto; }
.table-product-option, .table-split-item { display: flex; align-items: center; justify-content: space-between; gap: 9px; min-width: 0; padding: 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--paper); color: var(--ink); text-align: left; overflow-wrap: anywhere; }
.table-product-option:hover { border-color: var(--gold); }
.table-product-option img { width: 38px; height: 38px; flex: 0 0 auto; object-fit: contain; }
.table-split-item input[type="number"] { width: 68px; }
.cart { display: grid; gap: 8px; margin-bottom: 12px; }
.cart-line { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px 9px; align-items: center; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.cart-line strong { overflow-wrap: anywhere; }
.cart-line .quantity { grid-row: span 2; display: flex; align-items: center; gap: 6px; }
.icon-button { display: grid; width: 31px; height: 31px; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 7px; background: transparent; color: var(--wine); font-size: 1.15rem; }
.icon-button:hover { background: var(--rose); }
.total { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 0; color: var(--wine); font-weight: 700; }
.total strong { font: 600 1.6rem/1 var(--display); }
.checkout { display: grid; gap: 10px; }
.detail-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 0 0 15px; }
.detail-list div { padding: 8px; border: 1px solid var(--line); border-radius: 7px; }
.detail-list dt { color: var(--muted); font-size: .75rem; }
.detail-list dd { margin: 2px 0 0; font-weight: 700; overflow-wrap: anywhere; }

dialog { width: min(100% - 28px, 560px); max-height: min(90vh, 720px); padding: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); color: var(--ink); box-shadow: 0 20px 60px #2b15234d; }
dialog::backdrop { background: #29131ecc; }
.dialog-header { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); background: var(--paper); }
#dialog-content { padding: 18px; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 3; max-width: min(360px, 100% - 40px); padding: 12px 16px; border-radius: 9px; background: var(--wine); color: #fff; box-shadow: 0 5px 19px #2b15234d; }

@media (max-width: 900px) {
  .app { grid-template-columns: 185px minmax(0, 1fr); }
  .sidebar { padding-inline: 11px; }
  .split { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 640px) {
  .app { display: block; }
  .sidebar { position: relative; display: grid; height: auto; grid-template-columns: 1fr auto; gap: 10px; padding: 12px 14px 0; }
  .brand { gap: 7px; margin: 0; }
  .brand-logo { width: 40px; height: 36px; border-radius: 6px; }
  .brand strong { font-size: .95rem; }
  .sidebar nav { display: flex; grid-column: 1 / -1; grid-row: 2; gap: 2px; padding: 2px 3px 8px; overflow-x: auto; }
  .sidebar nav a, .sidebar-footer a, .sidebar-footer button { width: auto; min-height: 36px; gap: 5px; padding: 6px; font-size: .81rem; }
  .sidebar-footer { display: flex; grid-column: 2; grid-row: 1; margin: 0; padding: 0; border: 0; }
  .sidebar svg { width: 15px; height: 15px; }
  .topbar { min-height: 46px; }
  .view { padding-top: 23px; }
  .page-head { display: grid; gap: 10px; margin-bottom: 14px; }
  .panel { padding: 13px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .metric { padding: 10px; }
  .quick-actions { grid-template-columns: 1fr; }
  .quick-actions a { min-height: 65px; }
  .register-bar { flex-wrap: wrap; }
  .table-map { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
  .table-card { min-height: 92px; padding: 9px; }
  .table-kpis .metric { padding: 8px; }
  .table-line, .table-payment { flex-wrap: wrap; }
}

@media (max-width: 400px) {
  .fields { grid-template-columns: minmax(0, 1fr); }
  .sidebar-footer svg { display: none; }
}
