/* ============================================================
   PayAudit Design System — PandaDoc-inspired, Facebook Blue
   ============================================================ */

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

:root {
  /* Primary palette */
  --accent: #1877F2;
  --accent-light: #e8f1fe;
  --accent-hover: #1464d0;
  --accent-soft: rgba(24, 119, 242, 0.06);
  --accent-ring: rgba(24, 119, 242, 0.18);

  /* Backgrounds */
  --bg: #f5f7fa;
  --bg-card: #ffffff;
  --bg-surface: #f0f3f7;
  --bg-hover: #f5f7fa;
  --bg-sidebar: #ffffff;

  /* Semantic colors */
  --red: #e74c3c;
  --red-light: #fdf0ef;
  --yellow: #f5a623;
  --yellow-light: #fef8ec;
  --green: #27ae60;
  --green-light: #edf9f0;

  /* Text */
  --text: #1a1d21;
  --text-secondary: #4e5d78;
  --text-muted: #8492a6;

  /* Borders */
  --border: #e3e8ef;
  --border-strong: #cdd5df;

  /* Shadows — very subtle, PandaDoc-style */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.03);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.03);
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.1);

  /* Radii — rounded, friendly */
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  /* Layout */
  --sidebar-width: 248px;
  --topbar-height: 60px;

  /* Transition */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================================
   App Layout — Sidebar + Topbar + Content
   ============================================================ */

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  overflow-y: auto;
  transition: transform 0.25s var(--ease);
}

.sidebar-logo {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-nav-group {
  padding: 1rem 0.75rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0.75rem 0.75rem 0.4rem;
}

.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* Main Area */
.main-area {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
  padding: 0 2rem;
  height: var(--topbar-height);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-left {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ============================================================
   Sidebar Navigation Links (replaces old .nav-link in topbar)
   ============================================================ */

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.15s var(--ease);
  cursor: pointer;
}

.nav-link svg {
  width: 18px;
  height: 18px;
  opacity: 0.55;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

.nav-link:hover {
  color: var(--text);
  background: var(--bg-surface);
}

.nav-link:hover svg {
  opacity: 0.8;
}

.nav-link.active {
  color: var(--accent);
  background: var(--accent-light);
  font-weight: 600;
}

.nav-link.active svg {
  opacity: 1;
}

/* ============================================================
   Logo
   ============================================================ */

.logo {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.logo span {
  color: var(--accent);
}

/* ============================================================
   Notification Bell
   ============================================================ */

.notif-btn {
  position: relative;
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: var(--radius);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  transition: all 0.15s var(--ease);
}

.notif-btn:hover {
  background: var(--bg-surface);
  color: var(--text);
  border-color: var(--border);
}

.notification-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background: var(--red);
  border-radius: 50%;
  border: 2px solid #fff;
  display: none;
}

.notification-dot.visible {
  display: block;
}

/* ============================================================
   Account Dropdown
   ============================================================ */

.account-dropdown {
  position: relative;
}

.account-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem 0.35rem 0.35rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  cursor: pointer;
  font-size: 0.83rem;
  font-weight: 500;
  color: var(--text);
  transition: all 0.15s var(--ease);
  font-family: inherit;
}

.account-btn:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.account-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #4da0ff);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  min-width: 200px;
  z-index: 300;
  padding: 0.5rem;
  animation: dropdownIn 0.15s var(--ease);
}

@keyframes dropdownIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.dropdown-menu.hidden {
  display: none;
}

.dropdown-item {
  display: block;
  padding: 0.55rem 0.85rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.12s var(--ease);
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.dropdown-item:hover {
  background: var(--bg-surface);
}

.dropdown-item.danger {
  color: var(--red);
}

.dropdown-item.danger:hover {
  background: var(--red-light);
}

.dropdown-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.35rem 0;
}

/* ============================================================
   Main Content Area
   ============================================================ */

#app-content {
  padding: 2rem 2.5rem;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
}

/* ============================================================
   Typography
   ============================================================ */

.page-title {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
  color: var(--text);
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 2rem;
  line-height: 1.5;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.section-title {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.section-label-sm {
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

/* ============================================================
   KPI Cards
   ============================================================ */

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2.5rem;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s var(--ease), border-color 0.2s;
}

.kpi-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--border-strong);
}

.kpi-card .label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 0.65rem;
}

.kpi-card .value {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.kpi-card .value.green { color: var(--green); }
.kpi-card .value.red { color: var(--red); }
.kpi-card .value.yellow { color: var(--yellow); }
.kpi-card .value.blue { color: var(--accent); }

/* ============================================================
   Cards
   ============================================================ */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.card-title {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  color: var(--text);
}

/* ============================================================
   Data Tables
   ============================================================ */

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.data-table th {
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 0.85rem 1.15rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
}

.data-table td {
  padding: 0.85rem 1.15rem;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  transition: background 0.1s;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background: var(--bg-hover);
}

.data-table .mono {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
}

.data-table .green { color: var(--green); }
.data-table .red { color: var(--red); }
.data-table .yellow { color: var(--yellow); }
.data-table .blue { color: var(--accent); }
.data-table .clickable { cursor: pointer; }
.data-table .clickable:hover td { background: var(--accent-soft); }

/* ============================================================
   Badges & Tags
   ============================================================ */

.tag, .badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.65rem;
  border-radius: 100px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.tag-high, .badge-red { background: var(--red-light); color: var(--red); }
.tag-medium, .badge-yellow { background: var(--yellow-light); color: var(--yellow); }
.tag-low, .badge-green { background: var(--green-light); color: var(--green); }
.tag-completed { background: var(--green-light); color: var(--green); }
.tag-processing { background: var(--yellow-light); color: var(--yellow); }
.tag-failed { background: var(--red-light); color: var(--red); }
.tag-pending { background: var(--bg-surface); color: var(--text-muted); }
.badge-blue { background: var(--accent-light); color: var(--accent); }
.badge-gray { background: var(--bg-surface); color: var(--text-muted); border: 1px solid var(--border); }

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.65rem;
  border-radius: 100px;
  font-size: 0.7rem;
  font-weight: 600;
}

.status-new { background: var(--accent-light); color: var(--accent); }
.status-under_review { background: var(--yellow-light); color: var(--yellow); }
.status-disputed { background: #f3e8ff; color: #7c3aed; }
.status-resolved { background: var(--green-light); color: var(--green); }
.status-closed { background: var(--bg-surface); color: var(--text-muted); }

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius);
  font-family: "Inter", -apple-system, sans-serif;
  font-weight: 600;
  font-size: 0.875rem;
  border: none;
  cursor: pointer;
  transition: all 0.18s var(--ease);
  text-decoration: none;
  line-height: 1.4;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(24, 119, 242, 0.2);
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 12px rgba(24, 119, 242, 0.3);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(24, 119, 242, 0.2);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

.btn-danger {
  background: var(--red-light);
  color: var(--red);
  border: 1px solid transparent;
}

.btn-danger:hover {
  border-color: var(--red);
  background: #fde8e8;
}

.btn-sm {
  padding: 0.38rem 0.85rem;
  font-size: 0.78rem;
  border-radius: 8px;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: none;
}

.btn-ghost:hover {
  background: var(--bg-surface);
  color: var(--text);
}

/* ============================================================
   Forms & Inputs
   ============================================================ */

.form-group {
  flex: 1;
  min-width: 200px;
}

.form-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.form-group select, .form-input {
  width: 100%;
  padding: 0.65rem 0.9rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  transition: all 0.15s var(--ease);
}

.form-group select {
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' fill='%238492a6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
}

.form-group select:focus, .form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

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

/* ============================================================
   Upload Zones
   ============================================================ */

.upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

@media (max-width: 768px) {
  .upload-grid { grid-template-columns: 1fr; }
}

.upload-zone {
  background: var(--bg-card);
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 2.75rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  position: relative;
}

.upload-zone:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.upload-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-light);
  box-shadow: 0 0 0 4px var(--accent-ring);
}

.upload-zone.uploading {
  pointer-events: none;
  opacity: 0.6;
}

.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  opacity: 0.45;
}

.upload-zone h3 {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.upload-zone p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.upload-zone .file-name {
  display: none;
  margin-top: 0.75rem;
  padding: 0.4rem 0.85rem;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 100px;
  font-size: 0.8rem;
  font-weight: 500;
}

.upload-zone.has-file .file-name {
  display: inline-block;
}

/* ============================================================
   Audit Runner
   ============================================================ */

.audit-runner {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
}

.audit-runner h3 {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.audit-form {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

/* ============================================================
   Discrepancy Cards
   ============================================================ */

.disc-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.disc-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
}

.disc-card:hover {
  box-shadow: var(--shadow);
}

.disc-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 4px;
  border-radius: 4px 0 0 4px;
}

.disc-card.severity-high::before { background: var(--red); }
.disc-card.severity-medium::before { background: var(--yellow); }
.disc-card.severity-low::before { background: var(--green); }

.disc-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.85rem;
  gap: 1rem;
}

.disc-header h4 {
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
}

.disc-amounts {
  display: flex;
  gap: 2rem;
  margin-bottom: 0.85rem;
}

.disc-amount {
  text-align: center;
}

.disc-amount .label {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.2rem;
}

.disc-amount .value {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
}

.disc-explanation {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.55;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}

/* ============================================================
   Comments
   ============================================================ */

.comment-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.comment-item {
  padding: 0.85rem 1rem;
  background: var(--bg-surface);
  border-radius: var(--radius);
  border-left: 3px solid var(--border);
}

.comment-item.internal {
  border-left-color: var(--yellow);
}

.comment-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.comment-text {
  font-size: 0.875rem;
  line-height: 1.5;
}

/* ============================================================
   Audit Detail
   ============================================================ */

.audit-detail-header {
  margin-bottom: 2rem;
}

.audit-detail-header h2 {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.6rem;
  letter-spacing: -0.02em;
}

.audit-detail-header .meta {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  flex-wrap: wrap;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 1.75rem;
  transition: opacity 0.15s;
}

.back-link:hover {
  opacity: 0.75;
}

.summary-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 2rem;
  font-size: 0.9rem;
  line-height: 1.65;
  color: var(--text-secondary);
}

.summary-box strong {
  color: var(--text);
}

/* ============================================================
   Vendor Cards
   ============================================================ */

.vendor-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s var(--ease);
}

.vendor-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.vendor-name {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.vendor-stats {
  display: flex;
  gap: 1.5rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ============================================================
   Spinner & Loading
   ============================================================ */

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner-large {
  width: 36px;
  height: 36px;
  border-width: 3px;
}

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

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 5rem 2rem;
  color: var(--text-muted);
  gap: 1rem;
}

.loading-state p {
  font-size: 0.9rem;
}

/* ============================================================
   Empty State
   ============================================================ */

.empty-state {
  text-align: center;
  padding: 5rem 2rem;
  color: var(--text-muted);
}

.empty-state .icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
  opacity: 0.35;
}

.empty-state h3 {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.empty-state p {
  font-size: 0.9rem;
  line-height: 1.6;
  max-width: 400px;
  margin: 0 auto 1.75rem;
}

/* ============================================================
   Toast Notifications
   ============================================================ */

#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  animation: toastIn 0.3s var(--ease);
  max-width: 400px;
  box-shadow: var(--shadow-md);
}

.toast-success { background: var(--green-light); color: var(--green); border: 1px solid #a3e2c0; }
.toast-error { background: var(--red-light); color: var(--red); border: 1px solid #f3b5b5; }
.toast-info { background: var(--accent-light); color: var(--accent); border: 1px solid #a8cdfb; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Notification Items
   ============================================================ */

.notification-item {
  display: flex;
  gap: 0.85rem;
  padding: 1rem 1.15rem;
  border-radius: var(--radius);
  transition: all 0.12s var(--ease);
  border-bottom: 1px solid var(--border);
}

.notification-item:last-child {
  border-bottom: none;
}

.notification-item.unread {
  background: var(--accent-soft);
}

.notification-item:hover {
  background: var(--bg-hover);
}

.notif-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.notif-icon.success { background: var(--green-light); }
.notif-icon.info { background: var(--accent-light); }
.notif-icon.warning { background: var(--yellow-light); }

.notif-content { flex: 1; }

.notif-title {
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 0.25rem;
}

.notif-message {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.notif-time {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

/* ============================================================
   Alerts
   ============================================================ */

.alert {
  padding: 0.9rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.alert-info { background: var(--accent-light); color: var(--accent); border: 1px solid #a8cdfb; }
.alert-warning { background: var(--yellow-light); color: var(--yellow); border: 1px solid #f5d68a; }
.alert-error { background: var(--red-light); color: var(--red); border: 1px solid #f3b5b5; }
.alert-success { background: var(--green-light); color: var(--green); border: 1px solid #a3e2c0; }

/* ============================================================
   Breadcrumb
   ============================================================ */

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.breadcrumb a {
  color: var(--accent);
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.breadcrumb-sep {
  opacity: 0.4;
}

/* ============================================================
   Modal
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 2.25rem;
  max-width: 500px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s var(--ease);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-title {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
}

.modal-footer {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.75rem;
}

/* ============================================================
   Admin Layout
   ============================================================ */

.admin-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 2rem;
}

.sidebar-nav {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  height: fit-content;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.12s var(--ease);
  background: none;
  border: none;
  width: 100%;
}

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

.sidebar-nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
}

/* ============================================================
   Onboarding Steps
   ============================================================ */

.onboarding-step {
  display: flex;
  gap: 1rem;
  padding: 1.15rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  margin-bottom: 0.75rem;
  transition: all 0.15s;
}

.onboarding-step.done {
  background: var(--green-light);
  border-color: #a3e2c0;
}

.step-number {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  flex-shrink: 0;
}

.onboarding-step.done .step-number {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

/* ============================================================
   Login Page
   ============================================================ */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 1.5rem;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 2.75rem;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow-md);
}

.login-logo {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: 1.6rem;
  text-align: center;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.login-logo span {
  color: var(--accent);
}

.login-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.75rem;
}

.tab {
  flex: 1;
  padding: 0.65rem;
  text-align: center;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s var(--ease);
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
  font-family: inherit;
}

.tab:hover {
  color: var(--text-secondary);
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.login-form label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 0.35rem;
}

.login-form input {
  width: 100%;
  padding: 0.72rem 1rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  color: var(--text);
  transition: all 0.15s var(--ease);
  font-family: inherit;
}

.login-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

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

.login-form .btn-primary {
  width: 100%;
  justify-content: center;
  padding: 0.8rem;
  font-size: 0.92rem;
  margin-top: 0.25rem;
}

.login-error {
  padding: 0.8rem 1rem;
  background: var(--red-light);
  color: var(--red);
  border-radius: var(--radius);
  font-size: 0.85rem;
  display: none;
  border: 1px solid #f3b5b5;
}

.login-error.visible {
  display: block;
}

/* ============================================================
   Security Page Styles
   ============================================================ */

.security-section {
  margin-bottom: 3.5rem;
}

.security-section h2 {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.85rem;
}

.security-section p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.75;
  margin-bottom: 0.75rem;
}

.security-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.security-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
}

.security-card:hover {
  box-shadow: var(--shadow);
}

.security-card-icon {
  font-size: 1.5rem;
  margin-bottom: 0.85rem;
}

.security-card h3 {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.security-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ============================================================
   Mobile Sidebar Toggle
   ============================================================ */

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  color: var(--text);
  border-radius: var(--radius);
}

.sidebar-toggle:hover {
  background: var(--bg-surface);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 150;
}

.sidebar-overlay.visible {
  display: block;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    z-index: 250;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-area {
    margin-left: 0;
  }

  .sidebar-toggle {
    display: flex;
  }

  #app-content {
    padding: 1.5rem 1.25rem;
  }
}

@media (max-width: 768px) {
  .topbar {
    padding: 0 1rem;
  }

  .kpi-row {
    grid-template-columns: 1fr 1fr;
  }

  .audit-form {
    flex-direction: column;
  }

  .disc-amounts {
    flex-wrap: wrap;
    gap: 1rem;
  }

  .admin-layout {
    grid-template-columns: 1fr;
  }

  .account-btn span {
    display: none;
  }
}

@media (max-width: 480px) {
  .kpi-row {
    grid-template-columns: 1fr;
  }

  .upload-grid {
    grid-template-columns: 1fr;
  }

  #app-content {
    padding: 1.25rem 1rem;
  }
}

/* ============================================================
   Phase 3+4: CFO Dashboard, Scorecards, Charts, Reports
   ============================================================ */

/* CFO Dashboard Header */
.cfo-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.cfo-header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-shrink: 0;
}

/* KPI Row extended — 5 columns */
.kpi-row-5 {
  grid-template-columns: repeat(5, 1fr);
}
@media (max-width: 1100px) {
  .kpi-row-5 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
  .kpi-row-5 { grid-template-columns: repeat(2, 1fr); }
}

/* Highlighted KPI card */
.kpi-card.kpi-highlight {
  border: 1.5px solid var(--red-light);
  background: linear-gradient(135deg, #fff 0%, #fdf0ef 100%);
}
.kpi-card .kpi-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

/* AI Empty Banner */
.ai-empty-banner {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--accent-light);
  border: 1.5px solid var(--accent-ring);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.ai-empty-icon {
  font-size: 1.75rem;
  flex-shrink: 0;
}
.ai-empty-banner > div {
  flex: 1;
  min-width: 150px;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Charts Grid */
.chart-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 900px) {
  .chart-grid { grid-template-columns: 1fr; }
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}
.chart-card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.chart-title {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}
.ai-tag {
  background: linear-gradient(135deg, #1877F2, #0d5ec4);
  color: white;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 20px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.chart-wrap {
  position: relative;
  height: 220px;
}
.chart-wrap-sm {
  height: 200px;
}

/* Dashboard 2-column grid */
.dashboard-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 900px) {
  .dashboard-grid-2 { grid-template-columns: 1fr; }
}

/* Vendor Leaderboard */
.rank-badge {
  display: inline-block;
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  margin-right: 0.25rem;
}
.leakage-bar {
  width: 80px;
  height: 6px;
  background: var(--bg-surface);
  border-radius: 3px;
  overflow: hidden;
}
.leakage-bar-fill {
  height: 100%;
  background: var(--red);
  border-radius: 3px;
  min-width: 2px;
  transition: width 0.4s var(--ease);
}

/* Dispute Pipeline */
.dispute-pipeline {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.dispute-row {
  display: grid;
  grid-template-columns: 140px 40px 80px 1fr;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
}
.dispute-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-secondary);
  font-weight: 500;
}
.dispute-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dispute-count { text-align: right; font-weight: 600; color: var(--text); }
.dispute-amount { text-align: right; color: var(--text-muted); }
.dispute-bar-wrap {
  height: 6px;
  background: var(--bg-surface);
  border-radius: 3px;
  overflow: hidden;
}
.dispute-bar {
  height: 100%;
  border-radius: 3px;
  min-width: 2px;
  transition: width 0.4s var(--ease);
}

/* Vendor Scorecard */
.scorecard-header {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  flex-wrap: wrap;
}
.scorecard-gauge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  flex-shrink: 0;
}
.risk-label {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.scorecard-stats {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}
@media (max-width: 900px) {
  .scorecard-stats { grid-template-columns: repeat(2, 1fr); }
}
.scorecard-stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.2rem;
}
.scorecard-stat-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}
.scorecard-stat-value.red { color: var(--red); }
.scorecard-stat-value.green { color: var(--green); }
.scorecard-stat-value.yellow { color: var(--yellow); }
.needs-more-badge {
  background: var(--yellow-light);
  color: var(--yellow);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  vertical-align: middle;
}
.needs-more-data {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 2.5rem 1.5rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  text-align: center;
}
.needs-more-data .icon { font-size: 2rem; }

/* Discrepancy type bars */
.disc-type-bars {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.5rem 0;
}
.disc-type-bar-row {
  display: grid;
  grid-template-columns: 1fr 120px 80px;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.8rem;
}
.disc-type-bar-label {
  color: var(--text-secondary);
  font-weight: 500;
}
.disc-type-bar-track {
  height: 6px;
  background: var(--bg-surface);
  border-radius: 3px;
  overflow: hidden;
}
.disc-type-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  min-width: 2px;
  transition: width 0.4s var(--ease);
}
.disc-type-bar-amount { text-align: right; }

/* Scheduled Reports Page */
.coming-soon-banner {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: var(--yellow-light);
  border: 1.5px solid #f5c842;
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}
.coming-soon-icon { font-size: 1.25rem; flex-shrink: 0; }

.reports-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.report-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-xs);
}
.report-card-placeholder {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg-surface);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  opacity: 0.7;
}
.report-card-icon { font-size: 1.5rem; flex-shrink: 0; }
.report-card-info, .report-card-name { flex: 1; }
.report-card-name {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.2rem;
}
.report-card-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.report-card-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}
.report-card-badge { flex-shrink: 0; }

/* Manual Export Cards */
.export-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}
@media (max-width: 768px) {
  .export-grid { grid-template-columns: 1fr; }
}
.export-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-xs);
}
.export-icon { font-size: 1.5rem; flex-shrink: 0; }
.export-info { flex: 1; }
.export-info strong { font-size: 0.875rem; color: var(--text); display: block; margin-bottom: 0.2rem; }
.export-info p { font-size: 0.78rem; color: var(--text-muted); margin: 0; }

/* Print styles for CFO PDF export */
@media print {
  .sidebar, .topbar, .cfo-header-actions, .btn, .back-link,
  .sidebar-overlay, #toast-container { display: none \!important; }
  .main-area { margin-left: 0 \!important; }
  .app-layout { display: block \!important; }
  body { background: white \!important; }
  .card, .chart-card, .kpi-card { box-shadow: none \!important; border: 1px solid #ddd \!important; }
  .kpi-row { page-break-inside: avoid; }
  .chart-grid, .dashboard-grid-2 { grid-template-columns: 1fr \!important; }
  h1.page-title { font-size: 20pt \!important; }
}
