/* Sage Intacct Theme for API Usage Application */
/* Based on Sage Intacct Partner Console design */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Sage Intacct color palette */
  --sage-green: #00854D;
  --sage-green-dark: #006B3F;
  --sage-green-light: #00A65A;
  --sage-teal: #008060;
  --header-bg: #2D2D2D;
  --header-secondary: #4A4A4A;
  --text-primary: #333333;
  --text-secondary: #666666;
  --text-muted: #6c757d;
  --border-color: #E0E0E0;
  --border-light: #F0F0F0;
  --bg-white: #FFFFFF;
  --bg-gray: #F5F5F5;
  --bg-page: #FAFAFA;
  --link-color: #008060;
  --error-red: #DC3545;
  --warning-orange: #B45309;
  --success-green: #28A745;
  --info-blue: #0056B3;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ========== HEADER ========== */
.app-header {
  background: var(--header-bg);
  color: white;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 15px;
}

.header-logo {
  height: 32px;
  width: auto;
}

.header-title {
  font-size: 16px;
  font-weight: 500;
  color: white;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.header-user {
  font-size: 14px;
  color: #ccc;
}

.header-help {
  color: #ccc;
  text-decoration: none;
  font-size: 14px;
}

.header-help:hover {
  color: white;
}

/* ========== SECONDARY NAV ========== */
.secondary-nav {
  background: var(--header-secondary);
  padding: 0 20px;
  display: flex;
  align-items: center;
}

/* ========== MAIN CONTAINER ========== */
.container {
  width: 80%;
  max-width: none;
  margin: 0 auto;
  padding: 20px 0;
  flex: 1;
}

/* Legacy banner - hide or style minimally */
.fusion-banner {
  display: none;
}

h1 {
  color: var(--text-primary);
  margin-bottom: 20px;
  font-size: 24px;
  font-weight: 500;
}

h2 {
  color: var(--text-primary);
  margin: 20px 0 15px;
  font-size: 18px;
  font-weight: 600;
}

h3 {
  color: var(--text-primary);
  margin: 15px 0 10px;
  font-size: 16px;
  font-weight: 600;
}

/* ========== CARDS ========== */
.card {
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: none;
}

.card > h3 {
  margin: 0 0 15px 0;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
  font-size: 1.1rem;
}

/* ========== FORM ELEMENTS ========== */
.form-group {
  margin-bottom: 15px;
}

label {
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
  color: var(--text-secondary);
  font-size: 14px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="time"],
input[type="date"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 14px;
  background: var(--bg-white);
  color: var(--text-primary);
  transition: border-color 0.2s ease;
  box-sizing: border-box;
  height: 36px;
  font-family: inherit;
}

textarea {
  height: auto;
  min-height: 80px;
  resize: vertical;
}

input[type="file"] {
  height: auto;
  padding: 8px;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="time"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--sage-green);
  box-shadow: 0 0 0 2px rgba(0, 133, 77, 0.15);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 15px;
}

.form-grid .form-group {
  margin-bottom: 0;
}

.form-section {
  margin-top: 15px;
}

.checkbox-align-bottom {
  display: flex;
  align-items: flex-end;
}

/* ========== TOGGLE SWITCH ========== */
.toggle-group {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
}

.toggle-group:last-child {
  border-bottom: none;
}

.toggle-label {
  flex: 1;
}

.toggle-label-text {
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.toggle-label .hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
}

.toggle-switch {
  position: relative;
  width: 50px;
  height: 26px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: 0.3s;
  border-radius: 26px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--sage-green);
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(24px);
}

.toggle-switch input:disabled + .toggle-slider {
  opacity: 0.5;
  cursor: not-allowed;
}

.toggle-switch.toggle-inline {
  display: inline-block;
  vertical-align: middle;
  margin-right: 8px;
}

.toggle-status {
  font-size: 0.8rem;
  min-width: 60px;
  text-align: right;
  transition: all 0.3s ease;
}

.toggle-status.saving {
  color: var(--warning-orange);
}

.toggle-status.saved {
  color: var(--success-green);
}

.toggle-status.error {
  color: var(--error-red);
}

/* Inline toggle with label on same line */
.toggle-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.toggle-inline .toggle-label {
  font-size: 14px;
  color: var(--text-secondary);
}

/* Toggle list for vertical list of toggles */
.toggle-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-gray);
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.toggle-row .toggle-label {
  font-weight: 500;
  color: var(--text-primary);
}

/* Proxy state indicator */
.proxy-collapsed {
  padding: 12px 16px;
  background: var(--bg-gray);
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.proxy-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--success-green);
  font-weight: 500;
}

.proxy-status .status-icon {
  font-size: 16px;
}

.proxy-state {
  margin-left: 4px;
  font-size: 13px;
  font-weight: normal;
}

.proxy-state.enabled {
  color: var(--success-green);
}

.proxy-state.disabled {
  color: var(--text-muted);
}

.status-none {
  margin: 0;
  color: var(--text-muted);
  font-style: italic;
}

/* ========== CHECKBOX ========== */
.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 5px;
}

.checkbox-group label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: normal;
}

.checkbox-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--sage-green);
}

.checkbox-group .hint {
  display: inline;
  margin-left: 8px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: normal;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: auto;
  margin: 0;
}

/* ========== FILE UPLOAD ========== */
.current-file {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 15px;
  border-radius: 4px;
  margin-top: 6px;
  margin-bottom: 10px;
}

.current-file.has-file {
  background: #E8F5E9;
  border: 1px solid var(--success-green);
}

.current-file.no-file {
  background: #FFEBEE;
  border: 1px solid var(--error-red);
}

.current-file .file-icon {
  font-size: 1.2em;
}

.current-file.has-file #currentFileName {
  font-weight: 600;
  color: #2E7D32;
}

.current-file.no-file #currentFileName {
  font-weight: 600;
  color: #C62828;
}

.current-file .file-size {
  color: var(--text-secondary);
  font-size: 0.9em;
}

#uploadMsg {
  display: inline-block;
  margin-top: 6px;
  margin-bottom: 2px;
}

.file-upload-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.file-upload-row input[type="file"] {
  flex: 1;
}

.file-upload-row button {
  flex-shrink: 0;
}

.api-source-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.api-source-row input[type="text"] {
  flex: 2;
  min-width: 200px;
}

.api-source-row input[type="password"] {
  flex: 1;
  min-width: 150px;
}

.api-source-row button {
  flex-shrink: 0;
}

/* Toggle Group for Source Selection */
.toggle-group {
  display: flex;
  gap: 0;
  margin-bottom: 15px;
}

.toggle-option {
  display: flex;
  align-items: center;
  cursor: pointer;
}

.toggle-option input[type="radio"] {
  display: none;
}

.toggle-option span {
  padding: 8px 20px;
  border: 1px solid var(--sage-green);
  background: white;
  color: var(--sage-green);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.toggle-option:first-child span {
  border-radius: 20px 0 0 20px;
}

.toggle-option:last-child span {
  border-radius: 0 20px 20px 0;
  border-left: none;
}

.toggle-option input[type="radio"]:checked + span {
  background: var(--sage-green);
  color: white;
}

.toggle-option:hover span {
  background: rgba(0, 133, 77, 0.1);
}

.toggle-option input[type="radio"]:checked + span:hover {
  background: var(--sage-green-dark);
}

/* ========== BUTTONS - Sage Intacct Pill Style ========== */
.button-group {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

.form-group-separated {
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid var(--border-color);
}

button {
  padding: 8px 20px;
  border: 1px solid var(--sage-green);
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  background: transparent;
  color: var(--sage-green);
}

button:hover {
  background: var(--sage-green);
  color: white;
}

button[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  border-color: #ccc;
  color: #999;
}

button[disabled]:hover {
  background: transparent;
  color: #999;
}

.btn-primary {
  background: transparent;
  color: var(--sage-green);
  border-color: var(--sage-green);
}

.btn-primary:hover {
  background: var(--sage-green);
  color: white;
}

.btn-secondary {
  background: transparent;
  color: var(--sage-green);
  border-color: var(--sage-green);
}

.btn-secondary:hover {
  background: var(--sage-green);
  color: white;
}

.btn-danger {
  background: transparent;
  color: var(--error-red);
  border-color: var(--error-red);
}

.btn-danger:hover {
  background: var(--error-red);
  color: white;
}

.btn-warning {
  background: transparent;
  color: var(--warning-orange);
  border-color: var(--warning-orange);
}

.btn-warning:hover {
  background: var(--warning-orange);
  color: white;
}

.btn-success {
  background: transparent;
  color: var(--success-green);
  border-color: var(--success-green);
}

.btn-success:hover {
  background: var(--success-green);
  color: white;
}

.btn-small {
  padding: 5px 14px;
  font-size: 13px;
  border-radius: 16px;
}

/* ========== TABS NAVIGATION ========== */
.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 0;
  background: var(--header-secondary);
  padding: 0 20px;
  position: sticky;
  top: 56px;
  z-index: 99;
}

.tab {
  padding: 12px 20px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #ccc;
  font-weight: 500;
  text-decoration: none;
  display: inline-block;
  font-size: 14px;
  border-radius: 0;
}

.tab:hover {
  background: rgba(255,255,255,0.1);
  color: white;
}

.tab.active {
  background: transparent;
  color: white;
  border-bottom-color: var(--sage-green);
}

/* Administration and Resources dropdowns */
.tab-dropdown {
  position: relative;
}

/* Push dropdowns to the right - only the first one needs margin-left: auto */
.tab-dropdown:not(.tab-dropdown ~ .tab-dropdown) {
  margin-left: auto;
}

.tab-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: 0 0 4px 4px;
  min-width: 180px;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.tab-dropdown-menu.show {
  display: block;
}

.tab-dropdown-item {
  padding: 10px 15px;
  cursor: pointer;
  color: var(--text-primary);
  transition: all 0.2s ease;
  display: block;
  text-decoration: none;
  font-size: 14px;
}

.tab-dropdown-item:hover {
  background: var(--bg-gray);
  color: var(--sage-green);
}

.tab-dropdown-item.active {
  background: rgba(0, 133, 77, 0.1);
  color: var(--sage-green);
  font-weight: 600;
}

.tab-dropdown-item:last-child {
  border-radius: 0 0 4px 4px;
}

.tab-dropdown-divider {
  height: 1px;
  background: var(--border-color);
  margin: 5px 0;
}

.tab-dropdown-item.logout-item {
  color: var(--error-red);
}

.tab-dropdown-item.logout-item:hover {
  background: rgba(220, 53, 69, 0.1);
}

/* Tab content */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ========== MESSAGES ========== */
.message {
  padding: 12px 15px;
  border-radius: 4px;
  margin: 15px 0;
  display: none;
  border: 1px solid;
}

.message.success {
  background: #E8F5E9;
  color: #2E7D32;
  border-color: #A5D6A7;
}

.message.error {
  background: #FFEBEE;
  color: #C62828;
  border-color: #EF9A9A;
}

.message.show {
  display: block;
}

/* Status messages */
.hint {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 15px;
}

.hint code {
  background-color: #E8F5E9;
  color: #2E7D32;
  padding: 2px 6px;
  border-radius: 3px;
}

.form-hint-block {
  display: block;
  margin-bottom: 15px;
}

.ok {
  color: #2E7D32;
}

.err {
  color: #C62828;
}

.warn {
  color: #F57C00;
}

.disclaimer {
  background: #FFF3E0;
  color: #E65100;
  border: 1px solid #FFCC80;
  padding: 10px 15px;
  border-radius: 4px;
  margin-bottom: 15px;
  font-size: 0.95rem;
}

/* ========== FILTER SELECT ========== */
.filter-select {
  margin-top: 20px;
}

.card.hidden {
  display: none;
}

.filter-select select {
  min-width: 300px;
  max-width: 100%;
}

/* ========== DATE INPUTS ========== */
.date-inputs {
  display: flex;
  gap: 15px;
  align-items: flex-end;
  margin: 15px 0;
  flex-wrap: wrap;
}

.date-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.date-group label {
  margin-bottom: 0;
}

.date-group input {
  width: 180px;
}

/* ========== ROW LAYOUT ========== */
.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 15px;
}

.grow {
  flex: 1 1 300px;
}

/* ========== LOG OUTPUT ========== */
#log {
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 13px;
  white-space: pre-wrap;
  background: #1E1E1E;
  color: #D4D4D4;
  padding: 16px;
  border-radius: 4px;
  max-height: 50vh;
  overflow-y: auto;
  border: 1px solid var(--border-color);
}

#log::-webkit-scrollbar {
  width: 10px;
}

#log::-webkit-scrollbar-track {
  background: #2D2D2D;
  border-radius: 4px;
}

#log::-webkit-scrollbar-thumb {
  background: #4A4A4A;
  border-radius: 4px;
}

#log::-webkit-scrollbar-thumb:hover {
  background: var(--sage-green);
}

/* ========== DOWNLOADS ========== */
.downloads-row {
  display: flex;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;
}

.download-format {
  display: flex;
  align-items: center;
  gap: 8px;
}

.download-format select {
  width: auto;
  min-width: 140px;
}

.links-bottom {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ========== TABLES - Sage Intacct Style ========== */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}

th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

th {
  background: var(--bg-gray);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

tr:hover {
  background: var(--bg-gray);
}

.tablewrap {
  overflow-x: auto;
}

/* Data table (filters table) */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 15px;
  table-layout: fixed;
}

.data-table th {
  background: var(--bg-gray);
  color: var(--text-primary);
  font-weight: 600;
  padding: 10px 12px;
  text-align: left;
  font-size: 13px;
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background: var(--bg-gray);
}

/* Column widths */
.data-table .col-order,
.data-table .filter-order-cell {
  width: 60px;
  text-align: center;
}

.data-table .col-name,
.data-table .filter-name-cell {
  width: 120px;
}

.data-table .col-prefix,
.data-table .filter-prefix-cell {
  width: 80px;
}

.data-table .col-actions,
.data-table .filter-actions-cell {
  width: 150px;
  text-align: right;
  white-space: nowrap;
}

/* Cell styles */
.data-table .filter-order-cell {
  font-weight: 500;
}

.data-table .filter-name-cell {
  font-weight: 500;
}

.data-table .filter-prefix-cell {
  font-family: monospace;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.data-table .filter-text-cell {
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-table .filter-actions-cell {
  white-space: nowrap;
}

.data-table .filter-actions-cell button,
.data-table .col-actions button {
  margin-left: 5px;
}

#notifConfigsTable,
#schedTable {
  table-layout: auto;
}

/* Table action links - Sage style */
.table-link {
  color: var(--sage-teal);
  text-decoration: none;
  cursor: pointer;
  font-size: 13px;
  margin-right: 10px;
}

.table-link:hover {
  text-decoration: underline;
}

/* ========== STATUS BADGES ========== */
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.status-success {
  background: #E8F5E9;
  color: #2E7D32;
}

.status-error {
  background: #FFEBEE;
  color: #C62828;
}

.status-pending {
  background: #FFF3E0;
  color: #E65100;
}

.status-disabled {
  background: #ECEFF1;
  color: #607D8B;
}

.status-running {
  background: #E3F2FD;
  color: #1565C0;
  animation: pulse 1.5s ease-in-out infinite;
}

.status-stopped {
  background: #FFF8E1;
  color: #F57C00;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ========== FILTER BREAKDOWN ========== */
#filterBreakdownSection {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

#filterBreakdownSection h3 {
  margin-bottom: 10px;
}

.breakdown-container {
  max-width: 50%;
}

#filterBreakdownTable tfoot {
  font-weight: 600;
  background: var(--bg-gray);
}

#filterBreakdownTable tfoot td {
  border-top: 2px solid var(--sage-green);
}

@media (max-width: 768px) {
  .breakdown-container {
    max-width: 100%;
  }
}

/* ========== SECTION HEADER ========== */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  flex-wrap: wrap;
  gap: 10px;
}

.section-header h2 {
  margin: 0;
}

.section-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Form header for multi-card forms */
.form-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--border-color);
}

.form-header h2 {
  margin: 0;
  font-size: 1.4rem;
}

/* ========== COLLAPSIBLE SECTIONS ========== */
.creds-collapsed,
.settings-collapsed,
.filters-collapsed {
  padding: 12px 16px;
  background: var(--bg-gray);
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.creds-status,
.settings-status,
.filters-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--success-green);
  font-weight: 500;
}

.creds-status .status-icon,
.settings-status .status-icon,
.filters-status .status-icon {
  font-size: 16px;
}

/* ========== CHARTS ========== */
canvas {
  max-width: 100%;
  outline: none;
}

/* ========== FILTER ITEMS ========== */
.filter-item {
  background: var(--bg-gray);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 15px;
  margin-bottom: 15px;
  transition: all 0.2s ease;
}

.filter-item:hover {
  border-color: var(--sage-green);
}

.filter-item.editing {
  background: var(--bg-white);
  border-color: var(--sage-green);
}

.filter-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
  gap: 10px;
}

.filter-header h3 {
  margin: 0;
}

.filter-id {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-family: monospace;
  margin-top: 2px;
}

.filter-text {
  font-family: monospace;
  font-size: 0.9rem;
  background: #ECEFF1;
  padding: 10px;
  border-radius: 4px;
  white-space: pre-wrap;
  word-break: break-all;
  border: 1px solid var(--border-color);
}

.filter-actions {
  display: flex;
  gap: 10px;
  margin-top: 15px;
}

.add-filter-form {
  display: none;
  margin-bottom: 20px;
}

.add-filter-form.visible {
  display: block;
}

/* ========== NAV LINK ========== */
.nav-link {
  color: var(--sage-teal);
  text-decoration: none;
}

.nav-link:hover {
  text-decoration: underline;
}

/* ========== VERSION BADGE ========== */
.version-badge {
  font-size: 0.5em;
  background: var(--bg-gray);
  padding: 0.2em 0.6em;
  border-radius: 4px;
  vertical-align: middle;
  font-weight: normal;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

/* ========== EDIT FORM ========== */
.edit-form {
  margin-top: 1rem;
}

/* ========== MODAL ========== */
.modal {
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s;
}

.modal.hidden {
  display: none;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.4);
}

.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  position: relative;
  z-index: 1001;
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 24px;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  animation: slideIn 0.3s;
}

.modal-buttons {
  justify-content: flex-end;
}

.modal-header {
  display: flex;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-body {
  margin-bottom: 20px;
  line-height: 1.6;
  color: var(--text-primary);
  overflow-y: auto;
}

.modal-body p + p {
  margin-top: 15px;
}

.modal-footer {
  text-align: right;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

.clear-warning-list {
  margin: 10px 0 10px 20px;
  line-height: 1.6;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideIn {
  from {
    transform: translateY(-30px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ========== LOADING & EMPTY STATES ========== */
.loading {
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  padding: 20px;
}

.empty-state {
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  padding: 40px 20px;
}

/* ========== LOGS VIEWER ========== */
.log-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 15px;
}

.log-controls select {
  min-width: 200px;
}

/* Pill group styling for log controls */
.log-controls .view-toggle {
  display: inline-flex;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--sage-green);
}

.log-controls .view-toggle button {
  padding: 6px 16px;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--sage-green);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 13px;
  font-weight: 500;
}

.log-controls .view-toggle button:hover {
  background: rgba(0, 133, 77, 0.1);
}

.log-controls .view-toggle button.active {
  background: var(--sage-green);
  color: white;
}

/* Pill group for log level filters */
.log-filters {
  display: inline-flex;
  margin-bottom: 15px;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--sage-green);
}

.filter-btn {
  padding: 6px 14px;
  border: none;
  background: transparent;
  color: var(--sage-green);
  cursor: pointer;
  transition: all 0.2s;
  border-radius: 0;
  font-size: 13px;
  font-weight: 500;
  border-right: 1px solid var(--sage-green);
}

.filter-btn:last-child {
  border-right: none;
}

.filter-btn:hover:not(.active) {
  background: rgba(0, 133, 77, 0.25);
  color: var(--sage-green-dark);
}

.filter-btn.active {
  background: var(--sage-green-dark);
  color: white;
  border-color: var(--sage-green-dark);
}

.log-auto-refresh {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.log-info {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.log-viewer {
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 13px;
  background: #1E1E1E;
  color: #D4D4D4;
  padding: 16px;
  border-radius: 4px;
  max-height: 60vh;
  overflow-y: auto;
  border: 1px solid var(--border-color);
}

.log-viewer::-webkit-scrollbar {
  width: 10px;
}

.log-viewer::-webkit-scrollbar-track {
  background: #2D2D2D;
  border-radius: 4px;
}

.log-viewer::-webkit-scrollbar-thumb {
  background: #4A4A4A;
  border-radius: 4px;
}

.log-viewer::-webkit-scrollbar-thumb:hover {
  background: var(--sage-green);
}

.log-viewer .empty-state {
  color: var(--text-muted);
}

.log-entry {
  display: flex;
  gap: 12px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.log-entry:last-child {
  border-bottom: none;
}

.log-timestamp {
  color: #888;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 160px;
}

.log-level {
  font-weight: bold;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 50px;
}

.log-level.info {
  color: #4FC3F7;
}

.log-level.warn {
  color: #FFA726;
}

.log-level.error {
  color: #EF5350;
}

.log-level.debug {
  color: #9E9E9E;
}

.log-message {
  color: #D4D4D4;
  word-break: break-word;
}

/* ========== MANAGE COMPANIES ========== */
.btn-manage {
  margin-left: auto;
}

.add-company-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.add-company-row input[type="text"] {
  flex: 1;
  height: 36px;
}

.add-company-row button {
  width: 52px;
  height: 28px;
  padding: 0;
  font-size: 11px;
  line-height: 26px;
}

.company-list {
  max-height: 350px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: 4px;
}

.company-list .empty-state {
  padding: 20px;
}

.company-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.15s;
}

.company-item:last-child {
  border-bottom: none;
}

.company-item:hover {
  background: var(--bg-gray);
}

.company-name {
  font-weight: 500;
  color: var(--text-primary);
}

.btn-remove {
  min-width: 28px;
  height: 28px;
  padding: 0;
  line-height: 28px;
  text-align: center;
  font-size: 16px;
  border-radius: 4px;
}

#companyModalMsg,
#exceptionsModalMsg {
  margin-top: 10px;
  font-size: 0.9rem;
}

.company-item-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.btn-skip,
.btn-unskip {
  width: 52px;
  height: 28px;
  padding: 0;
  line-height: 26px;
  text-align: center;
  font-size: 11px;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-skip {
  background: transparent;
  color: var(--sage-green);
  border: 1px solid var(--sage-green);
}

.btn-skip:hover {
  background: var(--sage-green);
  color: white;
}

.btn-unskip {
  background: var(--sage-green);
  color: white;
  border: 1px solid var(--sage-green);
}

.btn-unskip:hover {
  background: var(--sage-green-dark);
  border-color: var(--sage-green-dark);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 6px;
  border-radius: 9px;
  background: var(--error-red);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  vertical-align: middle;
}

/* Badge inside button - ensure proper alignment */
button .badge {
  margin-left: 8px;
  position: relative;
  top: 0;
}

.exceptions-hint {
  margin-bottom: 12px;
}

/* ========== ERROR SUMMARY ========== */
#errorSummaryTable .col-count {
  width: 100px;
  text-align: center;
}

#errorSummaryTable .col-actions {
  width: 80px;
  text-align: right;
}

#errorSummaryTable tfoot {
  font-weight: 600;
  background: var(--bg-gray);
}

#errorSummaryTable tfoot td {
  border-top: 2px solid var(--sage-green);
}

#errorCompaniesModal .modal-content {
  max-width: 650px;
}

#errorCompaniesModal .modal-body {
  padding: 0;
}

#errorCompaniesModal .modal-description {
  padding: 0 5px 10px;
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

#errorCompaniesModal table {
  margin-top: 0;
}

#errorCompaniesModal table th {
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  position: relative;
  padding-right: 22px;
}

#errorCompaniesModal table th:hover {
  background: #E0E0E0;
}

#errorCompaniesModal table th .sort-icon {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  opacity: 0.6;
}

#errorCompaniesModal table th .sort-icon.active {
  opacity: 1;
}

/* ========== STATUS MODAL ========== */
.status-modal-content {
  max-width: 400px;
  text-align: center;
}

.status-modal-content .modal-header {
  justify-content: center;
  border-bottom: none;
  padding-bottom: 0;
}

.status-modal-content .modal-title {
  font-size: 20px;
}

.status-modal-content .modal-body {
  padding: 20px 0;
}

.status-modal-content .modal-footer {
  border-top: none;
  padding-top: 0;
  text-align: center;
}

.status-modal-content.status-success .modal-title {
  color: var(--sage-green);
}

.status-modal-content.status-error .modal-title {
  color: var(--error-red);
}

.status-modal-content.status-warning .modal-title {
  color: var(--warning-orange);
}

.status-modal-content.status-info .modal-title {
  color: var(--info-blue);
}

/* Status icon before title */
.status-modal-content .status-icon {
  font-size: 48px;
  margin-bottom: 10px;
  display: block;
}

.status-modal-content.status-success .status-icon::before {
  content: "\2713";
  color: var(--sage-green);
}

.status-modal-content.status-error .status-icon::before {
  content: "\2717";
  color: var(--error-red);
}

.status-modal-content.status-warning .status-icon::before {
  content: "\26A0";
  color: var(--warning-orange);
}

.status-modal-content.status-info .status-icon::before {
  content: "\2139";
  color: var(--info-blue);
}

/* ========== CONFIRM MODAL ========== */
.confirm-modal-content {
  max-width: 400px;
}

.confirm-modal-content .modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ========== USER GUIDE ========== */
.guide-intro {
  font-size: 1.1em;
  color: var(--text-secondary);
}

.guide-toc {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.guide-toc li {
  margin: 0;
}

.guide-toc a {
  display: inline-block;
  padding: 8px 16px;
  border: 1px solid var(--sage-green);
  border-radius: 20px;
  color: var(--sage-green);
  text-decoration: none;
  transition: all 0.2s ease;
}

.guide-toc a:hover {
  background: var(--sage-green);
  color: white;
}

#guide-tab h3 {
  color: var(--sage-green);
  border-bottom: 2px solid var(--sage-green);
  padding-bottom: 8px;
  margin-top: 0;
}

#guide-tab h4 {
  color: var(--text-primary);
  margin-top: 20px;
  margin-bottom: 10px;
}

#guide-tab h5 {
  color: var(--text-primary);
  margin-bottom: 5px;
}

#guide-tab ul,
#guide-tab ol {
  margin-left: 20px;
  margin-bottom: 15px;
}

#guide-tab li {
  margin-bottom: 8px;
  line-height: 1.5;
}

#guide-tab code {
  background: var(--bg-gray);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.9em;
}

.guide-table {
  width: 100%;
  border-collapse: collapse;
  margin: 15px 0;
}

.guide-table th,
.guide-table td {
  padding: 10px 12px;
  text-align: left;
  border: 1px solid var(--border-color);
}

.guide-table th {
  background: var(--bg-gray);
  font-weight: 600;
}

.guide-table tr:hover {
  background: var(--bg-gray);
}

.guide-issue {
  background: var(--bg-gray);
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 15px;
  border-left: 4px solid var(--sage-green);
}

.guide-issue h5 {
  margin-top: 0;
  color: var(--error-red);
}

.guide-issue p:last-child {
  margin-bottom: 0;
}

.guide-code {
  background: var(--bg-dark);
  color: var(--text-light);
  padding: 10px 15px;
  border-radius: 6px;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 13px;
  overflow-x: auto;
  margin: 10px 0;
}

/* ========== HIDDEN UTILITY ========== */
.hidden {
  display: none !important;
}

/* ========== ABOUT PAGE ========== */
.about-section {
  margin-bottom: 30px;
}

.about-section:last-child {
  margin-bottom: 0;
}

.about-section p {
  margin-bottom: 5px;
}

.about-section h3 {
  margin-bottom: 10px;
}

.about-section.copyright {
  text-align: center;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
  margin-top: 30px;
}

.about-section.copyright p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.muted {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 10px;
}

/* ========== FOOTER ========== */
.app-footer {
  background: var(--header-bg);
  color: #ccc;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  margin-top: auto;
}

.footer-left {
  display: flex;
  align-items: center;
  gap: 20px;
}

.footer-link {
  color: #ccc;
  text-decoration: none;
}

.footer-link:hover {
  color: white;
}

.footer-right {
  display: flex;
  align-items: center;
  gap: 15px;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.footer-logo {
  height: 20px;
}

/* ========== MOBILE NAVIGATION ========== */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-white);
  border-top: 1px solid var(--border-color);
  z-index: 1000;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
  padding-bottom: env(safe-area-inset-bottom);
}

.mobile-nav-container {
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 8px 0;
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 16px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  transition: all 0.2s ease;
  border-radius: 8px;
  cursor: pointer;
  min-width: 60px;
}

.mobile-nav-item:hover {
  background: rgba(0, 133, 77, 0.1);
  color: var(--sage-green);
}

.mobile-nav-item.active {
  color: var(--sage-green);
  font-weight: 600;
}

.mobile-nav-icon {
  font-size: 22px;
  line-height: 1;
}

.mobile-more-menu {
  display: none;
  position: absolute;
  bottom: 100%;
  right: 10px;
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
  min-width: 180px;
}

.mobile-more-menu.show {
  display: block;
}

.mobile-more-item {
  display: block;
  padding: 12px 16px;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mobile-more-item:hover {
  background: rgba(0, 133, 77, 0.1);
  color: var(--sage-green);
}

/* ========== MOBILE RESPONSIVE ========== */
@media (max-width: 768px) {
  body {
    padding: 0;
  }

  .container {
    padding: 15px;
  }

  /* Hide desktop tabs on mobile */
  .tabs {
    display: none;
  }

  /* Show mobile bottom nav */
  .mobile-nav {
    display: block;
  }

  /* Add padding for bottom nav */
  .container {
    padding-bottom: 80px;
  }

  /* Hide footer on mobile */
  .app-footer {
    display: none;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .date-inputs {
    flex-direction: column;
    align-items: stretch;
  }

  .date-group input {
    width: 100%;
  }

  .button-group {
    flex-direction: column;
  }

  .button-group button {
    width: 100%;
  }

  .filter-select select {
    min-width: 100%;
  }

  .log-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .log-controls select {
    min-width: 100%;
  }

  .log-filters {
    justify-content: center;
  }

  .log-entry {
    flex-direction: column;
    gap: 4px;
  }

  .log-timestamp {
    min-width: auto;
    font-size: 0.85em;
  }

  .log-level {
    min-width: auto;
  }

  .downloads-row {
    flex-direction: column;
    align-items: stretch;
  }

  .download-format {
    justify-content: stretch;
  }

  .download-format select {
    flex: 1;
    min-width: 0;
  }

  .links-bottom {
    flex-direction: column;
  }

  .links-bottom button {
    width: 100%;
  }

  #errorSummaryTable .col-count {
    width: 60px;
  }

  #errorSummaryTable .col-actions {
    width: 60px;
  }

  #errorCompaniesModal .modal-content {
    max-width: 95%;
    padding: 20px;
  }
}
