:root {
  --bg: #0d0f14;
  --bg2: #13161d;
  --bg3: #1a1e28;
  --card: #1e2230;
  --border: #2a2f3f;
  --accent: #6c5ce7;
  --accent2: #a29bfe;
  --green: #00b894;
  --red: #d63031;
  --yellow: #fdcb6e;
  --blue: #0984e3;
  --text: #e8eaf0;
  --text2: #8892a4;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,.4);
  --trans: .2s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 15px; }
body { background: var(--bg); color: var(--text); font-family: 'Inter', system-ui, sans-serif; min-height: 100vh; }

a { color: var(--accent2); text-decoration: none; }
a:hover { color: var(--accent); }

/* Layout */
.app-layout { display: flex; min-height: 100vh; }
.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* Topbar */
.topbar {
  background: var(--bg2); border-bottom: 1px solid var(--border);
  padding: .75rem 1.5rem; display: flex; align-items: center; gap: 1rem;
  position: sticky; top: 0; z-index: 100;
}
.topbar-title { font-size: 1.1rem; font-weight: 600; flex: 1; }
.topbar-menu-btn { background: none; border: none; color: var(--text); font-size: 1.4rem; cursor: pointer; padding: .25rem .5rem; }

.page-body { padding: 1.5rem; flex: 1; }

/* Sidebar */
.sidebar {
  width: 240px; background: var(--bg2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; transition: transform var(--trans);
  position: relative; z-index: 200;
}
.sidebar-header { padding: 1.25rem 1rem; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.sidebar-logo { display: flex; align-items: center; gap: .6rem; font-size: 1.25rem; font-weight: 700; }
.logo-icon { font-size: 1.6rem; color: var(--accent); filter: drop-shadow(0 0 8px var(--accent)); }
.logo-text { background: linear-gradient(135deg, var(--accent), var(--accent2)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.sidebar-close { display: none; background: none; border: none; color: var(--text2); cursor: pointer; font-size: 1.2rem; }
.sidebar-user { padding: 1rem; display: flex; align-items: center; gap: .75rem; border-bottom: 1px solid var(--border); }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .9rem; flex-shrink: 0; }
.user-name { font-weight: 600; font-size: .9rem; }
.user-role { font-size: .75rem; color: var(--text2); }
.sidebar-nav { flex: 1; padding: .75rem 0; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: .75rem; padding: .6rem 1rem; color: var(--text2); cursor: pointer; transition: all var(--trans); border: none; background: none; width: 100%; text-align: left; font-size: .9rem; border-radius: var(--radius-sm); margin: 1px .5rem; }
.nav-item:hover { background: var(--bg3); color: var(--text); }
.nav-item.active { background: rgba(108,92,231,.2); color: var(--accent2); }
.nav-icon { width: 20px; text-align: center; font-size: 1rem; }
.sidebar-footer { padding: .75rem .5rem; border-top: 1px solid var(--border); }
.logout-btn { color: var(--red) !important; }
.sidebar-overlay { display: none; }

/* Cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; position: relative; overflow: hidden;
}
.stat-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--accent); }
.stat-card.green::before { background: var(--green); }
.stat-card.blue::before { background: var(--blue); }
.stat-card.yellow::before { background: var(--yellow); }
.stat-card.red::before { background: var(--red); }
.stat-label { font-size: .75rem; color: var(--text2); text-transform: uppercase; letter-spacing: .05em; margin-bottom: .5rem; }
.stat-value { font-size: 1.6rem; font-weight: 700; }
.stat-sub { font-size: .75rem; color: var(--text2); margin-top: .25rem; }

/* Panels */
.panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 1.5rem; }
.panel-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.panel-title { font-weight: 600; font-size: .95rem; }
.panel-body { padding: 1.25rem; }

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { background: var(--bg3); padding: .65rem 1rem; text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text2); }
td { padding: .65rem 1rem; border-bottom: 1px solid var(--border); font-size: .875rem; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.02); }

/* Badges */
.badge { display: inline-flex; align-items: center; padding: .2rem .6rem; border-radius: 20px; font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.badge-green { background: rgba(0,184,148,.15); color: var(--green); }
.badge-red { background: rgba(214,48,49,.15); color: var(--red); }
.badge-yellow { background: rgba(253,203,110,.15); color: var(--yellow); }
.badge-blue { background: rgba(9,132,227,.15); color: var(--blue); }
.badge-purple { background: rgba(108,92,231,.15); color: var(--accent2); }
.badge-gray { background: rgba(136,146,164,.15); color: var(--text2); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem 1rem; border-radius: var(--radius-sm); border: none; cursor: pointer; font-size: .875rem; font-weight: 500; transition: all var(--trans); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #7d6cf5; }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #00a381; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #c0392b; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent2); }
.btn-sm { padding: .3rem .7rem; font-size: .8rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; justify-content: center; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; margin-bottom: .4rem; font-size: .85rem; color: var(--text2); font-weight: 500; }
.form-control {
  width: 100%; padding: .6rem .9rem; background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: .9rem; transition: border var(--trans);
}
.form-control:focus { outline: none; border-color: var(--accent); }
.form-control::placeholder { color: var(--text2); }
select.form-control { cursor: pointer; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

/* Modal */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 1000; align-items: center; justify-content: center; padding: 1rem; }
.modal-overlay.open { display: flex; }
.modal { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); width: 100%; max-width: 500px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow); }
.modal-lg { max-width: 700px; }
.modal-header { padding: 1.25rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-weight: 700; font-size: 1rem; }
.modal-close { background: none; border: none; color: var(--text2); cursor: pointer; font-size: 1.3rem; line-height: 1; }
.modal-body { padding: 1.25rem; }
.modal-footer { padding: 1rem 1.25rem; border-top: 1px solid var(--border); display: flex; gap: .75rem; justify-content: flex-end; }

/* Toast */
.toast { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .75rem 1.25rem; font-size: .875rem; box-shadow: var(--shadow); transform: translateY(100px); opacity: 0; transition: all .3s ease; max-width: 350px; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast-success { border-left: 3px solid var(--green); }
.toast-error { border-left: 3px solid var(--red); }
.toast-info { border-left: 3px solid var(--blue); }

/* Spinner */
.spinner-sm { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Login */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at 20% 50%, rgba(108,92,231,.15), transparent 60%), var(--bg); }
.login-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 2.5rem; width: 100%; max-width: 400px; box-shadow: var(--shadow); }
.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo-icon { font-size: 3rem; display: block; margin-bottom: .5rem; filter: drop-shadow(0 0 20px var(--accent)); }
.login-logo h1 { font-size: 1.8rem; font-weight: 800; background: linear-gradient(135deg, var(--accent), var(--accent2)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.login-logo p { color: var(--text2); font-size: .85rem; margin-top: .25rem; }

/* PDV specific */
.pdv-layout { display: grid; grid-template-columns: 1fr 360px; gap: 1.5rem; height: calc(100vh - 64px); overflow: hidden; }
.pdv-products { overflow-y: auto; padding: 1.5rem; }
.pdv-cart { background: var(--card); border-left: 1px solid var(--border); display: flex; flex-direction: column; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .75rem; }
.product-tile { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; cursor: pointer; transition: all var(--trans); text-align: center; }
.product-tile:hover { border-color: var(--accent); background: rgba(108,92,231,.1); transform: translateY(-2px); }
.product-tile-name { font-size: .875rem; font-weight: 600; margin-bottom: .3rem; }
.product-tile-price { font-size: 1rem; color: var(--green); font-weight: 700; }
.product-tile-cat { font-size: .7rem; color: var(--text2); }
.cart-header { padding: 1rem; border-bottom: 1px solid var(--border); }
.cart-items { flex: 1; overflow-y: auto; padding: .75rem; }
.cart-item { display: flex; align-items: center; gap: .5rem; padding: .5rem; border-radius: var(--radius-sm); background: var(--bg3); margin-bottom: .5rem; }
.cart-item-name { flex: 1; font-size: .85rem; font-weight: 500; }
.cart-qty { display: flex; align-items: center; gap: .4rem; }
.qty-btn { background: var(--border); border: none; color: var(--text); width: 24px; height: 24px; border-radius: 4px; cursor: pointer; font-size: .9rem; display: flex; align-items: center; justify-content: center; }
.qty-btn:hover { background: var(--accent); }
.cart-item-total { font-size: .85rem; font-weight: 600; color: var(--green); min-width: 60px; text-align: right; }
.cart-footer { padding: 1rem; border-top: 1px solid var(--border); }
.cart-total-line { display: flex; justify-content: space-between; margin-bottom: .5rem; font-size: .875rem; }
.cart-grand-total { font-size: 1.4rem; font-weight: 700; color: var(--green); }

/* Category tabs */
.cat-tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.cat-tab { padding: .35rem .9rem; border-radius: 20px; border: 1px solid var(--border); background: none; color: var(--text2); cursor: pointer; font-size: .8rem; transition: all var(--trans); }
.cat-tab:hover, .cat-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Card scan feedback */
.scan-result { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.scan-result.success { border-color: var(--green); background: rgba(0,184,148,.05); }
.scan-result.error { border-color: var(--red); background: rgba(214,48,49,.05); }
.balance-display { font-size: 2rem; font-weight: 800; color: var(--green); }

/* QR Code display */
.qr-container { text-align: center; padding: 1.5rem; }
.qr-container img { border-radius: var(--radius); border: 8px solid white; }

/* Charts */
.chart-bar-wrap { display: flex; flex-direction: column; gap: .4rem; }
.chart-bar-row { display: flex; align-items: center; gap: .75rem; font-size: .8rem; }
.chart-bar-label { width: 100px; color: var(--text2); text-align: right; flex-shrink: 0; }
.chart-bar-track { flex: 1; background: var(--bg3); border-radius: 4px; height: 18px; overflow: hidden; }
.chart-bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); border-radius: 4px; transition: width .5s ease; min-width: 2px; }
.chart-bar-val { width: 80px; color: var(--text2); flex-shrink: 0; }

/* Responsive */
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow); }
  .sidebar-close { display: block; }
  .sidebar-overlay { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 190; opacity: 0; pointer-events: none; transition: opacity var(--trans); }
  .sidebar-overlay.active { opacity: 1; pointer-events: all; }
  .pdv-layout { grid-template-columns: 1fr; height: auto; }
  .pdv-cart { border-left: none; border-top: 1px solid var(--border); }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .page-body { padding: 1rem; }
}

/* Misc */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text2); }
.empty-state-icon { font-size: 3rem; margin-bottom: 1rem; }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-muted { color: var(--text2); }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-sm { gap: .5rem; }
.gap { gap: 1rem; }
.mt { margin-top: 1rem; }
.mb { margin-bottom: 1rem; }
.fw-bold { font-weight: 700; }
.text-sm { font-size: .8rem; }
.pix-code { font-family: monospace; font-size: .7rem; word-break: break-all; background: var(--bg3); padding: .75rem; border-radius: var(--radius-sm); border: 1px solid var(--border); margin-top: .75rem; }
