/* =========================================================================
   OLIVO On-the-Go — Design System
   Palette: #6e852b (olive primary) · #B97C4C (terracotta accent) · #F6F5EF (cream bg)
   Font: Plus Jakarta Sans · No gradients · WCAG AA
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  /* brand */
  --primary: #6e852b;
  --primary-dark: #5a6f22;
  --primary-tint: #eef1e0;
  --accent: #B97C4C;
  --accent-dark: #9d6539;
  --accent-tint: #f3e7da;

  /* surfaces */
  --bg: #F6F5EF;
  --surface: #ffffff;
  --surface-2: #fbfaf5;

  /* text */
  --ink: #2b2b2b;
  --muted: #6c757d;
  --faint: #9aa0a6;

  /* lines */
  --border: #e3e1d6;
  --border-strong: #d4d2c4;

  /* status */
  --success: #2f7d32;
  --success-tint: #e4f0e4;
  --warning: #b7791f;
  --warning-tint: #f7ecd6;
  --danger: #b03a2e;
  --danger-tint: #f6e3e0;
  --info: #3b6b8a;
  --info-tint: #e1ecf3;

  /* shape */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 18px;

  /* elevation */
  --shadow-sm: 0 1px 2px rgba(43,43,43,.06);
  --shadow: 0 2px 8px rgba(43,43,43,.07);
  --shadow-lg: 0 12px 32px rgba(43,43,43,.12);

  /* layout */
  --sidebar-w: 232px;
  --topbar-h: 64px;

  --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --ease: cubic-bezier(.22,.61,.36,1);
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; }
h1,h2,h3,h4,h5 { margin: 0; font-weight: 700; color: var(--ink); letter-spacing: -0.01em; }
p { margin: 0 0 .75rem; }

/* skip link (a11y §1) */
.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 2000;
  background: var(--primary); color: #fff; padding: 10px 16px; border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

/* focus visibility (a11y) */
:focus-visible { outline: 3px solid rgba(110,133,43,.45); outline-offset: 2px; border-radius: 4px; }

/* ---------- layout shell ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 60;
  display: flex; flex-direction: column;
  transition: transform .25s var(--ease);
}
.sidebar__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 20px; height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
}
.sidebar__logo {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--primary); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 16px;
  flex: none;
}
.sidebar__brand-name { font-weight: 800; font-size: 16px; line-height: 1.1; }
.sidebar__brand-sub { font-size: 11px; color: var(--muted); font-weight: 500; }

.sidebar__nav { flex: 1; overflow-y: auto; padding: 14px 12px; }
.sidebar__heading {
  font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--faint); font-weight: 700; padding: 14px 12px 6px;
}
.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; margin: 2px 0;
  border-radius: var(--radius-sm);
  color: var(--ink); font-weight: 600; font-size: 14px;
  position: relative; cursor: pointer;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.nav-link svg { width: 18px; height: 18px; flex: none; color: var(--muted); }
.nav-link:hover { background: var(--primary-tint); color: var(--primary-dark); }
.nav-link:hover svg { color: var(--primary); }
.nav-link.active { background: var(--primary-tint); color: var(--primary-dark); }
.nav-link.active::before {
  content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--primary);
}
.nav-link.active svg { color: var(--primary); }

.sidebar__footer {
  padding: 14px 16px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--muted);
}
.sidebar__footer strong { color: var(--ink); display: block; font-size: 13px; }

/* main */
.main {
  flex: 1; margin-left: var(--sidebar-w);
  display: flex; flex-direction: column; min-width: 0;
}
.topbar {
  height: var(--topbar-h); position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.85); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px;
  padding: 0 22px;
}
.topbar__toggle {
  display: none; background: none; border: 0; cursor: pointer;
  padding: 8px; border-radius: var(--radius-sm); color: var(--ink);
}
.topbar__toggle:hover { background: var(--primary-tint); }
.topbar__title { font-size: 13px; color: var(--muted); font-weight: 500; }
.topbar__title strong { color: var(--ink); font-weight: 700; }
.topbar__spacer { flex: 1; }
.topbar__date { font-size: 13px; color: var(--muted); font-weight: 500; }

.content { padding: 26px 22px 48px; max-width: 1320px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head__title { font-size: 24px; font-weight: 800; display: flex; align-items: center; gap: 10px; }
.page-head__title svg { width: 24px; height: 24px; color: var(--primary); }
.page-head__sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.page-head__actions { display: flex; gap: 10px; flex-wrap: wrap; }

.footer { padding: 18px 22px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--border); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-family: inherit; font-size: 14px; font-weight: 600;
  padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  cursor: pointer; text-decoration: none; line-height: 1.2;
  transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease), transform .1s var(--ease);
  min-height: 40px; white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-dark); color: #fff; }
.btn-outline { background: transparent; color: var(--primary); border-color: var(--border-strong); }
.btn-outline:hover { background: var(--primary-tint); color: var(--primary-dark); }
.btn-light { background: var(--surface); color: var(--ink); border-color: var(--border); }
.btn-light:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--muted); padding: 8px 10px; }
.btn-ghost:hover { background: var(--primary-tint); color: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.93); color: #fff; }
.btn-sm { padding: 6px 11px; font-size: 13px; min-height: 34px; }
.btn-icon { padding: 8px; min-height: 36px; min-width: 36px; }
.btn-icon svg { width: 16px; height: 16px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card__header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.card__header h2, .card__header h3 { font-size: 16px; font-weight: 700; }
.card__body { padding: 18px; }
.card__footer { padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }

/* ---------- metric cards ---------- */
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.metric {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 12px;
  transition: box-shadow .2s var(--ease), transform .2s var(--ease);
}
.metric:hover { box-shadow: var(--shadow); }
.metric__top { display: flex; align-items: center; justify-content: space-between; }
.metric__chip {
  width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center;
}
.metric__chip svg { width: 22px; height: 22px; }
.chip-primary { background: var(--primary-tint); color: var(--primary); }
.chip-accent { background: var(--accent-tint); color: var(--accent); }
.chip-success { background: var(--success-tint); color: var(--success); }
.chip-warning { background: var(--warning-tint); color: var(--warning); }
.metric__label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.metric__value { font-size: 34px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.metric__link { font-size: 13px; font-weight: 600; color: var(--primary); }

/* ---------- grids ---------- */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.row-gap { margin-bottom: 22px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
table.data-table, table.table {
  width: 100%; border-collapse: collapse; font-size: 14px;
}
.table thead th, .data-table thead th {
  text-align: left; padding: 11px 14px; background: var(--surface-2);
  color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td, .data-table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td, .data-table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover, .data-table tbody tr:hover { background: var(--surface-2); }
.table-secondary td { color: var(--faint); }
.text-center { text-align: center; }
.text-end { text-align: right; }
.text-muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
a.row-link { color: var(--ink); font-weight: 600; }
a.row-link:hover { color: var(--primary); }

/* simple-datatables overrides */
.datatable-container .datatable-search,
.datatable-container .datatable-dropdown { margin-bottom: 12px; }
.datatable-container input, .datatable-container select {
  font-family: inherit; font-size: 14px; padding: 8px 12px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); color: var(--ink); background: var(--surface);
}
.datatable-container .datatable-table { border-radius: var(--radius-sm); overflow: hidden; }
.datatable-container th { background: var(--surface-2) !important; }
.datatable-container .datatable-container a.datatable-sorter { color: var(--muted); }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; line-height: 1.5;
}
.badge svg { width: 12px; height: 12px; }
.badge-success { background: var(--success-tint); color: var(--success); }
.badge-warning { background: var(--warning-tint); color: var(--warning); }
.badge-secondary { background: #eceae2; color: var(--muted); }
.badge-accent { background: var(--accent-tint); color: var(--accent); }
.badge-danger { background: var(--danger-tint); color: var(--danger); }
.badge-info { background: var(--info-tint); color: var(--info); }
.badge-primary { background: var(--primary-tint); color: var(--primary-dark); }

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-grid .span-2 { grid-column: span 2; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink); }
.field label .req { color: var(--danger); }
.field .help { font-size: 12px; color: var(--muted); }
.input, .select, .textarea, input[type=text], input[type=email], input[type=password],
input[type=tel], input[type=date], input[type=number], select, textarea {
  font-family: inherit; font-size: 14px; color: var(--ink);
  padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); width: 100%; min-height: 42px;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
textarea { min-height: 96px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus,
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(110,133,43,.18);
}
.input-is-invalid { border-color: var(--danger) !important; }
.invalid-feedback { color: var(--danger); font-size: 12px; font-weight: 500; }

/* flatpickr theme tie-in */
.flatpickr-input { background: var(--surface) !important; }

/* ---------- alerts ---------- */
.alert {
  display: flex; align-items: flex-start; gap: 10px; padding: 13px 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; font-size: 14px; margin-bottom: 14px;
}
.alert svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.alert-success { background: var(--success-tint); color: var(--success); border-color: #cfe3cf; }
.alert-danger { background: var(--danger-tint); color: var(--danger); border-color: #ecc9c4; }
.alert-warning { background: var(--warning-tint); color: var(--warning); border-color: #ecdcb8; }
.alert-info { background: var(--info-tint); color: var(--info); border-color: #cddfe9; }

/* ---------- toasts ---------- */
.toast-stack {
  position: fixed; top: 18px; right: 18px; z-index: 2000;
  display: flex; flex-direction: column; gap: 10px; max-width: 360px;
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm); padding: 13px 15px; box-shadow: var(--shadow-lg);
  font-size: 14px; animation: toast-in .25s var(--ease); min-width: 280px;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast.info { border-left-color: var(--info); }
.toast svg { width: 18px; height: 18px; flex: none; margin-top: 1px; color: var(--primary); }
.toast.success svg { color: var(--success); }
.toast.error svg { color: var(--danger); }
.toast.warning svg { color: var(--warning); }
.toast.info svg { color: var(--info); }
.toast__title { font-weight: 700; margin-bottom: 1px; }
.toast__msg { color: var(--muted); font-size: 13px; }
.toast__close { margin-left: auto; background: none; border: 0; cursor: pointer; color: var(--faint); padding: 0 0 0 8px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ---------- modal (bootstrap override) ---------- */
.modal-content { border: 0; border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.modal-header, .modal-footer { border-color: var(--border); padding: 16px 20px; }
.modal-body { padding: 20px; }
.modal-title { font-weight: 700; font-size: 17px; }
.modal-backdrop.show { opacity: .5; }

/* ---------- chart card ---------- */
.chart-card .card__body { padding: 18px 14px 22px; }
.chart-legend { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 10px; }
.chart-legend__item { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); font-weight: 600; cursor: pointer; }
.chart-legend__dot { width: 11px; height: 11px; border-radius: 3px; }

/* ---------- empty state ---------- */
.empty { text-align: center; padding: 32px 16px; color: var(--muted); }
.empty svg { width: 30px; height: 30px; margin-bottom: 8px; color: var(--faint); }

/* ---------- dropdown (profile) ---------- */
.dropdown { position: relative; }
.dropdown__btn {
  display: flex; align-items: center; gap: 9px; background: none; border: 1px solid transparent;
  border-radius: 999px; padding: 4px 10px 4px 4px; cursor: pointer; color: var(--ink);
}
.dropdown__btn:hover { background: var(--primary-tint); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--accent-tint); color: var(--accent);
  display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none;
}
.dropdown__name { font-size: 13px; font-weight: 700; line-height: 1.1; }
.dropdown__role { font-size: 11px; color: var(--muted); text-transform: capitalize; }
.dropdown__menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 8px; z-index: 100; display: none;
}
.dropdown.open .dropdown__menu { display: block; }
.dropdown__header { padding: 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.dropdown__item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--ink); font-size: 14px; font-weight: 500; cursor: pointer; width: 100%; text-align: left;
  background: none; border: 0; font-family: inherit;
}
.dropdown__item:hover { background: var(--primary-tint); color: var(--primary-dark); }
.dropdown__item svg { width: 16px; height: 16px; color: var(--muted); }
.dropdown__divider { height: 1px; background: var(--border); margin: 6px 0; }

/* backdrop for mobile drawer */
.scrim {
  position: fixed; inset: 0; background: rgba(43,43,43,.45); z-index: 55;
  opacity: 0; visibility: hidden; transition: opacity .25s var(--ease);
}
body.drawer-open .scrim { opacity: 1; visibility: visible; }

/* ---------- helpers ---------- */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 18px; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 18px; }
.w-full { width: 100%; }
.font-mono { font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace; font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ---------- responsive ---------- */
@media (max-width: 1024px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  body.drawer-open .sidebar { transform: none; }
  .main { margin-left: 0; }
  .topbar__toggle { display: inline-flex; }
}
@media (max-width: 640px) {
  .metric-grid { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
  .content { padding: 18px 14px 40px; }
  .page-head__title { font-size: 20px; }
  .dropdown__name, .dropdown__role { display: none; }
}

/* ---------- responsive card tables ---------- */
@media (max-width: 640px) {
  table.card-table, table.card-table thead, table.card-table tbody,
  table.card-table tr, table.card-table th, table.card-table td { display: block; }
  table.card-table { box-shadow: none; }
  table.card-table thead { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
  table.card-table tr {
    margin-bottom: 12px; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 6px 14px; box-shadow: var(--shadow-sm);
  }
  table.card-table tr:last-child { margin-bottom: 0; }
  table.card-table td {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 9px 0; border: 0; border-bottom: 1px solid var(--border); text-align: right;
  }
  table.card-table tr td:last-child { border-bottom: 0; }
  table.card-table td::before {
    content: attr(data-label); font-weight: 700; font-size: 12px; color: var(--muted);
    text-transform: uppercase; letter-spacing: .03em; text-align: left; flex: none;
  }
  table.card-table td[data-full] { flex-direction: column; align-items: flex-start; }
  table.card-table td[data-full]::before { margin-bottom: 4px; }
  /* keep simple-datatables chrome tidy */
  .datatable-container .datatable-top { flex-direction: column; align-items: stretch; gap: 8px; }
  .datatable-container .datatable-top input, .datatable-container .datatable-top select { width: 100%; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
