*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #080b14;
  --surface: #0e1220;
  --surface2: #141828;
  --surface3: #1a2035;
  --border: rgba(255,255,255,0.06);
  --border2: rgba(255,255,255,0.1);
  --accent: #7c3aed;
  --accent2: #4f46e5;
  --accent-hover: #6d28d9;
  --text: #e2e8f0;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  --red: #ef4444;
  --green: #22c55e;
  --yellow: #eab308;
  --sidebar-w: 240px;
}

html, body {
  background: var(--bg);
  font-family: 'Inter', sans-serif;
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* ── SIDEBAR ─────────────────────────────── */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 260;
  transition: transform 0.25s ease;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px;
  border-bottom: 1px solid var(--border);
}
.logo-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800;
  letter-spacing: 0.5px;
}
.logo-title { font-size: 15px; font-weight: 700; }
.logo-version { font-size: 11px; color: var(--text-muted); }

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}
.nav-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  padding: 0 8px;
  margin-bottom: 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 10px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  position: relative;
  cursor: pointer;
  margin-bottom: 2px;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item span:first-of-type { flex: 1; }
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active {
  background: linear-gradient(135deg, rgba(124,58,237,0.2), rgba(79,70,229,0.2));
  color: #a78bfa;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -12px; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 20px;
  background: linear-gradient(var(--accent), var(--accent2));
  border-radius: 0 3px 3px 0;
}
.nav-item-soon { opacity: 0.5; cursor: default; }
.nav-item-soon:hover { background: none; color: var(--text-dim); }

.nav-badge {
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 20px;
  min-width: 22px;
  text-align: center;
}
.soon-tag {
  background: rgba(234,179,8,0.15);
  color: var(--yellow);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}
.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.user-avatar {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; }
.user-role {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.footer-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 34px; height: 34px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { background: var(--surface3); color: var(--text); }

/* ── MAIN ─────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  padding: 32px;
}

.page { display: block; }
.page.hidden { display: none; }

.mobile-toggle {
  display: none;
  position: fixed;
  top: 16px; left: 16px;
  z-index: 270;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 38px; height: 38px;
  align-items: center; justify-content: center;
  color: var(--text);
  cursor: pointer;
}
.mobile-toggle svg { width: 18px; height: 18px; }

/* ── PAGE HEADER ──────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 16px;
}
.page-title { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.page-sub { font-size: 13px; color: var(--text-muted); }

/* ── STATS GRID ───────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: border-color 0.2s;
}
.stat-card:hover { border-color: var(--border2); }
.stat-card-soon { opacity: 0.5; }

.stat-icon {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-icon-blue { background: rgba(79,70,229,0.15); color: #818cf8; }
.stat-icon-green { background: rgba(34,197,94,0.15); color: #4ade80; }
.stat-icon-gray { background: rgba(100,116,139,0.15); color: #94a3b8; }
.stat-icon-purple { background: rgba(124,58,237,0.15); color: #a78bfa; }

.stat-value { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── SECTION TITLE ────────────────────────── */
.section-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ── CARD ─────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
}

/* ── LOG LIST ─────────────────────────────── */
.log-list { padding: 4px 0; }
.log-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.log-item:last-child { border-bottom: none; }
.log-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}
.log-action { flex: 1; color: var(--text-dim); }
.log-time { color: var(--text-muted); font-size: 12px; white-space: nowrap; }

/* ── TOOLBAR ──────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.search-wrap {
  flex: 1;
  min-width: 200px;
  position: relative;
}
.search-wrap svg {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}
.search-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px 10px 38px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text-muted); }

.filter-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
}
.filter-tab {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 7px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.filter-tab:hover { color: var(--text); }
.filter-tab.active { background: var(--surface3); color: var(--text); }

/* ── TABLE ────────────────────────────────── */
.table-card { overflow: hidden; }
.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
}
.table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: 13px 16px;
  font-size: 13.5px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: rgba(255,255,255,0.02); }

.table td:first-child { color: var(--text-muted); font-size: 12px; }
.col-title { font-weight: 500; color: var(--text); max-width: 200px; }
.col-code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 12px;
  color: #a78bfa;
  display: inline-block;
  white-space: nowrap;
}
.col-product { font-size: 13.5px; color: var(--text-dim); }
.col-amount { font-weight: 600; color: #4ade80; }
.col-note { color: var(--text-muted); max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.col-date { color: var(--text-muted); font-size: 12px; white-space: nowrap; }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.status-active { background: rgba(34,197,94,0.12); color: #4ade80; }
.status-archived { background: rgba(100,116,139,0.12); color: #94a3b8; }
.status-pending { background: rgba(234,179,8,0.12); color: #fbbf24; }

.status-badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}
.action-btn {
  width: 30px; height: 30px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.action-btn svg { width: 14px; height: 14px; }
.action-btn:hover { background: var(--surface3); color: var(--text); }
.action-btn.del:hover { background: rgba(239,68,68,0.1); color: var(--red); border-color: rgba(239,68,68,0.2); }

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.table-count { font-size: 12px; color: var(--text-muted); }

.pagination { display: flex; gap: 4px; }
.page-btn {
  width: 30px; height: 30px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
}
.page-btn:hover { background: var(--surface3); color: var(--text); }
.page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 48px 20px;
  font-size: 14px;
}
.empty-state svg {
  width: 40px; height: 40px;
  opacity: 0.3;
  display: block;
  margin: 0 auto 12px;
}

/* ── BUTTONS ──────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  white-space: nowrap;
}
.btn-primary svg { width: 16px; height: 16px; }
.btn-primary:hover { opacity: 0.9; }
.btn-primary:active { transform: scale(0.98); }

.btn-ghost {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-dim);
  padding: 10px 18px;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-ghost:hover { background: var(--surface3); color: var(--text); }

.btn-danger {
  background: rgba(239,68,68,0.9);
  border: none;
  border-radius: 10px;
  color: #fff;
  padding: 10px 18px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn-danger:hover { opacity: 0.85; }

/* ── MODAL ────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }

.overlay-bg {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 250;
}
.overlay-bg.open { display: block; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 18px;
  width: 100%;
  max-width: 540px;
  z-index: 310;
  box-shadow: 0 25px 60px rgba(0,0,0,0.5);
  animation: modalIn 0.2s ease;
}
.modal-sm { max-width: 380px; }

@keyframes modalIn {
  from { opacity: 0; transform: translateY(-10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close {
  width: 30px; height: 30px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.modal-close svg { width: 14px; height: 14px; }
.modal-close:hover { background: var(--surface3); color: var(--text); }

.modal-body { padding: 24px; }
.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* ── FORM ─────────────────────────────────── */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-group { margin-bottom: 18px; }
label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 7px;
}
.req { color: var(--accent); }

.amount-wrap {
  display: flex;
  gap: 8px;
}
.amount-wrap input { flex: 1; }
.amount-wrap select { width: 72px; flex-shrink: 0; padding-left: 8px; padding-right: 8px; }

.table-total-badge {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 500;
  white-space: nowrap;
}

input[type=text], input[type=number], input[type=password], select, textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 11px 14px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  resize: vertical;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--text-muted); }
select { cursor: pointer; }
select option { background: var(--surface2); }

.status-select {
  display: flex;
  gap: 8px;
}
.status-opt {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 9px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
}
.status-opt:hover { border-color: var(--border2); color: var(--text); }
.status-opt.active { border-color: var(--accent); background: rgba(124,58,237,0.1); color: var(--text); }

.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-green { background: var(--green); }
.dot-yellow { background: var(--yellow); }
.dot-gray { background: var(--text-muted); }

.modal-error {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.25);
  border-radius: 8px;
  padding: 10px 14px;
  color: #f87171;
  font-size: 13px;
  display: none;
}
.modal-error.show { display: block; }
.modal-success {
  background: rgba(34,197,94,0.1);
  border: 1px solid rgba(34,197,94,0.25);
  border-radius: 8px;
  padding: 10px 14px;
  color: #4ade80;
  font-size: 13px;
  display: none;
}
.modal-success.show { display: block; }

/* ── COMING SOON ──────────────────────────── */
.coming-soon-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  text-align: center;
  gap: 16px;
}
.coming-soon-icon {
  width: 80px; height: 80px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
}
.coming-soon-icon svg { width: 40px; height: 40px; }
.coming-soon-wrap h2 { font-size: 20px; }
.coming-soon-wrap p { color: var(--text-muted); font-size: 14px; }

/* ── TOAST ────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  transform: translateY(10px);
  opacity: 0;
  transition: all 0.25s ease;
  z-index: 400;
  pointer-events: none;
}
.toast.show {
  transform: translateY(0);
  opacity: 1;
}
.toast.success { border-color: rgba(34,197,94,0.3); color: #4ade80; }
.toast.error { border-color: rgba(239,68,68,0.3); color: #f87171; }

/* ── RESPONSIVE ───────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; padding: 20px 16px; padding-top: 64px; }
  .mobile-toggle { display: flex; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .status-select { flex-wrap: wrap; }
  .filter-tabs { display: none; }
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 3px; }
