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

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-border: #bfdbfe;

  --success: #059669;
  --success-light: #ecfdf5;
  --success-border: #a7f3d0;

  --warning: #d97706;
  --warning-light: #fffbeb;
  --warning-border: #fde68a;

  --danger: #dc2626;
  --danger-light: #fef2f2;
  --danger-border: #fecaca;

  --bg-page: #f8fafc;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  --border-color: #e2e8f0;
  --border-focus: #3b82f6;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.07);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.08);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-heading: 'Outfit', 'Inter', sans-serif;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Container */
.container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 28px;
}

/* Header */
.app-header {
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  padding: 16px 28px;
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo-badge {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #1e40af, #3b82f6);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 20px;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
}

.brand-title {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.company-select-header {
  padding: 6px 12px;
  font-size: 13.5px;
  font-weight: 600;
  color: #1e293b;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-md);
  outline: none;
  cursor: pointer;
  transition: all 0.15s ease;
}
.company-select-header:hover, .company-select-header:focus {
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.brand-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

.brand-sep {
  color: var(--text-light);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
}

.badge-env-prod {
  background-color: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.badge-env-sandbox {
  background-color: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}

.badge-transmitted {
  background-color: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

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

.badge-cancelled {
  background-color: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.badge-active {
  background-color: #f1f5f9;
  color: #475569;
}

.sync-status {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.btn-primary {
  background-color: var(--primary);
  color: white;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.2);
}
.btn-primary:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-outline {
  background-color: white;
  color: #334155;
  border-color: var(--border-color);
}
.btn-outline:hover {
  background-color: var(--bg-subtle);
  color: #0f172a;
  border-color: #cbd5e1;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

/* KPI Cards Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
}

.kpi-card.card-sales::before { background: linear-gradient(90deg, #10b981, #059669); }
.kpi-card.card-expenses::before { background: linear-gradient(90deg, #3b82f6, #1d4ed8); }
.kpi-card.card-vat::before { background: linear-gradient(90deg, #f59e0b, #d97706); }
.kpi-card.card-balance::before { background: linear-gradient(90deg, #8b5cf6, #6d28d9); }

.kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.kpi-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.kpi-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.icon-sales { background: var(--success-light); color: var(--success); }
.icon-expenses { background: var(--primary-light); color: var(--primary); }
.icon-vat { background: var(--warning-light); color: var(--warning); }
.icon-balance { background: #f5f3ff; color: #7c3aed; }

.kpi-value {
  font-family: var(--font-heading);
  font-size: 26px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
  margin-bottom: 8px;
}

.kpi-subtext {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.kpi-subtext strong {
  color: var(--text-main);
}

/* Main Dashboard Panel */
.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

/* Tabs */
.tabs-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  background: #ffffff;
  padding: 0 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.tabs-group {
  display: flex;
  gap: 4px;
}

.tab-btn {
  padding: 16px 20px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s ease;
}

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

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

.tab-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  color: var(--text-muted);
}

.tab-btn.active .tab-pill {
  background: var(--primary-light);
  color: var(--primary);
}

/* Filters bar */
.filter-bar {
  padding: 18px 20px;
  background: #fafbfc;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
}

.filter-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  flex: 1;
}

.search-box {
  position: relative;
  min-width: 280px;
  flex: 1;
  max-width: 420px;
}

.search-input {
  width: 100%;
  padding: 9px 14px 9px 38px;
  font-size: 14px;
  font-family: inherit;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: #ffffff;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  pointer-events: none;
  font-size: 14px;
}

.select-control {
  padding: 9px 14px;
  font-size: 14px;
  font-family: inherit;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: #ffffff;
  color: var(--text-main);
  outline: none;
  cursor: pointer;
  min-width: 140px;
}

.select-control:focus {
  border-color: var(--border-focus);
}

.filter-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Results summary bar */
.results-summary {
  padding: 12px 20px;
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
}

/* Table Container */
.table-responsive {
  overflow-x: auto;
  position: relative;
  min-height: 250px;
}

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

.data-table thead th {
  background: #f8fafc;
  color: #475569;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  user-select: none;
}

.data-table thead th.sortable {
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.data-table thead th.sortable:hover {
  background: #f1f5f9;
  color: var(--text-main);
}

.data-table thead th.sortable .sort-icon {
  display: inline-block;
  margin-left: 5px;
  font-size: 11px;
  opacity: 0.45;
  transition: opacity 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.data-table thead th.sortable:hover .sort-icon {
  opacity: 0.85;
}

.data-table thead th.sorted-asc,
.data-table thead th.sorted-desc {
  color: var(--primary) !important;
  background: #eff6ff !important;
}

.data-table thead th.sorted-asc .sort-icon,
.data-table thead th.sorted-desc .sort-icon {
  opacity: 1 !important;
  color: var(--primary) !important;
  font-weight: 700;
}

.data-table tbody tr {
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.15s ease;
}

.data-table tbody tr:hover {
  background-color: #f8fafc;
}

.data-table tbody td {
  padding: 14px 16px;
  vertical-align: middle;
}

.cell-doc {
  display: flex;
  flex-direction: column;
}

.cell-doc-number {
  font-weight: 600;
  color: var(--text-main);
}

.cell-doc-mark {
  font-size: 11.5px;
  color: var(--text-muted);
  font-family: monospace;
}

.cell-party {
  display: flex;
  flex-direction: column;
  max-width: 240px;
}

.cell-party-name {
  font-weight: 500;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cell-party-vat {
  font-size: 12px;
  color: var(--text-muted);
}

.cell-number {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cell-net {
  font-weight: 600;
}

.cell-gross {
  font-weight: 700;
  color: #0f172a;
}

/* Pagination */
.pagination-bar {
  padding: 16px 20px;
  background: #ffffff;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.pagination-info {
  font-size: 13px;
  color: var(--text-muted);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.page-btn {
  padding: 6px 12px;
  border: 1px solid var(--border-color);
  background: #ffffff;
  color: var(--text-main);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.page-btn:hover:not(:disabled) {
  background: var(--bg-subtle);
  border-color: #cbd5e1;
}

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

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

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.open {
  display: flex;
  animation: fadeIn 0.2s ease-out;
}

.modal-dialog {
  background: #ffffff;
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.2s ease-out;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
}

.modal-title {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-light);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.modal-close-btn:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-section {
  margin-bottom: 24px;
}

.modal-section-title {
  font-size: 14px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.info-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.info-card {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.info-card-label {
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.info-card-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}

.raw-json-viewer {
  background: #0f172a;
  color: #f1f5f9;
  padding: 16px;
  border-radius: var(--radius-md);
  font-family: monospace;
  font-size: 12px;
  max-height: 250px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 0.8s ease-in-out infinite;
}

.spinner-dark {
  border: 2px solid rgba(0, 0, 0, 0.15);
  border-top-color: var(--primary);
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: #0f172a;
  color: white;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideInRight 0.25s ease-out;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 40px;
  margin-bottom: 12px;
  color: var(--text-light);
}

.empty-state-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

/* Wizard style enhancements */
.wizard-box {
  max-width: 650px;
  margin: 40px auto;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-md);
}

.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #334155;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: inherit;
}

.form-input:focus {
  border-color: var(--border-focus);
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-help {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

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

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

@media (max-width: 768px) {
  .container {
    padding: 16px;
  }
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .search-box {
    max-width: none;
  }
}

/* Header Navigation Tabs */
.nav-tabs-wrapper {
  max-width: 1440px;
  margin: 14px auto -16px auto;
  border-top: 1px solid var(--border-color);
  padding-top: 8px;
}

.nav-tabs-container {
  display: flex;
  gap: 8px;
}

/* Back-to-top button of the pinned tab strip, mobile only */
.nav-top-btn {
  display: none;
}

.nav-tab-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  border-bottom: 2px solid transparent;
  transition: all 0.15s ease;
}

.nav-tab-item:hover {
  color: var(--primary);
  background-color: #f8fafc;
}

.nav-tab-item.active {
  color: var(--primary);
  border-bottom: 2px solid var(--primary);
  background-color: var(--primary-light);
}

/* KPI Cards entities styling */
.kpi-card.card-entities::before { background: linear-gradient(90deg, #6366f1, #4f46e5); }
.kpi-icon.icon-entities { background: #e0e7ff; color: #4338ca; }

/* Role Badges */
.badge-role {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
}

.badge-client {
  background-color: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

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

.badge-both {
  background-color: #f3e8ff;
  color: #7e22ce;
  border: 1px solid #d8b4fe;
}

.party-afm-link {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  transition: color 0.15s;
}

.party-afm-link:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}


/* Account & data policy link, bottom right on every page */
body {
  padding-bottom: 56px;
}

.app-footer-pill {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100vw - 32px);
  padding: 7px 14px;
  font-size: 12.5px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-md);
}

.app-footer-pill a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.app-footer-pill a:hover {
  text-decoration: underline;
}

.app-footer-user {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-footer-logout button {
  font: inherit;
  color: #334155;
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
}

.app-footer-sep {
  color: var(--text-light);
}

.app-footer-version {
  white-space: nowrap;
}

/* Accuracy note at the top of the data pages */
.data-disclaimer {
  padding: 10px 14px;
  margin-bottom: 20px;
  font-size: 13px;
  line-height: 1.5;
  color: #92400e;
  background: var(--warning-light);
  border: 1px solid var(--warning-border);
  border-radius: var(--radius-md);
}

.data-disclaimer.info {
  color: #1e40af;
  background: var(--primary-light);
  border-color: var(--primary-border);
}

/* Sign-in & data policy pages */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: #f1f5f9;
}

.google-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 600;
  color: #1f2937;
  text-decoration: none;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.google-btn:hover {
  background: #f9fafb;
  border-color: #9ca3af;
}

.policy-page {
  max-width: 820px;
  margin: 0 auto;
  padding: 32px 20px;
}

.policy-page h1 {
  font-family: var(--font-heading);
  font-size: 26px;
  margin-bottom: 6px;
}

.policy-page h2 {
  font-family: var(--font-heading);
  font-size: 18px;
  margin: 28px 0 10px;
}

.policy-page p,
.policy-page li {
  font-size: 14.5px;
  color: #334155;
  line-height: 1.7;
}

.policy-page ul {
  padding-left: 20px;
  margin: 8px 0;
}

.policy-page code {
  font-size: 13px;
  background: var(--bg-subtle);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
}

.policy-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-top: 16px;
}

.policy-notice {
  padding: 12px 16px;
  margin-top: 16px;
  font-size: 14px;
  border-radius: var(--radius-md);
}

.policy-notice.success {
  color: var(--success);
  background: var(--success-light);
  border: 1px solid var(--success-border);
}

.policy-notice.error {
  color: var(--danger);
  background: var(--danger-light);
  border: 1px solid var(--danger-border);
}

/* Company credit & about page */
.app-footer-credit {
  color: #334155 !important;
}

.company-credit {
  display: block;
  margin-top: 20px;
  padding-top: 16px;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  border-top: 1px solid var(--border-color);
}

.company-credit strong {
  color: var(--text-main);
}

.company-credit a {
  text-decoration: none;
}

.company-credit a:hover strong,
.company-credit-more:hover {
  text-decoration: underline;
}

.company-credit-more {
  display: block;
  margin-top: 4px;
  color: var(--primary);
  font-weight: 600;
}

.about-hero {
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  color: #ffffff;
  border-radius: var(--radius-lg);
  padding: 28px 28px 26px;
  margin: 16px 0 8px;
}

.about-hero h1 {
  color: #ffffff;
  margin: 0 0 8px;
}

.about-hero p {
  color: #dbeafe !important;
  margin: 0;
  font-size: 15.5px !important;
}

.about-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
  margin-top: 12px;
}

.about-grid .policy-card {
  margin-top: 0;
  padding: 18px 20px;
}

.about-grid h3 {
  font-family: var(--font-heading);
  font-size: 16px;
  margin: 6px 0 6px;
}

.about-grid p {
  margin: 0;
  font-size: 14px !important;
}

.about-icon {
  font-size: 22px;
}

.about-page {
  padding-bottom: 88px;
}

/* Suggestions button & form */
.feedback-fab {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 31;
  padding: 9px 16px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: #ffffff;
  background: var(--primary);
  border: none;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg);
  cursor: pointer;
}

.feedback-fab:hover {
  background: var(--primary-hover);
}

.feedback-dialog {
  width: min(480px, calc(100vw - 32px));
  padding: 22px 24px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
}

.feedback-dialog::backdrop {
  background: rgb(15 23 42 / 0.45);
}

.feedback-dialog h2 {
  font-family: var(--font-heading);
  font-size: 19px;
  margin: 0 0 6px;
}

.feedback-hint {
  font-size: 13.5px;
  color: var(--text-muted);
  margin: 0 0 10px;
}

.feedback-dialog label {
  display: block;
  margin-top: 10px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}

.feedback-dialog input,
.feedback-dialog textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 9px 11px;
  font: inherit;
  font-size: 14px;
  font-weight: 400;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  resize: vertical;
}

.feedback-dialog input:focus,
.feedback-dialog textarea:focus {
  outline: none;
  border-color: var(--border-focus);
}

.feedback-dialog .feedback-hp {
  position: absolute;
  left: -9999px;
}

.feedback-status {
  min-height: 20px;
  margin-top: 10px;
  font-size: 13.5px;
  color: var(--text-muted);
}

.feedback-status.success {
  color: var(--success);
}

.feedback-status.error {
  color: var(--danger);
}

.feedback-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.about-hero-title {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 10px;
}

.about-hero-title h1 {
  margin: 0;
}

.about-hero-title img {
  flex-shrink: 0;
  border-radius: 50%;
  border: 2px solid rgb(255 255 255 / 0.6);
}

.company-credit img {
  display: block;
  margin: 0 auto 6px;
  border-radius: 50%;
}

.about-hero-link {
  display: flex;
  align-items: center;
  gap: 16px;
  color: inherit;
  text-decoration: none;
}

.about-hero-link:hover h1 {
  text-decoration: underline;
}

/* myDATA sync progress */
.sync-progress {
  background: var(--bg-card);
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 12px 16px;
  margin-bottom: 16px;
}
.sync-progress[hidden] { display: none; }
.sync-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 600;
  color: var(--text-main);
}
.sync-progress-track {
  height: 8px;
  background: var(--bg-subtle);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin: 10px 0 6px;
}
.sync-progress-bar {
  height: 100%;
  width: 0;
  background: var(--primary);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}
.sync-progress.is-error { border-color: var(--danger-border); }
.sync-progress.is-error .sync-progress-bar { background: var(--danger); }
.sync-progress.is-done .sync-progress-bar { background: var(--success); }
.sync-progress-detail {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Mobile layout: nothing but the tab strip stays pinned, so the data keeps the screen */
@media (max-width: 768px) {
  /* The header box dissolves: its top part scrolls with the page, its tab strip sticks */
  .app-header {
    display: contents;
  }

  .header-inner {
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 10px;
    padding: 10px 16px;
    background: #ffffff;
  }

  /* Logo and title share a row, the company picker takes the full width below them */
  .brand-section {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 4px 10px;
  }
  .brand-section > div:last-child {
    display: contents;
  }
  .brand-section .brand-logo-badge {
    width: 32px;
    height: 32px;
    font-size: 15px;
    border-radius: var(--radius-sm);
  }
  .brand-title {
    flex-wrap: wrap;
    gap: 4px 6px;
    font-size: 16px;
  }
  .brand-title .badge {
    padding: 3px 7px;
    font-size: 10.5px;
  }
  .brand-subtitle {
    grid-column: 1 / -1;
    font-size: 12px;
  }
  .brand-sep {
    display: none;
  }
  .company-select-header {
    flex: 1 1 100%;
    min-width: 0;
    padding: 8px 10px;
  }

  /* Action buttons: one row, swiped sideways */
  .header-actions {
    flex-wrap: nowrap;
    gap: 8px;
    margin: 0 -16px;
    padding: 2px 16px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }
  .header-actions::-webkit-scrollbar {
    display: none;
  }
  .header-actions .btn,
  .header-actions .btn-group {
    flex: 0 0 auto;
    white-space: nowrap;
  }
  .header-actions .btn {
    padding: 8px 12px;
  }

  /* Pinned tab strip, icons only */
  .nav-tabs-wrapper {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: none;
    margin: 0;
    padding: 0 16px;
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
  }
  .nav-tabs-container {
    flex: 1;
    gap: 4px;
    min-width: 0;
  }
  .nav-tab-item {
    flex: 1;
    justify-content: center;
    padding: 9px 0;
    font-size: 19px;
    line-height: 1.3;
    border-radius: 0;
  }

  /* The title, shrunk to an icon once it has scrolled out of view (.is-stuck, mobileHeader.js) */
  .nav-top-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    margin-left: -42px;
    padding: 0;
    font-size: 16px;
    color: #ffffff;
    background: linear-gradient(135deg, #1e40af, #3b82f6);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: scale(0.6);
    transition: margin-left 0.2s ease, opacity 0.2s ease, transform 0.2s ease, visibility 0s linear 0.2s;
  }
  .nav-top-btn::after {
    content: '↑';
    position: absolute;
    right: -5px;
    bottom: -4px;
    width: 15px;
    height: 15px;
    font-size: 10px;
    font-weight: 700;
    line-height: 13px;
    color: var(--primary);
    background: #ffffff;
    border: 1px solid var(--primary-border);
    border-radius: 50%;
  }
  .nav-tabs-wrapper.is-stuck .nav-top-btn {
    margin-left: 0;
    opacity: 1;
    visibility: visible;
    transform: none;
    transition-delay: 0s;
  }
  @media (prefers-reduced-motion: reduce) {
    .nav-top-btn {
      transition: none;
    }
  }

  /* Labels dropped from view but still read out by screen readers */
  .nav-tab-label,
  .feedback-fab-label,
  .brand-subtitle label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  /* 16px keeps iOS from zooming the page when a field gets focus */
  .company-select-header,
  .search-input,
  .select-control,
  .form-input,
  .feedback-dialog input,
  .feedback-dialog textarea {
    font-size: 16px;
  }

  /* Panel */
  .tabs-bar {
    padding: 0 8px;
  }
  .tabs-group {
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .tabs-group::-webkit-scrollbar {
    display: none;
  }
  .tab-btn {
    flex: 0 0 auto;
    padding: 12px;
    font-size: 13px;
    white-space: nowrap;
  }
  .filter-bar {
    flex-wrap: nowrap;
    padding: 12px;
    gap: 10px;
  }
  .filter-controls > div {
    flex: 1 1 auto;
    min-width: 0;
  }
  .filter-controls > .search-box {
    flex-basis: 100%;
  }
  .select-control {
    flex: 1 1 130px;
    min-width: 0;
    max-width: 100%;
  }
  .results-summary {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 10px 12px;
    font-size: 12px;
  }
  .data-table thead th,
  .data-table tbody td {
    padding: 10px 12px;
  }
  .data-table .badge {
    white-space: nowrap;
  }
  .pagination-bar {
    justify-content: center;
    padding: 12px;
  }
  .pagination-controls {
    flex-wrap: wrap;
    justify-content: center;
  }

  /* Modals */
  .modal-overlay {
    padding: 8px;
  }
  .modal-header {
    padding: 14px 16px;
  }
  .modal-body {
    padding: 16px;
  }

  /* Footer: the links sit at the end of the page instead of floating over it */
  body {
    padding-bottom: 72px;
  }
  .about-page {
    padding-bottom: 24px;
  }
  .app-footer-pill {
    position: static;
    flex-wrap: wrap;
    justify-content: center;
    row-gap: 2px;
    max-width: none;
    margin: 0 16px;
    border-radius: var(--radius-md);
    box-shadow: none;
  }
  .feedback-fab {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    font-size: 18px;
  }
}

/* VAT Settlement & Estimator Modal Styles */
.vat-period-toggle {
  background: transparent;
  border: none;
  color: #475569;
  font-weight: 500;
  transition: all 0.15s ease;
}

.vat-period-toggle.active {
  background: #ffffff !important;
  color: #0f172a !important;
  font-weight: 700 !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
}

@media (max-width: 768px) {
  .vat-breakdown-grid,
  .audit-grid {
    grid-template-columns: 1fr !important;
  }
}

@media print {
  body * {
    visibility: hidden;
  }
  #vatModal, #vatModal * {
    visibility: visible;
  }
  #vatModal {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: auto;
    background: transparent !important;
    display: block !important;
  }
  #vatModal .modal-dialog {
    max-width: 100% !important;
    border: none !important;
    box-shadow: none !important;
    max-height: none !important;
  }
  #vatModal .modal-close-btn,
  #vatModal .modal-footer,
  #vatModal .vat-period-toggle,
  #vatYearSelect,
  #vatPeriodSelect {
    display: none !important;
  }
}

/* ==========================================================================
   Button Help Badges & Explanation Modal for Entrepreneurs
   ========================================================================== */

.btn-help-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
  width: 18px;
  height: 18px;
  border-radius: var(--radius-full);
  font-size: 11px;
  line-height: 1;
  background: rgba(15, 23, 42, 0.08);
  color: var(--text-main);
  cursor: pointer;
  vertical-align: middle;
  transition: transform 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.btn-help-trigger:hover,
.btn-help-trigger:focus-visible {
  transform: scale(1.22);
  background: #3b82f6;
  color: #ffffff;
  border-color: #2563eb;
  box-shadow: 0 2px 5px rgba(37, 99, 235, 0.28);
  outline: none;
}

/* Inside primary buttons */
.btn-primary .btn-help-trigger {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.35);
}

.btn-primary .btn-help-trigger:hover,
.btn-primary .btn-help-trigger:focus-visible {
  background: #ffffff;
  color: var(--primary);
  border-color: #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Dialog Container */
.button-help-dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: 90vh;
  padding: 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  background: var(--bg-surface);
  color: var(--text-main);
  overflow: hidden;
}

.button-help-dialog::backdrop {
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
}

.button-help-dialog-inner {
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

.button-help-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-color);
  background: linear-gradient(to bottom, #ffffff, #f8fafc);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.button-help-header-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.button-help-icon {
  font-size: 24px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: var(--primary-light);
  border: 1px solid var(--primary-border);
  flex-shrink: 0;
}

.button-help-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--primary);
  background: var(--primary-light);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  margin-bottom: 4px;
}

.button-help-title {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
  line-height: 1.3;
}

.button-help-close-btn {
  background: transparent;
  border: none;
  font-size: 24px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.button-help-close-btn:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

.button-help-body {
  padding: 20px 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.button-help-card {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}

.button-help-card-primary {
  background: #f0f7ff;
  border-color: #bfdbfe;
}

.button-help-label {
  font-size: 13px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.button-help-text {
  font-size: 13.5px;
  line-height: 1.55;
  color: #334155;
  margin: 0;
}

.button-help-details {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.button-help-detail-item {
  font-size: 13px;
  line-height: 1.5;
  color: #334155;
  background: #ffffff;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid #dbeafe;
}

.button-help-tip {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--warning-light);
  border: 1px solid var(--warning-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.button-help-tip-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.button-help-tip-text {
  font-size: 12.5px;
  line-height: 1.5;
  color: #78350f;
}

.button-help-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border-color);
  background: #f8fafc;
  display: flex;
  justify-content: flex-end;
}

/* Company Modal Help Guide */
.company-help-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 640px) {
  .company-help-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}


