/* TRIGG Invoice Studio - Design System & Styling */

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

:root {
  /* Color Palette */
  --primary: #FF2E93; /* TRIGG Pink */
  --primary-hover: #E01E7E;
  --primary-light: #FFF0F6;
  --bg-app: #FAFAFA;
  --bg-card: #FFFFFF;
  --bg-sidebar: #111111;
  --text-main: #111111;
  --text-muted: #666666;
  --text-light: #999999;
  --text-on-dark: #FFFFFF;
  --border: #ECECEC;
  --border-focus: #111111;
  
  /* Status Colors */
  --color-draft: #9E9E9E;
  --color-draft-bg: #F5F5F5;
  --color-generated: #00BCD4;
  --color-generated-bg: #E0F7FA;
  --color-sent: #2196F3;
  --color-sent-bg: #E3F2FD;
  --color-paid: #4CAF50;
  --color-paid-bg: #E8F5E9;
  --color-overdue: #F44336;
  --color-overdue-bg: #FFEBEE;
  --color-cancelled: #757575;
  --color-cancelled-bg: #EEEEEE;

  /* Typography */
  --font-display: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  
  /* Layout & Spacing */
  --sidebar-width: 260px;
  --header-height: 70px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --radius-round: 9999px;
  
  /* Shadows & Depth */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.02), 0 1px 3px rgba(0, 0, 0, 0.01);
  --shadow-md: 0 12px 30px rgba(0, 0, 0, 0.04), 0 2px 8px rgba(0, 0, 0, 0.02);
  --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.02);
  --transition-smooth: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

/* Scrollbar customization */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #E0E0E0;
  border-radius: var(--radius-round);
}

::-webkit-scrollbar-thumb:hover {
  background: #CCCCCC;
}

/* App Shell Layout */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar Styling */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  color: var(--text-on-dark);
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.05);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 3rem;
  padding-left: 0.5rem;
}

.brand-logo {
  width: 32px;
  height: 32px;
  background-color: var(--primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.25rem;
  color: white;
  box-shadow: 0 4px 12px rgba(255, 46, 147, 0.3);
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.5px;
}

.brand-name span {
  color: var(--primary);
}

.nav-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-grow: 1;
}

.nav-item {
  width: 100%;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.875rem 1rem;
  color: #888888;
  text-decoration: none;
  border-radius: var(--radius-md);
  font-weight: 500;
  transition: var(--transition-smooth);
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

.nav-link svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  opacity: 0.7;
  transition: var(--transition-smooth);
}

.nav-link:hover {
  color: var(--text-on-dark);
  background-color: rgba(255, 255, 255, 0.05);
}

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

.nav-link.active {
  color: var(--text-on-dark);
  background-color: var(--primary);
  box-shadow: 0 8px 20px rgba(255, 46, 147, 0.25);
}

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

.sidebar-footer {
  margin-top: auto;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

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

.app-header {
  height: var(--header-height);
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 0 2.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 90;
  backdrop-filter: blur(8px);
  background: rgba(255, 255, 255, 0.85);
}

.header-title h2 {
  font-size: 1.35rem;
}

.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-round);
  background-color: var(--bg-app);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.user-profile-badge:hover {
  background-color: #F0F0F0;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background-color: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.875rem;
  border: 1px solid rgba(255, 46, 147, 0.15);
}

.user-name {
  font-size: 0.875rem;
  font-weight: 600;
}

.content-body {
  padding: 2.5rem;
  flex-grow: 1;
  max-width: 1300px;
  width: 100%;
  margin: 0 auto;
}

/* Tab Panels */
.view-panel {
  display: none;
  animation: fadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.view-panel.active {
  display: block;
}

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

/* Grid & Cards System */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

.metric-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-smooth);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.metric-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: #D6D6D6;
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background-color: transparent;
  transition: var(--transition-smooth);
}

.metric-card.primary::before {
  background-color: var(--primary);
}

.metric-label {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.metric-value {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.metric-footer {
  margin-top: auto;
  padding-top: 0.75rem;
  font-size: 0.75rem;
  color: var(--text-light);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Dashboard Layout */
.dashboard-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

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

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

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

.card-title h3 {
  font-size: 1.15rem;
  font-weight: 600;
}

/* AI Quick Invoice UI */
.ai-assistant-container {
  background: linear-gradient(135deg, #111111 0%, #222222 100%);
  color: white;
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-bottom: 2.5rem;
  position: relative;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
}

.ai-assistant-container::after {
  content: '';
  position: absolute;
  top: -50px;
  right: -50px;
  width: 150px;
  height: 150px;
  background: var(--primary);
  opacity: 0.15;
  filter: blur(50px);
  border-radius: 50%;
}

.ai-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.ai-icon-pulse {
  position: relative;
  width: 10px;
  height: 10px;
  background-color: var(--primary);
  border-radius: 50%;
}

.ai-icon-pulse::after {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  background-color: var(--primary);
  border-radius: 50%;
  animation: pulse 1.8s infinite ease-in-out;
}

@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(2.8);
    opacity: 0;
  }
}

.ai-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--primary);
}

.ai-description {
  font-size: 0.875rem;
  color: #CCCCCC;
  margin-bottom: 1.25rem;
  max-width: 600px;
  line-height: 1.5;
}

.ai-input-group {
  position: relative;
  display: flex;
  background-color: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.5rem;
  transition: var(--transition-smooth);
}

.ai-input-group:focus-within {
  border-color: var(--primary);
  background-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 0 0 3px rgba(255, 46, 147, 0.2);
}

.ai-input {
  flex-grow: 1;
  background: transparent;
  border: none;
  color: white;
  padding: 0.75rem;
  font-size: 0.935rem;
  outline: none;
}

.ai-input::placeholder {
  color: #666666;
}

.ai-btn-submit {
  background-color: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0 1.25rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ai-btn-submit:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
}

.ai-btn-submit:active {
  transform: translateY(0);
}

.ai-samples {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.ai-sample-chip {
  font-size: 0.75rem;
  background-color: rgba(255, 255, 255, 0.05);
  color: #AAAAAA;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-round);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.ai-sample-chip:hover {
  color: white;
  background-color: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition-smooth);
  text-decoration: none;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background-color: var(--primary);
  color: white;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(255, 46, 147, 0.2);
}

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

.btn-secondary:hover {
  background-color: var(--bg-app);
  border-color: #CCCCCC;
}

.btn-danger {
  background-color: #FFF5F5;
  border-color: #FFE3E3;
  color: #E53E3E;
}

.btn-danger:hover {
  background-color: #FED7D7;
  border-color: #FEB2B2;
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
}

.btn-icon-only {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-md);
}

/* Forms controls */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

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

.form-control {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  font-size: 0.935rem;
  background-color: var(--bg-card);
  transition: var(--transition-smooth);
  width: 100%;
  outline: none;
}

.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.05);
}

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

.toggle-group {
  display: flex;
  align-items: center;
  gap: 2rem;
  margin: 1rem 0;
}

.toggle-container {
  display: flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
  gap: 0.75rem;
}

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  background-color: #E0E0E0;
  border-radius: 99px;
  transition: var(--transition-smooth);
}

.toggle-switch::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background-color: white;
  top: 3px;
  left: 3px;
  transition: var(--transition-smooth);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

input:checked + .toggle-switch {
  background-color: var(--primary);
}

input:checked + .toggle-switch::after {
  left: 23px;
}

.toggle-label {
  font-size: 0.935rem;
  font-weight: 500;
}

/* File Upload input */
.file-upload-wrapper {
  position: relative;
  width: 100%;
  height: 120px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background-color: var(--bg-app);
  overflow: hidden;
  transition: var(--transition-smooth);
}

.file-upload-wrapper:hover {
  border-color: var(--primary);
  background-color: rgba(255, 46, 147, 0.02);
}

.file-upload-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.file-upload-preview {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background-color: #FFFFFF;
  display: none;
}

.file-upload-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
  text-align: center;
  padding: 1rem;
}

.file-upload-info svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.file-upload-info span {
  font-size: 0.8rem;
  font-weight: 500;
}

/* Tables Styling */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background-color: var(--bg-card);
}

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

.data-table th {
  background-color: var(--bg-app);
  padding: 1rem 1.25rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
}

.data-table td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text-main);
}

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

.data-table tbody tr {
  transition: var(--transition-smooth);
}

.data-table tbody tr:hover {
  background-color: rgba(0, 0, 0, 0.01);
}

/* Badges for Invoice Statuses */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-round);
  text-transform: capitalize;
}

.badge-draft { background-color: var(--color-draft-bg); color: var(--color-draft); }
.badge-generated { background-color: var(--color-generated-bg); color: var(--color-generated); }
.badge-sent { background-color: var(--color-sent-bg); color: var(--color-sent); }
.badge-paid { background-color: var(--color-paid-bg); color: var(--color-paid); }
.badge-overdue { background-color: var(--color-overdue-bg); color: var(--color-overdue); }
.badge-cancelled { background-color: var(--color-cancelled-bg); color: var(--color-cancelled); }

/* Invoice Line Items Creator */
.item-lines-container {
  margin-top: 2rem;
  margin-bottom: 2rem;
}

.item-line-header {
  display: grid;
  grid-template-columns: 3fr 1fr 1.5fr 1.5fr 40px;
  gap: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.item-line-row {
  display: grid;
  grid-template-columns: 3fr 1fr 1.5fr 1.5fr 40px;
  gap: 1rem;
  margin-bottom: 0.75rem;
  align-items: center;
}

.item-amount-output {
  padding: 0.75rem;
  font-weight: 600;
  font-size: 0.935rem;
  text-align: right;
  background-color: var(--bg-app);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

/* Calculations Layout */
.invoice-creator-layout {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 2rem;
}

@media (max-width: 1024px) {
  .invoice-creator-layout {
    grid-template-columns: 1fr;
  }
}

.invoice-summary-box {
  background-color: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px dashed var(--border);
  font-size: 0.935rem;
}

.summary-row:last-child {
  border-bottom: none;
}

.summary-row.total {
  border-top: 1px solid var(--text-main);
  border-bottom: none;
  font-size: 1.25rem;
  font-weight: 700;
  padding-top: 1rem;
}

.amount-words-box {
  background-color: var(--primary-light);
  border: 1px solid rgba(255, 46, 147, 0.1);
  padding: 1rem;
  border-radius: var(--radius-md);
  margin-top: 1.25rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--primary-hover);
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition-smooth);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-window {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: var(--transition-smooth);
}

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

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

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* History filter and search toolbar */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.search-bar {
  position: relative;
  flex-grow: 1;
  max-width: 400px;
}

.search-bar svg {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  fill: var(--text-light);
  width: 18px;
  height: 18px;
}

.search-bar input {
  padding-left: 2.75rem;
}

.toolbar-filters {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Toast System */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toast {
  background-color: #111111;
  color: white;
  padding: 1rem 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  transform: translateY(20px);
  opacity: 0;
  animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

.toast.success { border-left: 4px solid var(--color-paid); }
.toast.error { border-left: 4px solid var(--color-overdue); }
.toast.info { border-left: 4px solid var(--primary); }

/* SVG Analytics Chart Custom Styles */
.chart-card {
  height: 320px;
  display: flex;
  flex-direction: column;
}

.chart-wrapper {
  flex-grow: 1;
  position: relative;
  margin-top: 1rem;
  width: 100%;
}

.chart-svg {
  width: 100%;
  height: 100%;
}

.chart-bar {
  fill: var(--border);
  rx: 4px;
  ry: 4px;
  transition: var(--transition-smooth);
  cursor: pointer;
}

.chart-bar:hover {
  fill: var(--primary);
  opacity: 0.85;
}

.chart-bar.active {
  fill: var(--primary);
}

.chart-text {
  font-family: var(--font-sans);
  font-size: 10px;
  fill: var(--text-light);
  text-anchor: middle;
}

.chart-gridline {
  stroke: var(--border);
  stroke-width: 1;
  stroke-dasharray: 4, 4;
}

.chart-tooltip {
  position: absolute;
  background-color: #111111;
  color: white;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  z-index: 10;
  box-shadow: var(--shadow-md);
}

/* Profile and Setup layouts */
.settings-layout {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 2.5rem;
}

@media (max-width: 768px) {
  .settings-layout {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
}

.settings-sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.settings-tab {
  padding: 1rem 1.25rem;
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-align: left;
  font-weight: 600;
  font-size: 0.935rem;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.settings-tab:hover {
  background-color: var(--bg-app);
}

.settings-tab.active {
  border-color: var(--primary);
  color: var(--primary);
  background-color: var(--primary-light);
}

/* ==========================================================================
   INVOICE PDF PRINT LAYOUT
   ========================================================================== */
#invoice-print-container {
  display: none;
}

@media print {
  body * {
    visibility: hidden;
  }
  
  #invoice-print-container, #invoice-print-container * {
    visibility: visible;
  }
  
  #invoice-print-container {
    display: block !important;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    background-color: white;
    color: black;
    font-family: var(--font-sans);
    padding: 20mm;
    box-sizing: border-box;
  }

  /* Reset layout margins for print */
  @page {
    size: A4;
    margin: 0;
  }
  
  body {
    background-color: white;
  }
}

/* High-fidelity PDF layout structure */
.print-invoice {
  max-width: 800px;
  margin: 0 auto;
  color: #111111;
  font-size: 13px;
  line-height: 1.45;
}

.print-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 2px solid #111111;
  padding-bottom: 1.5rem;
  margin-bottom: 1.5rem;
}

.print-company-logo {
  max-height: 50px;
  max-width: 150px;
  object-fit: contain;
  margin-bottom: 0.5rem;
}

.print-company-details {
  font-size: 0.85rem;
  color: #555555;
  text-align: left;
}

.print-invoice-title {
  text-align: right;
}

.print-invoice-title h1 {
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
}

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

.print-bill-to {
  border: 1px solid #ECECEC;
  border-radius: var(--radius-md);
  padding: 1.25rem;
  background-color: #FAFAFA;
}

.print-bill-to h4, .print-payment-details h4 {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #888888;
  margin-bottom: 0.5rem;
}

.print-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 2rem;
}

.print-table th {
  background-color: #111111;
  color: white;
  padding: 0.65rem 1rem;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
}

.print-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #ECECEC;
}

.print-table tbody tr:last-child td {
  border-bottom: 2px solid #111111;
}

.print-summary-grid {
  display: grid;
  grid-template-columns: 55% 45%;
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

.print-words-and-notes {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.print-summary-table {
  width: 100%;
  border-collapse: collapse;
}

.print-summary-table td {
  padding: 0.5rem 0.75rem;
  text-align: right;
}

.print-summary-table tr.total td {
  font-weight: 700;
  font-size: 1.1rem;
  border-top: 1.5px solid #111111;
  color: var(--primary);
}

.print-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  border-top: 1px solid #ECECEC;
  padding-top: 1.5rem;
  font-size: 0.8rem;
  color: #777777;
}

.print-terms {
  max-width: 60%;
}

.print-signature-area {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.print-signature-img {
  max-height: 45px;
  margin-bottom: 0.25rem;
}

.print-signature-line {
  width: 150px;
  height: 1px;
  background-color: #555555;
  margin-bottom: 0.25rem;
}

/* ==========================================================================
   FINANCE OS EXTENSIONS (same design language — tokens reused throughout)
   ========================================================================== */

/* Grid/flex children may always shrink below content width (prevents
   mobile viewport blow-out from long labels and nowrap amounts) */
.main-layout,
.content-body,
.view-panel,
.card,
.dashboard-row > *,
.metrics-grid > *,
.collections-grid > *,
.invoice-creator-layout > *,
.settings-layout > * {
  min-width: 0;
}

.dashboard-row,
.metrics-grid {
  max-width: 100%;
}

/* ---------------- App-like viewport lock (mobile) ----------------
   No pinch/double-tap zoom, no horizontal slide, no rubber-band overscroll. */
html {
  overflow-x: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  overflow-x: hidden;
  max-width: 100vw;
  overscroll-behavior-y: none;
  overscroll-behavior-x: none;
  touch-action: pan-y;              /* vertical scroll only — blocks pinch & horizontal pan */
  -webkit-tap-highlight-color: transparent;
}

/* Containers that legitimately scroll sideways keep their own touch handling */
.table-responsive,
.nav-menu {
  touch-action: pan-x pan-y;
  overscroll-behavior-x: contain;
}

button, .btn, .nav-link, .settings-tab, a {
  touch-action: manipulation;       /* kills the 300ms delay + double-tap zoom on controls */
}

@media (max-width: 768px) {
  /* iOS Safari auto-zooms into inputs under 16px — pin them at 16px on mobile */
  .form-control,
  input, select, textarea {
    font-size: 16px !important;
  }

  /* Toolbars (Invoices, Expenses, Influencers, Vendors...) stack vertically
     instead of overflowing off-screen */
  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .toolbar .search-bar {
    max-width: 100%;
  }

  .toolbar-filters {
    flex-wrap: wrap;
    width: 100%;
    gap: 0.5rem;
  }

  .toolbar-filters select,
  .toolbar-filters .form-control {
    flex: 1 1 40%;
    width: auto !important;
    min-width: 0;
  }

  .toolbar-filters .btn {
    flex: 1 1 100%;
  }

  /* Toolbar action groups (e.g. Vendors: Add Vendor + Upload Invoice) */
  .toolbar > div:not(.search-bar):not(.toolbar-filters):not(.card-title) {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    width: 100%;
  }

  .toolbar > div:not(.search-bar):not(.toolbar-filters):not(.card-title) > .btn {
    flex: 1 1 auto;
  }

  .toolbar > .btn {
    width: 100%;
  }
}

/* ---------------- Login Screen ---------------- */
#login-screen {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(135deg, #111111 0%, #1d1d1d 55%, #111111 100%);
  overflow: hidden;
}

#login-screen::after {
  content: '';
  position: absolute;
  top: -120px;
  right: -120px;
  width: 380px;
  height: 380px;
  background: var(--primary);
  opacity: 0.18;
  filter: blur(110px);
  border-radius: 50%;
  pointer-events: none;
}

#login-screen::before {
  content: '';
  position: absolute;
  bottom: -140px;
  left: -100px;
  width: 320px;
  height: 320px;
  background: var(--primary);
  opacity: 0.1;
  filter: blur(110px);
  border-radius: 50%;
  pointer-events: none;
}

.login-card {
  position: relative;
  z-index: 1;
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
  animation: fadeIn 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.login-logo {
  display: block;
  height: 44px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  margin: 0 auto 0.85rem;
}

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

.login-error {
  background-color: var(--color-overdue-bg);
  color: var(--color-overdue);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.25rem;
  text-align: center;
}

.login-card.shake {
  animation: loginShake 0.4s ease;
}

@keyframes loginShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

/* trigg.fund brand wordmark (white variant on the dark sidebar) */
.brand-wordmark {
  height: 34px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  display: block;
}

/* Sidebar can hold more modules */
.nav-menu {
  overflow-y: auto;
  padding-right: 2px;
}

.nav-link {
  padding: 0.7rem 1rem;
  font-size: 0.9rem;
}

.brand {
  margin-bottom: 2rem;
}

/* Header controls: global search + FY selector + profile */
.header-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-grow: 1;
  justify-content: flex-end;
  min-width: 0;
}

.global-search {
  position: relative;
  width: 340px;
  max-width: 40vw;
}

.global-search > svg {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  fill: var(--text-light);
  width: 16px;
  height: 16px;
  pointer-events: none;
}

.global-search input {
  padding: 0.55rem 1rem 0.55rem 2.5rem;
  font-size: 0.85rem;
  border-radius: var(--radius-round);
  background-color: var(--bg-app);
}

.global-search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 420px;
  overflow-y: auto;
  display: none;
  z-index: 500;
}

.global-search-results.active {
  display: block;
}

.gsr-group-label {
  padding: 0.6rem 1rem 0.3rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
}

.gsr-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  cursor: pointer;
  font-size: 0.85rem;
  transition: var(--transition-smooth);
}

.gsr-item:hover {
  background-color: var(--primary-light);
}

.gsr-item .gsr-main {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gsr-item .gsr-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fy-selector {
  width: 130px;
  flex-shrink: 0;
  font-weight: 600;
  font-size: 0.85rem;
  border-radius: var(--radius-round);
  padding: 0.55rem 1rem;
  background-color: var(--bg-app);
  cursor: pointer;
}

/* Activity feed */
.activity-list {
  display: flex;
  flex-direction: column;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.7rem 0;
  border-bottom: 1px dashed var(--border);
  font-size: 0.85rem;
}

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

.activity-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.activity-dot.in { background-color: var(--color-paid-bg); color: var(--color-paid); }
.activity-dot.out { background-color: var(--color-overdue-bg); color: var(--color-overdue); }
.activity-dot.neutral { background-color: var(--primary-light); color: var(--primary); }

.activity-dot svg { width: 14px; height: 14px; fill: currentColor; }

.activity-text {
  flex-grow: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.activity-meta {
  font-size: 0.72rem;
  color: var(--text-light);
}

.activity-amount {
  font-weight: 700;
  white-space: nowrap;
}

.activity-amount.in { color: var(--color-paid); }
.activity-amount.out { color: var(--color-overdue); }

/* Collections client cards */
.collections-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.collection-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-smooth);
  cursor: pointer;
}

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

.collection-stat-row {
  display: flex;
  justify-content: space-between;
  padding: 0.45rem 0;
  border-bottom: 1px dashed var(--border);
  font-size: 0.82rem;
}

.collection-stat-row:last-child { border-bottom: none; }

/* Sub navigation tabs (Reports hub) reusing settings-tab look horizontally */
.subnav {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.subnav .settings-tab {
  padding: 0.6rem 1.1rem;
  font-size: 0.85rem;
  border-radius: var(--radius-round);
}

/* Detail page header (collection / vendor profile) */
.profile-header {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.profile-header .profile-info { flex-grow: 1; min-width: 200px; }

.profile-header h2 {
  font-size: 1.5rem;
  margin-bottom: 0.15rem;
}

.profile-header .profile-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Timeline (collection payment history) */
.timeline {
  position: relative;
  padding-left: 1.5rem;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background-color: var(--border);
  border-radius: 2px;
}

.timeline-item {
  position: relative;
  padding: 0.5rem 0 0.9rem;
  font-size: 0.85rem;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -1.5rem;
  top: 0.9rem;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: var(--bg-card);
  border: 3px solid var(--primary);
}

.timeline-item.muted::before { border-color: var(--border); }

/* Report figure rows */
.figure-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 0;
  border-bottom: 1px dashed var(--border);
  font-size: 0.9rem;
}

.figure-row:last-child { border-bottom: none; }

.figure-row .figure-value { font-weight: 700; font-family: var(--font-display); }

.figure-row.total {
  border-top: 1px solid var(--text-main);
  border-bottom: none;
  font-size: 1.05rem;
  font-weight: 700;
  padding-top: 1rem;
}

/* Responsive adjustments for narrow viewports */
@media (max-width: 768px) {
  body {
    padding-bottom: 80px; /* space for mobile bottom navigation */
  }

  .sidebar {
    width: 100%;
    height: 60px;
    flex-direction: row;
    padding: 0.5rem 1rem;
    top: auto;
    bottom: 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.05);
    align-items: center;
  }
  
  .brand {
    display: none;
  }
  
  .nav-menu {
    flex-direction: row;
    justify-content: flex-start;
    width: 100%;
    max-width: 100vw;
    margin-bottom: 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .nav-item {
    width: auto;
    flex-shrink: 0;
  }

  .nav-link {
    padding: 0.5rem;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.65rem;
    white-space: nowrap;
  }

  .nav-link svg {
    width: 18px;
    height: 18px;
  }

  .main-layout {
    margin-left: 0;
  }
  
  .app-header {
    padding: 0 1.25rem;
  }
  
  .content-body {
    padding: 1.25rem;
  }
  
  .item-line-header {
    display: none;
  }
  
  .item-line-row {
    grid-template-columns: 1fr;
    gap: 0.5rem;
    border: 1px solid var(--border);
    padding: 1rem;
    border-radius: var(--radius-md);
    background-color: var(--bg-card);
    position: relative;
  }

  .item-line-row input, .item-line-row div {
    width: 100% !important;
  }
  
  .item-line-row button {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 24px;
    height: 24px;
  }

  /* Finance OS: compact header on mobile */
  .sidebar {
    overflow-x: hidden;
  }

  .global-search {
    display: none;
  }

  .header-controls {
    min-width: 0;
    flex-shrink: 1;
  }

  .user-profile-badge .user-name {
    display: none;
  }

  .fy-selector {
    width: 110px;
  }

  .nav-link {
    font-size: 0.6rem;
    padding: 0.4rem 0.25rem;
  }
}
