/* Design tokens — ported from frontend/src/app/globals.css */
:root {
  --navy: #1e2433;
  --panel-bg: #101c2c;
  --sidebar-bg: #18233a;
  --accent-soft-glow: #7db2f0;
  --primary-blue: #1e70c8;
  --primary-blue-deep: #0e4186;
  --blue-2: #2563eb;
  --blue-pale: #eff6ff;
  --blue-border: #ccdff7;
  --blue-glow: rgba(30, 112, 200, 0.15);
  --green: #10b981;
  --green-light: #d1fae5;
  --amber: #d97706;
  --amber-light: #fef3c7;
  --red: #dc2626;
  --red-light: #fee2e2;
  --gray-900: #1e2433;
  --gray-700: #3d4660;
  --gray-500: #64748b;
  --gray-400: #94a3b8;
  --gray-300: #b8bfd0;
  --gray-200: #e2e8f0;
  --gray-100: #f1f5f9;
  --gray-50: #f8fafc;
  --white: #ffffff;
  --border-color: #e2e8f0;
  --shadow-card: 0 20px 40px -15px rgba(30, 112, 200, 0.08),
    0 15px 30px -10px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.02);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08);
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 7px;
  --sidebar-w: 248px;
  --sidebar-collapsed-w: 72px;
  --wash: #f7f9fc;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  background: var(--wash);
  color: var(--gray-900);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

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

button {
  font-family: inherit;
  cursor: pointer;
}

input,
select,
textarea {
  font-family: inherit;
  font-size: 14px;
}

/* ---------- Shell layout ---------- */

.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: #fff;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  transition: width 0.2s, transform 0.2s;
}

.sidebar[data-collapsed="true"] {
  width: var(--sidebar-collapsed-w);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding: 22px 20px;
}

.sidebar-brand-mark {
  display: flex;
  height: 32px;
  width: 32px;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: linear-gradient(to bottom right, var(--primary-blue), var(--blue-2));
  font-size: 15px;
  font-weight: 800;
  color: #fff;
}

.sidebar-brand-name {
  font-size: 15px;
  font-weight: 700;
}

.sidebar-brand-sub {
  margin-top: 2px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gray-300);
}

.sidebar[data-collapsed="true"] .sidebar-hide-collapsed {
  display: none;
}

.sidebar-toggle {
  display: flex;
  height: 32px;
  width: 32px;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--gray-300);
  margin-left: auto;
}
.sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
}

.sidebar-nav-label {
  padding: 14px 10px 6px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.1px;
  color: var(--gray-400);
}

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 2px;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--gray-300);
  transition: background 0.15s, color 0.15s;
}
.nav-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}
.nav-link.active {
  background: rgba(125, 178, 240, 0.14);
  color: #fff;
}
.nav-link.active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 3px;
  background: var(--accent-soft-glow);
  box-shadow: 0 0 10px rgba(125, 178, 240, 0.45);
}
.nav-link svg {
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding: 16px 20px;
}

.sidebar-user-avatar {
  display: flex;
  height: 34px;
  width: 34px;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: linear-gradient(to bottom right, var(--primary-blue), var(--green));
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 11px;
  color: var(--gray-400);
}

.sidebar-sign-out {
  margin-left: auto;
  flex-shrink: 0;
  border: none;
  background: transparent;
  font-size: 11px;
  font-weight: 500;
  color: var(--gray-400);
}
.sidebar-sign-out:hover {
  color: #fff;
}

.shell-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  margin-left: var(--sidebar-w);
  transition: margin 0.2s;
}
.sidebar[data-collapsed="true"] ~ .shell-content {
  margin-left: var(--sidebar-collapsed-w);
}

.shell-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--border-color);
  background: #fff;
  padding: 0 26px;
}

.shell-page-title {
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--gray-900);
}

.shell-page-crumb {
  margin-top: 2px;
  font-size: 13px;
  color: var(--gray-500);
}

.role-badge {
  display: inline-flex;
  border-radius: 999px;
  border: 1px solid var(--blue-border);
  background: var(--blue-pale);
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--primary-blue-deep);
}

.shell-main {
  flex: 1;
  padding: 26px 30px 60px;
}

.shell-main-inner {
  margin: 0 auto;
  max-width: 1320px;
}

@media (max-width: 1023px) {
  .sidebar {
    transform: translateX(-100%);
    width: min(var(--sidebar-w), 85vw);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .shell-content {
    margin-left: 0 !important;
  }
  .sidebar-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(0, 0, 0, 0.4);
  }
  .sidebar-toggle {
    display: none !important;
  }
}

.shell-menu-open {
  display: none;
  height: 40px;
  width: 40px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: #fff;
  color: var(--gray-500);
}
@media (max-width: 1023px) {
  .shell-menu-open {
    display: flex;
  }
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.15s, box-shadow 0.15s, transform 0.15s;
  padding: 9px 17px;
  font-size: 13.5px;
}
.btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}
.btn-sm {
  padding: 6px 12px;
  font-size: 12.5px;
}
.btn-primary {
  background: var(--primary-blue);
  color: #fff;
  box-shadow: 0 1px 3px rgba(30, 112, 200, 0.35);
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-blue-deep);
}
.btn-secondary {
  background: #fff;
  border-color: var(--border-color);
  color: var(--gray-900);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--gray-50);
}
.btn-danger {
  background: var(--red-light);
  color: var(--red);
}
.btn-danger:hover:not(:disabled) {
  filter: brightness(0.95);
}
.btn-ghost {
  background: transparent;
  color: var(--gray-500);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--gray-50);
  color: var(--navy);
}

/* ---------- Badge ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.badge::before {
  content: "";
  height: 6px;
  width: 6px;
  border-radius: 999px;
  background: currentColor;
}
.badge-green {
  background: var(--green-light);
  color: #067a55;
}
.badge-amber {
  background: var(--amber-light);
  color: #92600a;
}
.badge-red {
  background: var(--red-light);
  color: var(--red);
}
.badge-blue {
  background: var(--blue-pale);
  color: var(--primary-blue-deep);
}
.badge-gray {
  background: var(--gray-100);
  color: var(--gray-500);
}

/* ---------- Card ---------- */

.card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  background: #fff;
  box-shadow: var(--shadow-sm);
  padding: 22px 24px;
}
.card-flush {
  padding: 0;
}

/* ---------- Forms ---------- */

.field {
  margin-bottom: 14px;
}
.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--gray-700);
}
.field-required {
  margin-left: 2px;
  color: var(--red);
}
.field-optional {
  margin-left: 4px;
  font-weight: 400;
  color: var(--gray-400);
}
.field-error {
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--red);
}
.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0 16px;
}

.control {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: #fff;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--gray-900);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.control:focus {
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px var(--blue-glow);
}
.control:disabled {
  opacity: 0.7;
  cursor: wait;
}
textarea.control {
  resize: vertical;
  min-height: 80px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--gray-700);
  margin-bottom: 6px;
}

/* ---------- Table ---------- */

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  background: #fff;
}
table.data-table {
  width: 100%;
  border-collapse: collapse;
}
.table-th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-500);
  font-weight: 700;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
  background: var(--gray-50);
  white-space: nowrap;
}
.table-th a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: inherit;
}
.table-td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 13.5px;
  color: var(--gray-700);
  vertical-align: middle;
}
tbody tr:last-child .table-td {
  border-bottom: none;
}
tbody tr.row-link:hover {
  background: var(--gray-50);
  cursor: pointer;
}

/* A compact table with no mobile-card fallback (dashboard summaries,
   report tables) — scrolls horizontally instead of disappearing, unlike
   .table-wrap below which hides in favor of .mobile-cards. */
.mini-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  background: #fff;
}

/* mobile card list (used below sm breakpoint instead of table) */
.mobile-cards {
  display: none;
}
@media (max-width: 720px) {
  .table-wrap {
    display: none;
  }
  .mobile-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
}
.mobile-card {
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: #fff;
  padding: 14px;
}

/* ---------- List toolbar / filters ---------- */

.list-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.search-mini {
  position: relative;
  flex: 1;
  min-width: 200px;
}
.search-mini input {
  padding-left: 34px;
}
.search-mini svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  pointer-events: none;
}

.filter-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: #fff;
  font-size: 13px;
  color: var(--gray-700);
  font-weight: 500;
}
.filter-chip select {
  border: none;
  background: transparent;
  outline: none;
  color: inherit;
  font-weight: 500;
  font-family: inherit;
  font-size: 13px;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.stat-tile {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  background: #fff;
  padding: 16px 18px;
}
.stat-tile-label {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-500);
}
.stat-tile-value {
  margin-top: 6px;
  font-size: 22px;
  font-weight: 700;
  color: var(--gray-900);
}

/* ---------- Empty state ---------- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 60px 20px;
  text-align: center;
}
.empty-state-icon {
  display: flex;
  height: 56px;
  width: 56px;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  background: var(--blue-pale);
  color: var(--primary-blue);
}
.empty-state-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--navy);
}
.empty-state-message {
  max-width: 320px;
  font-size: 13px;
  color: var(--gray-500);
}

/* ---------- Pagination ---------- */

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--border-color);
  font-size: 12.5px;
  color: var(--gray-500);
}
.pagination-links {
  display: flex;
  gap: 6px;
}

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
  padding: 20px;
}
.modal {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 640px;
  max-height: min(92vh, 92dvh);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 30px 60px -15px rgba(0, 0, 0, 0.3);
}
.modal-wide {
  max-width: 900px;
}
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
  padding: 16px 20px;
  flex-shrink: 0;
}
.modal-title {
  font-size: 15.5px;
  font-weight: 600;
  color: var(--gray-900);
}
.modal-close {
  display: flex;
  height: 32px;
  width: 32px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--gray-500);
}
.modal-close:hover {
  background: var(--gray-50);
}
.modal-body {
  overflow-y: auto;
  padding: 20px;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--border-color);
  padding: 14px 20px;
  flex-shrink: 0;
}

/* ---------- Messages / toasts ---------- */

.messages {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.message-toast {
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toast-in 0.2s ease-out;
}
.message-toast.success {
  background: var(--green-light);
  color: #067a55;
}
.message-toast.error {
  background: var(--red-light);
  color: var(--red);
}
.message-toast.info,
.message-toast.warning {
  background: var(--blue-pale);
  color: var(--primary-blue-deep);
}

@keyframes toast-in {
  from {
    transform: translateY(12px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ---------- Auth pages ---------- */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  background: #fff;
  box-shadow: var(--shadow-card);
  padding: 32px 28px;
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}

/* ---------- Onboarding stepper ---------- */

.stepper {
  display: flex;
  align-items: center;
  width: 100%;
  margin-bottom: 24px;
}
.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1;
  position: relative;
}
.step .node {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--gray-200);
  color: var(--gray-500);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  z-index: 2;
}
.step.done .node {
  background: var(--green);
  color: #fff;
}
.step.current .node {
  background: var(--primary-blue);
  color: #fff;
  box-shadow: 0 0 0 4px var(--blue-glow);
}
.step .lbl {
  font-size: 11px;
  color: var(--gray-500);
  text-align: center;
  font-weight: 600;
}
.step.done .lbl,
.step.current .lbl {
  color: var(--navy);
}
.step::after {
  content: "";
  position: absolute;
  top: 13px;
  left: calc(50% + 16px);
  right: calc(-50% + 16px);
  height: 2px;
  background: var(--gray-200);
  z-index: 1;
}
.step:last-child::after {
  display: none;
}
.step.done::after {
  background: var(--green);
}

/* ---------- Location picker ---------- */

.location-picker-map {
  position: relative;
  height: 260px;
  width: 100%;
  overflow: hidden;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}
.location-picker-locate {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 1000;
  display: flex;
  height: 36px;
  width: 36px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: #fff;
  color: var(--gray-700);
  box-shadow: var(--shadow-sm);
}
.location-picker-locate:hover {
  background: var(--gray-50);
  color: var(--primary-blue);
}
.location-search-results {
  position: absolute;
  z-index: 1000;
  margin-top: 4px;
  max-height: 220px;
  width: 100%;
  overflow-y: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: #fff;
  padding: 4px 0;
  font-size: 13px;
  box-shadow: var(--shadow-sm);
}
.location-search-results button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--gray-900);
  font-size: 13px;
}
.location-search-results button:hover {
  background: var(--gray-50);
}

/* ---------- Utility ---------- */

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.text-muted {
  color: var(--gray-500);
}
.section-title {
  font-size: 15.5px;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 4px;
}
.section-subtitle {
  font-size: 12.5px;
  color: var(--gray-500);
  margin-bottom: 14px;
}
