/* ===== Reset & Variables ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #0066cc;
  --primary-dark: #0052a3;
  --danger: #dc3545;
  --success: #28a745;
  --warning-bg: #fff3cd;
  --info-bg: #cce5ff;
  --error-bg: #f8d7da;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --border: #dee2e6;
  --text: #212529;
  --text-muted: #6c757d;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --touch: 44px;
  --gap: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

.container {
  max-width: 400px;
  margin: 0 auto;
  padding: 0 var(--gap);
}

/* ===== Layout ===== */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 var(--gap);
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.app-header .logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
}

.app-header nav {
  display: flex;
  gap: 8px;
  align-items: center;
}

.app-header nav a {
  color: var(--text);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  min-height: var(--touch);
  display: flex;
  align-items: center;
}

.app-header nav a:hover { background: var(--bg); }
.app-header nav a.active { color: var(--primary); font-weight: 600; }

.page-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--gap);
}

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--gap);
  margin-bottom: var(--gap);
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 12px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--touch);
  padding: 0 20px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }

.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--border); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b02a37; }

.btn-sm { min-height: 36px; padding: 0 12px; font-size: 0.875rem; }
.btn-full { width: 100%; }
.btn-icon { padding: 0; width: var(--touch); border-radius: 50%; }

/* ===== Forms ===== */
.form-group { margin-bottom: var(--gap); }

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 0.95rem;
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="file"],
select,
textarea {
  width: 100%;
  min-height: var(--touch);
  padding: 0 12px;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  -webkit-appearance: none;
}

input[type="file"] { padding: 10px 12px; }
textarea { padding: 12px; resize: vertical; min-height: 80px; }

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  border-color: var(--primary);
}

/* ===== Alerts / Banners ===== */
.alert {
  padding: 12px var(--gap);
  border-radius: var(--radius);
  margin-bottom: var(--gap);
  font-size: 0.95rem;
}

.alert-warning { background: var(--warning-bg); color: #664d03; }
.alert-info    { background: var(--info-bg);    color: #084298; }
.alert-error   { background: var(--error-bg);   color: #721c24; }
.alert-success { background: #d1e7dd;           color: #0a3622; }

/* ===== Tables ===== */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { background: var(--bg); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: none; }

/* ===== Tabs ===== */
.tab-nav { display:flex; gap:4px; margin-bottom:var(--gap); }
.tab-btn { padding:8px 16px; border:1px solid var(--border); background:var(--bg); border-radius:var(--radius); cursor:pointer; font-size:0.9rem; }
.tab-btn.active { background:var(--primary); color:#fff; border-color:var(--primary); }
.tab-panel { display:none; }
.tab-panel.active { display:block; }

/* ===== Account — legal content typography ===== */
#tab-privacy h3, #tab-terms h3 { font-size:1.15rem; margin-bottom:4px; }
#tab-privacy p.text-muted, #tab-terms p.text-muted { margin-bottom:16px; }
#tab-privacy h4, #tab-terms h4 { font-size:1rem; margin-top:16px; margin-bottom:6px; }
#tab-privacy p, #tab-terms p { margin-bottom:10px; line-height:1.5; }
#tab-privacy ul, #tab-terms ul { margin:0 0 10px 20px; }
#tab-privacy li, #tab-terms li { margin-bottom:4px; }

/* ===== Auth pages (login / signup) ===== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--gap);
}

.auth-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px var(--gap);
  width: 100%;
  max-width: 420px;
}

.auth-card h1 { font-size: 1.5rem; margin-bottom: 8px; }
.auth-card .subtitle { color: var(--text-muted); margin-bottom: 24px; }

/* ===== Logo upload ===== */
.logo-preview {
  width: 80px;
  height: 80px;
  object-fit: contain;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* ===== POS — Catalog grid ===== */
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding-bottom: 80px; /* space for sticky basket bar */
}

@media (min-width: 640px) {
  .catalog-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1024px) {
  .catalog-grid { grid-template-columns: repeat(4, 1fr); }
}

.catalog-item {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  cursor: pointer;
  position: relative;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.1s, box-shadow 0.1s;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.catalog-item:active { transform: scale(0.97); }
.catalog-item.in-basket { border: 2px solid var(--primary); }
.catalog-item.custom-item { border: 2px dashed var(--border); color: var(--text-muted); align-items: center; }

.catalog-item .item-name { font-weight: 600; font-size: 0.95rem; }
.catalog-item .item-price { font-size: 0.9rem; color: var(--text-muted); }
.catalog-item .item-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== POS — Tab toggle ===== */
.pos-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: var(--gap);
}

.pos-tab {
  flex: 1;
  min-height: var(--touch);
  border: none;
  background: transparent;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}

.pos-tab.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow);
}

/* ===== POS — Basket bar ===== */
.basket-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--primary);
  color: #fff;
  padding: 12px var(--gap);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 200;
  min-height: 56px;
}

.basket-bar.empty { background: var(--border); color: var(--text-muted); }

/* ===== POS — Basket panel ===== */
.basket-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.12);
  z-index: 300;
  max-height: 85vh;
  overflow-y: auto;
  padding: var(--gap);
  transform: translateY(100%);
  transition: transform 0.25s ease;
}

.basket-panel.open { transform: translateY(0); }

.basket-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.basket-line .line-name { flex: 1; font-weight: 500; }
.basket-line .line-total { font-weight: 600; min-width: 60px; text-align: right; }

.qty-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.qty-controls button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qty-controls .qty-value { min-width: 24px; text-align: center; font-weight: 600; }

.basket-remove {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 1.1rem;
  min-width: var(--touch);
  min-height: var(--touch);
  display: flex;
  align-items: center;
  justify-content: center;
}

.basket-totals { padding: 12px 0; }
.basket-totals .total-line {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 0.95rem;
}

.basket-totals .total-line.grand-total {
  font-size: 1.1rem;
  font-weight: 700;
  border-top: 2px solid var(--text);
  margin-top: 8px;
  padding-top: 8px;
}

/* ===== QR / payment result ===== */
.qr-result {
  text-align: center;
  padding: var(--gap);
}

.qr-result img { max-width: 200px; height: auto; }

/* ===== VAT selector ===== */
.vat-selector {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.vat-option {
  flex: 1;
  min-width: 80px;
  min-height: var(--touch);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  transition: border-color 0.15s, background 0.15s;
}

.vat-option.selected {
  border-color: var(--primary);
  background: #e8f0fb;
  color: var(--primary);
}

/* ===== Overlay backdrop ===== */
.overlay-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 250;
  display: none;
}

.overlay-backdrop.visible { display: block; }

/* ===== Bank picker grid ===== */
.bank-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  max-height: 320px;
  overflow-y: auto;
  margin-bottom: var(--gap);
}

.bank-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 6px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  background: var(--surface);
  gap: 6px;
  transition: border-color 0.15s;
  width: 100%;
  box-sizing: border-box;
}

.bank-tile:hover { border-color: #9ca3af; }
.bank-tile.selected { border-color: var(--primary); background: #e8f0fb; }

.bank-tile img { height: 24px; width: auto; object-fit: contain; flex-shrink: 0; }
.bank-tile span { font-size: 0.8rem; text-align: center; color: var(--text); }

.bank-grid-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 16px 0;
}

.link-btn {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 0.875rem;
  padding: 0;
  text-decoration: underline;
}

@media (min-width: 640px) {
  .bank-tile img { height: 28px; }
}

@media (min-width: 1024px) {
  .bank-tile img { height: 32px; }
}

.bank-confirm-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  background: #e8f0fb;
  margin-bottom: var(--gap);
}

.bank-confirm-card img {
  height: 32px;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
}

.bank-confirm-card span {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.bank-phase-fade-out {
  opacity: 0;
  transition: opacity 150ms ease;
  pointer-events: none;
}

@keyframes bankFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.bank-phase-fade-in {
  animation: bankFadeIn 150ms ease both;
}

/* ===== Utility ===== */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; }

/* ===== Responsive tweaks ===== */
@media (min-width: 640px) {
  .auth-card { padding: 40px; }
  .page-content { padding: 24px; }
}
