:root {
  --bg: #090c10;
  --bg-grad: radial-gradient(circle at 15% 0%, rgba(247, 147, 26, 0.08) 0%, transparent 45%),
             radial-gradient(circle at 85% 10%, rgba(56, 189, 248, 0.05) 0%, transparent 40%),
             #090c10;
  --panel: #11161f;
  --panel-2: #171e2b;
  --panel-hover: #1c2433;
  --ink: #f1f5f9;
  --muted: #94a3b8;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --accent: #f7931a;
  --accent-2: #ffad33;
  --accent-grad: linear-gradient(135deg, #ff9f1c 0%, #f77f00 100%);
  --accent-ink: #0f0a02;
  --ok: #10b981;
  --bad: #ef4444;
  --warn: #f59e0b;
  --info: #38bdf8;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font: 14.5px/1.55 "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-grad);
  background-attachment: fixed;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* ---------------- Top Header Bar ---------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 24px;
  background: rgba(17, 22, 31, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
}

.brand::before {
  content: "⚡";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--accent-grad);
  color: var(--accent-ink);
  font-size: 15px;
  box-shadow: 0 2px 10px rgba(247, 147, 26, 0.35);
}

.brand span {
  color: var(--muted);
  font-weight: 500;
  font-size: 13.5px;
  padding-left: 10px;
  border-left: 1px solid var(--line-strong);
}

.who {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  background: var(--panel-2);
  border: 1px solid var(--line);
  padding: 5px 12px;
  border-radius: 999px;
  max-width: 48vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.who:empty {
  display: none;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.error {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.28);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-top: 12px;
}
.error:empty {
  display: none;
}

/* ---------------- Form Controls & Buttons ---------------- */
input, select, textarea {
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  font: inherit;
  font-size: 14px;
  min-width: 0;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

input::placeholder, textarea::placeholder {
  color: #64748b;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(247, 147, 26, 0.18);
  background: #1a2232;
}

button {
  background: var(--accent-grad);
  color: var(--accent-ink);
  border: 0;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  transition: transform 0.1s ease, filter 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 2px 8px rgba(247, 147, 26, 0.25);
}

button:hover {
  filter: brightness(1.07);
}

button:active {
  transform: translateY(1px);
}

.btn-subtle {
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 13px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: none;
}

.btn-subtle:hover {
  background: var(--panel-hover);
  border-color: rgba(255, 255, 255, 0.22);
}

/* ---------------- Login & Registration View ---------------- */
.login {
  max-width: 580px;
  margin: 5vh auto;
  padding: 0 16px;
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-lg);
}

.login h1 {
  margin: 0 0 8px 0;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.login form#login-form {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.login form#login-form input {
  flex: 1;
  width: 100%;
}

.register-box {
  margin-top: 22px;
  background: rgba(23, 30, 43, 0.75);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  padding: 16px 18px;
}

.register-box summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--accent-2);
  font-size: 14px;
  user-select: none;
}

/* ---------------- App Shell (Desktop Sidebar + Mobile Tabs) ---------------- */
.app {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

#merchant-announcements {
  grid-column: 1 / -1;
}

#merchant-announcements:empty {
  display: none;
}

.tabs {
  position: sticky;
  top: 76px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 12px;
  box-shadow: var(--shadow-sm);
}

.tabs button:not(.logout) {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  justify-content: flex-start;
  text-align: left;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13.5px;
  box-shadow: none;
  width: 100%;
}

.tabs button:not(.logout):hover {
  background: var(--panel-2);
  color: var(--ink);
}

.tabs button.active {
  background: var(--accent-grad) !important;
  color: var(--accent-ink) !important;
  border-color: transparent !important;
  font-weight: 700 !important;
  box-shadow: 0 4px 12px rgba(247, 147, 26, 0.3) !important;
}

.logout {
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.25);
  margin-top: 10px;
  width: 100%;
  justify-content: center;
  box-shadow: none;
}

.logout:hover {
  background: rgba(239, 68, 68, 0.18);
}

/* ---------------- Panels, Cards & Tables ---------------- */
.panel {
  min-width: 0;
  animation: fadeIn 0.18s ease-out;
}

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

.panel h2 {
  margin: 0;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.panel h3 {
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease;
}

.card:hover {
  border-color: var(--line-strong);
}

.card .k {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.card .v {
  font-size: 22px;
  font-weight: 800;
  margin-top: 6px;
  letter-spacing: -0.02em;
  color: #fff;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.badge.ok { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge.bad { background: rgba(239, 68, 68, 0.15); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.3); }
.badge.warn { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }
.badge.mut { background: rgba(148, 163, 184, 0.14); color: #cbd5e1; border: 1px solid rgba(148, 163, 184, 0.25); }

.table-wrap {
  overflow-x: auto;
  margin-top: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  -webkit-overflow-scrolling: touch;
}

.card .table-wrap {
  background: transparent;
  border: none;
  box-shadow: none;
  border-radius: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

th, td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

th {
  color: var(--muted);
  font-weight: 700;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(255, 255, 255, 0.02);
  white-space: nowrap;
}

code {
  background: var(--panel-2);
  border: 1px solid var(--line);
  padding: 2px 7px;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12.5px;
  color: #e2e8f0;
}

pre code {
  background: transparent;
  border: none;
  padding: 0;
}

.inline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  align-items: center;
  margin: 12px 0;
}

.inline button {
  height: 41px;
}

a.link, a {
  color: var(--accent-2);
  text-decoration: none;
}

a.link:hover, a:hover {
  text-decoration: underline;
}

/* ---------------- POS & Kiosk ---------------- */
.pos-top-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pos-layout {
  display: grid;
  grid-template-columns: minmax(310px, 440px) minmax(320px, 1fr);
  gap: 20px;
  margin-top: 16px;
}

.pos-column {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
}

.pos-currency-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  font-size: 13px;
}

.pos-curr-group { display: flex; gap: 4px; }
.pos-curr-btn {
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--line-strong);
  padding: 5px 12px;
  font-size: 12px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
  box-shadow: none;
}
.pos-curr-btn.active {
  background: var(--accent-grad);
  color: var(--accent-ink);
  border-color: transparent;
}
.pos-rate-badge {
  background: rgba(247, 147, 26, 0.14);
  color: var(--accent-2);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
}
.pos-screen {
  background: #06080c;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-md);
  padding: 18px;
  text-align: right;
  margin-bottom: 14px;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.6);
}
.pos-screen-main {
  font-size: 40px;
  font-weight: 800;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #fff;
  letter-spacing: -1px;
  word-break: break-all;
}
.pos-screen-sub {
  font-size: 14px;
  color: var(--muted);
  margin-top: 4px;
}
.pos-presets {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin-bottom: 14px;
}
.pos-preset-btn {
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  padding: 8px 4px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: none;
}
.pos-preset-btn:hover { background: rgba(247, 147, 26, 0.2); border-color: var(--accent); }
.pos-keypad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.pos-key {
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  font-size: 22px;
  font-weight: 700;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  box-shadow: none;
  transition: transform 0.05s ease, background 0.1s ease;
}
.pos-key:hover { background: var(--panel-hover); }
.pos-key:active { transform: scale(0.97); }
.pos-key.action {
  background: rgba(239, 68, 68, 0.14);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}
.pos-key.charge-btn {
  background: var(--accent-grad);
  color: var(--accent-ink);
  border-color: transparent;
  font-size: 18px;
  box-shadow: 0 4px 14px rgba(247, 147, 26, 0.35);
}
.pos-meta-group { display: flex; flex-direction: column; gap: 8px; }
.pos-meta-group input { width: 100%; }

/* Active bill / QR display */
.pos-display-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 440px;
  text-align: center;
}
.pos-idle { padding: 40px 20px; }
.pos-idle-icon { font-size: 54px; margin-bottom: 12px; }
.pos-idle h3 { margin: 0 0 8px 0; font-size: 20px; }
.pos-card-bill {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.pos-bill-header { font-size: 14px; color: var(--muted); }
.pos-bill-amount {
  font-size: 32px;
  font-weight: 800;
  color: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.pos-qr-box {
  background: #ffffff;
  padding: 16px;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}
.pos-qr-box img { width: 220px; height: 220px; display: block; max-width: 70vw; max-height: 70vw; }
.pos-bill-meta { font-size: 13px; color: var(--muted); }
.pos-bill-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
}
.pos-bill-status.waiting {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}
.pos-bill-status.paid {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  font-size: 16px;
  animation: pulse-paid 1.2s infinite;
}
@keyframes pulse-paid {
  0% { transform: scale(1); }
  50% { transform: scale(1.04); }
  100% { transform: scale(1); }
}
.pos-bill-actions { display: flex; gap: 10px; width: 100%; justify-content: center; flex-wrap: wrap; }

/* Receipt modal & print */
.receipt-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.receipt-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(4px);
}
.receipt-dialog {
  position: relative;
  z-index: 1001;
  max-width: 400px;
  width: 92%;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  padding: 20px;
  max-height: 90vh;
  overflow-y: auto;
}
.receipt-dialog-actions {
  display: flex;
  justify-content: space-between;
  margin-bottom: 14px;
}
.receipt-paper {
  background: #ffffff;
  color: #111;
  padding: 24px;
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
.receipt-paper h3 { margin: 0 0 4px 0; text-align: center; font-size: 16px; color: #000; }
.receipt-paper .r-center { text-align: center; }
.receipt-paper .r-divider { border-top: 1px dashed #777; margin: 12px 0; }
.receipt-paper .r-row { display: flex; justify-content: space-between; margin: 4px 0; gap: 8px; }
.receipt-paper .r-bold { font-weight: 700; }
.receipt-paper .r-large { font-size: 18px; }
.receipt-paper .r-qr { text-align: center; margin: 14px 0; }
.receipt-paper .r-qr img { width: 140px; height: 140px; }

/* Kiosk Fullscreen Mode */
body.kiosk-mode .topbar,
body.kiosk-mode .tabs,
body.kiosk-mode #overview,
body.kiosk-mode #charges,
body.kiosk-mode #refunds,
body.kiosk-mode #team {
  display: none !important;
}
body.kiosk-mode .app {
  display: block;
  max-width: 100vw;
  margin: 0;
  padding: 12px 24px;
}

/* ---------------- All-Device Responsive Breakpoints ---------------- */
@media (max-width: 1024px) {
  .app {
    grid-template-columns: 1fr;
    padding: 16px;
    gap: 16px;
  }

  .tabs {
    position: sticky;
    top: 62px;
    z-index: 90;
    flex-direction: row;
    overflow-x: auto;
    white-space: nowrap;
    padding: 8px;
    gap: 6px;
    border-radius: var(--radius-md);
    background: rgba(17, 22, 31, 0.92);
    backdrop-filter: blur(12px);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  .tabs button:not(.logout),
  .tabs button.logout {
    width: auto;
    flex: 0 0 auto;
    margin-top: 0;
    padding: 8px 14px;
    font-size: 13px;
  }

  .pos-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 12px 14px;
  }

  .brand span {
    display: none;
  }

  .who {
    max-width: 55vw;
    font-size: 12px;
  }

  .login {
    margin: 3vh auto;
  }

  .login-card {
    padding: 20px 16px;
  }

  .login form#login-form {
    flex-direction: column;
  }

  .login form#login-form button {
    width: 100%;
  }

  .app {
    padding: 12px;
  }

  .cards {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
  }

  .card {
    padding: 14px;
  }

  .card .v {
    font-size: 18px;
  }

  .inline {
    grid-template-columns: 1fr;
  }

  .inline button {
    width: 100%;
  }

  .pos-presets {
    grid-template-columns: repeat(3, 1fr);
  }

  .pos-screen-main {
    font-size: 30px;
  }
}

@media print {
  body * { visibility: hidden !important; }
  .no-print { display: none !important; }
  #receipt-modal, #receipt-modal * { visibility: visible !important; }
  #receipt-modal {
    position: static; width: 100%; height: auto; display: block;
  }
  .receipt-backdrop { display: none; }
  .receipt-dialog {
    border: none; background: transparent; padding: 0; width: 100%; max-width: 100%;
  }
  .receipt-paper {
    box-shadow: none; border: none; padding: 0; width: 100%;
  }
}
