/* =========================================================================
   Mr.Gadget POS — design system
   Direction: a technician's diagnostic bench. Cool slate-and-jade surfaces,
   an amber "solder-iron" accent for actions, status reported the way a
   real device reports it — small LED dots, register-tape mono numerals.
   ========================================================================= */

:root {
  --bg: #F2F5F4;
  --surface: #FFFFFF;
  --surface-alt: #E9EFED;
  --surface-sunken: #E3EAE8;
  --ink: #102322;
  --ink-soft: #51635F;
  --ink-faint: #8B9C97;
  --border: #DCE5E2;
  --border-strong: #C3D0CC;

  --primary: #0F6B5C;
  --primary-dark: #0A4F44;
  --primary-soft: #E2F1ED;
  --accent: #FF6A3D;
  --accent-dark: #E2542A;
  --accent-soft: #FFE9DF;

  --success: #1E9E62;
  --success-soft: #E1F5EA;
  --warn: #D98A1E;
  --warn-soft: #FCEFD9;
  --danger: #D6453F;
  --danger-soft: #FBE5E3;
  --info: #2A6FB0;
  --info-soft: #E3EEF9;

  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(16, 35, 34, 0.06);
  --shadow: 0 4px 16px rgba(16, 35, 34, 0.08);
  --shadow-lg: 0 12px 32px rgba(16, 35, 34, 0.16);

  --sidebar-w: 224px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; margin: 0; color: var(--ink); }
p { margin: 0; }
button { font-family: inherit; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--accent-soft); }

.num, .money, td.num, td.money { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---------- status LED, the signature motif ---------- */
.led {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--ink-faint);
  flex-shrink: 0;
}
.led--accent { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.led--success { background: var(--success); }
.led--warn { background: var(--warn); animation: pulse 1.8s ease-in-out infinite; }
.led--danger { background: var(--danger); animation: pulse 1.8s ease-in-out infinite; }
.led--info { background: var(--info); }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(217, 138, 30, .35); }
  50% { box-shadow: 0 0 0 4px rgba(217, 138, 30, 0); }
}

/* ===================== LOGIN ===================== */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 15% 20%, rgba(15,107,92,.18), transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(255,106,61,.14), transparent 40%),
    var(--ink);
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 36px 32px 28px;
}
.login-brand { text-align: center; margin-bottom: 28px; }
.brand-mark {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}
.fv-logo {
  position: relative;
  display: inline-flex;
  align-items: flex-end;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--primary);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18), 0 0 0 3px var(--primary-soft);
  flex-shrink: 0;
}
.fv-logo--sm {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
}
.fv-phone {
  width: 11px;
  height: 18px;
  border-radius: 3px;
  background: #fff;
  margin: 0 1px 5px 0;
  position: relative;
}
.fv-phone::after {
  content: '';
  position: absolute;
  left: 4px;
  bottom: 2px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--primary);
}
.fv-vape {
  width: 10px;
  height: 12px;
  border-radius: 2px 2px 4px 4px;
  background: var(--accent);
  margin: 0 0 5px 1px;
  position: relative;
}
.fv-vape::before {
  content: '';
  position: absolute;
  left: 2px;
  top: -5px;
  width: 8px;
  height: 7px;
  border-top: 2px solid var(--accent-soft);
  border-radius: 50%;
}
.fv-logo--sm .fv-phone {
  width: 9px;
  height: 15px;
  margin-bottom: 4px;
}
.fv-logo--sm .fv-vape {
  width: 8px;
  height: 10px;
  margin-bottom: 4px;
}
.login-tagline { color: var(--ink-soft); margin-top: 6px; font-size: 13px; letter-spacing: .02em; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-hint { margin-top: 18px; font-size: 12px; color: var(--ink-faint); text-align: center; }
.login-hint code { background: var(--surface-alt); padding: 1px 5px; border-radius: 4px; }

/* ===================== FORM FIELDS ===================== */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }
.field-hint { font-size: 11.5px; color: var(--ink-faint); }
input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 9px 11px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  width: 100%;
  transition: border-color .15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
textarea { resize: vertical; min-height: 64px; }
.form-row { display: flex; gap: 12px; }
.form-row > * { flex: 1; min-width: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-error {
  background: var(--danger-soft); color: var(--danger);
  padding: 9px 12px; border-radius: var(--radius-sm); font-size: 13px;
}
.checkbox-field { display: flex; align-items: center; gap: 8px; }
.checkbox-field input { width: auto; }

/* ===================== BUTTONS ===================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-weight: 600; font-size: 13.5px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: transform .08s ease, filter .15s ease, background .15s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-dark); }
.btn--accent { background: var(--accent); color: #fff; }
.btn--accent:hover { background: var(--accent-dark); }
.btn--ghost { background: transparent; color: var(--ink-soft); border-color: var(--border); }
.btn--ghost:hover { background: var(--surface-alt); color: var(--ink); }
.btn--danger { background: var(--danger-soft); color: var(--danger); }
.btn--danger:hover { background: var(--danger); color: #fff; }
.btn--sm { padding: 5px 10px; font-size: 12.5px; }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  border: none; background: transparent; color: var(--ink-soft); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-alt); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; fill: currentColor; }

/* ===================== APP SHELL / SIDEBAR ===================== */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: var(--ink);
  color: #DCE7E4;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 20;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 9px;
  padding: 20px 20px 16px;
  font-family: var(--font-display);
  font-weight: 700; font-size: 18px; color: #fff;
}
.nav { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; flex: 1; overflow-y: auto; }
.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: #AFC2BE;
  font-size: 13.5px; font-weight: 500;
}
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link.active { background: var(--primary); color: #fff; }
.nav-icon { width: 18px; height: 18px; fill: currentColor; flex-shrink: 0; }
.sidebar-footer { padding: 12px; border-top: 1px solid rgba(255,255,255,.08); }
.store-select { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.12); color: #DCE7E4; font-size: 12.5px; }
.store-select option { color: #111; }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 0 24px;
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.topbar-toggle { display: none; }
.topbar-title { font-family: var(--font-display); font-weight: 600; font-size: 17px; }
.topbar-spacer { flex: 1; }
.topbar-clock { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-faint); }
.user-menu { position: relative; }
.user-chip {
  display: flex; align-items: center; gap: 8px;
  background: transparent; border: none; cursor: pointer;
  padding: 6px 8px; border-radius: var(--radius-sm);
}
.user-chip:hover { background: var(--surface-alt); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; font-family: var(--font-display);
}
.user-name { font-size: 13px; font-weight: 600; }
.user-dropdown {
  position: absolute; right: 0; top: 44px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
  min-width: 150px; overflow: hidden; z-index: 30;
}
.dropdown-item {
  display: block; width: 100%; text-align: left;
  padding: 10px 14px; background: none; border: none;
  font-size: 13px; cursor: pointer; color: var(--ink);
}
.dropdown-item:hover { background: var(--surface-alt); }

.view-root { flex: 1; padding: 22px 26px 60px; max-width: 1320px; width: 100%; margin: 0 auto; }

/* ===================== CARDS / GRID ===================== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card-pad { padding: 18px 20px; }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  gap: 10px; flex-wrap: wrap;
}
.card-header h3 { font-size: 15px; }
.section { margin-bottom: 22px; }
.section-title { font-family: var(--font-display); font-size: 15px; font-weight: 600; margin-bottom: 12px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px;
  position: relative; overflow: hidden;
}
.stat-card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--primary);
}
.stat-card.accent::before { background: var(--accent); }
.stat-card.warn::before { background: var(--warn); }
.stat-card.info::before { background: var(--info); }
.stat-label { font-size: 12px; color: var(--ink-soft); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-family: var(--font-mono); font-size: 26px; font-weight: 600; margin-top: 6px; }
.stat-sub { font-size: 12px; color: var(--ink-faint); margin-top: 4px; }

.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
.period-tabs { display: inline-flex; background: var(--surface-alt); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.period-tab {
  border: none; background: transparent; padding: 6px 13px; border-radius: 5px;
  font-size: 12.5px; font-weight: 600; color: var(--ink-soft); cursor: pointer;
}
.period-tab.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }

/* ===================== TABLE ===================== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--ink-faint); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-alt); }
tbody tr.clickable { cursor: pointer; }
.text-right { text-align: right; }
.empty-row td { text-align: center; color: var(--ink-faint); padding: 36px 14px; }

/* ===================== BADGES / PILLS ===================== */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 600;
  background: var(--surface-alt); color: var(--ink-soft);
}
.badge--success { background: var(--success-soft); color: var(--success); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--info { background: var(--info-soft); color: var(--info); }
.badge--accent { background: var(--accent-soft); color: var(--accent-dark); }

/* ===================== TOOLBAR / FILTERS ===================== */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .field { flex: 0 0 auto; }
.search-input-wrap { position: relative; flex: 1; min-width: 200px; max-width: 320px; }
.search-input-wrap svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; fill: var(--ink-faint); }
.search-input-wrap input { padding-left: 32px; }
.toolbar-spacer { flex: 1; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.page-head h2 { font-size: 21px; }
.page-head-sub { color: var(--ink-soft); font-size: 13px; margin-top: 2px; }

/* ===================== MODAL ===================== */
.modal-root:empty { display: none; }
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(13, 27, 26, .55);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto; z-index: 100;
  animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  width: 100%; max-width: 560px;
  box-shadow: var(--shadow-lg);
  max-height: calc(100vh - 80px);
  display: flex; flex-direction: column;
}
.modal--wide { max-width: 820px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; }
.modal-body { padding: 20px 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 16px 22px; border-top: 1px solid var(--border);
}
.modal-footer .footer-note { margin-right: auto; font-size: 12.5px; color: var(--ink-faint); }

/* ===================== TOASTS ===================== */
.toast-root { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast {
  background: var(--ink); color: #fff; padding: 11px 16px; border-radius: var(--radius-sm);
  font-size: 13px; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 8px;
  animation: toastIn .18s ease;
  max-width: 320px;
}
.toast--error { background: var(--danger); }
.toast--success { background: var(--primary); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ===================== POS VIEW ===================== */
.pos-layout { display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px; align-items: start; }
.pos-catalog { display: flex; flex-direction: column; gap: 12px; }
.category-chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  padding: 6px 12px; border-radius: 99px; font-size: 12.5px; font-weight: 600;
  background: var(--surface-alt); color: var(--ink-soft); cursor: pointer; border: 1px solid transparent;
}
.chip.active { background: var(--primary-soft); color: var(--primary-dark); border-color: var(--primary); }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; max-height: 560px; overflow-y: auto; padding-right: 4px; }
.product-tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px; cursor: pointer; text-align: left; display: flex; flex-direction: column; gap: 6px;
  transition: border-color .12s ease, transform .08s ease;
}
.product-tile:hover { border-color: var(--primary); transform: translateY(-1px); }
.product-tile[disabled] { opacity: .4; cursor: not-allowed; }
.product-tile-name { font-size: 13px; font-weight: 600; line-height: 1.3; }
.product-tile-meta { font-size: 11.5px; color: var(--ink-faint); }
.product-tile-price { font-family: var(--font-mono); font-weight: 600; color: var(--primary-dark); font-size: 14px; }
.product-tile-stock { font-size: 11px; }

.cart-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; position: sticky; top: 76px; }
.cart-items { max-height: 320px; overflow-y: auto; padding: 6px 14px; }
.cart-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.cart-row:last-child { border-bottom: none; }
.cart-row-info { flex: 1; min-width: 0; }
.cart-row-name { font-size: 13px; font-weight: 600; }
.cart-row-price { font-size: 11.5px; color: var(--ink-faint); font-family: var(--font-mono); }
.qty-stepper { display: flex; align-items: center; gap: 6px; }
.qty-stepper button { width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-alt); cursor: pointer; font-weight: 700; }
.qty-stepper span { min-width: 18px; text-align: center; font-family: var(--font-mono); font-size: 13px; }
.cart-row-total { font-family: var(--font-mono); font-weight: 600; min-width: 56px; text-align: right; }
.cart-empty { padding: 40px 14px; text-align: center; color: var(--ink-faint); font-size: 13px; }
.cart-summary { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.summary-row { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-soft); }
.summary-row.total { font-size: 17px; font-weight: 700; color: var(--ink); font-family: var(--font-mono); padding-top: 6px; border-top: 1px dashed var(--border); }
.pay-methods { display: flex; gap: 6px; }
.pay-method-btn {
  flex: 1; padding: 8px; border-radius: var(--radius-sm); border: 1.5px solid var(--border);
  background: var(--surface); cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--ink-soft);
}
.pay-method-btn.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-dark); }

/* ===================== RECEIPT ===================== */
.receipt { font-family: var(--font-mono); font-size: 12.5px; padding: 4px; }
.receipt-center { text-align: center; }
.receipt-policy { font-size: 10.5px; line-height: 1.35; }
.receipt hr { border: none; border-top: 1px dashed var(--border-strong); margin: 10px 0; }
.receipt-row { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; }
.receipt-total { font-weight: 700; font-size: 14px; }

/* ===================== KANBAN (repairs) ===================== */
.kanban { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; overflow-x: auto; }
.kanban-col { background: var(--surface-alt); border-radius: var(--radius); padding: 10px; min-width: 200px; }
.kanban-col-title { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-soft); margin-bottom: 8px; display: flex; justify-content: space-between; }
.kanban-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 11px; margin-bottom: 8px; cursor: pointer; font-size: 12.5px;
}
.kanban-card:hover { border-color: var(--primary); }
.kanban-card-title { font-weight: 600; margin-bottom: 3px; }
.kanban-card-meta { color: var(--ink-faint); font-size: 11px; }

/* ===================== MISC ===================== */
.muted { color: var(--ink-faint); }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }
.empty-state { text-align: center; padding: 50px 20px; color: var(--ink-faint); }
.empty-state h4 { color: var(--ink-soft); margin-bottom: 6px; }
.chart-box { position: relative; height: 260px; }
.chart-box-sm { position: relative; height: 180px; }
.skeleton { background: linear-gradient(90deg, var(--surface-alt) 25%, var(--border) 37%, var(--surface-alt) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.low-stock-row { color: var(--danger); }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 1080px) {
  .pos-layout { grid-template-columns: 1fr; }
  .cart-panel { position: static; }
  .two-col { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .kanban { grid-template-columns: repeat(5, minmax(180px, 1fr)); }
}
@media (max-width: 760px) {
  .sidebar { position: fixed; left: 0; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .topbar-toggle { display: inline-flex; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .view-root { padding: 16px 14px 50px; }
  .form-grid { grid-template-columns: 1fr; }
  .topbar-clock { display: none; }
}
