:root {
  --primary: #2f6b92;
  --primary-dark: #204b66;
  --secondary: #07b49f;
  --secondary-soft: rgba(7, 180, 159, 0.15);
  --background: #f5f8fb;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-strong: #ffffff;
  --text: #173042;
  --muted: #6b8191;
  --border: rgba(47, 107, 146, 0.14);
  --danger: #dc5d5d;
  --warning: #e8b949;
  --success: #35b36e;
  --shadow: 0 24px 48px rgba(34, 66, 97, 0.12);
  --radius-lg: 28px;
  --radius-md: 20px;
  --radius-sm: 14px;
}

body.dark {
  --background: #0f1d28;
  --surface: rgba(19, 35, 49, 0.82);
  --surface-strong: #152533;
  --text: #ecf5fb;
  --muted: #aac0cf;
  --border: rgba(255, 255, 255, 0.08);
  --shadow: 0 28px 60px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Poppins", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(7, 180, 159, 0.12), transparent 30%),
    radial-gradient(circle at top right, rgba(47, 107, 146, 0.18), transparent 28%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.8), transparent 35%),
    var(--background);
  color: var(--text);
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

.glass-card,
.panel,
.topbar,
.sidebar,
.welcome-banner {
  background: var(--surface);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.login-body {
  display: grid;
  place-items: center;
  padding: 32px;
}

.login-shell {
  width: min(1180px, 100%);
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 24px;
}

.login-visual,
.login-panel,
.panel,
.sidebar,
.topbar,
.welcome-banner {
  border-radius: var(--radius-lg);
  padding: 28px;
}

.brand-lockup,
.sidebar-brand {
  display: flex;
  gap: 16px;
  align-items: center;
}

.brand-logo {
  width: 148px;
  height: 74px;
  object-fit: contain;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
  padding: 8px 12px;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 0.76rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--secondary);
  font-weight: 600;
}

.topbar .eyebrow,
.panel-head .eyebrow,
.welcome-banner .eyebrow,
.manual-fare-block .eyebrow {
  display: none;
}

.panel-head h3 {
  display: none;
}

.topbar h1,
.welcome-banner h2,
.panel-head {
  margin-top: 0;
}

h1,
h2,
h3 {
  margin: 0;
}

.hero-copy {
  max-width: 560px;
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--muted);
}

.hero-stats,
.card-grid,
.content-grid,
.action-grid,
.filter-grid,
.settings-form {
  display: grid;
  gap: 18px;
}

.hero-stats {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 28px;
}

.hero-stats article,
.stat-card {
  padding: 18px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.48);
}

body.dark .hero-stats article,
body.dark .stat-card {
  background: rgba(255, 255, 255, 0.04);
}

.hero-stats span,
.stat-card strong {
  display: block;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary);
}

.login-form,
.settings-form {
  margin-top: 22px;
}

.login-form label,
.settings-form label,
.filter-grid label {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.filter-action {
  display: grid;
  gap: 8px;
  align-self: stretch;
  min-width: 0;
}

.filter-action span {
  line-height: 1.35;
  color: var(--text);
}

.filter-action .btn {
  min-height: 58px;
}

.filter-action,
.filter-action .btn {
  width: 100%;
}

.filter-action-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  width: 100%;
}

.login-form input,
.settings-form input,
.filter-grid input,
.filter-grid select,
.search-wrap input {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 13px 14px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
}

.filter-grid input,
.filter-grid select,
.filter-action .btn {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

body.dark .login-form input,
body.dark .settings-form input,
body.dark .filter-grid input,
body.dark .filter-grid select,
body.dark .search-wrap input {
  background: rgba(255, 255, 255, 0.04);
}

.checkbox-field {
  display: flex !important;
  align-items: center;
  gap: 12px;
  margin: 12px 0 20px;
}

.checkbox-field input {
  width: 18px;
  height: 18px;
}

.btn {
  border: 0;
  border-radius: 14px;
  padding: 12px 18px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.btn:hover,
.pill:hover,
.action-card:hover {
  transform: translateY(-2px);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  box-shadow: 0 14px 24px rgba(47, 107, 146, 0.2);
}

.btn-secondary {
  background: rgba(47, 107, 146, 0.1);
  color: var(--primary);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-block {
  width: 100%;
}

.quick-access {
  margin-top: 24px;
}

.pill-row,
.status-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.pill,
.status-pill {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 9px 14px;
  background: rgba(255, 255, 255, 0.55);
}

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

.status-pill.warning {
  color: #996700;
}

.status-pill.info {
  color: var(--primary);
}

.app-shell {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  padding: 24px;
  align-items: start;
  width: 100%;
}

.sidebar {
  position: static;
  align-self: start;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  width: 100%;
  z-index: 40;
  isolation: isolate;
}

.sidebar-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  justify-content: flex-end;
}

.sidebar-nav a {
  padding: 14px 16px;
  border-radius: 16px;
  color: var(--muted);
  display: flex;
  gap: 12px;
  align-items: center;
  font-weight: 500;
}

.sidebar-nav a.active,
.sidebar-nav a:hover {
  background: linear-gradient(135deg, rgba(47, 107, 146, 0.16), rgba(7, 180, 159, 0.16));
  color: var(--text);
}

.sidebar-footer {
  display: grid;
  gap: 10px;
}

.sidebar-brand {
  flex: 0 0 auto;
}

.main-content {
  display: grid;
  gap: 22px;
  min-width: 0;
  width: 100%;
  overflow: hidden;
}

.panel {
  min-width: 0;
}

.topbar,
.welcome-banner {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  min-width: 0;
}

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

.search-wrap {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.6);
}

.search-wrap input {
  border: 0;
  padding-left: 0;
  background: transparent;
  min-width: 240px;
}

.stats-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: stretch;
}

.stat-card {
  position: relative;
  overflow: hidden;
  min-height: 150px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.stat-card::after {
  content: "";
  position: absolute;
  inset: auto -30% -45% auto;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(7, 180, 159, 0.16), transparent 60%);
}

.stat-card p,
.hero-stats p {
  margin: 6px 0 0;
  color: var(--muted);
}

.content-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
}

.content-grid.triple {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.content-grid > *,
.main-content > *,
.stats-grid > *,
.topbar > *,
.welcome-banner > * {
  min-width: 0;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.chart-panel {
  display: flex;
  flex-direction: column;
  min-height: 420px;
}

.chart-panel .panel-head {
  min-height: 96px;
}

.chart-stage {
  position: relative;
  flex: 1;
  min-height: 260px;
}

.chart-stage canvas {
  height: 100% !important;
}

.action-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.action-card {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.55);
  border-radius: 18px;
  padding: 18px;
  display: flex;
  gap: 14px;
  align-items: center;
  cursor: pointer;
  color: var(--text);
}

.action-card i {
  font-size: 1.2rem;
  color: var(--primary);
}

.settings-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.filter-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-items: end;
}

.filter-grid > * {
  min-width: 0;
}

.data-entry-form {
  display: grid;
  gap: 16px;
}

.data-entry-form textarea {
  width: 100%;
  min-height: 180px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
}

body.dark .data-entry-form textarea {
  background: rgba(255, 255, 255, 0.04);
}

.data-entry-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.section-note {
  margin: 0 0 16px;
  color: var(--muted);
}

.manual-fare-form {
  display: grid;
  gap: 22px;
}

.manual-fare-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.manual-fare-grid label {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.manual-fare-grid label span {
  line-height: 1.35;
}

.manual-fare-grid input,
.manual-fare-grid select {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 13px 14px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  width: 100%;
  min-width: 0;
}

body.dark .manual-fare-grid input,
body.dark .manual-fare-grid select {
  background: rgba(255, 255, 255, 0.04);
}

.manual-fare-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.manual-fare-detail-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.manual-fare-block {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.4);
  min-width: 0;
}

body.dark .manual-fare-block {
  background: rgba(255, 255, 255, 0.03);
}

.manual-fare-block .eyebrow {
  margin-bottom: 14px;
}

.supplier-row-list {
  display: grid;
  gap: 18px;
}

.supplier-row-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.supplier-row-head .eyebrow {
  margin-bottom: 0;
}

.supplier-row-grid {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.compact-table {
  margin-top: 20px;
}

.sticky-filter-panel {
  position: sticky;
  top: 16px;
  z-index: 5;
}

.table-wrap {
  overflow: auto;
  max-width: 100%;
}

table.dataTable,
.app-table {
  border-collapse: collapse !important;
  width: 100% !important;
}

canvas {
  display: block;
  width: 100% !important;
  max-width: 100%;
}

table.dataTable thead th {
  position: sticky;
  top: 0;
  background: var(--surface-strong);
  z-index: 1;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.status-badge.green {
  background: #DDE8C8;
  color: #69BA69;
}

.status-badge.red {
  background: rgba(220, 93, 93, 0.16);
  color: var(--danger);
}

.status-badge.yellow {
  background: rgba(232, 185, 73, 0.18);
  color: #8d6b00;
}

.status-badge.blue {
  background: rgba(47, 107, 146, 0.16);
  color: var(--primary);
}

.page-loader {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(15, 29, 40, 0.18);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.page-loader.visible {
  opacity: 1;
  pointer-events: auto;
}

.spinner {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.4);
  border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}

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

.toast-container {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: grid;
  gap: 10px;
  z-index: 30;
}

.toast {
  min-width: 280px;
  background: var(--surface-strong);
  color: var(--text);
  border-radius: 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.table-positive {
  color: var(--success);
  font-weight: 600;
}

.table-negative {
  color: var(--danger);
  font-weight: 600;
}

.table-neutral {
  color: #9a7c00;
  font-weight: 600;
}

#manualFareTable tbody tr.verdict-row-flyshop td {
  background: #DDF5E6;
}

#manualFareTable tbody tr.verdict-row-supplier td {
  background: rgba(220, 93, 93, 0.2);
}

#manualFareTable tbody tr.verdict-row-equal td {
  background: rgba(232, 185, 73, 0.12);
}

@media (max-width: 1180px) {
  .stats-grid,
  .content-grid.triple {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .manual-fare-columns {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .login-shell,
  .app-shell,
  .content-grid,
  .stats-grid,
  .settings-form,
  .hero-stats,
  .action-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar,
  .welcome-banner {
    flex-direction: column;
    align-items: flex-start;
  }

  .manual-fare-detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .login-body,
  .app-shell {
    padding: 16px;
  }

  .login-visual,
  .login-panel,
  .panel,
  .sidebar,
  .topbar,
  .welcome-banner {
    padding: 20px;
    border-radius: 22px;
  }

  .filter-grid,
  .manual-fare-grid,
  .manual-fare-detail-grid,
  .settings-form {
    grid-template-columns: 1fr;
  }

  .sidebar-nav {
    width: 100%;
    justify-content: stretch;
  }

  .sidebar-nav a {
    width: 100%;
  }

  .search-wrap input {
    min-width: 0;
    width: 100%;
  }
}
