/* Reset & Base Styles */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Sync status banner */
.sync-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 1rem;
  background: #f59e0b;
  color: #1a1205;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 2px 10px rgb(0 0 0 / 25%);
}
.sync-banner.hidden { display: none; }
.sync-banner-icon { width: 18px; height: 18px; flex-shrink: 0; }
.sync-banner-message,
.sync-banner #sync-banner-message { flex: 1; }
.sync-banner-close {
  background: transparent;
  border: none;
  color: inherit;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.25rem;
}

:root {
  /* Colors */
  --bg-primary: #0b0f19;
  --bg-secondary: #131a2e;
  --bg-tertiary: #1b253f;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #00d2ff;
  --accent-gradient: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%);
  --accent-hover: #33d9ff;
  --success: #10b981;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --warning: #f59e0b;

  /* Borders & Shadows */

  --border-focus: rgb(0 210 255 / 40%);
  --shadow-sm: 0 2px 4px rgb(0 0 0 / 10%);
  --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 30%), 0 4px 6px -2px rgb(0 0 0 / 5%);
  --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 50%), 0 10px 10px -5px rgb(0 0 0 / 4%);

  /* Layout */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: Outfit, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  line-height: 1.5;
}

/* App Wrapper */
.app-wrapper {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding: 0.5rem 1rem;
  background: rgb(19 26 46 / 60%);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

/* Header Left & Right Layouts */
.header-left {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: rgb(255 255 255 / 3%);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.nav-btn:hover {
  background: rgb(255 255 255 / 8%);
  color: var(--text-primary);
  border-color: rgb(255 255 255 / 15%);
}

.nav-btn.active {
  background: rgb(0 210 255 / 10%);
  color: var(--accent);
  border-color: rgb(0 210 255 / 25%);
  box-shadow: 0 0 12px rgb(0 210 255 / 5%);
}

.nav-btn i {
  width: 16px;
  height: 16px;
}

.header-settings-widgets {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.btn-settings-gear {
  border: 1px solid var(--border-color) !important;
}

.app-header:not(.collapsed) .btn-settings-gear {
  color: var(--accent);
  border-color: rgb(0 210 255 / 25%) !important;
  background: rgb(0 210 255 / 10%) !important;
}

.logo-title {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  transition: color var(--transition-fast);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--bg-primary);
  box-shadow: 0 0 15px rgb(0 210 255 / 40%);
}

.logo-icon i {
  width: 24px;
  height: 24px;
}

/* Collapsed / Expanded states */
.app-header.collapsed .header-settings-widgets {
  display: none !important;
}

.app-header.collapsed .logo-area {
  display: flex !important;
}

.app-header:not(.collapsed) .logo-area {
  display: none !important;
}

.app-header:not(.collapsed) .header-settings-widgets {
  display: flex !important;
}

.app-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  background: var(--accent-gradient);
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.app-header .subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* Header Company Input */
.header-company-group {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.header-company-group label {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.header-company-input {
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 600;
  padding: 0.35rem 0.65rem;
  min-width: 160px;
  max-width: 320px;
  transition: all var(--transition-fast);
  letter-spacing: -0.01em;
}

.header-company-input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.9rem;
}

.header-company-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(0 210 255 / 15%);
}

/* The <select> variant (e.g. PDF/Image conversion toggle) needs an explicit
   themed background — a transparent select and its native option list render
   white in dark mode. Also swap the native arrow for a themed chevron. */
select.header-company-input {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  background-size: 1rem;
  padding-right: 2rem;
}

select.header-company-input option {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}

/* Modal Select Dropdown */
.modal-select {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.75rem 1rem 0.75rem 2.75rem;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  cursor: pointer;
  appearance: none;
  appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 16px;
}

.modal-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(0 210 255 / 15%);
}

.modal-select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
  padding: 0.5rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Main Grid Layout */
.main-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  flex-grow: 1;
}



/* Panels */
.panel {
  background: rgb(19 26 46 / 45%);
  backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transition: border-color var(--transition-normal);
}

.panel:hover {
  border-color: rgb(0 210 255 / 15%);
}

.panel-header {
  position: relative;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.panel-header i {
  color: var(--accent);
  width: 20px;
  height: 20px;
}

.panel-header h2 {
  font-size: 1.2rem;
  font-weight: 600;
  flex-grow: 1;
}

.unpaid-panel-toggle {
  width: 100%;
  border-top: 0;
  border-right: 0;
  border-left: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  appearance: none;
}

.unpaid-panel-toggle:focus-visible {
  outline: 2px solid #ef4444;
  outline-offset: -2px;
}

.unpaid-panel-title {
  flex-grow: 1;
  font-size: 1.2rem;
  font-weight: 600;
}

.unpaid-toggle-chevron {
  flex-shrink: 0;
  color: #ef4444 !important;
  transition: transform 0.2s ease;
}

.unpaid-panel-toggle[aria-expanded="true"] .unpaid-toggle-chevron {
  transform: rotate(180deg);
}

.panel-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  flex-grow: 1;
}

/* Capture Panel Desktop Split Layout */
.capture-controls {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

@media (width >=768px) {
  /* Single full-width column on desktop too: analysis is now automatic, so the
     right-hand action column is gone and the upload area spans the whole panel. */
  .capture-panel .panel-body {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
  }

  /* Keep the now full-width upload/camera area from getting too tall. */
  .capture-panel .media-container {
    max-height: 360px;
  }
}

/* Source Toggle */
.source-toggle {
  display: none !important;
}

.toggle-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all var(--transition-fast);
}

.toggle-btn i {
  width: 16px;
  height: 16px;
}

.toggle-btn.active {
  background: var(--bg-tertiary);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

/* Media Container */
.media-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #060912;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px dashed var(--border-color);
}

.media-view {
  width: 100%;
  height: 100%;
  position: relative;
}

/* Mobile Scan Zone & Elements */
.mobile-scan-zone {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  padding: 1.5rem;
  text-align: center;
  background: #060912;
}

.scan-icon-container {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgb(0 210 255 / 8%);
  border: 1px solid rgb(0 210 255 / 15%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  margin-bottom: 0.25rem;
  box-shadow: 0 0 15px rgb(0 210 255 / 15%);
  animation: pulse-glow 2s infinite alternate;
}

.scan-icon-container i {
  width: 24px;
  height: 24px;
}

.mobile-scan-zone h3 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.mobile-scan-zone p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  max-width: 260px;
  margin: 0 0 0.5rem;
  line-height: 1.4;
}

.btn-mobile-scan {
  font-weight: 600 !important;
}

/* Auto-analysis progress bar (replaces the Analyze button) */
.analyze-progress {
  margin-top: 0.6rem;
  grid-column: 1 / -1; /* span full width under the upload/dropzone in the desktop grid */
}
.analyze-progress-bar {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.analyze-progress-bar-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}
.analyze-progress.indeterminate .analyze-progress-bar-fill {
  width: 40%;
  animation: analyze-indeterminate 1.1s ease-in-out infinite;
}
@keyframes analyze-indeterminate {
  0% { margin-left: -40%; }
  100% { margin-left: 100%; }
}
.analyze-progress-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-align: center;
  margin-top: 0.4rem;
  font-weight: 600;
}

/* Mobile capture row: "Снимай" + "Качи" side by side (mobile only) */
.mobile-capture-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.mobile-capture-row .btn-mobile-scan {
  flex: 1;
  margin-bottom: 0 !important;
}
@media (width >= 768px) {
  .mobile-capture-row { display: none !important; }
}

@keyframes pulse-glow {
  0% {
    transform: scale(1);
    box-shadow: 0 0 10px rgb(0 210 255 / 15%);
  }

  100% {
    transform: scale(1.06);
    box-shadow: 0 0 20px rgb(0 210 255 / 35%);
  }
}

.placeholder-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  color: var(--text-muted);
  background: #060912;
}

.placeholder-overlay i {
  width: 48px;
  height: 48px;
}

.capture-trigger {
  position: absolute;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  box-shadow: 0 4px 20px rgb(0 0 0 / 40%);
  z-index: 10;
}

/* Dropzone style */
.dropzone {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.dropzone:hover {
  background: rgb(0 210 255 / 2%);
}

.dropzone-icon {
  width: 48px;
  height: 48px;
  color: var(--text-muted);
  transition: color var(--transition-fast);
}

.dropzone:hover .dropzone-icon {
  color: var(--accent);
}

.dropzone-text {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.dropzone-text span {
  color: var(--accent);
  font-weight: 500;
  text-decoration: underline;
}

.file-input-hidden {
  display: none;
}

/* Image Preview Overlay */
.preview-overlay {
  position: absolute;
  inset: 0;
  background: #060912;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 15;
}

.preview-overlay img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.reset-preview-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgb(0 0 0 / 60%);
  border: 1px solid var(--border-color);
  color: white;
  z-index: 20;
}

.reset-preview-btn:hover {
  background: var(--bg-tertiary);
  color: var(--danger);
  border-color: rgb(239 68 68 / 40%);
}

.rotate-preview-btn {
  position: absolute;
  top: 1rem;
  right: 4rem;

  /* Spaced to the left of discard button */
  background: rgb(0 0 0 / 60%);
  border: 1px solid var(--border-color);
  color: white;
  z-index: 20;
}

.rotate-preview-btn:hover {
  background: var(--bg-tertiary);
  color: var(--accent);
  border-color: rgb(0 210 255 / 40%);
}

/* Input Fields */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
}

.input-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrapper i {
  position: absolute;
  left: 1rem;
  color: var(--text-muted);
  width: 18px;
  height: 18px;
}

.input-wrapper input {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.75rem 1rem 0.75rem 2.75rem;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.input-wrapper input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(0 210 255 / 15%);
}

.input-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.input-hint a {
  color: var(--accent);
  text-decoration: none;
}

.input-hint a:hover {
  text-decoration: underline;
}

.meta-section {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  flex-grow: 1;
  height: 100%;
}

.btn-analyse {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  font-size: 1.25rem;
  font-weight: 600;
  padding: 1.5rem;
  height: 100%;
  min-height: 120px;
  border-radius: var(--radius-md);
}

.btn-analyse i {
  width: 28px !important;
  height: 28px !important;
}


/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}

.btn-xs {
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--accent-gradient);
  color: var(--bg-primary);
  font-weight: 600;
  box-shadow: 0 4px 15px rgb(0 210 255 / 20%);
}

.btn-primary:hover:not(:disabled) {
  opacity: 0.95;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgb(0 210 255 / 35%);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary:disabled {
  background: var(--bg-tertiary);
  color: var(--text-muted);
  box-shadow: none;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: rgb(255 255 255 / 8%);
  border-color: rgb(255 255 255 / 15%);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: var(--danger-hover);
}

.btn-danger-text {
  background: transparent;
  color: var(--text-muted);
}

.btn-danger-text:hover {
  color: var(--danger);
}

.icon-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.icon-btn i {
  width: 16px;
  height: 16px;
}

.btn-circle {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-full);
}

.badge-info {
  background: rgb(0 210 255 / 10%);
  color: var(--accent);
  border: 1px solid rgb(0 210 255 / 15%);
}

.badge-success {
  background: rgb(16 185 129 / 10%);
  color: var(--success);
  border: 1px solid rgb(16 185 129 / 15%);
}

.badge-error {
  background: rgb(239 68 68 / 10%);
  color: var(--danger);
  border: 1px solid rgb(239 68 68 / 15%);
}

.badge i {
  width: 12px;
  height: 12px;
}

/* Search bar inside list panel */
.list-body {
  gap: 1rem;
}

.controls-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
}

.date-range-filter {
  display: flex;
  align-items: center;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.45rem 0.75rem;
  gap: 0.5rem;
}

.filter-date-input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
}

.date-separator {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.btn-clear-dates {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.btn-clear-dates:hover {
  color: var(--danger);
  background: rgb(239 68 68 / 10%);
}

.btn-clear-dates i {
  width: 14px;
  height: 14px;
}

/* Pagination controls styles */
.pagination-controls {
  display: flex;
  align-items: center;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.45rem 0.75rem;
  gap: 0.5rem;
}

/* Active-tab name inside the pagination row: mobile-only (the desktop tab bar
   already shows the names). */
.current-tab-label {
  display: none;
}

.btn-pagination {
  background: transparent;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.btn-pagination:hover:not(:disabled) {
  color: var(--accent);
}

.btn-pagination:disabled {
  color: var(--text-muted);
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-pagination i {
  width: 16px;
  height: 16px;
}

.page-indicator {
  font-size: 0.85rem;
  color: var(--text-primary);
  font-weight: 500;
  min-width: 35px;
  text-align: center;
  user-select: none;
}

.search-bar {
  display: flex;
  align-items: center;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.85rem;
  gap: 0.5rem;
  flex-grow: 1;
}

.search-bar i {
  color: var(--text-muted);
  width: 16px;
  height: 16px;
}

.search-bar input {
  flex-grow: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
}

.search-bar input:focus {
  outline: none;
}

.btn-clear-search {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast), transform var(--transition-fast);
  flex-shrink: 0;
}

.btn-clear-search:hover {
  color: var(--text-primary);
  transform: scale(1.15);
}

.btn-clear-search i,
.btn-clear-search svg {
  width: 14px;
  height: 14px;
}

/* Document List */
.document-list {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-right: 0.25rem;
  min-height: 250px;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
  flex-grow: 1;
}

.empty-state i {
  width: 48px;
  height: 48px;
  margin-bottom: 1rem;
}

.empty-state h3 {
  color: var(--text-secondary);
  font-size: 1.1rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.empty-state p {
  font-size: 0.85rem;
  max-width: 250px;
}

/* Document Entry Cards */
.document-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  transition: all var(--transition-fast);
}

.document-card:hover {
  border-color: rgb(255 255 255 / 15%);
  background: var(--bg-tertiary);
  transform: translateX(2px);
}

/* Left side: Metadata & Text preview */
.doc-info {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex-grow: 1;
  min-width: 0;

  /* allows text truncation */
}

.doc-header-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.doc-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.doc-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.doc-date i {
  width: 12px;
  height: 12px;
}

.doc-preview {
  font-size: 0.85rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 90%;
}

.doc-actions {
  margin-top: 0.25rem;
  display: flex;
  gap: 0.5rem;
}

/* Right side: Clickable attached image thumbnail */
.doc-attachment-area {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
}

.doc-thumb-link {
  display: block;
  width: 60px;
  height: 60px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.doc-thumb-link img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.doc-thumb-link:hover {
  transform: scale(1.05);
  border-color: var(--accent);
  box-shadow: 0 0 8px rgb(0 210 255 / 30%);
}

.doc-thumb-link::after {
  content: '\e9b3';

  /* lucide-eye code fallback or custom eye overlay */
  font-family: inherit;
  position: absolute;
  inset: 0;
  background: rgb(0 0 0 / 40%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.doc-thumb-link:hover::after {
  opacity: 1;
}

.doc-link-label {
  font-size: 0.75rem;
  color: var(--accent);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
}

.doc-link-label:hover {
  text-decoration: underline;
  color: var(--accent-hover);
}

/* Tabs Navigation */
.tabs-row-container {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  width: 100%;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.tabs-row-container .tabs-nav {
  flex-grow: 1;
  margin-bottom: 0;
}

.tabs-nav {
  display: flex;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  padding: 0.35rem;
  border-radius: var(--radius-md);
  gap: 0.25rem;
}

.tabs-nav .tab-link {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.65rem 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: all var(--transition-fast);
  position: relative;
  min-width: 0;
}

.tabs-nav .tab-link i {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.tabs-nav .tab-link span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tabs-nav .tab-link.active {
  background: var(--bg-tertiary);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.tab-badge {
  display: none;
  background: rgb(255 255 255 / 8%);
  color: var(--text-secondary);
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-full);
  font-weight: 600;
  flex-shrink: 0;
}

.tabs-nav .tab-link.active .tab-badge {
  background: rgb(0 210 255 / 15%);
  color: var(--accent);
}

/* Inline badge next to the tab text: count of entries added in the last 12h */
.tab-recent-badge {
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #04121c;
  font-size: 0.6rem;
  font-weight: 700;
  line-height: 1;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

/* Invoice List Layout */
.invoice-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.invoice-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.25rem;
  display: grid;
  grid-template-columns: 1.5fr 1fr 1.2fr minmax(max-content, 1.2fr);
  align-items: center;
  gap: 1rem;
  transition: all var(--transition-fast);
}

.invoice-item:hover {
  border-color: rgb(255 255 255 / 15%);
  background: var(--bg-tertiary);
  transform: translateX(2px);
}

/* Entries uploaded within the last 12 hours */
.invoice-item.recently-added {
  border-color: rgb(0 210 255 / 45%);
  background: rgb(0 210 255 / 8%);
  box-shadow: inset 3px 0 0 var(--accent);
}

.invoice-item.recently-added:hover {
  background: rgb(0 210 255 / 14%);
}

/* Product lines that match the active search, listed under the document row */
.product-match-row {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding-top: 0.5rem;
  margin-top: 0.15rem;
  border-top: 1px dashed var(--border-color);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.product-match-line {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.product-match-line i,
.product-match-line svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--accent);
}

.product-match-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.product-match-name mark {
  background: rgb(0 210 255 / 22%);
  color: inherit;
  border-radius: 3px;
  padding: 0 2px;
}

.product-match-meta {
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.product-match-vat {
  color: var(--accent);
  white-space: nowrap;
  flex-shrink: 0;
  opacity: 0.9;
}

.invoice-header {
  background: rgb(19 26 46 / 70%);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  display: grid;
  grid-template-columns: 1.5fr 1fr 1.2fr minmax(max-content, 1.2fr);
  gap: 1rem;
  margin-bottom: 0.25rem;
  letter-spacing: 0.03em;
}

body.light-theme .invoice-header {
  color: #fff;
}

.invoice-col {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.invoice-header .sortable-col {
  cursor: pointer;
  user-select: none;
  transition: color 0.15s ease;
}

.invoice-header .sortable-col:hover {
  color: var(--accent);
}

.sort-arrow {
  margin-left: 0.3em;
  font-size: 0.7em;
  color: var(--accent);
  vertical-align: middle;
}

.invoice-supplier {
  font-weight: 600;
  color: var(--text-primary);
}

.invoice-date {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.invoice-amount {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  color: var(--accent);
  font-size: 0.95rem;
}

.invoice-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  justify-content: flex-end;
  overflow: visible;
}

.entry-move-select {
  width: min(180px, 100%);
  min-width: 120px;
  padding: 0.28rem 1.5rem 0.28rem 0.45rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
}

.entry-move-select:hover,
.entry-move-select:focus {
  border-color: var(--accent);
  outline: none;
}

.entry-move-select-compact {
  width: 160px;
}

.invoice-action-link {
  font-size: 0.8rem;
  color: var(--accent);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  cursor: pointer;
  transition: color var(--transition-fast);
}

.invoice-action-link:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.invoice-action-link i {
  width: 13px;
  height: 13px;
}

.invoice-action-link.text-danger {
  color: var(--danger);
}

.invoice-action-link.text-danger:hover {
  color: var(--danger-hover);
}

/* Invoice Summary Bar */
.invoice-summary-bar {
  background: rgb(0 210 255 / 5%);
  border: 1px solid rgb(0 210 255 / 15%);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.5rem;
  box-shadow: 0 -4px 10px rgb(0 0 0 / 20%);
}

.summary-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.summary-label i {
  color: var(--accent);
  width: 18px;
  height: 18px;
}

.summary-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
  text-shadow: 0 0 10px rgb(0 210 255 / 30%);
}

.summary-values {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.summary-today {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding-left: 1.25rem;
  border-left: 1px solid rgb(0 210 255 / 20%);
}

.summary-today-label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.summary-today-value {
  font-size: 1.05rem;
}

/* Responsive styles for invoice item */
@media (width <=600px) {
  .invoice-header {
    display: none;
  }

  .invoice-item {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    padding: 0.85rem 0.75rem;
  }

  .invoice-item> :nth-child(1) {
    /* supplier */
    grid-column: 1 / -1;
  }

  .invoice-item> :nth-child(4) {
    /* actions */
    grid-column: 1 / -1;
    justify-content: flex-start;
    margin-top: 0.25rem;
  }
}

/* Inline Edit Inputs for Invoice List */
.invoice-item-input {
  background: transparent;
  border: 1px solid transparent;
  color: inherit;
  font-family: inherit;
  font-size: 1rem;
  width: 90%;
  padding: 0.25rem 0.4rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.invoice-item-input:hover {
  background: rgb(255 255 255 / 3%);
  border-color: rgb(255 255 255 / 10%);
}

body.light-theme .invoice-item-input:hover {
  background: rgb(0 0 0 / 3%);
  border-color: rgb(0 0 0 / 8%);
}

.invoice-item-input:focus {
  outline: none;
  background: var(--bg-primary);
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgb(0 210 255 / 15%);
  color: var(--text-primary);
}

body.light-theme .invoice-item-input:focus {
  background: var(--bg-primary);
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgb(2 132 199 / 15%);
  color: var(--text-primary);
}

.invoice-item-input[type="date"]::-webkit-calendar-picker-indicator {
  display: none !important;
  appearance: none !important;
}

.invoice-item-input.amount-input {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  color: var(--accent);
}

/* Styled Read-Only Columns for Invoice List */
.invoice-item-text {
  font-size: 0.9rem;
  padding: 0.25rem 0.4rem;
  display: block;
}

.invoice-item-text.main-party-text {
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 90%;
}

.invoice-item-text.amount-text {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  color: var(--accent);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgb(5 8 16 / 85%);
  backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1.5rem;
  transition: opacity var(--transition-normal);
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  width: 100%;
  max-width: 500px;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modal-enter var(--transition-normal);
}

.modal-lg {
  max-width: 900px;
}

@keyframes modal-enter {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;

  /* Let long file names shrink/wrap instead of pushing the close button away */
  min-width: 0;
  flex: 1;
}

.modal-title-group i {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.text-accent {
  color: var(--accent);
}

.modal-header h3 {
  font-size: 1.2rem;
  font-weight: 600;
  min-width: 0;
  overflow-wrap: anywhere;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.75rem;
  cursor: pointer;
  transition: color var(--transition-fast);
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  max-height: 70vh;
}

.modal-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
}

.modal-footer {
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background: rgb(11 15 25 / 40%);
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.75rem;
  align-items: center;
}

/* Mobile: keep the whole modal on screen — smaller title, wrapping footer
   buttons that stay visible instead of overflowing off the right edge. */
@media (width <= 600px) {
  .modal-backdrop {
    padding: 0.75rem;
  }

  .modal-content {
    max-height: calc(100vh - 1.5rem);
    max-height: calc(100dvh - 1.5rem);
  }

  .modal-header {
    padding: 0.9rem 1rem;
  }

  .modal-header h3 {
    font-size: 0.92rem;
    line-height: 1.3;
  }

  .modal-body {
    padding: 1rem;
    max-height: none;
    flex: 1 1 auto;
    min-height: 0;
  }

  .modal-footer {
    padding: 0.75rem 1rem;
    gap: 0.5rem;
  }

  /* The "Saved on" note gets its own full-width row above the buttons */
  .modal-footer > span.text-muted {
    flex-basis: 100%;
    font-size: 0.78rem;
  }

  .modal-footer .btn {
    flex: 1 1 auto;
    justify-content: center;
    padding: 0.55rem 0.6rem;
    font-size: 0.85rem;
    white-space: nowrap;
  }
}

/* Lightbox Modal */
.lightbox-backdrop {
  background: rgb(0 0 0 / 95%);
  z-index: 250;

  /* Make sure it shows in front of all other elements and modals */
}

.lightbox-content {
  position: relative;
  max-width: 90%;
  max-height: 85%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lightbox-content img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: 0 0 30px rgb(0 0 0 / 80%);
  transition: transform 0.08s ease-out;

  /* Smooth zoom/pan animation */
  cursor: zoom-in;
  user-select: none;
  -webkit-user-drag: none;
}

.lightbox-close {
  position: absolute;
  top: -2.5rem;
  right: 0;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 2rem;
  cursor: pointer;
}

.lightbox-close:hover {
  color: white;
}

.lightbox-caption {
  margin-top: 1rem;
  color: var(--text-secondary);
  font-size: 0.95rem;
  text-align: center;
}

/* Detailed Doc View Modal Grid */
.view-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (width >=768px) {
  .view-grid {
    grid-template-columns: 4fr 6fr;
  }
}

.view-image-pane {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  aspect-ratio: 4 / 5;
  overflow: hidden;
}

.view-image-pane img {
  max-width: 100%;
  max-height: 100%;
  flex: 1 1 auto;
  min-height: 0;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

/* Zoomable preview: a window onto the document image (wheel zooms at the
   pointer, drag pans). Used for the whole page and for the framed snippets. */
.zoom-viewport {
  position: relative;
  overflow: hidden;
  width: 100%;
  border-radius: var(--radius-sm);
  cursor: grab;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}

.zoom-viewport.dragging {
  cursor: grabbing;
}

.zoom-viewport > img.zoom-img {
  position: absolute;
  top: 0;
  left: 0;
  max-width: none;
  max-height: none;
  flex: none;
  object-fit: fill;
  border-radius: 0;
  transform-origin: 0 0;
  pointer-events: none;
  -webkit-user-drag: none;
}

/* Whole-page window: fills the preview pane */
.zoom-full {
  flex: 1 1 auto;
  min-height: 0;
  align-self: stretch;
}

.zoom-reset {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
  border-radius: 50%;
  background: rgba(11, 15, 25, 0.8);
  color: #fff;
  cursor: pointer;
}

/* PDF preview: the drawn page in a zoom window, a pager under it when the
   file has several pages */
.pdf-status {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.pdf-pager {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.pdf-pager-label {
  min-width: 3.5rem;
  text-align: center;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

.pdf-pager-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
  border-radius: 50%;
  background: transparent;
  color: var(--text-primary);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.pdf-pager-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

/* Preview host in both document modals: one whole-page window, a PDF page
   with its pager, or the framed snippets (number/date block, totals block)
   when the analysis located them */
.view-zoom-pane {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.75rem;
  overflow: hidden;
}

.view-snippet {
  margin: 0;
  flex: 0 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.view-snippet figcaption {
  flex-shrink: 0;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.view-snippet .zoom-viewport {
  flex: 0 1 auto;
  min-height: 0;
  aspect-ratio: 5 / 2;
  background: #fff;
  border: 1px solid var(--border-color);
}

/* The buttons under the preview must never be squeezed out by the image */
.view-image-pane .btn,
.view-image-pane .view-file-actions {
  flex-shrink: 0;
}

/* Print / Email actions row under the "View Full Size" button */
.view-file-actions {
  display: flex;
  gap: 0.5rem;
  width: 100%;
  justify-content: center;
}

.view-file-actions .btn {
  flex: 1 1 0;
  justify-content: center;
}

.view-text-pane {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.pane-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.details-edit-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.input-group-modal {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.input-group-modal label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.products-textarea {
  width: 100%;
  height: 140px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  resize: vertical;
}

.products-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(0 210 255 / 15%);
}

/* Toast Notifications */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent);
  color: var(--text-primary);
  padding: 1rem 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  z-index: 200;
  animation: toast-enter 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast i {
  width: 18px;
  height: 18px;
}

@keyframes toast-enter {
  from {
    transform: translateY(20px) scale(0.9);
    opacity: 0;
  }

  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

/* Utility Helpers */
.hidden {
  display: none !important;
}

.text-muted {
  color: var(--text-muted);
}

/* Products Table Styles */
.products-table-wrapper {
  width: 100%;
  max-height: 250px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  margin-top: 0.25rem;
}

.products-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  text-align: left;
}

.products-table th {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-weight: 600;
  padding: 0.6rem 0.75rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 2;
}

.products-table td {
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.products-table tr:last-child td {
  border-bottom: none;
}

.products-table-input {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.products-table-input:focus {
  outline: none;
  background: rgb(255 255 255 / 3%);
  border-color: var(--accent);
}

.products-table-input.qty-input {
  text-align: center;
}

.products-table-input.price-input {
  text-align: right;
  padding-right: 1.25rem;
}

/* Chrome/Safari/Edge number input spin button removal */
.products-table-input[type="number"]::-webkit-outer-spin-button,
.products-table-input[type="number"]::-webkit-inner-spin-button {
  appearance: none;
  margin: 0;
}

.products-table-input[type="number"] {
  appearance: textfield;
}

.btn-table-delete {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast);
  margin: 0 auto;
}

.btn-table-delete:hover {
  color: var(--danger);
}

/* Light Theme Variable Overrides */
body.light-theme {
  --bg-primary: #f8fafc;

  /* Slate 50 */
  --bg-secondary: #fff;

  /* White cards */
  --bg-tertiary: #f1f5f9;

  /* Slate 100 */
  --text-primary: #0f172a;

  /* Slate 900 */
  --text-secondary: #475569;

  /* Slate 600 */
  --text-muted: #94a3b8;

  /* Slate 400 */

  --accent: #0284c7;

  /* Sky 600 */
  --accent-gradient: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
  --accent-hover: #0369a1;

  /* Sky 700 */

  --border-color: rgb(15 23 42 / 8%);
  --border-focus: rgb(2 132 199 / 40%);
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 5%);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 5%), 0 2px 4px -1px rgb(0 0 0 / 3%);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 5%), 0 4px 6px -2px rgb(0 0 0 / 3%);
}

/* Light Theme Component Overrides */
body.light-theme .app-header {
  background: rgb(255 255 255 / 70%);
  box-shadow: 0 4px 30px rgb(0 0 0 / 2%);
}

body.light-theme .panel {
  background: rgb(255 255 255 / 70%);
  box-shadow: 0 8px 32px rgb(0 0 0 / 3%);
}

body.light-theme .panel:hover {
  border-color: rgb(2 132 199 / 20%);
}

body.light-theme .modal-backdrop:not(.lightbox-backdrop) {
  background: rgb(15 23 42 / 40%);
}

body.light-theme .modal-footer {
  background: rgb(248 250 252 / 70%);
}

body.light-theme .preview-overlay {
  background: #f1f5f9;
}

body.light-theme .document-card:hover,
body.light-theme .invoice-item:hover {
  border-color: rgb(2 132 199 / 25%);
  background: var(--bg-tertiary);
}

body.light-theme .tab-badge {
  background: rgb(15 23 42 / 6%);
}

body.light-theme .tabs-nav .tab-link.active .tab-badge {
  background: rgb(2 132 199 / 15%);
}

body.light-theme .btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

body.light-theme .btn-secondary:hover {
  background: rgb(15 23 42 / 4%);
  border-color: rgb(15 23 42 / 12%);
}

/* Hover Image Preview */
.hover-image-preview {
  position: fixed;
  width: 260px;
  height: 340px;
  background: rgb(19 26 46 / 85%);
  backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  pointer-events: none;

  /* Do not capture cursor clicks or drags */
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  animation: hover-preview-enter 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

body.light-theme .hover-image-preview {
  background: rgb(255 255 255 / 90%);
  box-shadow: 0 10px 30px rgb(0 0 0 / 8%);
}

.hover-image-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

@keyframes hover-preview-enter {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(5px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Backup & Restore Panel Styles */
.backup-panel-body {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.75rem !important;
}

.backup-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  text-align: center;
}

.backup-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}

@media (width >=768px) {
  .backup-panel-body {
    flex-direction: row;
    text-align: left;
  }
}

/* Document Preview Placeholder styling */
.document-preview-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.5rem;
  width: 100%;
  height: 100%;
  color: var(--text-secondary);
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  text-align: center;
}

.doc-placeholder-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-md);
  background: rgb(0 210 255 / 10%);
  border: 1px solid rgb(0 210 255 / 20%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  margin-bottom: 0.25rem;
}

.doc-placeholder-icon i {
  width: 32px;
  height: 32px;
}

.doc-placeholder-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-width: 90%;
}

.doc-placeholder-name {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 250px;
}

.doc-placeholder-size {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.doc-thumb-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.doc-thumb-placeholder i {
  width: 24px;
  height: 24px;
  color: var(--accent);
}

/* Drag & Drop Visual Styles */
.invoice-item.dragging,
.document-card.dragging {
  opacity: 0.4;
  border: 1px dashed var(--border-color) !important;
}

.tabs-nav .tab-link.drag-over {
  background: rgb(0 210 255 / 10%) !important;
  color: var(--accent) !important;
  outline: 2px dashed var(--accent) !important;
  outline-offset: -2px;
  transform: scale(1.03);
}

/* Native Date Input Theme Overrides */
input[type="date"] {
  color-scheme: dark;
}

body.light-theme input[type="date"] {
  color-scheme: light;
}

/* Mobile (Compressed) Layout Adjustments */
@media (width <=767px) {

  /* Skip collapsed view: hide expand button and show capture panel */
  .btn-expand-capture {
    display: none !important;
  }

  .capture-panel.hidden {
    display: flex !important;
  }

  .btn-close-capture {
    display: none !important;
  }

  /* Hide the media container entirely on mobile */
  .capture-panel .media-container {
    display: none !important;
  }

  /* ...except while an image awaits the user's orientation confirmation:
     the preview overlay (image + rotate + discard) lives inside it. */
  .capture-panel .media-container.preview-active {
    display: block !important;
    aspect-ratio: 3 / 4;
    max-height: 55vh;
  }

  /* Stacking the Снимай Документ and Analyse buttons */
  .capture-panel .panel-body {
    gap: 1rem;
    padding: 1.25rem;
  }

  .capture-panel .meta-section {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 0.75rem;
  }

  .btn-mobile-scan {
    display: inline-flex !important;
    padding: 1rem !important;
    font-size: 1.05rem !important;
    border-radius: var(--radius-md) !important;
    font-weight: 600 !important;
    box-shadow: 0 4px 12px rgb(255 255 255 / 5%);
    align-items: center;
    justify-content: center;
  }

  .btn-analyse {
    padding: 1rem !important;
    font-size: 1.05rem !important;
    min-height: auto !important;
    height: auto !important;
    flex-grow: 0 !important;
  }

  /* Stacking the Saved Documents navigation tabs vertically */
  .tabs-row-container {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .tabs-row-container .tabs-nav {
    flex-direction: column;
    padding: 0.5rem;
    gap: 0.35rem;
    width: 100%;
  }

  .tabs-row-container .pagination-controls {
    width: 100%;
    justify-content: flex-end;
    padding: 0.45rem 0.75rem;
  }

  /* Current tab name on the left; "+" and the page selector go right. */
  .tabs-row-container .pagination-controls .current-tab-label {
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    text-align: left;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .tabs-nav .tab-link {
    flex: none;
    width: 100%;
    justify-content: flex-start;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
  }
}

/* Desktop Camera button override */
@media (width >=768px) {
  .btn-mobile-scan {
    display: none !important;
  }
}

/* Style for search bar trash icon button */
.btn-icon-only {
  padding: 0.5rem !important;
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Responsive Text Helpers (Global Defaults) */
.desktop-text {
  display: inline;
}

.mobile-text {
  display: none;
}

/* Mobile-Specific Overrides (under 768px width) */
@media (width <=767px) {

  /* Maximize horizontal space: panels and their entries run nearly edge to
     edge of the window (desktop keeps the roomy 1.5rem insets). */
  .app-wrapper {
    padding-left: 0.4rem;
    padding-right: 0.4rem;
  }

  .panel-body {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  .staff-card {
    padding: 1rem 0.75rem;
  }

  /* Hide the panel header for Capture Document on mobile */
  .capture-panel .panel-header {
    display: none !important;
  }

  /* Hide document count badge on mobile */
  .list-panel #doc-count {
    display: none !important;
  }

  /* Unpaid entries panel is desktop-only */
  #panel-unpaid {
    display: none !important;
  }

  /* Hide date range filter on mobile */
  .date-range-filter {
    display: none !important;
  }

  /* Wrap controls on mobile */
  .controls-row {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .controls-row .search-bar {
    flex-grow: 1;
    width: auto;
  }

  .controls-row .pagination-controls {
    flex-shrink: 0;
  }

  /* Responsive label toggle */
  .desktop-text {
    display: none !important;
  }

  .mobile-text {
    display: inline !important;
  }

  /* Counter badges: show only the number on mobile (hide the unit word) */
  .badge .count-unit {
    display: none;
  }

  /* Invoice summary: on mobile only show today's price */
  #invoice-summary #invoice-total-value {
    display: none;
  }

  #invoice-summary .summary-label .mobile-text {
    display: none !important;
  }

  #invoice-summary .summary-today {
    padding-left: 0;
    border-left: none;
  }

  /* Mobile Header Styles */
  .app-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.75rem;
  }

  .header-left {
    flex-direction: row;
    align-items: center;
    flex-grow: 1;
    width: auto;
  }

  .header-nav {
    width: 100%;
    justify-content: space-between;
    gap: 0.25rem;
  }

  .nav-btn {
    flex: 1;
    padding: 0.5rem 0.25rem;
    font-size: 0.8rem;
    justify-content: center;
  }

  .nav-btn span {
    display: none !important;
  }

  .nav-btn i {
    width: 20px;
    height: 20px;
  }

  .header-right {
    width: auto;
    display: flex;
    justify-content: flex-end;
    align-items: center;
  }
}

/* Multi-Page View Containers */
.main-view-container {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  width: 100%;
}

.main-view-container.hidden {
  display: none !important;
}

/* Staff Directory View Styling */
.staff-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.staff-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  transition: all var(--transition-normal);
}

.staff-card:hover {
  border-color: rgb(0 210 255 / 15%);
  background: var(--bg-tertiary);
}

.staff-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.staff-info-block {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-grow: 1;
  min-width: 250px;
}

.staff-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgb(0 210 255 / 10%);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.staff-avatar i {
  width: 20px;
  height: 20px;
}

.staff-meta {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.staff-name {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--text-primary);
}

.staff-hiring-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.staff-hiring-group i {
  width: 14px;
  height: 14px;
}

.staff-hiring-input {
  background: rgb(255 255 255 / 3%);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  outline: none;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.staff-hiring-input:hover {
  background: var(--border-color);
}

.staff-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.btn-toggle-docs {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.85rem;
  font-size: 0.85rem;
}

.btn-toggle-docs i.chevron {
  width: 14px;
  height: 14px;
  transition: transform var(--transition-normal);
}

.staff-card.expanded .btn-toggle-docs i.chevron {
  transform: rotate(180deg);
}

/* Expandable Personnel Documents */
.staff-docs-panel {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px dashed var(--border-color);
  display: none;
  animation: fadeIn var(--transition-normal) ease;
}

.staff-card.expanded .staff-docs-panel {
  display: block;
}

.staff-docs-list {
  display: flex;
  flex-direction: column;
  gap: 0.50rem;
}

.staff-doc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgb(0 0 0 / 15%);
  border: 1px solid var(--border-color);
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  transition: border-color var(--transition-fast);
  flex-wrap: wrap;
  gap: 0.75rem;
}

.staff-doc-row:hover {
  border-color: rgb(255 255 255 / 15%);
}

.staff-doc-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 150px;
  overflow: hidden;
}

.staff-doc-title .sub-doc-icon {
  color: var(--accent);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.staff-doc-name-input {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 500;
  padding: 0.2rem 0.45rem;
  width: 100%;
  min-width: 0;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.staff-doc-name-input:hover {
  border-color: var(--border-color);
  background: rgb(255 255 255 / 3%);
}

.staff-doc-name-input:focus {
  outline: none;
  border-color: var(--accent);
  background: rgb(0 210 255 / 5%);
}

.staff-doc-meta {
  color: var(--text-muted);
  font-size: 0.75rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.staff-doc-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.staff-doc-actions .btn.text-danger:hover {
  color: var(--danger);
  border-color: rgb(239 68 68 / 30%);
  background: rgb(239 68 68 / 8%);
}

/* Expandable Capture Panel Styles */
.btn-expand-capture {
  background: rgb(0 210 255 / 8%);
  border: 1px dashed rgb(0 210 255 / 35%);
  color: var(--accent);
  padding: 1.15rem 1.5rem;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-normal);
  width: 100%;
  margin-bottom: 1rem;
}

.btn-expand-capture:hover {
  background: rgb(0 210 255 / 15%);
  border-color: var(--accent);
  box-shadow: 0 0 15px rgb(0 210 255 / 20%);
}

.btn-expand-capture i {
  width: 20px;
  height: 20px;
}

.btn-close-capture {
  position: absolute;
  right: 1.25rem;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color var(--transition-fast);
  padding: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.btn-close-capture:hover {
  color: var(--danger);
  background: rgb(255 255 255 / 5%);
}

.btn-close-capture i {
  width: 18px;
  height: 18px;
}

/* Combined Footer Settings Panel */
.footer-settings-body {
  display: flex;
  gap: 2rem;
  padding: 1.5rem 1.75rem !important;
  flex-wrap: wrap;
}

.footer-settings-column {
  flex: 1;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.footer-section-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px dashed var(--border-color);
  padding-bottom: 0.5rem;
  margin-bottom: 0.25rem;
}

.footer-section-header i {
  width: 20px;
  height: 20px;
  color: var(--accent);
}

.footer-section-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.footer-settings-controls {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  justify-content: center;
  height: 100%;
}

.footer-company-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

.footer-company-group label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.footer-company-group input {
  background: rgb(255 255 255 / 3%);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.75rem;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  transition: all var(--transition-fast);
  width: 100%;
}

.footer-company-group input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgb(0 210 255 / 15%);
}

.footer-settings-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.footer-settings-controls-row {
  flex-direction: row !important;
  align-items: flex-end;
  gap: 1.5rem;
}

.footer-divider {
  width: 1px;
  background: var(--border-color);
  align-self: stretch;
}

@media (width <=767px) {
  .footer-settings-body {
    flex-direction: column;
    gap: 1.5rem;
  }

  .footer-divider {
    display: none;
  }

  .footer-settings-controls-row {
    flex-direction: column !important;
    align-items: stretch;
    gap: 0.75rem;
  }
}

/* Theme Toggle Clickable Icon Button */
.theme-toggle-icon-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem;
  transition: color var(--transition-fast), transform var(--transition-fast);
  border-radius: var(--radius-sm);
}

.theme-toggle-icon-btn:hover {
  color: var(--accent);
  transform: scale(1.08);
  background: rgb(255 255 255 / 5%);
}

.theme-toggle-icon-btn i {
  width: 20px;
  height: 20px;
}

/* Staff Table View Layout */
.staff-section {

  border-radius: var(--radius-lg);
  padding: 0.4rem;
  margin-bottom: 1.5rem;
}

.staff-section-header-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.staff-table-header {
  display: grid;
  grid-template-columns: 1.5fr 1.2fr 1.8fr 1.2fr;
  gap: 1rem;
  padding: 0.5rem 1rem;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  background: rgb(19 26 46 / 70%);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  margin-bottom: 0.5rem;
}

body.light-theme .staff-table-header {
  color: #fff;
}

body.light-theme .staff-doc-row {
  background: rgb(0 0 0 / 3%);
}

body.light-theme .staff-doc-row:hover {
  border-color: rgb(0 0 0 / 15%);
}

body.light-theme .staff-doc-name-input:hover {
  background: rgb(0 0 0 / 3%);
}

body.light-theme .staff-doc-name-input:focus {
  background: rgb(0 120 255 / 4%);
}

.staff-table-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 0.5rem;
  transition: all var(--transition-normal);
}

.staff-table-item:hover {
  border-color: rgb(0 210 255 / 15%);
  background: var(--bg-tertiary);
}

.staff-table-row {
  display: grid;
  grid-template-columns: 1.5fr 1.2fr 1.8fr 1.2fr;
  gap: 1rem;
  padding: 0.5rem 1rem;
  align-items: center;
}

.staff-table-col {
  white-space: nowrap;
  text-overflow: ellipsis;
  min-width: 0;
  font-size: 0.9rem;
}

.staff-inline-date-input {
  background: rgb(255 255 255 / 3%);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  outline: none;
  padding: 0.2rem 0.4rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.staff-inline-date-input:hover {
  background: var(--border-color);
}

.staff-row-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.staff-files-panel {
  border-top: 1px solid var(--border-color);
  background: rgb(0 0 0 / 15%);
  padding: 1rem;
  border-bottom-left-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
}

.empty-sub-state {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 0.5rem;
}

.date-col-double {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.date-col-double .date-lbl {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

@media (width <=768px) {
  .staff-table-header {
    display: none;
  }

  .staff-table-row {
    grid-template-columns: 1fr;
    gap: 0.5rem;
    padding: 1rem;
  }

  .staff-row-actions {
    justify-content: flex-start;
    margin-top: 0.5rem;
  }

  .date-col-double {
    flex-flow: row wrap;
    align-items: center;
  }
}

/* Past staff list columns adjustment (4 columns) */
.staff-table-header.past-staff-header,
.staff-table-row.past-staff-row {
  grid-template-columns: 1.5fr 1.2fr 1.8fr 1.2fr;
}

@media (width <=768px) {
  .staff-table-row.past-staff-row {
    grid-template-columns: 1fr;
  }
}

/* Unattached staff list columns adjustment (4 columns) */
.staff-table-header.unattached-staff-header,
.staff-table-row.unattached-staff-row {
  grid-template-columns: 1.5fr 1.2fr 2fr 0.8fr;
}

@media (width <=768px) {
  .staff-table-row.unattached-staff-row {
    grid-template-columns: 1fr;
  }
}

/* Document list item: compressed view adaptations */
.short-name-text {
  display: none;
}

.full-name-text {
  display: inline;
}

.date-text-only {
  display: none;
}

.date-input {
  display: inline-block;
}

.paid-col,
.paid-header-col {
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-paid-toggle {
  background: transparent;
  border: none;
  color: var(--danger);
  padding: 0;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast) ease;
}

.btn-paid-toggle i {
  width: 9px;
  height: 9px;
}

.btn-paid-toggle:hover {
  color: var(--danger-hover);
}

.btn-paid-toggle.paid {
  background: transparent;
  border: none;
  color: var(--success);
}

.btn-paid-toggle.paid:hover {
  color: var(--success);
  opacity: 0.85;
}

/* Paid check in the invoice modal footer: the list's circle, sized for a
   tap target next to „Запази“ (red circle = unpaid, green check = paid) */
.modal-footer .btn-view-paid {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.modal-footer .btn-view-paid i,
.modal-footer .btn-view-paid svg {
  width: 26px;
  height: 26px;
}

/* Keep the invoice modal's buttons on one row (so the paid mark sits right
   next to „Запази“); the "Записан на" note wraps instead. Phones keep their
   own two-row footer layout. */
@media (width > 600px) {
  #modal-view .modal-footer {
    flex-wrap: nowrap;
  }

  #modal-view .modal-footer > #view-date {
    flex: 1 1 0;
    min-width: 0;
  }

  #modal-view .modal-footer .btn {
    flex-shrink: 0;
    white-space: nowrap;
  }
}

/* Phones: Изтрий + Преанализирай fill the first row, so the paid check
   wraps onto „Запази“'s row and stays next to it. */
@media (width <= 600px) {
  #modal-view .modal-footer #btn-delete-doc,
  #modal-view .modal-footer #btn-reanalyze-doc {
    flex: 1 1 calc(50% - 0.25rem);
  }
}

.invoice-item.is-taxes,
.invoice-header.is-taxes {
  grid-template-columns: 1.5fr 1fr 1fr 0.8fr minmax(max-content, 1.2fr);
}

@media (width <=767px) {
  .invoice-header {
    display: none !important;
  }

  .invoice-item {
    grid-template-columns: 1.2fr 1fr 1fr auto !important;
    gap: 0.5rem !important;
    padding: 0.6rem 0.75rem !important;
  }

  .invoice-item.is-taxes {
    grid-template-columns: 1.5fr 1fr 0.6fr auto !important;
  }

  .invoice-item.is-taxes .date-col {
    display: none !important;
  }

  .invoice-item> :nth-child(1),
  .invoice-item> :nth-child(4) {
    grid-column: auto !important;
    margin-top: 0 !important;
  }

  .short-name-text {
    display: inline !important;
  }

  .full-name-text {
    display: none !important;
  }

  .date-text-only {
    display: inline-block !important;
    font-size: 0.85rem;
    color: var(--text-primary);
  }

  .date-input {
    display: none !important;
  }

  .amount-currency {
    display: none;
  }

  #view-invoices .tabs-row-container .tabs-nav {
    flex-flow: row nowrap;
    gap: 0.2rem;
    padding: 0.35rem;
  }

  #view-invoices .tabs-nav .tab-link {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
    min-height: 52px;
    justify-content: center;
    padding: 0.45rem 0.25rem 1.25rem;
  }

  #view-invoices .tabs-nav .tab-link > span:not(.tab-recent-badge) {
    display: none !important;
  }

  #view-invoices .tabs-nav .tab-link > .tab-recent-badge:not(.hidden) {
    position: absolute;
    bottom: 0.2rem;
    left: 50%;
    display: inline-flex !important;
    transform: translateX(-50%);
  }

  #view-invoices .tabs-nav .tab-link i,
  #view-invoices .tabs-nav .tab-link svg {
    width: 20px;
    height: 20px;
  }

  .invoice-actions {
    justify-content: flex-end !important;
    gap: 0.25rem !important;
  }

  .entry-move-select {
    display: none !important;
  }

  .invoice-actions .btn-row-delete {
    display: none !important;
  }

  .invoice-item.no-file .invoice-actions .btn-row-delete {
    display: inline-flex !important;
  }

  .invoice-actions .btn-text {
    display: none !important;
  }

  /* General documents list item: compressed view adaptations */
  #document-list-docs .invoice-item {
    grid-template-columns: 1fr auto !important;
    gap: 0.5rem !important;
    padding: 0.6rem 0.75rem !important;
  }

  #document-list-docs .invoice-item> :nth-child(2),
  #document-list-docs .invoice-item> :nth-child(3) {
    display: none !important;
  }

  #document-list-docs .invoice-item> :nth-child(1),
  #document-list-docs .invoice-item> :nth-child(4) {
    grid-column: auto !important;
    margin-top: 0 !important;
  }

  #document-list-docs .invoice-actions .btn-row-delete-doc {
    display: none !important;
  }

  #document-list-docs .invoice-actions .btn-view-doc-file .btn-text {
    display: none !important;
  }
}

/* Monthly Expense Summary Bar */
.monthly-expense-summary-bar {
  background: rgba(239, 68, 68, 0.04);
  border: 1px solid rgba(239, 68, 68, 0.15);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.75rem;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

body.dark-theme .monthly-expense-summary-bar {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.25);
}

.monthly-expense-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-grow: 1;
}

.monthly-expense-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
  text-align: center;
}

.monthly-expense-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.5rem;
  font-weight: 700;
  color: #ef4444;
  /* red */
  text-align: center;
  text-shadow: 0 0 10px rgba(239, 68, 68, 0.2);
}

/* Оборот − Общо разходи − Заплати = Приход */
.monthly-finance-row {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.35rem 0.6rem;
}

.fin-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.fin-label {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.1rem;
  white-space: nowrap;
}

.fin-op {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-secondary);
  /* aligns the operator with the value line below the small labels */
  align-self: flex-end;
  padding-bottom: 0.15rem;
}

.fin-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.2rem;
  font-weight: 700;
  white-space: nowrap;
}

.fin-revenue {
  color: #3b82f6;
}

.fin-expenses {
  color: #ef4444;
  text-shadow: 0 0 10px rgba(239, 68, 68, 0.2);
}

.fin-salaries {
  color: #f59e0b;
}

.fin-profit {
  color: #22c55e;
  text-shadow: 0 0 10px rgba(34, 197, 94, 0.2);
}

.fin-profit.negative {
  color: #ef4444;
  text-shadow: 0 0 10px rgba(239, 68, 68, 0.2);
}

@media (max-width: 640px) {
  .monthly-expense-summary-bar {
    padding: 0.75rem 0.6rem;
  }

  .monthly-finance-row {
    gap: 0.25rem 0.45rem;
  }

  .fin-value {
    font-size: 0.98rem;
  }

  .fin-op {
    font-size: 0.9rem;
  }

  .fin-label {
    font-size: 0.62rem;
  }
}

.btn-month-nav {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  width: 32px;
  height: 32px;
}

.btn-month-nav:hover {
  background: var(--bg-hover);
  border-color: var(--text-secondary);
}

.btn-month-nav i {
  width: 18px;
  height: 18px;
}

/* General Doc Details Modal Grid */
.details-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (width >=768px) {
  .details-grid {
    grid-template-columns: 4fr 6fr;
  }
}

.details-preview-side {
  display: flex;
  flex-direction: column;
}

.modal-image-preview {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  aspect-ratio: 4 / 5;
  overflow: hidden;
}

.modal-image-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

.details-form-side {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Document Preview Placeholder styling alias */
.document-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.5rem;
  width: 100%;
  height: 100%;
  color: var(--text-secondary);
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  text-align: center;
}

.document-placeholder i.placeholder-icon {
  width: 48px;
  height: 48px;
  color: var(--accent);
}

.document-placeholder .placeholder-filename {
  font-size: 0.9rem;
  color: var(--text-secondary);
  word-break: break-all;
}

/* Textarea Consistency styling */
.modal-textarea {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  resize: vertical;
}

.modal-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(0 210 255 / 15%);
}

/* PIN Authentication Overlay Styles */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.auth-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.auth-card {
  background: rgba(19, 26, 46, 0.6);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius-lg);
  padding: 3rem 2.5rem;
  text-align: center;
  max-width: 380px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  transition: border-color 0.3s ease;
}

.auth-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.auth-logo-icon {
  width: 48px;
  height: 48px;
  color: var(--accent);
  filter: drop-shadow(0 0 8px rgba(0, 210, 255, 0.4));
}

.auth-logo h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 2.25rem;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.02em;
}

.auth-subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

.pin-dots {
  display: flex;
  justify-content: center;
  gap: 1.25rem;
  margin-bottom: 2.5rem;
}

.pin-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--text-muted);
  transition: all 0.15s ease;
}

.pin-dot.active {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(0, 210, 255, 0.6);
  transform: scale(1.15);
}

.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  justify-items: center;
  margin-bottom: 2rem;
}

.pin-key {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-primary);
  font-size: 1.5rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  outline: none;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.pin-key:hover {
  background: rgba(0, 210, 255, 0.08);
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(0, 210, 255, 0.2);
  transform: translateY(-2px);
}

.pin-key:active {
  transform: scale(0.92) translateY(0);
  background: rgba(0, 210, 255, 0.15);
}

.pin-key.text-btn {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.pin-key.text-btn:hover {
  color: var(--text-primary);
}

.pin-key.text-btn i {
  width: 22px;
  height: 22px;
}

.auth-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 1rem;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-10px); }
  40%, 80% { transform: translateX(10px); }
}

.auth-card.shake {
  animation: shake 0.4s ease;
  border-color: var(--danger) !important;
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.2);
}

/* Delete confirmation — reuses the login card design, but dims the app behind
   it and swaps the accent to danger red. */
.delete-confirm-overlay {
  background: rgb(2 6 16 / 72%);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 100001;
}

.delete-confirm-overlay .auth-logo-icon {
  color: var(--danger);
  filter: drop-shadow(0 0 8px rgb(239 68 68 / 40%));
}

.delete-confirm-overlay .auth-logo h2 {
  font-size: 1.75rem;
  background: linear-gradient(135deg, #ef4444, #f97316);
  -webkit-background-clip: text;
  background-clip: text;
}

.delete-confirm-overlay .auth-subtitle {
  margin-bottom: 1.5rem;
  font-weight: 500;
  color: var(--text-primary);
}

.delete-confirm-actions {
  display: flex;
  gap: 0.75rem;
}

.delete-confirm-actions .btn {
  flex: 1;
  justify-content: center;
}

/* Light Theme overrides for Auth Overlay */
body.light-theme .auth-overlay {
  background: #f8fafc;
}

body.light-theme .delete-confirm-overlay {
  background: rgb(148 163 184 / 45%);
}

body.light-theme .auth-card {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
}

body.light-theme .pin-dot {
  border-color: var(--text-secondary);
}

body.light-theme .pin-dot.active {
  background: var(--accent);
  border-color: var(--accent);
}

body.light-theme .pin-key {
  background: #fff;
  border-color: var(--border-color);
  color: #0f172a;
}

body.light-theme .pin-key:hover {
  background: rgba(2, 132, 199, 0.05);
  border-color: var(--accent);
}
/* ==========================================
   Tabbed settings: alias / routing-rule rows
   ========================================== */
.settings-rows {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.settings-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.settings-row input,
.settings-row select {
  flex: 1 1 180px;
  min-width: 140px;
}

.settings-row .btn-row-delete {
  flex: 0 0 auto;
}

.settings-row .settings-row-arrow {
  color: var(--text-muted);
  flex: 0 0 auto;
}

/* Full-width products row inside the detail modals: the image pane sits
   top-left, the editable fields top-right, and products span both columns. */
.view-grid > .view-products-pane,
.details-grid > .view-products-pane {
  grid-column: 1 / -1;
  min-width: 0;
}

/* On very narrow phones, prioritize the saved-document lists over capture UI. */
@media (width < 450px) {
  .capture-panel,
  .capture-panel.hidden {
    display: none !important;
  }
}
