/* ==========================================================================
   Base reset + typography
   ========================================================================== */
* , *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg-app);
  color: var(--grey-900);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4 { margin: 0; font-family: var(--font-serif); color: var(--navy-800); font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--accent-900); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
::selection { background: var(--accent-100); color: var(--navy-900); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ==========================================================================
   Layout primitives
   ========================================================================== */
.container { max-width: var(--content-max); margin: 0 auto; padding: 0 var(--space-6); }
.stack > * + * { margin-top: var(--space-4); }
.cluster { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  --btn-bg: var(--accent);
  --btn-fg: var(--white);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  background: var(--btn-bg); color: var(--btn-fg);
  border: 1.5px solid transparent;
  padding: 11px 20px;
  border-radius: var(--radius-full);
  font-size: var(--text-sm); font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background var(--duration-fast) var(--ease), transform var(--duration-fast) var(--ease), box-shadow var(--duration-fast) var(--ease);
}
.btn:hover { background: var(--accent-900); }
.btn:active { transform: scale(0.98); }
.btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.btn:disabled { background: var(--grey-200); color: var(--grey-400); cursor: not-allowed; }
.btn.btn-lg { padding: 14px 28px; font-size: var(--text-base); }
.btn.btn-sm { padding: 7px 14px; font-size: var(--text-xs); }
.btn.btn-secondary { --btn-bg: var(--navy-800); }
.btn.btn-secondary:hover { background: var(--navy-700); }
.btn.btn-ghost { --btn-bg: transparent; --btn-fg: var(--navy-800); border-color: var(--grey-200); }
.btn.btn-ghost:hover { background: var(--grey-50); border-color: var(--grey-300); }
.btn.btn-danger { --btn-bg: var(--danger); }
.btn.btn-danger:hover { background: #A5301F; }
.btn.btn-block { width: 100%; }
.btn .icon { width: 16px; height: 16px; flex-shrink: 0; }

/* ==========================================================================
   Cards
   ========================================================================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
}
.card-pad { padding: var(--space-6); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-4); }
.card-title { font-size: var(--text-md); color: var(--navy-800); font-weight: 700; }
.card-subtitle { font-size: var(--text-sm); color: var(--grey-600); margin-top: 2px; }

/* ==========================================================================
   Forms
   ========================================================================== */
.field { display: block; margin-bottom: var(--space-4); }
.field-label {
  display: flex; align-items: center; gap: var(--space-2);
  font-size: var(--text-xs); font-weight: 700; color: var(--grey-700);
  text-transform: uppercase; letter-spacing: 0.03em;
  margin-bottom: var(--space-2);
}
.field-hint { font-size: var(--text-xs); color: var(--grey-500); margin-top: var(--space-1); }
input[type="text"], input[type="email"], input[type="tel"], input[type="number"],
input[type="password"], textarea, select {
  display: block; width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--grey-200);
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  background: var(--white);
  transition: border-color var(--duration-fast) var(--ease), box-shadow var(--duration-fast) var(--ease);
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent); box-shadow: var(--shadow-focus);
}
input::placeholder, textarea::placeholder { color: var(--grey-400); }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--space-4); }
@media (max-width: 720px) { .field-grid { grid-template-columns: 1fr; } }

.badge-auto {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase;
  background: var(--success-bg); color: var(--success);
  padding: 3px 8px; border-radius: var(--radius-full);
}

/* ==========================================================================
   Pills / status badges
   ========================================================================== */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: var(--radius-full);
  font-size: 12px; font-weight: 700;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-high, .pill-High { background: var(--danger-bg); color: var(--danger); }
.pill-medium, .pill-Medium { background: var(--warning-bg); color: var(--warning); }
.pill-low, .pill-Low { background: var(--info-bg); color: var(--info); }
.pill-success { background: var(--success-bg); color: var(--success); }
.pill-neutral { background: var(--grey-100); color: var(--grey-600); }

/* ==========================================================================
   Tables
   ========================================================================== */
.table-wrap { overflow-x: auto; border-radius: var(--radius-md); border: 1px solid var(--border); }
table.data-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); background: var(--white); }
table.data-table th {
  text-align: left; font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--grey-500); background: var(--grey-50);
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
table.data-table td { padding: 13px 16px; border-bottom: 1px solid var(--grey-100); color: var(--grey-800); vertical-align: middle; }
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tbody tr { transition: background var(--duration-fast) var(--ease); }
table.data-table tbody tr:hover { background: var(--grey-50); }

/* ==========================================================================
   Toasts (replaces the old plain "status" text lines)
   ========================================================================== */
#toast-root { position: fixed; top: var(--space-5); right: var(--space-5); z-index: 999; display: flex; flex-direction: column; gap: var(--space-2); }
.toast {
  min-width: 280px; max-width: 380px;
  background: var(--navy-900); color: var(--white);
  padding: 14px 18px; border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  font-size: var(--text-sm); display: flex; align-items: flex-start; gap: 10px;
  animation: toast-in var(--duration-base) var(--ease);
}
.toast.toast-error { background: var(--danger); }
.toast.toast-success { background: var(--success); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* ==========================================================================
   Inline status line (lightweight, non-toast feedback e.g. under a button)
   ========================================================================== */
.status-line { font-size: var(--text-sm); min-height: 18px; margin-top: var(--space-2); }
.status-line.error { color: var(--danger); }
.status-line.ok { color: var(--success); }

/* ==========================================================================
   Loading skeletons
   ========================================================================== */
.skeleton {
  background: linear-gradient(90deg, var(--grey-100) 25%, var(--grey-200) 37%, var(--grey-100) 63%);
  background-size: 400% 100%;
  animation: skeleton-shimmer 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ==========================================================================
   Empty states
   ========================================================================== */
.empty-state { text-align: center; padding: var(--space-12) var(--space-6); color: var(--grey-500); }
.empty-state .empty-icon {
  width: 48px; height: 48px; margin: 0 auto var(--space-4);
  border-radius: 50%; background: var(--grey-100);
  display: flex; align-items: center; justify-content: center; color: var(--grey-400);
}
.empty-state h3 { color: var(--grey-700); font-size: var(--text-md); margin-bottom: var(--space-1); }
.empty-state p { font-size: var(--text-sm); max-width: 360px; margin: 0 auto; }

/* ==========================================================================
   Utility
   ========================================================================== */
.hidden { display: none !important; }
.text-muted { color: var(--grey-500); }
.text-danger { color: var(--danger); }
.mt-0 { margin-top: 0 !important; }
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.35); border-top-color: currentColor;
  animation: spin 0.7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

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