@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&family=DM+Mono:wght@400;500&display=swap');

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

:root {
  --bg-page:        #F0F4FA;
  --bg-card:        #FFFFFF;
  --bg-card-hover:  #F8FAFD;
  --bg-header:      #FFFFFF;
  --bg-table-head:  #F8FAFD;
  --border:         #DDE3EE;
  --text-primary:   #111827;
  --text-secondary: #6B7280;
  --text-muted:     #9CA3AF;
  --icon-stroke:    #0F2B5B;
  --icon-bg:        #F0F4FA;
  --icon-border:    #DDE3EE;
  --bar-track:      #EEF2F8;
  --sidebar-bg:     #0F2B5B;
  --accent:         #378ADD;
}
[data-theme="dark"] {
  --bg-page:        #1A1F2E;
  --bg-card:        #272D3F;
  --bg-card-hover:  #2E3550;
  --bg-header:      #222839;
  --bg-table-head:  #2E3550;
  --border:         rgba(255,255,255,0.07);
  --text-primary:   #F1F5F9;
  --text-secondary: #94A3B8;
  --text-muted:     #64748B;
  --icon-stroke:    #FCD34D;
  --icon-bg:        #2E3550;
  --icon-border:    rgba(255,255,255,0.1);
  --bar-track:      #1A1F2E;
}

html, body {
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-page);
  height: 100%;
  transition: background 0.25s, color 0.25s;
}

.shell { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ── */
.sidebar {
  width: 210px; min-width: 210px;
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  height: 100vh; position: fixed; left: 0; top: 0; z-index: 100;
  overflow-y: auto;
}
.sidebar-logo {
  padding: 18px 16px 14px;
  border-bottom: 0.5px solid rgba(255,255,255,0.1);
  display: flex; align-items: center; gap: 10px; text-decoration: none;
}
.logo-icon {
  width: 30px; height: 30px; background: var(--accent); border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; line-height: 1; flex-shrink: 0;
}
.logo-name { font-size: 14px; font-weight: 600; color: #fff; line-height: 1.3; }
.logo-sub  { font-size: 10px; color: rgba(255,255,255,0.4); }
.sidebar-section {
  padding: 14px 16px 4px; font-size: 9.5px;
  color: rgba(255,255,255,0.3); text-transform: uppercase; letter-spacing: 1px;
}
.sidebar-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 16px; font-size: 12.5px;
  color: rgba(255,255,255,0.55); text-decoration: none;
  border-left: 3px solid transparent; transition: all 0.15s;
}
.sidebar-item:hover { background: rgba(55,138,221,0.12); color: rgba(255,255,255,0.85); }
.sidebar-item.active { background: rgba(55,138,221,0.2); border-left: 3px solid var(--accent); color: #fff; }
.sidebar-item svg {
  width: 12px; height: 12px; stroke: currentColor; fill: none;
  stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
  flex-shrink: 0; opacity: 0.7;
}
.sidebar-item.active svg { opacity: 1; }
.sidebar-spacer { flex: 1; }
.sidebar-user {
  padding: 14px 16px; border-top: 0.5px solid rgba(255,255,255,0.1);
  display: flex; align-items: center; gap: 9px;
}
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%; background: #1D9E75;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: #fff; font-weight: 600; flex-shrink: 0;
}
.user-name { font-size: 12px; color: rgba(255,255,255,0.8); font-weight: 500; }
.user-role { font-size: 10px; color: rgba(255,255,255,0.35); }

/* ── Main ── */
.main { margin-left: 210px; flex: 1; display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* ── Topbar ── */
.topbar {
  background: var(--bg-header); border-bottom: 0.5px solid var(--border);
  padding: 0 28px; height: 54px;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0; transition: background 0.25s, border-color 0.25s;
}
.topbar-left h1 { font-size: 15px; font-weight: 500; color: var(--text-primary); margin: 0; }
.topbar-left p  { font-size: 11.5px; color: var(--text-secondary); margin: 0; }
.topbar-right   { display: flex; align-items: center; gap: 10px; }
.period-pill    { background: #DBEAFE; color: #1E40AF; font-size: 11px; padding: 4px 11px; border-radius: 20px; font-weight: 500; }
.theme-btn {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--icon-bg); border: 0.5px solid var(--icon-border);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background 0.2s;
}
.theme-btn svg { width: 14px; height: 14px; stroke: var(--icon-stroke); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.theme-btn:hover { background: var(--bg-card-hover); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px;
  font-family: 'DM Sans', sans-serif; font-size: 13px; font-weight: 500;
  cursor: pointer; border: none; text-decoration: none; transition: all 0.2s;
}
.btn-primary   { background: #0F2B5B; color: #fff; }
.btn-primary:hover { background: #1A3D6B; transform: translateY(-1px); }
.btn-success   { background: #065F46; color: #fff; }
.btn-success:hover { background: #047857; }

/* KEY FIX: secondary buttons fully theme-aware */
.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 0.5px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-card-hover); color: var(--text-primary); }

.btn-danger    { background: #991B1B; color: #fff; }
.btn-danger:hover { background: #7F1D1D; }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* Sign out link in topbar — always readable */
a.btn-secondary, a.btn.btn-secondary {
  color: var(--text-primary) !important;
}

/* ── Content ── */
.content { flex: 1; overflow-y: auto; padding: 24px 28px; }

/* ── Cards ── */
.card { background: var(--bg-card); border: 0.5px solid var(--border); border-radius: 12px; transition: background 0.25s, border-color 0.25s; }
.card-header { padding: 14px 18px; border-bottom: 0.5px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-title  { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.card-body   { padding: 18px; }

/* ── Metrics ── */
.metrics-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 20px; }
.metric-card { background: var(--bg-card); border: 0.5px solid var(--border); border-radius: 12px; padding: 14px 16px; transition: background 0.25s; }
.metric-label { font-size: 10.5px; color: var(--text-secondary); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.metric-value { font-size: 28px; font-weight: 500; color: var(--text-primary); line-height: 1; }
.metric-badge { display: inline-block; margin-top: 6px; font-size: 10px; padding: 2px 7px; border-radius: 8px; font-weight: 500; }
.badge-blue  { background: #DBEAFE; color: #1E40AF; }
.badge-green { background: #D1FAE5; color: #065F46; }
.badge-red   { background: #FEE2E2; color: #991B1B; }
.badge-amber { background: #FEF3C7; color: #92400E; }

/* ── Two col ── */
.two-col { display: grid; grid-template-columns: 1fr 320px; gap: 16px; align-items: start; }

/* ── Table ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 9px 14px; text-align: left; font-size: 11px; font-weight: 500;
  color: var(--text-secondary); background: var(--bg-table-head);
  border-bottom: 0.5px solid var(--border); text-transform: uppercase; letter-spacing: 0.4px;
}
tbody td { padding: 10px 14px; font-size: 12.5px; color: var(--text-primary); border-bottom: 0.5px solid var(--border); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-card-hover); }
.mono { font-family: 'DM Mono', monospace; font-size: 11px; color: var(--text-muted); }

/* ── Pills ── */
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; padding: 3px 8px; border-radius: 10px; font-weight: 500; }
.pill-dot      { width: 5px; height: 5px; border-radius: 50%; }
.pill-matched  { background: #D1FAE5; color: #065F46; }
.pill-mismatch { background: #FEE2E2; color: #991B1B; }
.pill-missing  { background: #FEF3C7; color: #92400E; }
.pill-extra    { background: #DBEAFE; color: #1E40AF; }

/* ── Right panel ── */
.right-panel { display: flex; flex-direction: column; gap: 12px; }

.ai-card { background: #162040; border: 0.5px solid rgba(55,138,221,0.25); border-radius: 12px; padding: 16px; }
.ai-card-header { display: flex; align-items: center; gap: 7px; margin-bottom: 10px; }
.ai-badge { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 10px; color: #fff; font-weight: 600; }
.ai-title { font-size: 12px; font-weight: 500; color: #E2EEFF; }
.ai-body  { font-size: 11.5px; color: #94B4D4; line-height: 1.7; }
.ai-btn {
  display: block; width: 100%; margin-top: 12px;
  background: var(--accent); color: #fff; border: none; border-radius: 8px;
  padding: 8px; font-size: 12px; font-weight: 500; cursor: pointer;
  text-align: center; font-family: 'DM Sans', sans-serif; transition: background 0.2s;
}
.ai-btn:hover { background: #2576C7; }
.ai-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.tax-card { background: var(--bg-card); border: 0.5px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.tax-title { font-size: 12px; font-weight: 500; color: var(--text-primary); margin-bottom: 12px; }
.tax-row   { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
.tax-label { font-size: 11px; color: var(--text-secondary); }
.tax-val   { font-size: 12px; font-weight: 500; color: var(--text-primary); }
.tax-bar   { height: 4px; background: var(--bar-track); border-radius: 3px; margin-bottom: 10px; overflow: hidden; }
.tax-bar-fill { height: 100%; border-radius: 3px; }
.tax-diff-row { display: flex; justify-content: space-between; align-items: center; padding-top: 10px; border-top: 0.5px solid var(--border); margin-top: 4px; }
.tax-diff-label { font-size: 11px; font-weight: 500; color: var(--text-secondary); }
.diff-negative  { font-size: 14px; font-weight: 600; color: #DC2626; }
.diff-zero      { font-size: 14px; font-weight: 600; color: #065F46; }

.wa-card { background: var(--bg-card); border: 0.5px solid var(--border); border-radius: 12px; padding: 13px 16px; display: flex; align-items: center; gap: 12px; }
.wa-icon { width: 32px; height: 32px; border-radius: 8px; background: #D1FAE5; display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.wa-text { font-size: 11.5px; color: var(--text-secondary); line-height: 1.5; flex: 1; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.form-input, .form-select, .form-textarea {
  width: 100%; background: var(--bg-card); border: 0.5px solid var(--border);
  border-radius: 8px; padding: 9px 12px; font-family: 'DM Sans', sans-serif;
  font-size: 13px; color: var(--text-primary); transition: border-color 0.2s; outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(55,138,221,0.12);
}
.form-textarea { resize: vertical; min-height: 80px; }

/* ── File drop ── */
.file-drop {
  background: var(--bg-card); border: 1.5px dashed var(--border); border-radius: 12px;
  padding: 24px; text-align: center; cursor: pointer;
  transition: border-color 0.2s, background 0.2s; position: relative;
}
.file-drop:hover, .file-drop.dragover { border-color: var(--accent); background: var(--bg-card-hover); }
.file-drop input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.file-drop-icon { font-size: 24px; margin-bottom: 8px; }
.file-drop-text { font-size: 13px; color: var(--text-secondary); }
.file-drop-sub  { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.file-selected  { font-size: 12px; color: #065F46; font-weight: 500; margin-top: 6px; }

/* ── Dashboard session rows ── */
.session-row {
  display: grid;
  grid-template-columns: 1fr 80px 80px 80px 80px 120px 100px;
  align-items: center; padding: 12px 16px;
  border-bottom: 0.5px solid var(--border); gap: 8px;
  transition: background 0.15s; text-decoration: none; color: inherit;
}
.session-row:hover { background: var(--bg-card-hover); }
.session-row:last-child { border-bottom: none; }
.session-date { font-size: 12px; color: var(--text-primary); font-weight: 500; }
.session-sub  { font-size: 11px; color: var(--text-muted); }
.session-num  { font-size: 14px; font-weight: 500; color: var(--text-primary); text-align: center; }
.session-num-label { font-size: 10px; color: var(--text-muted); text-align: center; }

/* KEY FIX: View button inside session rows */
.session-row .btn-secondary {
  color: var(--text-primary) !important;
  border-color: var(--border) !important;
}

/* ── Alerts ── */
.alert { padding: 12px 16px; border-radius: 10px; font-size: 13px; margin-bottom: 16px; }
.alert-error   { background: #FEF2F2; border: 0.5px solid #FCA5A5; color: #991B1B; }
.alert-success { background: #F0FDF4; border: 0.5px solid #86EFAC; color: #166534; }
.alert-info    { background: #EFF6FF; border: 0.5px solid #BFDBFE; color: #1E40AF; }
.alert-warning { background: #FFFBEB; border: 0.5px solid #FCD34D; color: #92400E; }

.divider { border: none; border-top: 0.5px solid var(--border); margin: 20px 0; }

/* ── Filter tabs ── */
.filter-tabs { display: flex; gap: 4px; background: var(--bg-card); border: 0.5px solid var(--border); border-radius: 10px; padding: 4px; }
.filter-tab  { padding: 5px 14px; border-radius: 7px; font-size: 12px; font-weight: 500; cursor: pointer; color: var(--text-secondary); border: none; background: none; font-family: 'DM Sans', sans-serif; transition: all 0.15s; }
.filter-tab.active { background: #0F2B5B; color: #fff; }
.filter-tab:hover:not(.active) { background: var(--bg-card-hover); color: var(--text-primary); }

/* ── Login ── */
.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg-page); padding: 20px; }
.login-card  { background: var(--bg-card); border: 0.5px solid var(--border); border-radius: 16px; padding: 40px; width: 100%; max-width: 400px; position: relative; }
.login-logo      { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.login-logo-icon { width: 38px; height: 38px; background: #0F2B5B; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 20px; }
.login-logo-name { font-size: 18px; font-weight: 600; color: var(--text-primary); }
.login-logo-sub  { font-size: 11px; color: var(--text-secondary); }
.login-title { font-size: 20px; font-weight: 500; color: var(--text-primary); margin-bottom: 6px; }
.login-sub   { font-size: 13px; color: var(--text-secondary); margin-bottom: 24px; }
.login-footer { margin-top: 20px; text-align: center; font-size: 12px; color: var(--text-muted); }

/* ── Spinner ── */
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite; margin-right: 6px; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 48px 24px; }
.empty-icon  { font-size: 36px; margin-bottom: 12px; }
.empty-title { font-size: 15px; font-weight: 500; color: var(--text-primary); margin-bottom: 6px; }
.empty-sub   { font-size: 13px; color: var(--text-secondary); }

/* ── WA input row ── */
.wa-input-row { display: flex; gap: 8px; margin-top: 12px; }
.wa-input-row .form-input { flex: 1; }

/* ── Sidebar expandable sub-menu ───────────────────────────────── */
.sidebar-item-parent {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 16px;
  font-size: 12.5px;
  color: rgba(255,255,255,0.55);
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all 0.15s;
  user-select: none;
}
.sidebar-item-parent:hover {
  background: rgba(55,138,221,0.12);
  color: rgba(255,255,255,0.85);
}
.sidebar-item-parent.active {
  background: rgba(55,138,221,0.15);
  color: rgba(255,255,255,0.85);
}
.sidebar-item-parent svg:first-child {
  width: 12px; height: 12px; flex-shrink: 0;
  stroke: currentColor; fill: none;
  stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
  opacity: 0.7;
}

.sidebar-submenu {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.25s ease;
  display: block;
  width: 100%;
}
.sidebar-submenu.open {
  max-height: 140px;
}

.sidebar-subitem {
  display: block;
  padding: 7px 16px 7px 30px;
  font-size: 12px;
  color: rgba(255,255,255,0.4);
  text-decoration: none;
  transition: all 0.12s;
  border-left: 3px solid transparent;
  white-space: nowrap;
  position: relative;
}
.sidebar-subitem::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  margin-right: 8px;
  vertical-align: middle;
  transition: background 0.15s;
}
.sidebar-subitem:hover {
  color: rgba(255,255,255,0.75);
  background: rgba(55,138,221,0.08);
}
.sidebar-subitem.active {
  color: #fff;
  font-weight: 500;
  background: rgba(55,138,221,0.18);
  border-left: 3px solid var(--accent);
}
.sidebar-subitem.active::before {
  background: var(--accent);
}

/* ── Company switcher ─────────────────────────────────────────── */
.company-switcher {
  margin: 8px 10px 4px;
  border-radius: 10px;
  border: 0.5px solid rgba(255,255,255,0.12);
  cursor: pointer;
  transition: all 0.15s;
  background: rgba(255,255,255,0.05);
}
.company-switcher:hover { background: rgba(55,138,221,0.15); border-color: rgba(55,138,221,0.4); }
.company-switcher-inner { display: flex; align-items: center; gap: 9px; padding: 9px 10px; }
.company-icon { font-size: 16px; flex-shrink: 0; }
.company-info { flex: 1; min-width: 0; }
.company-name-text {
  font-size: 12px; font-weight: 500; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.company-gstin-text {
  font-size: 10px; color: rgba(255,255,255,0.4);
  font-family: 'DM Mono', monospace; margin-top: 1px;
}
.company-chevron {
  width: 12px; height: 12px; flex-shrink: 0;
  stroke: rgba(255,255,255,0.4); fill: none;
  stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
  transition: transform 0.2s;
}

.company-dropdown {
  display: none; flex-direction: column;
  margin: 0 10px; padding: 4px;
  background: rgba(255,255,255,0.06);
  border-radius: 8px; border: 0.5px solid rgba(255,255,255,0.1);
  margin-bottom: 8px;
}
.company-dropdown.open { display: flex; }

.company-option {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 7px; text-decoration: none;
  transition: background 0.12s; cursor: pointer;
}
.company-option:hover { background: rgba(55,138,221,0.15); }
.company-option.active { background: rgba(55,138,221,0.2); }
.company-option-dot {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
  background: rgba(255,255,255,0.25); transition: background 0.15s;
}
.company-option-dot.active { background: #378ADD; }
.company-option-name {
  font-size: 12px; font-weight: 500; color: rgba(255,255,255,0.85);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 130px;
}
.company-option-gstin { font-size: 10px; color: rgba(255,255,255,0.35); font-family: 'DM Mono', monospace; }

.company-add-btn {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 10px; border-radius: 7px;
  font-size: 11.5px; color: rgba(255,255,255,0.45);
  text-decoration: none; transition: all 0.12s;
  border-top: 0.5px solid rgba(255,255,255,0.08); margin-top: 2px;
}
.company-add-btn:hover { color: rgba(255,255,255,0.8); background: rgba(55,138,221,0.12); }