/* ============================================================================
   Amego POS — tablet-first UI  ·  light default + optional dark
   Single source of truth for theming. No build step; plain CSS custom props.
   ========================================================================= */

:root {
  /* Brand */
  --brand:        #6d28d9;
  --brand-2:      #4f46e5;
  --brand-grad:   linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);
  --brand-soft:   #ede9fe;

  /* Light surfaces */
  --bg:           #eef0f4;
  --surface:      #ffffff;
  --surface-2:    #f7f8fb;
  --surface-3:    #eef0f4;
  --border:       #dfe3ea;
  --border-strong:#c8cdd8;

  /* Text */
  --text:         #14151f;
  --text-2:       #4b5060;
  --text-muted:   #8a90a2;
  --on-brand:     #ffffff;

  /* Status */
  --green:        #16a34a;
  --green-soft:   #dcfce7;
  --red:          #dc2626;
  --red-soft:     #fee2e2;
  --amber:        #d97706;
  --amber-soft:   #fef3c7;
  --blue:         #2563eb;
  --blue-soft:    #dbeafe;

  /* Sizing — tuned for finger taps on tablets */
  --tap:          52px;     /* minimum interactive height */
  --radius:       14px;
  --radius-sm:    10px;
  --radius-lg:    20px;
  --gap:          14px;
  --shadow:       0 1px 2px rgba(16,18,32,.06), 0 6px 20px rgba(16,18,32,.06);
  --shadow-lg:    0 12px 40px rgba(16,18,32,.18);
  --font:         'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

[data-theme="dark"] {
  --bg:           #0b0c14;
  --surface:      #15172300;
  --surface:      #161826;
  --surface-2:    #1c1f30;
  --surface-3:    #232739;
  --border:       #2a2e42;
  --border-strong:#3a3f57;
  --text:         #f1f2f8;
  --text-2:       #b4b8c8;
  --text-muted:   #767c93;
  --brand-soft:   #2a2148;
  --green-soft:   #0f2e1d;
  --red-soft:     #3a1818;
  --amber-soft:   #3a2c10;
  --blue-soft:    #16243f;
  --shadow:       0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  --shadow-lg:    0 16px 48px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
h1,h2,h3,h4 { margin: 0; font-weight: 800; letter-spacing: -0.02em; }
a { color: var(--brand); text-decoration: none; }
img { max-width: 100%; }

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 700; font-size: 15px; cursor: pointer;
  transition: transform .08s, background .15s, box-shadow .15s, border-color .15s;
  user-select: none; white-space: nowrap;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn-primary { background: var(--brand-grad); color: var(--on-brand); border: none; box-shadow: 0 6px 18px rgba(99,82,237,.35); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.05); background: var(--brand-grad); }
.btn-danger { background: var(--red-soft); color: var(--red); border-color: transparent; }
.btn-danger:hover:not(:disabled) { background: var(--red); color: #fff; }
.btn-success { background: var(--green-soft); color: var(--green); border-color: transparent; }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.btn-lg { min-height: 60px; font-size: 17px; }
.btn-sm { min-height: 40px; padding: 0 12px; font-size: 14px; }
.btn-icon { min-width: var(--tap); padding: 0; }

/* ── Inputs ───────────────────────────────────────────────────────────────── */
.field { display: block; margin-bottom: 14px; }
.field label, .label { display: block; font-size: 13px; font-weight: 700; color: var(--text-2); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .04em; }
.input, .select, textarea.input {
  width: 100%; min-height: var(--tap); padding: 12px 14px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; font-size: 16px;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, textarea.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.input.invalid { border-color: var(--red); }
textarea.input { resize: vertical; min-height: 80px; }

/* ── Cards & surfaces ─────────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
.muted { color: var(--text-muted); }
.text-2 { color: var(--text-2); }

/* ── Badges & pills ───────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 800; letter-spacing: .03em; }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-brand { background: var(--brand-soft); color: var(--brand); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot-green { background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.dot-red { background: var(--red); box-shadow: 0 0 0 4px var(--red-soft); }
.dot-amber { background: var(--amber); box-shadow: 0 0 0 4px var(--amber-soft); }

/* ── Grad text ────────────────────────────────────────────────────────────── */
.grad { background: var(--brand-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10,12,22,.55); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 1000;
  animation: fade .15s ease;
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 440px; max-height: 92vh; overflow: auto; animation: pop .18s ease;
}
.modal-lg { max-width: 620px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.modal-head h3 { font-size: 18px; }
.modal-body { padding: 20px; }
.modal-x { background: var(--surface-2); border: none; width: 40px; height: 40px; border-radius: 10px; cursor: pointer; color: var(--text-2); display: grid; place-items: center; transition: background .12s, color .12s; }
.modal-x:hover { background: var(--surface-3); color: var(--text); }
.modal-x svg { display: block; }
.modal-x i { font-size: 18px; line-height: 1; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98); } }

/* ── Numpad ───────────────────────────────────────────────────────────────── */
.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.numpad button {
  min-height: 60px; font-size: 22px; font-weight: 800;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); cursor: pointer; transition: background .12s, transform .06s;
}
.numpad button:active { transform: scale(.96); background: var(--brand-soft); }

/* ── Toast ────────────────────────────────────────────────────────────────── */
#toasts { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 700; font-size: 14px; box-shadow: var(--shadow-lg); animation: pop .18s ease; max-width: 90vw; }
.toast.ok { background: var(--green); color: #fff; }
.toast.err { background: var(--red); color: #fff; }

/* ── Utility ──────────────────────────────────────────────────────────────── */
.row { display: flex; align-items: center; gap: var(--gap); }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }
.hide { display: none !important; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
