/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
}
body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

/* ── Layout ── */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 240px; background: var(--primary); color: #fff; display: flex; flex-direction: column; padding: 0; flex-shrink: 0; }
.sidebar-logo { padding: 24px 20px 20px; border-bottom: 1px solid rgba(255,255,255,.15); }
.sidebar-logo h2 { font-size: 1.1rem; font-weight: 700; }
.sidebar-logo span { font-size: .75rem; opacity: .7; }
.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 20px; color: rgba(255,255,255,.8); text-decoration: none; font-size: .9rem; transition: all .15s; cursor: pointer; border: none; background: none; width: 100%; }
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,.15); color: #fff; }
.nav-item .icon { font-size: 1.1rem; width: 22px; text-align: center; }
.nav-section { padding: 16px 20px 4px; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; opacity: .5; }
.sidebar-user { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.15); font-size: .85rem; }
.sidebar-user .name { font-weight: 600; }
.sidebar-user .role { opacity: .6; font-size: .75rem; }
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar { background: var(--card); border-bottom: 1px solid var(--border); padding: 0 28px; height: 60px; display: flex; align-items: center; justify-content: space-between; }
.topbar h1 { font-size: 1.1rem; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.content { flex: 1; padding: 28px; overflow-y: auto; }

/* ── Cards ── */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 8px; }
.grid { display: grid; gap: 20px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

/* ── Stat Cards ── */
.stat-card { padding: 20px; }
.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.stat-change { font-size: .78rem; margin-top: 8px; }
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }
.stat-icon { font-size: 2rem; float: right; opacity: .15; margin-top: -4px; }

/* ── Badges ── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: .72rem; font-weight: 600; }
.badge-success { background: #dcfce7; color: var(--success); }
.badge-danger  { background: #fee2e2; color: var(--danger); }
.badge-warning { background: #fef3c7; color: var(--warning); }
.badge-info    { background: #dbeafe; color: var(--primary); }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th { text-align: left; padding: 10px 14px; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border-bottom: 2px solid var(--border); }
td { padding: 12px 14px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 8px; font-size: .875rem; font-weight: 500; cursor: pointer; border: none; transition: all .15s; text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 5px 12px; font-size: .8rem; }
.btn-danger { background: var(--danger); color: #fff; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: 6px; }
input, select, textarea { width: 100%; padding: 9px 12px; border: 1.5px solid var(--border); border-radius: 8px; font-size: .9rem; transition: border .15s; background: var(--card); }
input:focus, select:focus { outline: none; border-color: var(--primary); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.input-group { display: flex; }
.input-group input { border-radius: 8px 0 0 8px; }
.input-group .btn { border-radius: 0 8px 8px 0; }

/* ── Login Page ── */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%); }
.login-card { background: #fff; border-radius: 16px; padding: 40px; width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo h1 { font-size: 1.5rem; font-weight: 800; color: var(--primary); }
.login-logo p { color: var(--muted); font-size: .875rem; }
.login-footer { text-align: center; margin-top: 20px; font-size: .8rem; color: var(--muted); }

/* ── Notifications ── */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 18px; border-radius: 10px; color: #fff; font-size: .875rem; font-weight: 500; box-shadow: 0 4px 12px rgba(0,0,0,.15); animation: slideIn .3s ease; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--primary); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Modal ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1000; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: opacity .2s; }
.modal-overlay.show { opacity: 1; pointer-events: all; }
.modal { background: #fff; border-radius: 16px; padding: 28px; width: 100%; max-width: 480px; box-shadow: 0 20px 60px rgba(0,0,0,.2); transform: translateY(20px); transition: transform .2s; }
.modal-overlay.show .modal { transform: translateY(0); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h3 { font-size: 1rem; font-weight: 600; }
.modal-close { background: none; border: none; cursor: pointer; font-size: 1.2rem; color: var(--muted); }

/* ── Balance Card ── */
.balance-card { background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%); color: #fff; border-radius: var(--radius); padding: 24px; }
.balance-label { opacity: .8; font-size: .85rem; }
.balance-amount { font-size: 2.2rem; font-weight: 800; margin: 4px 0 12px; }
.balance-id { opacity: .7; font-size: .8rem; }

/* ── Product Grid ── */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.product-item { border: 2px solid var(--border); border-radius: 10px; padding: 14px 12px; cursor: pointer; transition: all .15s; text-align: center; }
.product-item:hover { border-color: var(--primary); background: #eff6ff; }
.product-item.selected { border-color: var(--primary); background: #eff6ff; }
.product-name { font-size: .8rem; font-weight: 600; margin-bottom: 4px; }
.product-price { font-size: .85rem; color: var(--primary); font-weight: 700; }

/* ── Operator Tabs ── */
.op-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.op-tab { padding: 6px 16px; border-radius: 20px; border: 1.5px solid var(--border); font-size: .82rem; cursor: pointer; font-weight: 500; transition: all .15s; background: var(--card); }
.op-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Misc ── */
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.section-header h2 { font-size: 1rem; font-weight: 600; }
.text-muted { color: var(--muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-right { text-align: right; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.gap-2 { gap: 8px; }
.flex { display: flex; align-items: center; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; }
.empty-state { text-align: center; padding: 40px; color: var(--muted); }
.empty-state .icon { font-size: 3rem; margin-bottom: 12px; }
.spinner { width: 20px; height: 20px; border: 2px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 768px) {
  .sidebar { display: none; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}
