:root {
  color-scheme: light;
  --ink: #0E1011;
  --ink-2: #555B60;
  --ink-3: #8E9397;
  --paper: #FFFFFF;
  --mist: #F6F6F6;
  --line: #E6E3DD;
  --line-2: #DCD8D1;
  --accent: #2ED3C6;
  --accent-ink: #0B6B63;
  --danger: #B3261E;
  --ok-bg: #E7F7F5;
  --radius: 18px;
  --glass: rgba(255,255,255,0.72);
  --shadow: 0 18px 50px rgba(14,16,17,0.08);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Inter Tight', 'Inter', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--mist); color: var(--ink); font-family: var(--font); -webkit-font-smoothing: antialiased; overflow-x: clip; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--display); font-weight: 500; letter-spacing: -0.015em; margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.topbar { position: sticky; top: 0; z-index: 30; background: rgba(14,16,17,0.92); backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%); color: #F4F2EE; }
.topbar-in { max-width: 1320px; margin: 0 auto; height: 60px; padding: 0 20px; display: flex; align-items: center; gap: 16px; }
.topbar img { height: 20px; width: auto; display: block; object-fit: contain; }
.topbar .tag { font-size: 12px; letter-spacing: 0.14em; color: rgba(244,242,238,0.6); padding-left: 16px; border-left: 1px solid rgba(255,255,255,0.16); }
.topbar nav { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: 14px; }
.topbar nav a, .topbar nav button { background: none; border: 0; color: rgba(244,242,238,0.82); text-decoration: none; min-height: 40px; padding: 0 12px; border-radius: 999px; cursor: pointer; display: inline-flex; align-items: center; }
.topbar nav a:hover, .topbar nav button:hover, .topbar nav a[aria-current="page"] { background: rgba(255,255,255,0.08); color: #fff; }
.topbar .who { color: #F4F2EE; font-weight: 500; padding: 0 8px; }

.wrap { max-width: 1320px; margin: 0 auto; padding: 28px 20px 120px; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; }
.page-head h1 { font-size: 34px; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.eyebrow { font-size: 11px; letter-spacing: 0.18em; color: var(--ink-3); text-transform: uppercase; }

.btn { height: 48px; padding: 0 22px; border-radius: 999px; border: 0; background: var(--ink); color: #F4F2EE; font-weight: 600; font-size: 15px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; box-shadow: inset 0 1px 0 rgba(255,255,255,0.18); text-decoration: none; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.ghost { background: var(--paper); color: var(--ink); border: 1px solid var(--line-2); box-shadow: none; }
.btn.sm { height: 38px; padding: 0 16px; font-size: 13px; }
.btn.block { width: 100%; }
.link { background: none; border: 0; padding: 0; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-weight: 500; min-height: 32px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--ink-2); }
.input, select.input, textarea.input { width: 100%; min-height: 46px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--paper); font-size: 15px; }
textarea.input { padding: 12px 14px; min-height: 84px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 12px; }
.error { color: var(--danger); font-size: 14px; }
.notice { padding: 12px 14px; border-radius: 12px; background: var(--ok-bg); color: var(--accent-ink); font-size: 14px; }
.warn { padding: 12px 14px; border-radius: 12px; background: #FFF4E5; color: #7A4B00; font-size: 14px; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: var(--ink); }
.login-art { position: relative; overflow: hidden; color: #F4F2EE; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; background: radial-gradient(100% 80% at 20% 0%, #1D2A30 0%, #0E1011 65%); }
.login-art h1 { font-size: 56px; line-height: 1.02; letter-spacing: -0.03em; max-width: 520px; }
.login-art p { color: rgba(244,242,238,0.72); max-width: 440px; line-height: 1.6; }
.login-art img.logo { height: 24px; width: auto; align-self: flex-start; object-fit: contain; }
.login-form { background: var(--mist); display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.login-card { width: 100%; max-width: 400px; padding: 32px 28px; border-radius: 24px; background: var(--paper); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 16px; }
@media (max-width: 860px) { .login { grid-template-columns: 1fr; } .login-art { padding: 28px 20px; gap: 24px; } .login-art h1 { font-size: 34px; } }

/* ---------- Portal ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 24px; align-items: start; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }
.search { flex: 1 1 260px; position: relative; }
.search input { padding-left: 42px; border-radius: 999px; }
.search svg { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--ink-3); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--paper); cursor: pointer; font-size: 14px; }
.chip[aria-pressed="true"] { background: var(--ink); color: #F4F2EE; border-color: var(--ink); }

.group-title { display: flex; align-items: baseline; gap: 10px; margin: 26px 0 12px; }
.group-title h2 { font-size: 20px; }
.products { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 12px; }
.prod { padding: 14px; display: flex; flex-wrap: wrap; gap: 12px 14px; align-items: flex-start; transition: border-color .2s, box-shadow .2s; }
.prod.in { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink) inset; }
.prod img { width: 64px; height: 64px; border-radius: 12px; object-fit: cover; background: var(--mist); flex: none; }
.prod .info { flex: 1 1 calc(100% - 80px); min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.prod .stepper { margin-left: auto; }
.prod .name { font-size: 14px; font-weight: 500; line-height: 1.3; }
.prod .code { font-size: 12px; color: var(--ink-3); }
.prod .price { font-size: 16px; font-weight: 600; }
.prod .retail { font-size: 12px; color: var(--ink-3); }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line-2); border-radius: 999px; background: var(--paper); }
.stepper button { width: 36px; height: 36px; border: 0; background: none; cursor: pointer; font-size: 18px; border-radius: 999px; }
.stepper button:hover { background: var(--mist); }
.stepper input { width: 44px; height: 36px; border: 0; text-align: center; font-weight: 600; background: transparent; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.order { position: sticky; top: 80px; padding: 20px; display: flex; flex-direction: column; gap: 16px; max-height: calc(100vh - 100px); overflow: auto; }
.order h2 { font-size: 22px; }
.client-box { padding: 14px; border-radius: 14px; background: var(--mist); display: flex; flex-direction: column; gap: 4px; }
.lines { display: flex; flex-direction: column; }
.line { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 13px; }
.line .n { font-weight: 500; }
.line .sub { text-align: right; font-weight: 600; }
.totals { display: flex; justify-content: space-between; align-items: baseline; padding-top: 12px; border-top: 1px solid var(--line-2); }
.totals .t { font-family: var(--display); font-size: 28px; letter-spacing: -0.02em; }
.empty { padding: 20px; border-radius: 14px; border: 1px dashed var(--line-2); text-align: center; color: var(--ink-3); font-size: 14px; }
.cond-box { padding: 14px; border-radius: 14px; border: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.cond-box .row { display: flex; justify-content: space-between; }
.check-box { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line-2); cursor: pointer; font-size: 14px; line-height: 1.4; }
.check-box input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--ink); flex: none; }
.check-box:has(input:checked) { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink) inset; }
#pag-tabs { align-self: stretch; }
#pag-tabs button { flex: 1; }

.mbar { display: none; }
.scrim { position: fixed; inset: 0; background: rgba(14,16,17,0.4); z-index: 39; }
@media (max-width: 1020px) {
  .layout { grid-template-columns: 1fr; }
  .order { position: fixed; inset: auto 0 0 0; top: auto; max-height: 88vh; border-radius: 24px 24px 0 0; z-index: 40; transform: translateY(105%); transition: transform .35s cubic-bezier(.2,.7,.2,1); box-shadow: 0 -20px 60px rgba(14,16,17,0.2); }
  .order.open { transform: translateY(0); }
  .mbar { display: flex; position: fixed; left: 12px; right: 12px; bottom: 14px; z-index: 35; padding: 8px 8px 8px 18px; border-radius: 22px; background: var(--glass); backdrop-filter: blur(24px) saturate(180%); -webkit-backdrop-filter: blur(24px) saturate(180%); border: 1px solid rgba(255,255,255,0.95); box-shadow: inset 0 1px 0 #fff, 0 16px 44px rgba(14,16,17,0.22); align-items: center; gap: 12px; }
  .mbar .sum { flex: 1; display: flex; flex-direction: column; font-size: 13px; }
  .mbar .sum strong { font-size: 16px; }
  .page-head h1 { font-size: 26px; }
}

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; z-index: 60; background: rgba(14,16,17,0.5); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; background: var(--paper); border-radius: 24px; padding: 24px; display: flex; flex-direction: column; gap: 16px; box-shadow: 0 40px 100px rgba(0,0,0,0.3); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.modal-head h2 { font-size: 22px; }
.x { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--paper); cursor: pointer; font-size: 18px; flex: none; }
.tabs { display: flex; gap: 6px; padding: 4px; background: var(--mist); border-radius: 999px; align-self: flex-start; }
.tabs button { min-height: 38px; padding: 0 16px; border: 0; border-radius: 999px; background: none; cursor: pointer; font-size: 14px; }
.tabs button[aria-selected="true"] { background: var(--paper); box-shadow: 0 2px 8px rgba(14,16,17,0.08); font-weight: 500; }
.results { display: flex; flex-direction: column; gap: 8px; }
.result { text-align: left; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--paper); cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.result:hover { border-color: var(--ink); }
@media (max-width: 600px) { .grid2, .grid3 { grid-template-columns: 1fr; } .modal { padding: 18px; border-radius: 20px; } }

/* ---------- Tabelas ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 500; color: var(--ink-2); font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; padding: 10px 12px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table .num { text-align: right; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.table tr.row-paid td { background: #EAF8F1; }
.table tr.row-paid td:first-child { box-shadow: inset 3px 0 0 #1E9E64; }
.table tr.row-off td { color: var(--ink-3); }
.badge { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--mist); white-space: nowrap; }
.badge.ok { background: #DDF3E8; color: #13724A; }
.badge.off { background: #FDECEA; color: var(--danger); }
.badge.info { background: var(--ok-bg); color: var(--accent-ink); }

.admin-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.stat .big { font-family: var(--display); font-size: 30px; letter-spacing: -0.02em; }
.stat.paid { border-color: #BFE6D2; background: #F3FBF7; }
.section { padding: 22px; display: flex; flex-direction: column; gap: 16px; margin-bottom: 18px; }
.section h2 { font-size: 20px; }
.paybtn { min-height: 34px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--paper); cursor: pointer; font-size: 13px; font-weight: 500; white-space: nowrap; }
.paybtn.on { background: #1E9E64; border-color: #1E9E64; color: #fff; }
@media (max-width: 900px) { .admin-grid { grid-template-columns: 1fr; } }

/* ---------- Celular ---------- */
@media (max-width: 720px) {
  .topbar-in { padding: 0 8px 0 16px; gap: 10px; }
  .topbar img { height: 16px; }
  .topbar .tag, .topbar .who, .topbar .hide-sm { display: none; }
  .topbar nav { gap: 0; font-size: 13px; }
  .topbar nav a, .topbar nav button { padding: 0 10px; }
  .wrap { padding: 20px 14px 120px; }
  /* tabelas viram cartões no celular */
  .table.stack thead { display: none; }
  .table.stack, .table.stack tbody, .table.stack tr, .table.stack td { display: block; width: 100%; }
  .table.stack tr { padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .table.stack td { border: 0; padding: 3px 0; text-align: left; }
  .table.stack td.num { text-align: left; }
  .table.stack td[data-l]::before { content: attr(data-l) ': '; color: var(--ink-3); font-size: 12px; }
}

.toast { position: fixed; top: 76px; left: 50%; transform: translateX(-50%); z-index: 90; background: var(--ink); color: #F4F2EE; padding: 10px 16px; border-radius: 999px; font-size: 13px; opacity: 0; transition: opacity .3s; pointer-events: none; max-width: calc(100vw - 32px); text-align: center; }
.toast.on { opacity: 1; }
.loading { min-height: 100vh; display: flex; align-items: center; justify-content: center; color: var(--ink-3); }
