/* ==============================================================================
   ExpenseTrack - Main Stylesheet (Pure CSS, Mobile-First, Clean Blue/White)
   ============================================================================== */

:root {
  --primary-50: #eff6ff;
  --primary-100: #dbeafe;
  --primary-200: #bfdbfe;
  --primary-500: #3b82f6;
  --primary-600: #2563eb;
  --primary-700: #1d4ed8;
  --primary-800: #1e40af;
  --primary-900: #1e3a8a;

  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;

  --success-bg: #ecfdf5;
  --success-text: #065f46;
  --success-border: #a7f3d0;

  --warning-bg: #fffbeb;
  --warning-text: #92400e;
  --warning-border: #fde68a;

  --danger-bg: #fef2f2;
  --danger-text: #991b1b;
  --danger-border: #fecaca;

  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--slate-50);
  color: var(--slate-800);
  min-height: 100vh;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary-600);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--primary-800);
}

/* --------------------------------------------------------------------------
   Layout & Container
   -------------------------------------------------------------------------- */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
}

#nav-root {
  position: sticky;
  top: 0;
  z-index: 1000;
  width: 100%;
}

#main-root {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  width: 100%;
}

#bottom-nav-root:empty,
.mobile-bottom-nav:empty {
  display: none !important;
  height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
}

#footer-root {
  margin-top: auto;
  width: 100%;
}

.content-wrapper {
  flex: 1;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem 1rem;
}

/* --------------------------------------------------------------------------
   Navigation Bar
   -------------------------------------------------------------------------- */
.navbar {
  background-color: #ffffff;
  border-bottom: 1px solid var(--slate-200);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.nav-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--slate-900);
  text-decoration: none;
}

.brand-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--primary-600), var(--primary-800));
  color: #ffffff;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  box-shadow: var(--shadow-sm);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  list-style: none;
}

.nav-user-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background-color: var(--slate-100);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  border: 1px solid var(--slate-200);
}

.user-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-admin {
  background-color: var(--primary-100);
  color: var(--primary-800);
  border: 1px solid var(--primary-200);
}

.badge-user,
.badge-active {
  background-color: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.badge-pending {
  background-color: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.badge-draft {
  background-color: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
}

.badge-sent {
  background-color: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.badge-paid {
  background-color: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.badge-cancelled {
  background-color: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.1rem;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  text-decoration: none;
  font-family: inherit;
}

.btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.btn-primary {
  background-color: var(--primary-600);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--primary-700);
  color: #ffffff;
}

.btn-outline {
  background-color: #ffffff;
  color: var(--slate-700);
  border-color: var(--slate-300);
}

.btn-outline:hover:not(:disabled) {
  background-color: var(--slate-100);
  border-color: var(--slate-400);
}

.btn-google {
  background-color: #ffffff;
  color: var(--slate-700);
  border: 1px solid var(--slate-300);
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  box-shadow: var(--shadow-sm);
}

.btn-google:hover:not(:disabled) {
  background-color: var(--slate-50);
  border-color: var(--slate-400);
  box-shadow: var(--shadow-md);
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
}

.btn-lg {
  padding: 0.85rem 1.5rem;
  font-size: 1.05rem;
}

/* --------------------------------------------------------------------------
   Hero & Home Section
   -------------------------------------------------------------------------- */
.hero-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--slate-200);
  padding: 2.5rem 1.5rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
  margin-bottom: 2rem;
}

.hero-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background-color: var(--primary-50);
  color: var(--primary-700);
  border: 1px solid var(--primary-200);
  padding: 0.3rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
}

.hero-title {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--slate-900);
  line-height: 1.25;
  margin-bottom: 0.75rem;
}

.hero-subtitle {
  font-size: 1.05rem;
  color: var(--slate-600);
  max-width: 650px;
  margin: 0 auto 2rem auto;
}

.hero-actions {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  max-width: 440px;
  margin: 0 auto;
}

@media (min-width: 640px) {
  .hero-title {
    font-size: 2.4rem;
  }
  .hero-actions {
    flex-direction: row;
    justify-content: center;
  }
}

.features-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  margin-top: 1.5rem;
}

@media (min-width: 768px) {
  .features-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.feature-box {
  background-color: #ffffff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.feature-icon-wrapper {
  width: 42px;
  height: 42px;
  background-color: var(--primary-50);
  color: var(--primary-600);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

.feature-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--slate-900);
  margin-bottom: 0.4rem;
}

.feature-desc {
  font-size: 0.9rem;
  color: var(--slate-600);
  line-height: 1.45;
}

/* --------------------------------------------------------------------------
   Auth Cards (Admin & User Login)
   -------------------------------------------------------------------------- */
.auth-wrapper {
  display: flex;
  justify-content: center;
  padding: 1.5rem 0;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background-color: #ffffff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-md);
}

.auth-header {
  text-align: center;
  margin-bottom: 1.75rem;
}

.auth-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--slate-900);
  margin-bottom: 0.4rem;
}

.auth-subtitle {
  font-size: 0.92rem;
  color: var(--slate-600);
}

/* --------------------------------------------------------------------------
   Forms & Inputs
   -------------------------------------------------------------------------- */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--slate-700);
  margin-bottom: 0.4rem;
}

.form-input {
  width: 100%;
  padding: 0.7rem 0.9rem;
  font-size: 0.95rem;
  color: var(--slate-800);
  background-color: #ffffff;
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
}

.form-input:focus {
  border-color: var(--primary-600);
  box-shadow: 0 0 0 3px var(--primary-100);
}

.password-input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.password-input-group .form-input {
  padding-right: 2.75rem;
}

.password-toggle-btn {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--slate-500);
  padding: 0.4rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.password-toggle-btn:hover {
  color: var(--slate-800);
}

.debug-identity-info {
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  background-color: var(--slate-100);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  color: var(--slate-600);
  word-break: break-all;
}

.debug-identity-info code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--primary-800);
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Alerts & Notifications
   -------------------------------------------------------------------------- */
.alert {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  line-height: 1.4;
}

.alert-danger {
  background-color: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid var(--danger-border);
}

.alert-warning {
  background-color: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid var(--warning-border);
}

.alert-info {
  background-color: var(--primary-50);
  color: var(--primary-900);
  border: 1px solid var(--primary-200);
}

.alert-code {
  font-weight: 700;
  display: block;
  font-size: 0.8rem;
  margin-top: 0.2rem;
  opacity: 0.9;
}

/* --------------------------------------------------------------------------
   Trial Banner (Admin Dashboard)
   -------------------------------------------------------------------------- */
.trial-banner {
  padding: 0.9rem 1.2rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-weight: 600;
}

.trial-banner-normal {
  background-color: var(--primary-50);
  color: var(--primary-900);
  border: 1px solid var(--primary-200);
}

.trial-banner-warning {
  background-color: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid var(--warning-border);
}

.trial-banner-expired {
  background-color: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid var(--danger-border);
}

/* --------------------------------------------------------------------------
   Dashboard & Cards
   -------------------------------------------------------------------------- */
.dashboard-header {
  margin-bottom: 1.5rem;
}

.dashboard-title {
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--slate-900);
}

.dashboard-subtitle {
  font-size: 0.95rem;
  color: var(--slate-600);
}

.card {
  background-color: #ffffff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--slate-900);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.metrics-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.metric-card {
  background-color: #ffffff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.metric-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--slate-500);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.3rem;
}

.metric-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--slate-900);
}

/* --------------------------------------------------------------------------
   Debug View
   -------------------------------------------------------------------------- */
.debug-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

@media (min-width: 800px) {
  .debug-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.code-box {
  background-color: var(--slate-900);
  color: #38bdf8;
  padding: 1rem;
  border-radius: var(--radius-md);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.85rem;
  overflow-x: auto;
  max-height: 280px;
  line-height: 1.45;
}

.badge-status {
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-status.success {
  background-color: #d1fae5;
  color: #065f46;
}

.badge-status.error {
  background-color: #fee2e2;
  color: #991b1b;
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
.app-footer {
  margin-top: auto;
  background-color: #ffffff;
  border-top: 1px solid var(--slate-200);
  padding: 1.25rem 1rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--slate-500);
}

.public-nav-links {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.public-nav-links a {
  color: var(--slate-600);
  font-weight: 600;
  font-size: 0.92rem;
  text-decoration: none;
  transition: color 0.15s ease;
}

.public-nav-links a:hover {
  color: var(--primary-700);
}

@media (max-width: 820px) {
  .public-nav-links {
    display: none;
  }
}

.app-shared-footer {
  margin-top: auto;
  background-color: #ffffff;
  border-top: 1px solid var(--slate-200);
  padding: 1.5rem 1rem;
  font-size: 0.85rem;
  color: var(--slate-500);
}

.app-footer-inner {
  max-width: 1120px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  text-align: center;
}

.app-footer-links {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1.25rem;
}

.app-footer-links a {
  color: var(--slate-600);
  font-weight: 500;
  text-decoration: none;
}

.app-footer-links a:hover {
  color: var(--primary-700);
  text-decoration: underline;
}

.app-footer-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--slate-500);
}

.app-footer-meta a {
  color: var(--slate-600);
}

/* --------------------------------------------------------------------------
   Loading Spinner
   -------------------------------------------------------------------------- */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

.spinner-primary {
  border: 2px solid var(--slate-200);
  border-top-color: var(--primary-600);
}

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

/* --------------------------------------------------------------------------
   Stage 3: Mobile Bottom Navigation Bar (Phones)
   -------------------------------------------------------------------------- */
.mobile-bottom-nav {
  display: none;
}

@media (max-width: 768px) {
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #ffffff;
    border-top: 1px solid var(--slate-200);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.06);
    z-index: 100;
    justify-content: space-around;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.35rem 0.25rem calc(0.35rem + env(safe-area-inset-bottom, 0px)) 0.25rem;
  }

  .bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--slate-500);
    font-size: 0.68rem;
    font-weight: 600;
    text-decoration: none;
    padding: 0.25rem 0.3rem;
    border-radius: var(--radius-sm);
    transition: color 0.15s, background-color 0.15s;
    min-width: 50px;
    flex: 1 0 auto;
    gap: 0.15rem;
    white-space: nowrap;
  }

  .bottom-nav-item.active {
    color: var(--primary-600);
  }

  .bottom-nav-item:hover {
    color: var(--primary-700);
  }

  .bottom-nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Add padding to wrapper on mobile so bottom nav does not overlap content */
  .content-wrapper {
    padding-bottom: 5.5rem !important;
  }
}

/* --------------------------------------------------------------------------
   Stage 3: Currency Addon & Form Controls
   -------------------------------------------------------------------------- */
.input-addon-wrapper {
  display: flex;
  align-items: stretch;
}

.input-addon-wrapper .form-input {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-right: none;
}

.input-addon {
  background-color: var(--slate-100);
  border: 1px solid var(--slate-300);
  border-top-right-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
  padding: 0 1rem;
  display: flex;
  align-items: center;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--primary-800);
  user-select: none;
}

.form-help {
  font-size: 0.8rem;
  color: var(--slate-500);
  margin-top: 0.25rem;
}

.form-select {
  width: 100%;
  padding: 0.7rem 0.9rem;
  font-size: 0.95rem;
  color: var(--slate-800);
  background-color: #ffffff;
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-md);
  outline: none;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-select:disabled {
  background-color: var(--slate-100);
  color: var(--slate-400);
  cursor: not-allowed;
}

.form-select:focus {
  border-color: var(--primary-600);
  box-shadow: 0 0 0 3px var(--primary-100);
}

.textarea {
  min-height: 85px;
  resize: vertical;
}

/* --------------------------------------------------------------------------
   Stage 3: File Upload Dropzone & Thumbnails
   -------------------------------------------------------------------------- */
.dropzone-container {
  border: 2px dashed var(--slate-300);
  border-radius: var(--radius-md);
  padding: 1.5rem 1rem;
  text-align: center;
  background-color: var(--slate-50);
  transition: all 0.2s ease;
  cursor: pointer;
}

.dropzone-container:hover,
.dropzone-container.dragover {
  border-color: var(--primary-600);
  background-color: var(--primary-50);
}

.dropzone-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 0.85rem;
  flex-wrap: wrap;
}

.file-list-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  margin-top: 1rem;
}

@media (min-width: 600px) {
  .file-list-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.file-item-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #ffffff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.85rem;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.file-thumb-preview {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background-color: var(--slate-100);
  border: 1px solid var(--slate-200);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--slate-600);
  flex-shrink: 0;
}

.file-item-details {
  flex: 1;
  min-width: 0;
}

.file-item-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--slate-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-item-meta {
  font-size: 0.75rem;
  color: var(--slate-500);
  margin-top: 0.15rem;
}

.btn-remove-file {
  background: none;
  border: none;
  color: var(--slate-400);
  padding: 0.35rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-remove-file:hover {
  color: var(--danger-text);
  background-color: var(--danger-bg);
}

.file-progress-track {
  width: 100%;
  height: 4px;
  background-color: var(--slate-200);
  border-radius: 2px;
  margin-top: 0.4rem;
  overflow: hidden;
}

.file-progress-bar {
  height: 100%;
  background-color: var(--primary-600);
  width: 0%;
  transition: width 0.15s ease-out;
}

/* --------------------------------------------------------------------------
   Stage 3: Expense Filter Bar & List View
   -------------------------------------------------------------------------- */
.filter-toolbar {
  background: #ffffff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  box-shadow: var(--shadow-sm);
}

@media (min-width: 768px) {
  .filter-toolbar {
    flex-direction: row;
    align-items: center;
  }
  .filter-toolbar .filter-search {
    flex: 2;
  }
  .filter-toolbar .filter-select {
    flex: 1;
  }
}

.total-summary-card {
  background: linear-gradient(135deg, var(--primary-700), var(--primary-900));
  color: #ffffff;
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-md);
}

.total-summary-label {
  font-size: 0.9rem;
  opacity: 0.9;
  font-weight: 500;
}

.total-summary-amount {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.expenses-table-wrapper {
  background: #ffffff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
  margin-bottom: 2rem;
}

/* Admin Full-Width Expenses Table (No fixed height, no inner vertical scroll) */
.admin-expenses-table-wrapper {
  background: #ffffff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  width: 100%;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}

.table-custom.admin-table-dense {
  font-size: 0.8rem;
  table-layout: auto;
  width: 100%;
  border-collapse: collapse;
}

.table-custom.admin-table-dense th {
  padding: 0.6rem 0.5rem;
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  background-color: var(--slate-50);
  white-space: nowrap;
}

.table-custom.admin-table-dense td {
  padding: 0.55rem 0.5rem;
  vertical-align: middle;
}

/* Sticky right Actions column for desktop */
.col-sticky-actions {
  position: sticky;
  right: 0;
  background: var(--slate-50);
  z-index: 3;
  box-shadow: -3px 0 5px rgba(0, 0, 0, 0.04);
}

.cell-sticky-actions {
  position: sticky;
  right: 0;
  background: #ffffff;
  z-index: 2;
  box-shadow: -3px 0 5px rgba(0, 0, 0, 0.04);
}

.table-custom.admin-table-dense tbody tr:hover .cell-sticky-actions {
  background: var(--slate-50);
}

/* Admin Mobile Expenses Cards Layout */
.admin-expenses-mobile-cards {
  display: none;
  margin-bottom: 1.5rem;
}

.admin-expense-mobile-card {
  background: #ffffff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.admin-mobile-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  border-bottom: 1px solid var(--slate-100);
  padding-bottom: 0.5rem;
}

.admin-mobile-card-amount {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--slate-900);
  text-align: right;
  white-space: nowrap;
}

.admin-mobile-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.admin-mobile-card-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--slate-900);
}

.admin-mobile-card-desc {
  font-size: 0.8rem;
  color: var(--slate-600);
  line-height: 1.4;
}

.admin-mobile-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  font-size: 0.75rem;
  margin-top: 0.25rem;
}

.admin-mobile-card-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  border-top: 1px solid var(--slate-100);
  padding-top: 0.65rem;
  margin-top: 0.25rem;
}

.admin-mobile-card-actions .btn {
  flex: 1;
  min-width: 70px;
  justify-content: center;
}

@media (max-width: 768px) {
  .admin-expenses-table-wrapper {
    display: none !important;
  }
  .admin-expenses-mobile-cards {
    display: flex !important;
    flex-direction: column;
    gap: 0.85rem;
  }
}

.table-custom {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.92rem;
}

.table-custom th {
  background-color: var(--slate-50);
  color: var(--slate-600);
  font-weight: 600;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--slate-200);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.table-custom td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--slate-100);
  vertical-align: middle;
}

.table-custom tbody tr:hover {
  background-color: var(--slate-50);
}

.category-tag {
  display: inline-block;
  background-color: var(--slate-100);
  color: var(--slate-700);
  border-radius: var(--radius-sm);
  padding: 0.2rem 0.5rem;
  font-size: 0.78rem;
  font-weight: 600;
}

.amount-tag {
  font-weight: 700;
  color: var(--slate-900);
  font-size: 1rem;
}

.badge-files {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background-color: var(--primary-50);
  color: var(--primary-700);
  border: 1px solid var(--primary-200);
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Stage 3: Modal Dialog
   -------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(2px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
}

.modal-dialog {
  background-color: #ffffff;
  border-radius: var(--radius-lg);
  max-width: 600px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--slate-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--slate-900);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--slate-400);
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: var(--slate-800);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--slate-200);
  background-color: var(--slate-50);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* --------------------------------------------------------------------------
   Admin Navigation (Sticky Top Bar >900px, Compact Mobile Menu <=900px)
   -------------------------------------------------------------------------- */
.navbar-admin {
  position: sticky;
  top: 0;
  z-index: 1000;
  background-color: #ffffff;
  border-bottom: 1px solid var(--slate-200);
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
  width: 100%;
}

.admin-nav-top-row {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.65rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: nowrap;
}

.nav-brand-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.nav-admin-desktop-row {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: 1 1 auto;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  padding: 0.15rem 0.25rem;
  white-space: nowrap;
}

.nav-admin-desktop-row::-webkit-scrollbar {
  height: 3px;
}

.nav-admin-desktop-row::-webkit-scrollbar-thumb {
  background: var(--slate-300);
  border-radius: var(--radius-full);
}

.nav-admin-link {
  color: var(--slate-600);
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  padding: 0.4rem 0.65rem;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
}

.nav-admin-link:hover {
  color: var(--primary-700);
  background-color: var(--slate-100);
}

.nav-admin-link.active {
  color: var(--primary-700);
  background-color: var(--primary-50);
  font-weight: 700;
  box-shadow: inset 0 0 0 1px var(--primary-200);
}

.nav-admin-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.btn-nav-logout {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 0.85rem;
}

/* Visibility toggles for 900px breakpoint */
.desktop-only {
  display: inline-flex !important;
}

.mobile-only {
  display: none !important;
}

@media (max-width: 900px) {
  .nav-admin-desktop-row {
    display: none !important;
  }

  .desktop-only {
    display: none !important;
  }

  .mobile-only {
    display: inline-flex !important;
  }
}

/* Admin Mobile Hamburger Button */
.admin-hamburger-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--slate-100);
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-sm);
  padding: 0.45rem;
  cursor: pointer;
  color: var(--slate-700);
  min-height: 44px;
  min-width: 44px;
  transition: background-color 0.15s, color 0.15s;
}

.admin-hamburger-btn:hover {
  background-color: var(--slate-200);
  color: var(--primary-800);
}

/* Admin Mobile Drawer (Slide-down menu right below header) */
.admin-mobile-drawer {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  width: 100%;
  background: #ffffff;
  border-top: 1px solid var(--slate-200);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  max-height: calc(100vh - 65px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 1001;
}

.admin-mobile-drawer.open {
  display: block;
  animation: slideDownMenu 0.2s ease-out;
}

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

.admin-mobile-drawer-inner {
  padding: 0.85rem 1rem 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-width: 1400px;
  margin: 0 auto;
}

.admin-drawer-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  color: var(--slate-700);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  min-height: 44px;
  transition: background-color 0.15s, color 0.15s;
}

.admin-drawer-link:hover {
  background-color: var(--slate-100);
  color: var(--primary-700);
}

.admin-drawer-link.active {
  background-color: var(--primary-50);
  color: var(--primary-800);
  font-weight: 700;
}

.admin-action-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  margin-bottom: 2rem;
}

@media (min-width: 768px) {
  .admin-action-cards {
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  }
}

.admin-action-card {
  background: #ffffff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.admin-action-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-300);
}

.admin-action-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.admin-action-card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--primary-50);
  color: var(--primary-700);
  display: flex;
  align-items: center;
  justify-content: center;
}

.admin-action-card-count {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--slate-900);
  margin-bottom: 0.25rem;
}

.admin-action-card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--slate-900);
  margin-bottom: 0.35rem;
}

.admin-action-card-desc {
  font-size: 0.88rem;
  color: var(--slate-600);
  line-height: 1.45;
  margin-bottom: 1.25rem;
  flex: 1;
}

.first-company-banner {
  background: linear-gradient(135deg, #1e40af, #1d4ed8);
  color: #ffffff;
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1.25rem;
}

.first-company-text h2 {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 0.3rem;
  color: #ffffff;
}

.first-company-text p {
  font-size: 0.92rem;
  color: #bfdbfe;
  max-width: 580px;
}

.admin-debug-footer-line {
  margin-top: 3rem;
  padding: 0.75rem 1rem;
  background-color: var(--slate-100);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-sm);
  font-size: 0.76rem;
  color: var(--slate-600);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.admin-debug-footer-line code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--primary-700);
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Stage A: Companies Cards & Profile Form
   -------------------------------------------------------------------------- */
.company-cards-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  margin-bottom: 2rem;
}

@media (min-width: 768px) {
  .company-cards-grid {
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  }
}

.company-card {
  background: #ffffff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.2s ease;
  position: relative;
}

.company-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-300);
}

.company-card-inactive {
  opacity: 0.8;
  background-color: var(--slate-50);
  border-style: dashed;
}

.company-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.company-card-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  min-width: 0;
}

.company-card-logo {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  object-fit: contain;
  background: #ffffff;
  border: 1px solid var(--slate-200);
  padding: 2px;
  flex-shrink: 0;
}

.company-card-avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary-600), var(--primary-800));
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.15rem;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.company-card-info {
  flex: 1;
  min-width: 0;
}

.company-card-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--slate-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.15rem;
}

.company-card-legal {
  font-size: 0.78rem;
  color: var(--slate-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge-inactive {
  background-color: var(--slate-200);
  color: var(--slate-700);
  border: 1px solid var(--slate-300);
}

.company-card-tags {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.company-tag {
  background-color: var(--slate-100);
  color: var(--slate-700);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-sm);
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
}

.company-card-address {
  font-size: 0.8rem;
  color: var(--slate-600);
  margin-bottom: 1rem;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.company-card-actions {
  display: flex;
  gap: 0.4rem;
  border-top: 1px solid var(--slate-100);
  padding-top: 0.85rem;
  flex-wrap: wrap;
}

.company-card-actions .btn {
  flex: 1;
  min-width: 70px;
  padding: 0.35rem 0.5rem;
  font-size: 0.8rem;
  justify-content: center;
}

/* --------------------------------------------------------------------------
   Company Form Layout & Live Preview
   -------------------------------------------------------------------------- */
.company-form-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.75rem;
  margin-bottom: 2.5rem;
}

@media (min-width: 992px) {
  .company-form-layout {
    grid-template-columns: 1.35fr 1fr;
  }
}

.form-tabs-bar {
  display: flex;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background-color: var(--slate-200);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  padding: 0.35rem 0.35rem 0 0.35rem;
  gap: 0.25rem;
}

.form-tab-btn {
  background: transparent;
  border: none;
  padding: 0.55rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--slate-600);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  font-family: inherit;
}

.form-tab-btn:hover {
  color: var(--primary-700);
  background-color: rgba(255, 255, 255, 0.5);
}

.form-tab-btn.active {
  background: #ffffff;
  color: var(--primary-800);
  font-weight: 700;
  box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.04);
}

.form-tab-content {
  display: none;
}

.form-tab-content.active {
  display: block;
}

.branding-upload-box {
  display: flex;
  gap: 1.25rem;
  align-items: center;
  background-color: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.branding-thumb {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-md);
  background-color: #ffffff;
  border: 2px dashed var(--slate-300);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  color: var(--slate-400);
  font-weight: 700;
  overflow: hidden;
  flex-shrink: 0;
}

.branding-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.signature-thumb {
  width: 110px;
  height: 60px;
}

.upload-progress-pill {
  font-size: 0.75rem;
  color: var(--primary-700);
  font-weight: 600;
  margin-top: 0.4rem;
}

/* --------------------------------------------------------------------------
   Live Invoice Sheet Mockup Preview
   -------------------------------------------------------------------------- */
.invoice-sheet-preview {
  background: #ffffff;
  border: 1px solid var(--slate-300);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  font-family: system-ui, -apple-system, sans-serif;
  color: var(--slate-800);
}

.invoice-sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 0.85rem;
  border-bottom: 2px solid var(--slate-800);
  margin-bottom: 0.85rem;
}

.invoice-sheet-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.invoice-sheet-logo {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--slate-100);
  border: 1px solid var(--slate-200);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--slate-400);
  overflow: hidden;
  flex-shrink: 0;
}

.invoice-sheet-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.invoice-sheet-company {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--slate-900);
  line-height: 1.2;
}

.invoice-sheet-legal {
  font-size: 0.72rem;
  color: var(--slate-500);
}

.invoice-sheet-meta {
  text-align: right;
}

.invoice-sheet-title {
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: var(--primary-700);
}

.invoice-sheet-details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

/* --------------------------------------------------------------------------
   Stage B: Admin Expenses, Filters, Currency Badges & ZIP Progress
   -------------------------------------------------------------------------- */
.filter-grid-admin {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
  align-items: flex-end;
}

.currency-badge-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.currency-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background-color: var(--primary-50);
  color: var(--primary-800);
  border: 1px solid var(--primary-200);
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.95rem;
}

.currency-badge-code {
  font-size: 0.75rem;
  color: var(--primary-600);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.index-alert-banner {
  background-color: #fffbeb;
  border: 1px solid #fef3c7;
  border-left: 4px solid #f59e0b;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.25rem;
  color: #92400e;
}

.download-progress-container {
  padding: 1.5rem 0.5rem;
  text-align: center;
}

.download-progress-bar-bg {
  width: 100%;
  height: 10px;
  background: var(--slate-200);
  border-radius: 9999px;
  overflow: hidden;
  margin: 1rem 0 0.5rem 0;
}

.download-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-600), #06b6d4);
  transition: width 0.2s ease-in-out;
  border-radius: 9999px;
}

.category-totals-card {
  margin-top: 2rem;
  border-top: 2px dashed var(--slate-200);
  padding-top: 1.5rem;
}

.category-totals-table {
  width: 100%;
  border-collapse: collapse;
}

.category-totals-table th {
  background: var(--slate-50);
  padding: 0.65rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--slate-600);
  text-align: left;
  border-bottom: 1px solid var(--slate-200);
}

.category-totals-table td {
  padding: 0.65rem 0.75rem;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--slate-100);
  color: var(--slate-800);
}

/* --------------------------------------------------------------------------
   Stage C: Financial Reports, Live Preview & Print Styles
   -------------------------------------------------------------------------- */
.report-preview-tabs {
  display: flex;
  gap: 0.35rem;
  border-bottom: 2px solid var(--slate-200);
  margin-bottom: 1.25rem;
  overflow-x: auto;
}

.report-preview-tab {
  background: none;
  border: none;
  padding: 0.6rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--slate-600);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: all 0.15s;
}

.report-preview-tab:hover {
  color: var(--primary-600);
}

.report-preview-tab.active {
  color: var(--primary-700);
  border-bottom-color: var(--primary-600);
  font-weight: 700;
}

.report-sheet-header-block {
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.report-company-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--primary-700);
  line-height: 1.2;
}

.report-company-subtitle {
  font-size: 0.82rem;
  color: var(--slate-600);
  margin-top: 0.25rem;
}

.status-badge-positive {
  background: #d1fae5;
  color: #065f46;
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  font-weight: 700;
  font-size: 0.78rem;
  display: inline-flex;
  align-items: center;
}

.status-badge-negative {
  background: #fee2e2;
  color: #991b1b;
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  font-weight: 700;
  font-size: 0.78rem;
  display: inline-flex;
  align-items: center;
}

.status-badge-neutral {
  background: #f1f5f9;
  color: #475569;
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  font-weight: 700;
  font-size: 0.78rem;
  display: inline-flex;
  align-items: center;
}

/* --------------------------------------------------------------------------
   Stage D: Invoice UI Styles
   -------------------------------------------------------------------------- */
.invoice-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.invoice-summary-card {
  background: #ffffff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow-sm);
}

.invoice-summary-title {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--slate-500);
  margin-bottom: 0.35rem;
  letter-spacing: 0.03em;
}

.invoice-summary-value {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--slate-900);
  line-height: 1.2;
}

.invoice-summary-sub {
  font-size: 0.78rem;
  color: var(--slate-500);
  margin-top: 0.25rem;
}

.invoice-filters-card {
  background: #ffffff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  margin-bottom: 1.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.75rem;
  align-items: flex-end;
}

.invoice-mobile-card {
  background: #ffffff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  margin-bottom: 0.85rem;
  box-shadow: var(--shadow-sm);
}

.invoice-mobile-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.65rem;
  gap: 0.5rem;
}

.invoice-mobile-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--slate-600);
  margin-bottom: 0.35rem;
}

.invoice-mobile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--slate-100);
}

@media (min-width: 901px) {
  .invoice-mobile-cards { display: none; }
  .invoice-desktop-table { display: block; }
}

@media (max-width: 900px) {
  .invoice-mobile-cards { display: block; }
  .invoice-desktop-table { display: none; }
}

.invoice-sheet-container {
  background: #ffffff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 2rem;
}

.invoice-totals-box {
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.invoice-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  color: var(--slate-700);
  margin-bottom: 0.5rem;
}

.invoice-total-row.grand-total {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--primary-800);
  border-top: 1px solid var(--slate-300);
  padding-top: 0.75rem;
  margin-top: 0.5rem;
}

@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 10pt;
  }

  #nav-root,
  #bottom-nav-root,
  #footer-root,
  .admin-debug-footer-line,
  .no-print,
  .dashboard-header a,
  .report-filters-card,
  .report-action-buttons,
  .report-preview-tabs {
    display: none !important;
  }

  .content-wrapper {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .card {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .table-custom,
  .category-totals-table {
    width: 100% !important;
    border-collapse: collapse !important;
  }

  .table-custom th,
  .table-custom td,
  .category-totals-table th,
  .category-totals-table td {
    border: 1px solid #cbd5e1 !important;
    padding: 4pt 6pt !important;
  }

  .report-sheet-header-block {
    border: 1px solid #cbd5e1 !important;
    background: #f8fafc !important;
    padding: 8pt !important;
    margin-bottom: 12pt !important;
  }
}

/* ==============================================================================
   PWA & Mobile Polish: Update Banner, Offline Badges, Install Prompts, Safe Areas
   ============================================================================== */

/* Prevent any horizontal overflow */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
  -webkit-text-size-adjust: 100%;
}

.app-container {
  overflow-x: hidden;
  max-width: 100vw;
}

/* PWA Top Update Banner */
.pwa-update-banner {
  background: #1e293b;
  color: #ffffff;
  padding: 0.65rem 1rem;
  font-size: 0.88rem;
  border-bottom: 2px solid var(--primary-600);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 1000;
  animation: slideDown 0.25s ease-out;
}

@keyframes slideDown {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

.pwa-update-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.pwa-update-text {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
}

.btn-pwa-refresh {
  background-color: var(--primary-600);
  color: #ffffff;
  border: 1px solid transparent;
  font-weight: 600;
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
}

.btn-pwa-refresh:hover {
  background-color: var(--primary-700);
}

/* Offline Badge in Navbar */
.badge-offline,
.navbar-offline-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background-color: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  min-height: 24px;
}

/* PWA Floating Toast Notifications */
.pwa-toast-container {
  position: fixed;
  bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 10000;
  pointer-events: none;
}

.pwa-toast {
  background: #0f172a;
  color: #ffffff;
  border-radius: var(--radius-md);
  padding: 0.75rem 1.15rem;
  font-size: 0.88rem;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
  pointer-events: auto;
  animation: toastFadeIn 0.25s ease-out;
  transition: opacity 0.3s, transform 0.3s;
  max-width: 380px;
}

.pwa-toast.fade-out {
  opacity: 0;
  transform: translateY(10px);
}

.pwa-toast-error {
  background: #991b1b;
  border-left: 4px solid #ef4444;
}

.pwa-toast-success {
  background: #065f46;
  border-left: 4px solid #10b981;
}

.pwa-toast-content {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

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

/* Accessible Mobile Tap Targets (Min 44px) */
.btn,
button.btn,
a.btn,
.nav-link,
.admin-drawer-link,
.bottom-nav-item {
  min-height: 44px;
  box-sizing: border-box;
}

.btn-sm {
  min-height: 38px;
}

.pwa-install-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 600;
}

/* Safe area padding for mobile bottom bar */
@media (max-width: 768px) {
  .mobile-bottom-nav {
    padding-bottom: max(0.5rem, env(safe-area-inset-bottom, 0.5rem)) !important;
  }
}




