:root {
  --rp-primary: #4f46e5;
  --rp-primary-strong: #3730a3;
  --rp-primary-soft: #eef2ff;
  --rp-success: #047857;
  --rp-success-soft: #ecfdf5;
  --rp-warning: #b45309;
  --rp-warning-soft: #fffbeb;
  --rp-danger: #b91c1c;
  --rp-danger-soft: #fef2f2;
  --rp-info: #0369a1;
  --rp-info-soft: #f0f9ff;
  --rp-sidebar: #111827;
  --rp-sidebar-muted: #9ca3af;
  --rp-shadow: 0 10px 25px rgba(15, 23, 42, .08);
}

body { min-height: 100vh; }
a { color: var(--rp-primary); text-decoration: none; }
a:hover { text-decoration: none; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
textarea { min-height: 7rem; resize: vertical; }
svg.icon { flex: 0 0 auto; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 260px minmax(0,1fr); }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 40;
  background: var(--rp-sidebar); color: #fff; padding: 1rem .85rem 1.5rem;
}
.brand { display: inline-flex; align-items: center; gap: .7rem; color: inherit; }
.brand:hover { color: inherit; }
.brand-mark { width: 2.5rem; height: 2.5rem; border-radius: .8rem; display: inline-grid; place-items: center; background: linear-gradient(145deg,#818cf8,#4f46e5); color: #fff; font-weight: 800; box-shadow: 0 8px 20px rgba(79,70,229,.3); }
.brand span:last-child { display: grid; line-height: 1.1; }
.brand b { font-size: 1.05rem; }
.brand small { color: #c7d2fe; font-size: .72rem; margin-top: .18rem; }
.nav { margin-top: 1.5rem; display: grid; gap: .28rem; }
.nav a { display: flex; align-items: center; gap: .72rem; min-height: 2.8rem; padding: .65rem .78rem; border-radius: .72rem; color: #d1d5db; font-weight: 600; font-size: .92rem; }
.nav a:hover, .nav a.is-active { color: #fff; background: rgba(99,102,241,.2); }
.nav a.is-active { box-shadow: inset 3px 0 0 #818cf8; }
.nav-label { color: var(--rp-sidebar-muted); font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; margin: 1.05rem .75rem .35rem; }
.sidebar-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 35; }
.main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 30; min-height: 4rem; display: flex; align-items: center; gap: 1rem; padding: .65rem 1.35rem; background: rgba(255,255,255,.94); backdrop-filter: blur(10px); border-bottom: 1px solid var(--app-border); }
.icon-btn { display: none; width: 2.75rem; height: 2.75rem; border: 1px solid var(--app-border); border-radius: .75rem; background: #fff; color: var(--app-text); align-items: center; justify-content: center; }
.top-company { display: grid; min-width: 0; }
.top-company strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-company span, .top-user > span { color: var(--app-muted); font-size: .8rem; }
.top-user { margin-left: auto; display: flex; align-items: center; gap: .9rem; }
.content { width: min(1500px, 100%); margin: 0 auto; padding: 1.5rem; }

.page-heading { align-items: center; }
.page-heading h1 { margin-bottom: .2rem; font-size: clamp(1.55rem, 2vw, 2rem); line-height: 1.2; }
.page-heading p { margin-bottom: 0; color: var(--app-muted); }
.eyebrow { color: var(--rp-primary); font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }

.btn { min-height: 2.65rem; border: 1px solid transparent; border-radius: .72rem; padding: .62rem .95rem; display: inline-flex; align-items: center; justify-content: center; gap: .48rem; font-weight: 700; line-height: 1.2; }
.btn:hover { filter: brightness(.98); }
.btn-primary { background: var(--rp-primary); color: #fff; border-color: var(--rp-primary); }
.btn-primary:hover { background: var(--rp-primary-strong); color: #fff; }
.btn-secondary { background: #fff; color: var(--app-text); border-color: #cbd5e1; }
.btn-ghost { background: transparent; color: var(--app-text); border-color: transparent; }
.btn-ghost.danger, .danger { color: var(--rp-danger); }
.btn-sm { min-height: 2.3rem; padding: .48rem .7rem; font-size: .84rem; }
.btn-lg { min-height: 3.1rem; padding-inline: 1.25rem; }
.btn-block { width: 100%; }

.alert { padding: .85rem 1rem; border-radius: .8rem; border: 1px solid; margin-bottom: 1rem; }
.alert-success { color: var(--rp-success); background: var(--rp-success-soft); border-color: #a7f3d0; }
.alert-danger, .alert-error { color: var(--rp-danger); background: var(--rp-danger-soft); border-color: #fecaca; }
.alert-info { color: var(--rp-info); background: var(--rp-info-soft); border-color: #bae6fd; }

.stats-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 1rem; margin-bottom: 1rem; }
.stat { background: #fff; border: 1px solid var(--app-border); border-radius: 1rem; padding: 1.05rem; display: grid; gap: .35rem; }
.stat span { color: var(--app-muted); font-size: .84rem; }
.stat strong { font-size: 1.55rem; line-height: 1.15; }
.grid-2 { display: grid; grid-template-columns: minmax(0,1.3fr) minmax(18rem,.7fr); gap: 1rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .75rem; }
.card-head h2 { margin: 0; font-size: 1.05rem; }
.rank-row { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: .75rem; padding: .75rem 0; border-bottom: 1px solid var(--app-border); }
.rank-row:last-child { border-bottom: 0; }
.rank { width: 2rem; height: 2rem; display: grid; place-items: center; border-radius: .65rem; background: var(--rp-primary-soft); color: var(--rp-primary-strong); font-weight: 800; }
.rank-row div { display: grid; }
.rank-row small { color: var(--app-muted); }
.empty { color: var(--app-muted); text-align: center; }
.pad { padding: 1.5rem; }
.block { display: block; color: var(--app-muted); margin-top: .15rem; }

.app-card { overflow: hidden; box-shadow: 0 1px 2px rgba(15,23,42,.02); }
.app-card + .app-card { margin-top: 1rem; }
[data-responsive-table] { font-size: .9rem; }
[data-responsive-table] th { color: #475569; font-size: .75rem; text-transform: uppercase; letter-spacing: .035em; background: #f8fafc; }
[data-responsive-table] tbody tr:last-child td { border-bottom: 0; }

.badge { display: inline-flex; align-items: center; width: fit-content; padding: .25rem .52rem; border-radius: 999px; font-size: .72rem; font-weight: 800; background: #f1f5f9; color: #475569; }
.badge-ok { background: var(--rp-success-soft); color: var(--rp-success); }
.badge-off { background: #f1f5f9; color: #64748b; }
.legend { display: flex; flex-wrap: wrap; gap: 1rem; margin-bottom: 1rem; color: var(--app-muted); font-size: .85rem; }
.legend span { display: inline-flex; align-items: center; gap: .38rem; }
.dot { width: .65rem; height: .65rem; border-radius: 50%; display: inline-block; }
.dot-free { background: #10b981; }
.dot-busy { background: #f59e0b; }

.tables-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 1rem; }
.table-card { background: #fff; border: 1px solid var(--app-border); border-radius: 1rem; padding: 1rem; min-width: 0; }
.table-card.busy { border-color: #fcd34d; box-shadow: inset 0 3px 0 #f59e0b; }
.table-card.free { box-shadow: inset 0 3px 0 #10b981; }
.table-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.table-symbol { width: 1.6rem; height: 1.6rem; color: var(--rp-primary); }
.table-card h2 { margin: .9rem 0 .1rem; font-size: 1.12rem; }
.table-card p { margin: .2rem 0; color: var(--app-muted); font-size: .84rem; }
.table-total { font-size: 1.35rem; font-weight: 800; margin: .85rem 0; }
.compact-form { display: grid; gap: .55rem; margin-top: .8rem; }
.compact-form label { font-size: .8rem; font-weight: 700; }

.stack { display: grid; gap: .2rem; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 0 1rem; }
.form-grid .full { grid-column: 1/-1; }
.field-error { color: var(--rp-danger); font-weight: 600; }
.help { color: var(--app-muted); font-size: .8rem; }
.check-row { display: flex; align-items: center; gap: .55rem; min-height: 2.75rem; }
.check-row input { width: 1.1rem; min-height: auto; }

.modal[hidden] { display: none; }
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 1rem; background: rgba(15,23,42,.6); overflow-y: auto; }
.modal-card { width: min(31rem,100%); max-height: calc(100vh - 2rem); overflow-y: auto; background: #fff; border-radius: 1rem; box-shadow: var(--rp-shadow); padding: 1.25rem; position: relative; }
.modal-wide { width: min(48rem,100%); }
.modal-card h2 { margin: 0 2.7rem 1rem 0; }
.modal-close { position: absolute; top: .7rem; right: .7rem; width: 2.75rem; height: 2.75rem; border: 0; border-radius: .7rem; background: #f1f5f9; color: #334155; font-size: 1.4rem; }
body.modal-open { overflow: hidden; }

.order-layout { display: grid; grid-template-columns: minmax(0,1.25fr) minmax(20rem,.75fr); gap: 1rem; align-items: start; }
.order-panel, .checkout-panel { min-width: 0; }
.product-search { display: flex; gap: .65rem; margin-bottom: .9rem; }
.product-search .icon { color: var(--app-muted); align-self: center; }
.product-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: .75rem; max-height: 34rem; overflow-y: auto; padding-right: .15rem; }
.product-tile { border: 1px solid var(--app-border); border-radius: .85rem; background: #fff; text-align: left; padding: .8rem; min-height: 6.5rem; display: grid; align-content: space-between; gap: .35rem; }
.product-tile:hover { border-color: #a5b4fc; background: #fafaff; }
.product-tile strong { color: var(--app-text); }
.product-tile small { color: var(--app-muted); }
.product-tile b { color: var(--rp-primary-strong); }
.order-items { display: grid; gap: .6rem; }
.order-item { border: 1px solid var(--app-border); border-radius: .8rem; padding: .75rem; display: grid; grid-template-columns: minmax(0,1fr) auto; gap: .5rem; }
.order-item small { color: var(--app-muted); }
.order-item-actions { display: flex; align-items: center; gap: .45rem; }
.order-summary { display: grid; gap: .48rem; margin: 1rem 0; }
.order-summary > div { display: flex; justify-content: space-between; gap: 1rem; }
.order-summary .total { padding-top: .7rem; border-top: 1px solid var(--app-border); font-size: 1.16rem; }
.payment-row { display: grid; grid-template-columns: minmax(0,1fr) minmax(8rem,.7fr) auto; gap: .5rem; align-items: end; margin-bottom: .55rem; }
.payment-row .remove-payment { min-width: 2.75rem; }
fieldset { border: 1px solid var(--app-border); border-radius: .8rem; padding: .8rem; margin: .8rem 0; }
legend { font-weight: 700; padding: 0 .35rem; }

.kitchen-board { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 1rem; align-items: start; }
.kitchen-column { background: #f1f5f9; border-radius: 1rem; padding: .75rem; min-height: 9rem; }
.kitchen-column h2 { margin: 0 0 .7rem; font-size: .95rem; }
.kitchen-ticket { background: #fff; border: 1px solid var(--app-border); border-radius: .8rem; padding: .75rem; margin-bottom: .65rem; box-shadow: 0 2px 8px rgba(15,23,42,.04); }
.kitchen-ticket h3 { margin: .25rem 0; }
.kitchen-ticket p { margin: .2rem 0; color: var(--app-muted); }

.cash-hero { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.cash-hero > div:first-child { display: grid; min-width: 12rem; }
.cash-hero > div:first-child > span { color: var(--rp-success); font-weight: 800; font-size: .8rem; }
.cash-hero > div:first-child > strong { font-size: 1.2rem; }
.cash-hero small { color: var(--app-muted); }
.payment-summary { flex: 1; display: flex; flex-wrap: wrap; gap: .55rem; }
.payment-summary span { background: #f8fafc; border: 1px solid var(--app-border); border-radius: .65rem; padding: .5rem .65rem; display: grid; font-size: .76rem; color: var(--app-muted); }
.payment-summary b { color: var(--app-text); font-size: .9rem; }

.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: radial-gradient(circle at top left,#eef2ff 0,#f8fafc 48%,#fff 100%); }
.auth-card { width: min(31rem,100%); background: #fff; border: 1px solid var(--app-border); border-radius: 1.15rem; box-shadow: var(--rp-shadow); padding: clamp(1.2rem,4vw,2rem); }
.brand-auth { color: var(--app-text); margin-bottom: 1.5rem; }
.auth-card h1 { margin: 0 0 .35rem; font-size: 1.55rem; }
.auth-card .intro { color: var(--app-muted); margin-top: 0; }
.auth-links { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-top: 1rem; font-size: .85rem; }

@media (max-width: 1180px) {
  .tables-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .product-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .kitchen-board { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

@media (max-width: 980px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; left: 0; top: 0; width: min(82vw,18rem); transform: translateX(-105%); transition: transform .2s ease; }
  .sidebar.is-open { transform: translateX(0); }
  .icon-btn { display: inline-flex; }
  .content { padding: 1.1rem; }
  .stats-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .grid-2, .order-layout { grid-template-columns: 1fr; }
  .tables-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .top-user > span { display: none; }
}

@media (max-width: 680px) {
  .content { padding: .85rem; }
  .topbar { padding-inline: .8rem; }
  .top-company span { display: none; }
  .top-user .btn span { display: none; }
  .top-user { gap: .4rem; }
  .btn, .icon-btn, .modal-close, .password-field__toggle { min-height: 44px; min-width: 44px; }
  .stats-grid, .tables-grid, .kitchen-board { grid-template-columns: 1fr; }
  .stat strong { font-size: 1.35rem; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .product-grid { grid-template-columns: 1fr 1fr; }
  .cash-hero { align-items: stretch; flex-direction: column; }
  .payment-row { grid-template-columns: 1fr 1fr; }
  .payment-row .remove-payment { grid-column: 1/-1; width: 100%; }
  .app-card { padding: .8rem; }
  [data-responsive-table] { border: 0; }
  [data-responsive-table] tr { padding: .7rem; }
}

@media (max-width: 430px) {
  .top-company strong { max-width: 10rem; }
  .product-grid { grid-template-columns: 1fr; }
  .page-heading .btn { width: 100%; }
  .modal { padding: .5rem; }
  .modal-card { max-height: calc(100vh - 1rem); padding: 1rem; }
  .auth-links { align-items: stretch; flex-direction: column; }
}

/* Componentes específicos das views do PDV. */
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }
.text-right { text-align: right; }
.btn-link { border: 0; background: transparent; padding: .2rem 0; font-weight: 700; }
.badge-live { background: var(--rp-warning-soft); color: var(--rp-warning); }

.pos-layout { display: grid; grid-template-columns: minmax(0,1.35fr) minmax(21rem,.65fr); gap: 1rem; align-items: start; }
.products-panel, .order-panel { min-width: 0; }
.search-field { width: min(24rem,100%); display: flex; align-items: center; gap: .45rem; position: relative; }
.search-field > .icon { position: absolute; left: .75rem; color: var(--app-muted); pointer-events: none; }
.search-field input { padding-left: 2.35rem; }
.product-card { border: 1px solid var(--app-border); border-radius: .9rem; background: #fff; padding: .8rem; display: grid; align-content: space-between; gap: .75rem; min-width: 0; }
.product-card:hover { border-color: #a5b4fc; box-shadow: 0 5px 16px rgba(79,70,229,.08); }
.product-card > div:first-of-type { display: grid; gap: .18rem; }
.product-card small, .product-card em { color: var(--app-muted); font-size: .75rem; font-style: normal; }
.product-card strong { font-size: .95rem; }
.product-card > div:first-of-type span { color: var(--rp-primary-strong); font-weight: 800; }
.product-controls { display: grid; grid-template-columns: minmax(4.8rem,.45fr) minmax(8rem,1fr); gap: .45rem; }
.product-controls .btn { grid-column: 1/-1; }
.product-controls input { min-height: 2.5rem; padding: .55rem .65rem; }
.order-item.cancelled { opacity: .55; background: #f8fafc; }
.order-item.cancelled strong { text-decoration: line-through; }
.order-item .text-right { display: grid; justify-items: end; gap: .25rem; }
.totals { display: grid; gap: .5rem; margin: 1rem 0; padding-top: .8rem; border-top: 1px solid var(--app-border); }
.totals > div { display: flex; justify-content: space-between; gap: 1rem; }
.totals .grand { font-size: 1.12rem; padding-top: .5rem; border-top: 1px dashed #cbd5e1; }
.checkout-total { display: flex; align-items: end; justify-content: space-between; gap: 1rem; padding: .8rem; border-radius: .8rem; background: var(--rp-primary-soft); color: var(--rp-primary-strong); }
.checkout-total span { font-size: .82rem; }
.checkout-total strong { font-size: 1.35rem; }

.kds-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 1rem; }
.kds-card { border: 1px solid var(--app-border); border-radius: 1rem; background: #fff; overflow: hidden; box-shadow: 0 2px 8px rgba(15,23,42,.04); }
.kds-card.status-new { box-shadow: inset 0 4px 0 #f59e0b; }
.kds-card.status-preparing { box-shadow: inset 0 4px 0 #3b82f6; }
.kds-card.status-ready { box-shadow: inset 0 4px 0 #10b981; }
.kds-card > header { display: flex; justify-content: space-between; align-items: flex-start; gap: .65rem; padding: .85rem; border-bottom: 1px solid var(--app-border); }
.kds-card > header div { display: grid; }
.kds-card > header small { color: var(--app-muted); }
.station { font-size: .72rem; font-weight: 800; padding: .25rem .5rem; border-radius: 999px; background: #f1f5f9; }
.kds-item { padding: 1rem .85rem; min-height: 6rem; }
.kds-item p { margin: .35rem 0 0; color: var(--app-muted); }
.kds-actions { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: .5rem; padding: .85rem; border-top: 1px solid var(--app-border); }

.settings-card h2 { margin-top: 0; }
.read-only-box { min-height: 4.35rem; border: 1px solid var(--app-border); border-radius: .75rem; background: #f8fafc; padding: .65rem .8rem; display: grid; align-content: center; }
.read-only-box span { color: var(--app-muted); font-size: .75rem; }
.chips { display: flex; flex-wrap: wrap; gap: .55rem; }
.chips span { border: 1px solid var(--app-border); border-radius: 999px; padding: .45rem .7rem; background: #f8fafc; font-size: .84rem; }
.stats-grid.stats-3 { grid-template-columns: repeat(3,minmax(0,1fr)); }
.footnote { color: var(--app-muted); font-size: .8rem; margin: 1rem 0 0; }
.auth-head p { color: var(--app-muted); margin-top: 0; }

@media (max-width: 1180px) {
  .pos-layout { grid-template-columns: 1fr; }
  .kds-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 680px) {
  .kds-grid, .stats-grid.stats-3 { grid-template-columns: 1fr; }
  .product-controls { grid-template-columns: 1fr; }
  .product-controls .btn { grid-column: auto; }
  .kds-actions { grid-template-columns: 1fr; }
  .search-field { width: 100%; }
  .products-panel .card-head { align-items: stretch; flex-direction: column; }
}

/* Locale switcher */
.locale-switcher { display: inline-flex; align-items: center; gap: .35rem; margin-left: auto; }
.locale-switcher select { min-height: 2.35rem; max-width: 11.5rem; padding: .42rem 2rem .42rem .65rem; font-size: .8rem; }
.locale-switcher .locale-apply { min-width: 2.65rem; }
.auth-brand-row { display: flex; align-items: flex-start; justify-content: space-between; gap: .8rem; margin-bottom: 1.25rem; }
.auth-brand-row .brand-auth { margin-bottom: 0; }
.auth-locale { margin-left: 0; }
.auth-locale select { max-width: 10.5rem; }
.demo-option { border: 1px solid #c7d2fe; background: #eef2ff; border-radius: .85rem; padding: .85rem; }
.demo-option strong { display: block; margin-bottom: .3rem; }
.demo-option small { display: block; color: var(--app-muted); margin-top: .35rem; line-height: 1.45; }
@media (max-width: 820px) {
  .locale-switcher select { max-width: 8.2rem; }
}
@media (max-width: 680px) {
  .topbar .locale-switcher { margin-left: auto; }
  .topbar .locale-switcher select { width: 5.4rem; max-width: 5.4rem; }
  .auth-brand-row { align-items: stretch; flex-direction: column; }
  .auth-locale { width: 100%; }
  .auth-locale select { flex: 1; max-width: none; }
}

/* Public demo */
.demo-badge { display:inline-flex; align-items:center; margin-left:.35rem; padding:.12rem .42rem; border-radius:999px; background:#ede9fe; color:#5b21b6; font-size:.68rem; font-weight:800; letter-spacing:.05em; vertical-align:middle; }
.demo-notice { display:flex; align-items:center; gap:.6rem; margin-bottom:1rem; padding:.8rem 1rem; border:1px solid #c4b5fd; border-radius:.8rem; background:#f5f3ff; color:#4c1d95; font-weight:650; }
.demo-notice .icon { flex:0 0 auto; }
.demo-entry { width:100%; text-decoration:none; }
