:root {
  --ink: #10233f;
  --ink-soft: #3d4f6a;
  --sand: #f3efe7;
  --sand-2: #e8e1d4;
  --sea: #0f766e;
  --sea-dark: #0b5a54;
  --alert: #b45309;
  --card: rgba(255, 255, 255, 0.92);
  --shadow: 0 18px 40px rgba(16, 35, 63, 0.12);
  --radius: 18px;
  --font: "Segoe UI", "Trebuchet MS", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.18), transparent 28%),
    linear-gradient(160deg, #f7f4ee 0%, #e9eef5 48%, #dfe8e6 100%);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  background: linear-gradient(180deg, #12304f 0%, #0d2238 100%);
  color: #fff;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  gap: 0.85rem;
  align-items: center;
  margin-bottom: 1.5rem;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 700;
  background: linear-gradient(135deg, #14b8a6, #0f766e);
  color: #fff;
}

.brand-name { font-weight: 700; letter-spacing: 0.02em; }
.brand-tag { font-size: 0.78rem; opacity: 0.7; }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
  overflow-y: auto;
  padding-right: 0.15rem;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.nav-group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin: 0.25rem 0 0;
  padding: 0.65rem 0.9rem;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: rgba(255,255,255,0.55);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 650;
  cursor: pointer;
  text-align: left;
}

.nav-group-toggle:hover {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.9);
}

.nav-chevron {
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.18s ease;
  opacity: 0.8;
}

.nav-group.open .nav-chevron {
  transform: rotate(45deg);
}

.nav-group-items {
  display: none;
  flex-direction: column;
  gap: 0.2rem;
  margin: 0.15rem 0 0.45rem 0.7rem;
  padding: 0.25rem 0 0.25rem 0.65rem;
  border-left: 2px solid rgba(255, 255, 255, 0.14);
}

.nav-group.open .nav-group-items {
  display: flex;
}

.sidebar-nav .nav-link {
  color: rgba(255, 255, 255, 0.72);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  margin-left: 0.15rem;
  text-decoration: none;
  font-size: 0.92rem;
  line-height: 1.25;
  position: relative;
}

.sidebar-nav .nav-link::before {
  content: "";
  position: absolute;
  left: -0.78rem;
  top: 50%;
  width: 0.45rem;
  height: 1px;
  background: rgba(255, 255, 255, 0.18);
  transform: translateY(-50%);
}

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link.active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.sidebar-nav .nav-link.active {
  box-shadow: inset 2px 0 0 #14b8a6;
}

.sidebar-footer { margin-top: auto; }

.main-area { min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1.25rem;
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
  background: rgba(247, 244, 238, 0.8);
  border-bottom: 1px solid rgba(16,35,63,0.06);
}
.topbar-title { font-weight: 650; flex: 1; }
.content { padding: 1.25rem; }

.page-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.page-header h1 {
  font-size: clamp(1.5rem, 2vw, 2rem);
  margin: 0 0 0.2rem;
}

.stat-tile, .panel {
  background: var(--card);
  border: 1px solid rgba(16,35,63,0.06);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stat-tile { padding: 1rem 1.1rem; }
.stat-tile-alert { border-color: rgba(180,83,9,0.35); background: #fff7ed; }
.stat-label { font-size: 0.82rem; color: var(--ink-soft); }
.stat-value { font-size: 1.8rem; font-weight: 700; margin-top: 0.15rem; }

.panel { padding: 1.1rem 1.2rem; }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.85rem;
}
.panel-head h2 {
  font-size: 1.05rem;
  margin: 0;
}
.panel-alert { border-color: rgba(180,83,9,0.25); }

.finance-tabs .nav-link {
  color: var(--ink-soft);
  font-weight: 600;
}
.finance-tabs .nav-link.active {
  color: var(--sea-dark);
  border-color: rgba(15, 118, 110, 0.25) rgba(15, 118, 110, 0.25) #fff;
}
.finance-filters .form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.chart-panel canvas {
  max-width: 100%;
}
.finance-guide summary {
  cursor: pointer;
  list-style: none;
}
.finance-guide summary::-webkit-details-marker { display: none; }
.finance-guide[open] summary { margin-bottom: 0.5rem; }

.training-search-panel .form-control-lg {
  border-radius: 12px;
}
.training-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.training-chip.active {
  background: var(--sea);
  border-color: var(--sea);
  color: #fff;
}
.training-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 1rem;
  align-items: start;
}
.training-toc {
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  overflow: auto;
}
.training-toc-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.training-toc-link {
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.9rem;
  line-height: 1.3;
}
.training-toc-link:hover { color: var(--sea-dark); }
.training-article-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}
.training-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: var(--sand);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  margin-right: 0.35rem;
  margin-bottom: 0.35rem;
}
.training-badge-admin {
  background: rgba(15, 118, 110, 0.12);
  color: var(--sea-dark);
}
.training-steps, .training-tips {
  padding-left: 1.2rem;
}
.training-steps li, .training-tips li {
  margin-bottom: 0.45rem;
}
.training-keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  margin-top: 0.75rem;
}
.training-keyword {
  border: 1px solid rgba(16,35,63,0.12);
  background: #fff;
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.78rem;
  color: var(--ink-soft);
  cursor: pointer;
}
.training-keyword:hover {
  border-color: var(--sea);
  color: var(--sea-dark);
}
@media (max-width: 991.98px) {
  .training-layout { grid-template-columns: 1fr; }
}

.ai-list {
  margin: 0;
  padding-left: 1.1rem;
}
.ai-list li { margin-bottom: 0.35rem; }

.day-chip {
  display: inline-block;
  background: var(--sand);
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
  font-size: 0.82rem;
}

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background:
    linear-gradient(135deg, rgba(15,118,110,0.18), transparent 40%),
    linear-gradient(160deg, #0d2238, #12304f 45%, #0f766e);
}
.auth-shell { width: min(440px, 100%); }
.auth-panel {
  background: rgba(255,255,255,0.96);
  border-radius: 24px;
  padding: 2rem 1.5rem;
  box-shadow: var(--shadow);
}
.auth-title { margin: 0.85rem 0 0.25rem; font-size: 1.8rem; }
.auth-subtitle { color: var(--ink-soft); margin-bottom: 1.5rem; }

.btn-primary {
  background: var(--sea);
  border-color: var(--sea);
}
.btn-primary:hover {
  background: var(--sea-dark);
  border-color: var(--sea-dark);
}

.ai-chat-log {
  background: var(--sand);
  border-radius: 14px;
  padding: 0.85rem;
  overflow: auto;
  min-height: 240px;
}
.ai-bubble {
  background: #fff;
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
  margin-bottom: 0.65rem;
  box-shadow: 0 4px 14px rgba(16,35,63,0.06);
}
.ai-bubble.user { background: #dbeafe; }

.table-pager {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0.25rem 0.15rem;
  border-top: 1px solid rgba(16, 35, 63, 0.08);
  margin-top: 0.5rem;
}
.table-pager-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.65rem;
}
.table-pager-toolbar .table-search {
  max-width: 280px;
  flex: 1 1 180px;
}
.table-pager-meta { font-size: 0.875rem; color: var(--ink-soft); }
.table-pager-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.table-pager .page-btn {
  min-width: 2rem;
  border: 1px solid rgba(16, 35, 63, 0.15);
  background: #fff;
  border-radius: 8px;
  padding: 0.25rem 0.55rem;
  color: var(--ink);
}
.table-pager .page-btn.active,
.table-pager .page-btn:hover {
  background: var(--sea);
  border-color: var(--sea);
  color: #fff;
}
.table-pager select {
  width: auto;
  min-width: 6.5rem;
  display: inline-block;
}
.table-compact th, .table-compact td {
  white-space: nowrap;
  font-size: 0.875rem;
}

/* Borders for all data tables */
.table.table-bordered > :not(caption) > * > * {
  border-width: 1px;
  border-color: rgba(16, 35, 63, 0.18);
}
.table.table-bordered {
  border: 1px solid rgba(16, 35, 63, 0.22);
}
.table thead th {
  background: rgba(16, 35, 63, 0.04);
  border-bottom-width: 1px !important;
}

/* Legacy-style transit row colors */
tr.row-on-transit > * {
  background-color: #198754 !important;
  color: #fff !important;
}
tr.row-long-trip > * {
  background-color: #ffc107 !important;
  color: #111 !important;
}
tr.row-on-transit a,
tr.row-on-transit .btn-link {
  color: #fff !important;
}
.table-status-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin-bottom: 0.5rem;
}
.table-status-legend span::before {
  content: "";
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 3px;
  margin-right: 0.35rem;
  vertical-align: -1px;
}
.legend-on-transit::before { background: #198754; }
.legend-long-trip::before { background: #ffc107; }

.timesheet-grid .time-input,
.timesheet-grid .break-input {
  min-width: 7.5rem;
}
.timesheet-grid .break-input {
  min-width: 5.5rem;
}

@media (max-width: 991.98px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(280px, 86vw);
    transform: translateX(-105%);
    transition: transform .2s ease;
    z-index: 40;
  }
  .sidebar.open { transform: translateX(0); }
  .content { padding: 1rem; }
}
