/* =================================================================
   QR Naplata — Desktop POS dashboard
   Inspired by Stripe / Square / Linear patterns
   ================================================================= */

:root {
  /* Palette */
  --bg:            #f6f8fb;
  --surface:       #ffffff;
  --surface-2:     #fbfcfe;
  --surface-3:     #f1f4f9;
  --border:        #e4e9f0;
  --border-strong: #cdd5e0;
  --text:          #0f172a;
  --text-muted:    #64748b;
  --text-subtle:   #94a3b8;

  --accent:        #2563eb;
  --accent-hover:  #1d4ed8;
  --accent-soft:   #eff4ff;
  --accent-border: #c7d8fc;

  --success:       #16a34a;
  --success-hover: #15803d;
  --success-soft:  #dcfce7;

  --danger:        #dc2626;
  --danger-hover:  #b91c1c;
  --danger-soft:   #fee2e2;

  --warning:       #b45309;
  --warning-soft:  #fef3c7;

  --indigo-soft:   #ede9fe;
  --indigo:        #4338ca;

  /* Shadows */
  --shadow-1: 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-2: 0 4px 14px rgba(15, 23, 42, .06);
  --shadow-3: 0 16px 48px rgba(15, 23, 42, .18);

  /* Radius */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter",
               "Roboto", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 { margin: 0; line-height: 1.2; font-weight: 600; }
h1 { font-size: 22px; }
h2 { font-size: 16px; letter-spacing: -.01em; }
h3 { font-size: 14px; }
p  { margin: 0; }

.hint {
  color: var(--text-muted);
  font-size: 12px;
}

/* =================================================================
   TOP BAR
   ================================================================= */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-1);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #4f46e5);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: -.02em;
}

.brand-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.01em;
}

.brand-merchant {
  font-size: 12px;
  color: var(--text-muted);
}

.topbar-spacer { flex: 1; }

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 14px;
}

.clock {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  padding: 6px 10px;
  background: var(--surface-3);
  border-radius: var(--r-md);
}

.separator {
  width: 1px; height: 22px;
  background: var(--border);
}

.operator-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.2;
}

.operator-block .label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.operator-block strong {
  font-size: 14px;
  color: var(--text);
}

/* =================================================================
   BUTTONS
   ================================================================= */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s, transform .05s;
  white-space: nowrap;
  user-select: none;
}
.button:active { transform: translateY(1px); }
.button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.button-lg {
  padding: 13px 18px;
  font-size: 14px;
  border-radius: 12px;
}

.button-primary {
  background: var(--accent);
  color: #fff;
}
.button-primary:hover { background: var(--accent-hover); }

.button-soft {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.button-soft:hover { border-color: var(--border-strong); background: var(--surface-2); }

.button-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.button-ghost:hover { background: var(--surface-3); color: var(--text); }

.button-success {
  background: var(--success);
  color: #fff;
}
.button-success:hover { background: var(--success-hover); }

.button-danger {
  background: var(--danger);
  color: #fff;
}
.button-danger:hover { background: var(--danger-hover); }

.button-danger-outline {
  background: #fff;
  color: var(--danger);
  border-color: var(--danger-soft);
}
.button-danger-outline:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.button:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none !important;
}

.icon-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }

.ghost-button {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.ghost-button:hover { background: var(--surface-3); }

kbd {
  display: inline-block;
  padding: 1px 6px;
  font: 600 11px/1.4 "SF Mono", Menlo, Consolas, monospace;
  background: rgba(255,255,255,.18);
  color: inherit;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,.25);
  letter-spacing: .02em;
}
.button-soft kbd, .button-ghost kbd {
  background: var(--surface-3);
  color: var(--text-muted);
  border-color: var(--border);
}

/* =================================================================
   WORKSPACE LAYOUT
   ================================================================= */
.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(380px, 440px) 1fr;
  gap: 20px;
  padding: 20px 24px 24px;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  align-items: start;
}

.pane { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.pane-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0 2px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 20px;
  box-shadow: var(--shadow-1);
}

/* =================================================================
   PAY CARD (left)
   ================================================================= */
.pay-card { display: flex; flex-direction: column; gap: 14px; }

.field-label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.field-label .optional {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

.field { display: flex; flex-direction: column; gap: 6px; }

input[type="text"],
input[type="password"],
input[type="search"],
input[type="date"],
input[type="number"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--r-md);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}

input:disabled, textarea:disabled, select:disabled {
  background: var(--surface-3);
  color: var(--text-muted);
  cursor: not-allowed;
}

textarea {
  resize: vertical;
  min-height: 60px;
}

/* Hero amount input */
#amount {
  font-size: 36px;
  font-weight: 700;
  text-align: center;
  padding: 16px 14px;
  letter-spacing: -.01em;
  font-variant-numeric: tabular-nums;
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
  cursor: pointer;
  user-select: none;
  transition: border-color .12s, background .12s;
}
.checkbox-row:hover { border-color: var(--border-strong); }
.checkbox-row.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.checkbox-row input[type="checkbox"] {
  width: 18px; height: 18px;
  margin: 2px 0 0;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.checkbox-content { display: flex; flex-direction: column; gap: 2px; }
.checkbox-title  { font-size: 13px; font-weight: 600; color: var(--text); }
.checkbox-hint   { font-size: 12px; color: var(--text-muted); line-height: 1.4; }
.checkbox-hint strong { color: var(--text); font-weight: 600; }

/* =================================================================
   KPI GRID
   ================================================================= */
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 16px;
  box-shadow: var(--shadow-1);
}

.kpi-today { border-top: 3px solid var(--accent); }
.kpi-month { border-top: 3px solid var(--indigo); }

.kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 6px;
}

.kpi-value {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.kpi-row {
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.kpi-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.closure-status {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 0 4px;
}
.closure-status.locked {
  color: var(--warning);
  font-weight: 600;
}

/* =================================================================
   TOOLBAR CARD (right top)
   ================================================================= */
.toolbar-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 14px 16px;
  box-shadow: var(--shadow-1);
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
}

.toolbar-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.toolbar-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  font-weight: 600;
}

.toolbar-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* =================================================================
   TX CARD (right bottom)
   ================================================================= */
.tx-card { display: flex; flex-direction: column; gap: 14px; padding: 16px 20px 20px; }

.tx-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.presets {
  display: inline-flex;
  background: var(--surface-3);
  padding: 3px;
  border-radius: 10px;
  gap: 2px;
}

.preset-btn {
  border: 0;
  background: transparent;
  font: 600 12px/1 inherit;
  color: var(--text-muted);
  padding: 7px 12px;
  border-radius: 7px;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.preset-btn:hover { color: var(--text); }
.preset-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-1);
}

.filters {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.filter-search {
  position: relative;
  display: flex;
  align-items: center;
}
.filter-search input {
  padding-left: 34px;
  padding-right: 60px;
}
.filter-search .icon {
  position: absolute;
  left: 12px;
  font-size: 16px;
  color: var(--text-muted);
  pointer-events: none;
}
.filter-search .shortcut {
  position: absolute;
  right: 10px;
  background: var(--surface-3);
  color: var(--text-muted);
  border-color: var(--border);
}

.filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr auto;
  gap: 8px;
  align-items: end;
}

.filter-grid > div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }

.micro-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.filter-actions {
  display: flex;
  gap: 6px;
}

/* Table head */
.tx-table-head {
  display: grid;
  grid-template-columns: 110px 1fr 1.1fr 1.4fr;
  gap: 12px;
  padding: 8px 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
}

.tx-list {
  display: flex;
  flex-direction: column;
  max-height: 520px;
  overflow-y: auto;
  margin: 0 -4px;
  padding: 0 4px;
}

.tx-list::-webkit-scrollbar { width: 10px; }
.tx-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 8px;
  border: 2px solid var(--surface);
}

/* Tx row (rendered by JS — keep existing .tx-item structure but desktop-grid it) */
.tx-item {
  display: grid;
  grid-template-columns: 110px 1fr 1.1fr 1.4fr;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.tx-item:hover { background: var(--surface-2); }
.tx-item:last-child { border-bottom: 0; }

.tx-item .tx-head {
  display: contents;
}

.tx-item .tx-amount {
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.tx-item .pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tx-item .tx-meta {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.tx-item .tx-note {
  font-size: 12px;
  color: var(--text);
  font-style: italic;
  background: var(--surface-3);
  padding: 4px 8px;
  border-radius: 6px;
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* =================================================================
   PILLS
   ================================================================= */
.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
}

.pill.pending   { color: var(--warning); background: var(--warning-soft); }
.pill.confirmed { color: var(--success); background: var(--success-soft); }
.pill.cancelled { color: var(--danger);  background: var(--danger-soft); }
.pill.legal     { color: var(--accent);  background: var(--accent-soft); }
.pill.individual{ color: var(--indigo);  background: var(--indigo-soft); }
.pill.locked    { color: var(--text-muted); background: var(--surface-3); }

/* =================================================================
   QR MODAL (customer-facing)
   ================================================================= */
.modal {
  position: fixed; inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal.hidden { display: none; }

.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 23, 42, .55);
  backdrop-filter: blur(4px);
}

.modal-panel {
  position: relative;
  background: var(--surface);
  border-radius: 20px;
  box-shadow: var(--shadow-3);
  width: min(560px, 92vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn .18s cubic-bezier(.2,.8,.2,1);
}

.modal-sm { width: min(440px, 92vw); }

@keyframes modalIn {
  from { transform: translateY(8px) scale(.98); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px 12px;
}

.modal-header h2 { font-size: 18px; }
.modal-header .hint { margin-top: 4px; }

.modal-body {
  padding: 8px 24px 16px;
  overflow-y: auto;
}

.modal-body p { margin: 0 0 10px; font-size: 13px; color: var(--text); }
.modal-body p:last-child { margin-bottom: 0; }

.modal-footer {
  display: flex;
  gap: 10px;
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.modal-footer .button { flex: 1; }
.modal-sm .modal-footer .button { flex: initial; }
.modal-sm .modal-footer { justify-content: flex-end; }

/* QR stage inside modal */
.qr-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 4px 0 8px;
}

.amount-hero {
  font-size: 32px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
  padding: 6px 18px;
  background: var(--accent-soft);
  border-radius: 14px;
}

.qr-frame {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 320px;
  height: 320px;
  box-shadow: var(--shadow-2);
}

#qrcode {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}
#qrcode img, #qrcode canvas {
  width: 100%;
  max-width: 280px;
  height: auto;
  display: block;
  image-rendering: pixelated;
}

.placeholder {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: 0 12px;
}

.tx-info {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  max-width: 380px;
  line-height: 1.5;
}

.status {
  min-height: 18px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}
.status.err { color: var(--danger); }
.status.ok  { color: var(--success); }

/* =================================================================
   TOASTS
   ================================================================= */
.toast-host {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}

.toast {
  background: var(--text);
  color: #fff;
  padding: 11px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-3);
  min-width: 240px;
  max-width: 360px;
  pointer-events: auto;
  animation: toastIn .18s ease-out;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.fadeout { animation: toastOut .2s ease-in forwards; }

@keyframes toastIn  { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toastOut { to { transform: translateY(10px); opacity: 0; } }

/* =================================================================
   LOGIN
   ================================================================= */
.login-app {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at top, rgba(37, 99, 235, .08), transparent 60%),
    var(--bg);
}

.login-app .login-box {
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 32px 28px;
  box-shadow: var(--shadow-2);
}

.login-app .title {
  text-align: center;
  margin-bottom: 22px;
}

.login-app .title h1 {
  font-size: 22px;
  margin-bottom: 4px;
}

.login-app .title .merchant-name {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.login-app label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 6px;
}

.login-app .field { margin-bottom: 14px; display: block; }

.login-app .button {
  width: 100%;
  margin-top: 4px;
}

.login-app .footer {
  text-align: center;
  font-size: 11px;
  color: var(--text-subtle);
  margin-top: 18px;
}

/* =================================================================
   RESPONSIVE (basic — primarily desktop)
   ================================================================= */
@media (max-width: 1100px) {
  .workspace { grid-template-columns: 1fr; }
  .filter-grid { grid-template-columns: 1fr 1fr; }
  .filter-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .tx-table-head, .tx-item { grid-template-columns: 100px 1fr 1.2fr; }
  .tx-table-head .tx-col-note, .tx-item .tx-note { display: none; }
}

.hidden { display: none !important; }
