@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Outfit:wght@400;600;700;800&display=swap');

/* ============================
   CSS VARIABLES & TOKENS
   ============================ */
:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #0f1629;
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-card-hover: rgba(255, 255, 255, 0.07);
  --bg-glass: rgba(255, 255, 255, 0.05);
  --bg-input: rgba(255, 255, 255, 0.06);

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-accent: rgba(0, 212, 255, 0.3);

  --text-primary: #f0f4ff;
  --text-secondary: #8b9cc4;
  --text-muted: #5a6888;

  --accent-cyan: #00d4ff;
  --accent-emerald: #00e5a0;
  --accent-amber: #ffa040;
  --accent-rose: #ff5470;
  --accent-violet: #9b6dff;

  --gradient-primary: linear-gradient(135deg, #00d4ff 0%, #00e5a0 100%);
  --gradient-danger: linear-gradient(135deg, #ff5470 0%, #ff8c00 100%);
  --gradient-warning: linear-gradient(135deg, #ffa040 0%, #ffd700 100%);
  --gradient-card: linear-gradient(135deg, rgba(0,212,255,0.08) 0%, rgba(0,229,160,0.04) 100%);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-card: 0 4px 24px rgba(0,0,0,0.4), 0 1px 0 rgba(255,255,255,0.05) inset;
  --shadow-glow-cyan: 0 0 20px rgba(0, 212, 255, 0.2);
  --shadow-glow-emerald: 0 0 20px rgba(0, 229, 160, 0.2);

  --transition: all 0.2s ease;
  --transition-slow: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================
   RESET & BASE
   ============================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  top: -30%;
  left: -20%;
  width: 60%;
  height: 60%;
  background: radial-gradient(ellipse, rgba(0,212,255,0.06) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}
body::after {
  content: '';
  position: fixed;
  bottom: -30%;
  right: -20%;
  width: 60%;
  height: 60%;
  background: radial-gradient(ellipse, rgba(0,229,160,0.05) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ============================
   LAYOUT
   ============================ */
.erp-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

.main-content {
  padding: 32px;
  position: relative;
  z-index: 1;
  overflow-y: auto;
}

/* ============================
   SIDEBAR
   ============================ */
.sidebar {
  grid-row: 1 / -1;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
  padding: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 10;
}

.sidebar-brand {
  padding: 28px 24px 24px;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-brand .brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-icon {
  width: 42px;
  height: 42px;
  background: var(--gradient-primary);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  box-shadow: var(--shadow-glow-cyan);
}

.brand-text h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.brand-text span {
  font-size: 11px;
  color: var(--accent-cyan);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-weight: 500;
}

.sidebar-nav {
  padding: 16px 12px;
  flex: 1;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px 12px 6px;
  margin-top: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
  margin-bottom: 2px;
  position: relative;
}

.nav-item .nav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.nav-item:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(0,212,255,0.12), rgba(0,229,160,0.06));
  color: var(--accent-cyan);
  border: 1px solid rgba(0,212,255,0.15);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 20%;
  bottom: 20%;
  width: 3px;
  background: var(--gradient-primary);
  border-radius: 0 3px 3px 0;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-subtle);
}

.sidebar-footer .ext-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: linear-gradient(135deg, rgba(0,229,160,0.1), rgba(0,212,255,0.05));
  border: 1px solid rgba(0,229,160,0.2);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--accent-emerald);
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
}

.sidebar-footer .ext-link:hover {
  background: linear-gradient(135deg, rgba(0,229,160,0.18), rgba(0,212,255,0.09));
  box-shadow: var(--shadow-glow-emerald);
}

/* ============================
   TOP BAR
   ============================ */
.topbar {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 9;
}

.topbar-left h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
}

.topbar-left p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 1px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-badge {
  padding: 6px 14px;
  background: linear-gradient(135deg, rgba(0,212,255,0.1), rgba(0,229,160,0.05));
  border: 1px solid var(--border-accent);
  border-radius: 20px;
  font-size: 12px;
  color: var(--accent-cyan);
  font-weight: 500;
}

/* ============================
   CARDS
   ============================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
  transition: var(--transition-slow);
  position: relative;
  overflow: hidden;
}

.card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255,255,255,0.12);
  transform: translateY(-1px);
}

.card-glass {
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
  transition: var(--transition-slow);
}

.kpi-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255,255,255,0.12);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--gradient-primary);
  opacity: 0.7;
}

.kpi-card.kpi-cyan::before { background: linear-gradient(90deg, #00d4ff, #0088ff); }
.kpi-card.kpi-emerald::before { background: linear-gradient(90deg, #00e5a0, #00d4ff); }
.kpi-card.kpi-amber::before { background: linear-gradient(90deg, #ffa040, #ffd700); }
.kpi-card.kpi-rose::before { background: linear-gradient(90deg, #ff5470, #ff8c00); }
.kpi-card.kpi-violet::before { background: linear-gradient(90deg, #9b6dff, #00d4ff); }

.kpi-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 8px;
}

.kpi-value {
  font-family: 'Outfit', sans-serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 6px;
}

.kpi-sub {
  font-size: 12px;
  color: var(--text-secondary);
}

.kpi-icon {
  position: absolute;
  top: 20px;
  right: 20px;
  font-size: 28px;
  opacity: 0.15;
}

/* ============================
   TABLES
   ============================ */
.table-container {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
}

.table-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.table-header h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
}

.table-body {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  background: rgba(255,255,255,0.03);
  padding: 13px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-subtle);
}

tbody tr {
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: background 0.15s ease;
}

tbody tr:hover { background: rgba(255,255,255,0.03); }
tbody tr:last-child { border-bottom: none; }

tbody td {
  padding: 13px 16px;
  font-size: 14px;
  color: var(--text-secondary);
  vertical-align: middle;
}

.td-primary { color: var(--text-primary) !important; font-weight: 500; }

/* ============================
   BADGES
   ============================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.badge-green {
  background: rgba(0, 229, 160, 0.12);
  color: #00e5a0;
  border: 1px solid rgba(0,229,160,0.2);
}
.badge-yellow {
  background: rgba(255, 160, 64, 0.12);
  color: #ffa040;
  border: 1px solid rgba(255,160,64,0.25);
}
.badge-red {
  background: rgba(255, 84, 112, 0.12);
  color: #ff5470;
  border: 1px solid rgba(255,84,112,0.2);
}
.badge-cyan {
  background: rgba(0, 212, 255, 0.12);
  color: #00d4ff;
  border: 1px solid rgba(0,212,255,0.2);
}
.badge-blue {
  background: rgba(96, 165, 250, 0.12);
  color: #60a5fa;
  border: 1px solid rgba(96,165,250,0.2);
}
.badge-violet {
  background: rgba(155, 109, 255, 0.12);
  color: #9b6dff;
  border: 1px solid rgba(155,109,255,0.2);
}

/* ============================
   BUTTONS
   ============================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
  font-family: 'Inter', sans-serif;
}

.btn-primary {
  background: var(--gradient-primary);
  color: #001a1a;
  box-shadow: 0 4px 14px rgba(0,212,255,0.25);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0,212,255,0.4);
}

.btn-secondary {
  background: var(--bg-card-hover);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}
.btn-secondary:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text-primary);
}

.btn-danger {
  background: rgba(255,84,112,0.1);
  color: #ff5470;
  border: 1px solid rgba(255,84,112,0.2);
}
.btn-danger:hover {
  background: rgba(255,84,112,0.2);
}

.btn-success {
  background: rgba(0,229,160,0.1);
  color: #00e5a0;
  border: 1px solid rgba(0,229,160,0.2);
}
.btn-success:hover { background: rgba(0,229,160,0.2); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon { padding: 8px; }

/* ============================
   FORMS
   ============================ */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-control {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  transition: var(--transition);
  width: 100%;
  outline: none;
}

.form-control:focus {
  border-color: var(--accent-cyan);
  background: rgba(0,212,255,0.05);
  box-shadow: 0 0 0 3px rgba(0,212,255,0.1);
}

.form-control::placeholder { color: var(--text-muted); }

select.form-control option {
  background: #1a2240;
  color: var(--text-primary);
}

textarea.form-control { resize: vertical; min-height: 90px; }

/* ============================
   MODAL
   ============================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: #131c35;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(10px);
  transition: var(--transition-slow);
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}

.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
}

.modal-header {
  padding: 24px 28px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 20px;
  font-weight: 700;
}

.modal-close {
  background: var(--bg-card-hover);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: var(--transition);
}
.modal-close:hover { color: var(--text-primary); background: var(--bg-card-hover); }

.modal-body { padding: 24px 28px; }
.modal-footer {
  padding: 0 28px 24px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ============================
   SEARCH & FILTERS
   ============================ */
.search-bar {
  position: relative;
  min-width: 220px;
}

.search-bar input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 9px 14px 9px 36px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  transition: var(--transition);
  outline: none;
}

.search-bar input:focus {
  border-color: var(--accent-cyan);
  background: rgba(0,212,255,0.04);
}

.search-bar .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
}

.filter-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-pill {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}
.filter-pill:hover { color: var(--text-primary); border-color: rgba(255,255,255,0.15); }
.filter-pill.active {
  background: linear-gradient(135deg, rgba(0,212,255,0.15), rgba(0,229,160,0.08));
  color: var(--accent-cyan);
  border-color: rgba(0,212,255,0.3);
}

/* ============================
   ALERTS & NOTIFICATIONS
   ============================ */
.alert-bar {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  animation: slideIn 0.3s ease forwards;
  max-width: 320px;
}

.toast-success { background: #0d2a1f; border: 1px solid rgba(0,229,160,0.3); color: #00e5a0; }
.toast-error { background: #2a0d15; border: 1px solid rgba(255,84,112,0.3); color: #ff5470; }
.toast-info { background: #0d1a2a; border: 1px solid rgba(0,212,255,0.3); color: #00d4ff; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ============================
   SECTION TITLES
   ============================ */
.section-title {
  font-family: 'Outfit', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

/* ============================
   UTILITIES
   ============================ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

.text-cyan { color: var(--accent-cyan); }
.text-emerald { color: var(--accent-emerald); }
.text-amber { color: var(--accent-amber); }
.text-rose { color: var(--accent-rose); }
.text-muted { color: var(--text-muted); }

.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.4; }
.empty-state p { font-size: 15px; }

/* ============================
   LOADING SPINNER
   ============================ */
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(0,212,255,0.15);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 40px auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================
   AMOUNT COLOR
   ============================ */
.amount-positive { color: var(--accent-emerald); font-weight: 600; }
.amount-negative { color: var(--accent-rose); font-weight: 600; }
.amount-neutral { color: var(--text-primary); font-weight: 600; }

/* ============================
   RESPONSIVE
   ============================ */
@media (max-width: 900px) {
  .erp-layout { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
  }
  .main-content { padding: 20px 16px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
}
