:root {
  --bg-page: #FAF8F5; --bg-surface: #FFF; --bg-dark: #1E242B; --text-main: #222831; --text-muted: #5F6B7A;
  --gold: #B88E44; --gold-hover: #9E7736; --green: #217346; --border: #E8E2D8; --cream: #F4F1EA;
  --radius: 12px; --shadow: 0 10px 30px rgba(30,36,43,.07);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Plus Jakarta Sans', sans-serif; background: var(--bg-page); color: var(--text-main); padding: calc(18px + env(safe-area-inset-top)) 14px calc(60px + env(safe-area-inset-bottom)); -webkit-tap-highlight-color: transparent; }
.container { max-width: 1400px; margin: 0 auto; }
header { text-align: center; margin-bottom: 22px; }
header h1 { font-family: 'Cinzel', serif; font-size: 2rem; color: var(--bg-dark); margin-bottom: 6px; }
header p { color: var(--text-muted); font-size: .92rem; }
.badge { display: inline-block; background: rgba(184,142,68,.12); color: var(--gold); padding: 5px 12px; border-radius: 20px; font-size: .78rem; font-weight: 600; margin-bottom: 10px; }
.tabs { display: inline-flex; gap: 6px; margin-top: 16px; background: var(--cream); padding: 5px; border-radius: 10px; }
.tab { border: 0; background: transparent; padding: 8px 16px; border-radius: 7px; font: inherit; font-weight: 600; font-size: .88rem; color: var(--text-muted); cursor: pointer; }
.tab.active { background: var(--bg-dark); color: #fff; }
.tab-panel { display: none; } .tab-panel.active { display: block; }
.grid-top { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; margin-bottom: 20px; align-items: start; }
@media (max-width: 1000px) { .grid-top { grid-template-columns: 1fr; } }
.side { display: flex; flex-direction: column; gap: 20px; }
.card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px; }
.side .card { margin-bottom: 0; }
.card h3 { font-family: 'Cinzel', serif; font-size: 1.1rem; color: var(--bg-dark); border-bottom: 1px solid var(--border); padding-bottom: 8px; margin-bottom: 14px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.fg { margin-bottom: 11px; }
label { display: block; font-weight: 600; font-size: .76rem; margin-bottom: 4px; color: var(--bg-dark); }
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; font: inherit; font-size: .88rem; background: #FAFAFA; color: var(--text-main); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); background: #fff; }
textarea { resize: vertical; margin-bottom: 8px; }
.checks { display: flex; flex-wrap: wrap; gap: 16px; background: var(--cream); padding: 10px 12px; border-radius: 8px; margin: 4px 0 12px; }
.checks label, .check-inline { display: flex; align-items: center; gap: 7px; margin: 0; cursor: pointer; font-size: .82rem; }
.check-inline { margin: 4px 0 10px; }
.checks input, .check-inline input { width: 16px; height: 16px; accent-color: var(--gold); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; width: 100%; border: 0; padding: 11px; border-radius: 8px; font: inherit; font-weight: 700; font-size: .9rem; cursor: pointer; text-decoration: none; transition: filter .15s; }
.btn:hover { filter: brightness(.93); } .btn:disabled { opacity: .55; cursor: wait; }
.btn-gold { background: var(--gold); color: #fff; } .btn-dark { background: var(--bg-dark); color: #fff; }
.btn-green { background: var(--green); color: #fff; } .btn-light { background: var(--border); color: var(--bg-dark); }
.btn-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 6px 0 8px; }
.btn-row.tight { grid-template-columns: 1fr 1fr; margin: 0; }
.small-btn { width: auto; padding: 8px 14px; margin-top: 10px; font-size: .82rem; }
.hint { color: var(--text-muted); font-size: .8rem; margin-bottom: 10px; line-height: 1.45; } .small { font-size: .76rem; margin-top: 8px; }
code { background: var(--cream); padding: 1px 5px; border-radius: 4px; font-size: .78rem; }
.muted { color: var(--text-muted); font-family: 'Plus Jakarta Sans'; font-size: .8rem; font-weight: 500; }
.sum-lines div { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: .88rem; }
.total-box { margin: 12px 0 6px; background: var(--bg-dark); color: #fff; padding: 14px; border-radius: 8px; text-align: right; }
.total-box h4 { font-size: .74rem; color: var(--gold); text-transform: uppercase; letter-spacing: .06em; }
.total-box .price { font-family: 'Cinzel', serif; font-size: 1.7rem; font-weight: 700; }
.table-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 8px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.table-head h3 { border: 0; margin: 0; }
.legend { font-size: .75rem; color: var(--text-muted); padding-bottom: 8px; }
.table-wrap { overflow-x: auto; }
table.items { width: 100%; border-collapse: collapse; font-size: .84rem; }
table.items th { background: var(--bg-dark); color: #fff; text-align: left; padding: 8px; font-size: .74rem; font-weight: 600; white-space: nowrap; }
table.items td { padding: 5px 4px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.items tr.group td { background: var(--cream); font-weight: 700; font-size: .78rem; color: var(--gold-hover); padding: 6px 8px; text-transform: uppercase; letter-spacing: .04em; }
table.items input, table.items select { padding: 6px 7px; font-size: .82rem; }
table.items .num { width: 80px; text-align: right; } table.items .unit { width: 80px; } table.items .cat { width: 140px; }
td.ext { text-align: right; font-weight: 700; white-space: nowrap; padding-right: 8px; min-width: 90px; }
.sku-cell { display: flex; gap: 4px; align-items: center; }
.sku-cell select { width: 78px; flex: none; }
.icon-btn { border: 0; background: var(--cream); border-radius: 6px; padding: 6px 8px; cursor: pointer; font-size: .85rem; flex: none; }
.icon-btn:hover { background: var(--border); } .icon-btn.del { color: #c0392b; }
.name-cell { display: flex; gap: 6px; align-items: center; }
.name-cell img { width: 30px; height: 30px; object-fit: contain; border-radius: 4px; background: #fff; border: 1px solid var(--border); flex: none; }
.tag { display: inline-block; font-size: .64rem; font-weight: 700; padding: 2px 6px; border-radius: 10px; text-transform: uppercase; flex: none; }
.tag.est { background: #FFF1D6; color: #9A6B00; } .tag.live { background: #DFF3E6; color: #1E7A43; } .tag.warn { background: #FDE2E1; color: #B42318; }
a.tag { text-decoration: none; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--bg-dark); color: #fff; padding: 11px 18px; border-radius: 8px; font-size: .85rem; max-width: 90vw; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 9; }
#toast.show { opacity: 1; } #toast.err { background: #B42318; }

#loginOverlay { position: fixed; inset: 0; background: var(--bg-page); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 16px; }
#loginOverlay[hidden] { display: none; }
.login-card { width: 100%; max-width: 380px; text-align: center; }
.login-card h1 { font-family: 'Cinzel', serif; font-size: 1.5rem; color: var(--bg-dark); margin-bottom: 4px; }
.login-card .fg { text-align: left; }
.login-error { color: #B42318; font-size: .82rem; margin-top: 10px; min-height: 1em; }

/* ---------- auth ---------- */
#authOverlay { position: fixed; inset: 0; background: var(--bg-page); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 16px; overflow-y: auto; }
#authOverlay[hidden] { display: none; }
.auth-logo { width: 72px; height: 72px; border-radius: 16px; margin-bottom: 10px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--cream); padding: 4px; border-radius: 9px; margin: 6px 0 14px; }
.auth-tab { border: 0; background: transparent; padding: 9px; border-radius: 7px; font: inherit; font-weight: 600; font-size: .85rem; color: var(--text-muted); cursor: pointer; }
.auth-tab.active { background: var(--bg-dark); color: #fff; }
.login-card a, .center a { color: var(--gold-hover); }
.center { text-align: center; }
[hidden] { display: none !important; }

/* ---------- settings ---------- */
.btn-red { background: #B42318; color: #fff; }
.card.danger { border-color: #F3C6C2; }
.logo-row { display: flex; align-items: center; gap: 10px; }
.logo-row img { max-height: 54px; max-width: 140px; border: 1px solid var(--border); border-radius: 6px; padding: 3px; background: #fff; }
.logo-row input[type=file] { flex: 1; }

/* ---------- phones: tables become cards ---------- */
@media (max-width: 720px) {
  header h1 { font-size: 1.45rem; }
  .tabs { display: grid; grid-template-columns: repeat(4, 1fr); width: 100%; }
  .tab { padding: 8px 4px; font-size: .8rem; }
  .card { padding: 15px; }
  .row2 { grid-template-columns: 1fr; }
  .btn-row { grid-template-columns: repeat(3, 1fr); }
  .table-wrap { overflow: visible; }
  table.responsive thead { display: none; }
  table.responsive, table.responsive tbody { display: block; width: 100%; }
  table.responsive tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; padding: 12px; margin-bottom: 10px;
                        border: 1px solid var(--border); border-radius: 10px; background: #fff; }
  table.responsive tr.group { display: block; padding: 4px 2px; border: 0; background: none; margin: 14px 0 4px; }
  table.responsive tr.group td { background: none; padding: 0; }
  table.responsive td { display: block; border: 0; padding: 0; min-width: 0; }
  table.responsive td[data-label]::before { content: attr(data-label); display: block; font-size: .68rem; font-weight: 600; color: var(--text-muted); margin-bottom: 3px; text-transform: uppercase; letter-spacing: .03em; }
  table.responsive td.wide { grid-column: 1 / -1; }
  table.responsive td.ext { text-align: left; font-size: 1rem; align-self: end; }
  table.responsive td.actions { display: flex; justify-content: flex-end; gap: 6px; align-items: end; }
  table.items .num, table.items .unit, table.items .cat { width: 100%; text-align: left; }
  table.items input, table.items select { font-size: 16px; } /* prevents zoom-on-focus */
  input, select, textarea { font-size: 16px; }
  .icon-btn { padding: 9px 12px; }
}
