/* ============================================
   GST PRO — Complete Stylesheet v2.0
   ============================================ */

/* ---- FONTS & VARIABLES ---- */
:root {
  --font-sans: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-display: 'Instrument Serif', Georgia, serif;
  --font-mono: 'Courier New', monospace;

  /* Light theme */
  --bg-base: #f4f6fb;
  --bg-surface: #ffffff;
  --bg-surface2: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-active: #ffffff;
  --sidebar-active-bg: rgba(255,255,255,0.1);
  --sidebar-hover: rgba(255,255,255,0.06);
  --topbar-bg: #ffffff;
  --topbar-border: #e2e8f0;

  --accent-blue: #1a56db;
  --accent-blue-light: #eff6ff;
  --accent-green: #059669;
  --accent-green-light: #ecfdf5;
  --accent-amber: #d97706;
  --accent-amber-light: #fffbeb;
  --accent-red: #dc2626;
  --accent-red-light: #fef2f2;
  --accent-purple: #7c3aed;
  --accent-purple-light: #f5f3ff;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  --sidebar-w: 240px;
  --topbar-h: 56px;
  --transition: 0.18s ease;
}

[data-theme="dark"] {
  --bg-base: #0d1117;
  --bg-surface: #161b22;
  --bg-surface2: #1c2128;
  --border: #30363d;
  --border-strong: #484f58;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --sidebar-bg: #010409;
  --sidebar-text: #8b949e;
  --sidebar-active: #e6edf3;
  --sidebar-active-bg: rgba(255,255,255,0.08);
  --sidebar-hover: rgba(255,255,255,0.04);
  --topbar-bg: #161b22;
  --topbar-border: #30363d;
  --accent-blue-light: #1a2744;
  --accent-green-light: #0d2818;
  --accent-amber-light: #2a1f0a;
  --accent-red-light: #2a0d0d;
  --accent-purple-light: #1e1040;
}

/* ---- RESET ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body { font-family: var(--font-sans); background: var(--bg-base); color: var(--text-primary); display: flex; min-height: 100vh; overflow-x: hidden; }
a { text-decoration: none; color: inherit; cursor: pointer; }
button { cursor: pointer; font-family: var(--font-sans); border: none; outline: none; }
input, select, textarea { font-family: var(--font-sans); }
table { border-collapse: collapse; width: 100%; }

/* ---- SIDEBAR ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--transition);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.logo-text { display: flex; flex-direction: column; }
.logo-main { font-size: 15px; font-weight: 700; color: #fff; letter-spacing: -0.3px; }
.logo-sub { font-size: 10px; color: rgba(255,255,255,0.35); letter-spacing: 0.5px; text-transform: uppercase; }

.sidebar-gstin {
  margin: 12px 12px 4px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.05);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255,255,255,0.08);
}
.gstin-label { font-size: 9px; text-transform: uppercase; letter-spacing: 0.8px; color: rgba(255,255,255,0.3); margin-bottom: 3px; }
.gstin-value { font-size: 11px; font-family: var(--font-mono); color: #60a5fa; letter-spacing: 1px; font-weight: 600; }
.gstin-period { font-size: 10px; color: rgba(255,255,255,0.4); margin-top: 2px; }

.sidebar-nav { flex: 1; padding: 8px 8px; }
.nav-section-label { font-size: 9px; text-transform: uppercase; letter-spacing: 1px; color: rgba(255,255,255,0.25); padding: 12px 8px 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
  margin-bottom: 1px;
  position: relative;
}
.nav-item:hover { background: var(--sidebar-hover); color: rgba(255,255,255,0.8); }
.nav-item.active { background: var(--sidebar-active-bg); color: var(--sidebar-active); }
.nav-item.active::before { content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%); width: 3px; height: 18px; background: #3b82f6; border-radius: 0 3px 3px 0; }
.nav-icon { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.7; }
.nav-item.active .nav-icon { opacity: 1; }
.nav-badge { margin-left: auto; font-size: 9px; padding: 2px 6px; border-radius: 20px; background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.5); font-weight: 600; }
.nav-badge.success { background: rgba(5,150,105,0.3); color: #34d399; }
.nav-badge.warning { background: rgba(217,119,6,0.3); color: #fbbf24; }
.nav-badge.error { background: rgba(220,38,38,0.3); color: #f87171; }

.sidebar-footer { padding: 12px; border-top: 1px solid rgba(255,255,255,0.06); }
.theme-toggle { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border-radius: var(--radius-md); background: rgba(255,255,255,0.05); color: rgba(255,255,255,0.5); font-size: 12px; transition: all var(--transition); }
.theme-toggle:hover { background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.8); }

/* ---- MAIN WRAPPER ---- */
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---- TOPBAR ---- */
.topbar {
  height: var(--topbar-h);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}
.menu-toggle { display: none; background: none; color: var(--text-secondary); padding: 6px; border-radius: var(--radius-sm); }
.topbar-title { font-size: 14px; font-weight: 600; color: var(--text-primary); flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.period-selector select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

/* ---- CONTENT AREA ---- */
.content-area { flex: 1; padding: 24px; overflow-y: auto; }
.page-enter { animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ---- PAGE HEADER ---- */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; gap: 16px; flex-wrap: wrap; }
.page-header-left h1 { font-size: 22px; font-weight: 700; color: var(--text-primary); letter-spacing: -0.5px; margin-bottom: 4px; }
.page-header-left p { font-size: 12px; color: var(--text-muted); }
.page-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- CARDS ---- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface2);
}
.card-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.card-subtitle { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.card-body { padding: 18px; }

/* ---- KPI GRID ---- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.kpi-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; }
.kpi-card.blue::before { background: var(--accent-blue); }
.kpi-card.green::before { background: var(--accent-green); }
.kpi-card.amber::before { background: var(--accent-amber); }
.kpi-card.red::before { background: var(--accent-red); }
.kpi-card.purple::before { background: var(--accent-purple); }
.kpi-icon { width: 34px; height: 34px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; margin-bottom: 10px; }
.kpi-icon.blue { background: var(--accent-blue-light); color: var(--accent-blue); }
.kpi-icon.green { background: var(--accent-green-light); color: var(--accent-green); }
.kpi-icon.amber { background: var(--accent-amber-light); color: var(--accent-amber); }
.kpi-icon.red { background: var(--accent-red-light); color: var(--accent-red); }
.kpi-icon.purple { background: var(--accent-purple-light); color: var(--accent-purple); }
.kpi-label { font-size: 11px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 4px; }
.kpi-value { font-size: 22px; font-weight: 800; color: var(--text-primary); letter-spacing: -0.5px; line-height: 1; margin-bottom: 4px; }
.kpi-sub { font-size: 10px; color: var(--text-muted); }

/* ---- GRIDS ---- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ---- BUTTONS ---- */
.btn-primary, .btn-secondary, .btn-success, .btn-danger {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-md);
  font-size: 12px; font-weight: 600; transition: all var(--transition);
  white-space: nowrap;
}
.btn-primary { background: var(--accent-blue); color: #fff; }
.btn-primary:hover { background: #1648c0; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(26,86,219,0.3); }
.btn-secondary { background: var(--bg-surface2); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); color: var(--text-primary); }
.btn-success { background: var(--accent-green); color: #fff; }
.btn-success:hover { background: #047857; transform: translateY(-1px); }
.btn-danger { background: var(--accent-red); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 5px 12px; font-size: 11px; }
.btn-xs { padding: 3px 8px; font-size: 10px; border-radius: var(--radius-sm); }
.btn-danger.btn-xs { background: var(--accent-red-light); color: var(--accent-red); }
.btn-danger.btn-xs:hover { background: var(--accent-red); color: #fff; }
.w-full { width: 100%; justify-content: center; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }

/* ---- FORMS ---- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }
.form-label { font-size: 11px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.4px; }
.form-input, .form-select, .form-textarea {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 13px;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(26,86,219,0.1);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-select { cursor: pointer; }

/* ---- TABS ---- */
.tabs { display: flex; gap: 2px; margin-bottom: 16px; background: var(--bg-surface2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 4px; flex-wrap: wrap; }
.tab-btn { padding: 7px 14px; border-radius: var(--radius-md); font-size: 12px; font-weight: 500; color: var(--text-muted); background: none; transition: all var(--transition); white-space: nowrap; }
.tab-btn:hover { color: var(--text-primary); background: var(--bg-surface); }
.tab-btn.active { background: var(--bg-surface); color: var(--text-primary); font-weight: 600; box-shadow: var(--shadow-sm); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ---- TABLE ---- */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
thead tr { background: var(--bg-surface2); }
th { padding: 10px 12px; text-align: left; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 9px 12px; border-bottom: 1px solid var(--border); color: var(--text-primary); vertical-align: middle; }
tbody tr:hover { background: var(--bg-surface2); }
tbody tr:last-child td { border-bottom: none; }
tfoot td { padding: 10px 12px; background: var(--bg-surface2); font-weight: 700; border-top: 2px solid var(--border); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-mono { font-family: var(--font-mono); }
.font-bold { font-weight: 700; }
.text-muted { color: var(--text-muted); }
.text-red { color: var(--accent-red); }
.text-green { color: var(--accent-green); }

/* Recon row colors */
.recon-matched td { background: rgba(5,150,105,0.04); }
.recon-mismatch td { background: rgba(217,119,6,0.06); }
.recon-missing td { background: rgba(220,38,38,0.04); }

/* ---- BADGES ---- */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 20px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; }
.badge-blue { background: var(--accent-blue-light); color: var(--accent-blue); }
.badge-green { background: var(--accent-green-light); color: var(--accent-green); }
.badge-amber { background: var(--accent-amber-light); color: var(--accent-amber); }
.badge-red { background: var(--accent-red-light); color: var(--accent-red); }
.badge-purple { background: var(--accent-purple-light); color: var(--accent-purple); }

/* ---- ALERTS ---- */
.alert { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--radius-md); font-size: 12px; margin-bottom: 12px; }
.alert-info { background: var(--accent-blue-light); color: var(--accent-blue); border: 1px solid rgba(26,86,219,0.15); }
.alert-success { background: var(--accent-green-light); color: var(--accent-green); border: 1px solid rgba(5,150,105,0.15); }
.alert-warning { background: var(--accent-amber-light); color: var(--accent-amber); border: 1px solid rgba(217,119,6,0.15); }
.alert-error { background: var(--accent-red-light); color: var(--accent-red); border: 1px solid rgba(220,38,38,0.15); }

/* ---- UPLOAD ZONE ---- */
.upload-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg-surface2);
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent-blue);
  background: var(--accent-blue-light);
}
.upload-zone-icon { font-size: 36px; margin-bottom: 10px; }
.upload-zone h3 { font-size: 14px; font-weight: 600; color: var(--text-primary); margin-bottom: 6px; }
.upload-zone p { font-size: 11px; color: var(--text-muted); }

/* ---- SUMMARY BOX ---- */
.summary-box { background: var(--bg-surface2); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.summary-row { display: flex; justify-content: space-between; align-items: center; padding: 9px 14px; border-bottom: 1px solid var(--border); }
.summary-row:last-child { border-bottom: none; }
.summary-row.total { background: var(--bg-base); }
.summary-label { font-size: 12px; color: var(--text-secondary); font-weight: 500; }
.summary-value { font-size: 13px; font-weight: 700; color: var(--text-primary); font-family: var(--font-mono); }
.summary-value.credit { color: var(--accent-green); }
.summary-value.debit { color: var(--accent-red); }

/* ---- EMPTY STATE ---- */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state p { font-size: 12px; }

/* ---- SECTION TITLE ---- */
.section-title { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent-blue); }

/* ---- MODAL ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: none; align-items: center; justify-content: center;
  z-index: 200; padding: 20px; backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 15px; font-weight: 700; }
.modal-close { background: none; color: var(--text-muted); font-size: 16px; padding: 4px 8px; border-radius: var(--radius-sm); }
.modal-close:hover { background: var(--bg-surface2); color: var(--text-primary); }
.modal-body { padding: 20px; }

/* ---- TOAST ---- */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--text-primary); color: var(--bg-surface);
  padding: 12px 18px; border-radius: var(--radius-lg);
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  transform: translateY(80px); opacity: 0;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 300; max-width: 320px;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: var(--accent-green); color: #fff; }
.toast.error { background: var(--accent-red); color: #fff; }
.toast.warning { background: var(--accent-amber); color: #fff; }

/* ---- LOADING ---- */
.loading::after { content: ''; display: inline-block; width: 10px; height: 10px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin 0.6s linear infinite; margin-left: 8px; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- RESPONSIVE ---- */
@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .menu-toggle { display: flex; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .content-area { padding: 16px; }
  .topbar-actions .btn-secondary { display: none; }
  .page-header { flex-direction: column; }
  .tabs { overflow-x: auto; flex-wrap: nowrap; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-value { font-size: 18px; }
  .topbar { padding: 0 12px; }
  .content-area { padding: 12px; }
}