/* ============================================================
   EP Local Pro AI — main.css
   Global design system: variables, reset, components
   Mobile-first. System fonts. No external dependencies.
   ============================================================ */

/* ── 1. Design tokens ───────────────────────────────────── */
:root {
  /* Brand colors */
  --navy:   #0f172a;
  --indigo: #4f46e5;
  --gold:   #f59e0b;
  --green:  #10b981;
  --red:    #ef4444;
  --muted:  #64748b;
  --border: #e2e8f0;
  --light:  #f8fafc;
  --ink:    #1e293b;
  --white:  #ffffff;

  /* Indigo tints */
  --indigo-50:  #eef2ff;
  --indigo-100: #e0e7ff;
  --indigo-600: #4338ca;
  --indigo-700: #3730a3;

  /* Green tints */
  --green-50:  #ecfdf5;
  --green-100: #d1fae5;
  --green-700: #047857;

  /* Red tints */
  --red-50:  #fef2f2;
  --red-100: #fee2e2;
  --red-700: #b91c1c;

  /* Gold tints */
  --gold-50:  #fffbeb;
  --gold-100: #fef3c7;
  --gold-700: #b45309;

  /* Typography */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, "Noto Sans", sans-serif,
          "Apple Color Emoji", "Segoe UI Emoji";
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo,
               Courier, monospace;

  --text-xs:   0.75rem;   /* 12px */
  --text-sm:   0.875rem;  /* 14px */
  --text-base: 1rem;      /* 16px */
  --text-lg:   1.125rem;  /* 18px */
  --text-xl:   1.25rem;   /* 20px */
  --text-2xl:  1.5rem;    /* 24px */
  --text-3xl:  1.875rem;  /* 30px */
  --text-4xl:  2.25rem;   /* 36px */

  --weight-normal:   400;
  --weight-medium:   500;
  --weight-semibold: 600;
  --weight-bold:     700;

  --leading-tight:  1.25;
  --leading-snug:   1.375;
  --leading-normal: 1.5;
  --leading-relaxed:1.625;

  /* Spacing scale (4px base) */
  --sp-1:  0.25rem;
  --sp-2:  0.5rem;
  --sp-3:  0.75rem;
  --sp-4:  1rem;
  --sp-5:  1.25rem;
  --sp-6:  1.5rem;
  --sp-8:  2rem;
  --sp-10: 2.5rem;
  --sp-12: 3rem;
  --sp-16: 4rem;
  --sp-20: 5rem;

  /* Border radius */
  --radius-sm: 0.25rem;
  --radius:    0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl:1.5rem;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow:    0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --duration-fast:   100ms;
  --duration:        150ms;
  --duration-slow:   250ms;

  /* Layout */
  --max-w-sm:   24rem;
  --max-w-md:   28rem;
  --max-w-lg:   32rem;
  --max-w-xl:   36rem;
  --max-w-2xl:  42rem;
  --max-w-3xl:  48rem;
  --max-w-4xl:  56rem;
  --max-w-5xl:  64rem;
  --max-w-6xl:  72rem;
  --max-w-7xl:  80rem;

  /* Z-index scale */
  --z-base:    0;
  --z-raised:  10;
  --z-dropdown:100;
  --z-sticky:  200;
  --z-modal:   300;
  --z-toast:   400;
}


/* ── 2. Box-sizing reset ─────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}


/* ── 3. Base / document ──────────────────────────────────── */
html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  height: 100%;
}

body {
  font-family: var(--font);
  font-size: var(--text-base);
  font-weight: var(--weight-normal);
  line-height: var(--leading-normal);
  color: var(--ink);
  background-color: var(--light);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Focus ring — visible for keyboard, hidden for mouse */
:focus-visible {
  outline: 2px solid var(--indigo);
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}


/* ── 4. Typography ───────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  color: var(--navy);
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl);  }
h4 { font-size: var(--text-lg);  }
h5 { font-size: var(--text-base);}
h6 { font-size: var(--text-sm);  }

@media (min-width: 768px) {
  h1 { font-size: var(--text-4xl); }
  h2 { font-size: var(--text-3xl); }
  h3 { font-size: var(--text-2xl); }
}

p {
  line-height: var(--leading-relaxed);
  color: var(--ink);
}

a {
  color: var(--indigo);
  text-decoration: none;
  transition: color var(--duration) var(--ease);
}

a:hover {
  color: var(--indigo-600);
  text-decoration: underline;
}

strong, b { font-weight: var(--weight-semibold); }
em, i     { font-style: italic; }

small {
  font-size: var(--text-sm);
  color: var(--muted);
}

code, kbd, pre {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

ul, ol {
  list-style: none;
}

img, svg, video {
  display: block;
  max-width: 100%;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--sp-6) 0;
}


/* ── 5. Layout utilities ─────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--max-w-7xl);
  margin-inline: auto;
  padding-inline: var(--sp-4);
}

@media (min-width: 640px)  { .container { padding-inline: var(--sp-6); } }
@media (min-width: 1024px) { .container { padding-inline: var(--sp-8); } }

.section {
  padding-block: var(--sp-12);
}

@media (min-width: 768px) {
  .section { padding-block: var(--sp-20); }
}

/* Flex helpers */
.flex       { display: flex; }
.flex-col   { flex-direction: column; }
.items-center  { align-items: center; }
.items-start   { align-items: flex-start; }
.items-end     { align-items: flex-end; }
.justify-center       { justify-content: center; }
.justify-between      { justify-content: space-between; }
.justify-end          { justify-content: flex-end; }
.flex-wrap    { flex-wrap: wrap; }
.flex-1       { flex: 1 1 0%; }
.gap-1  { gap: var(--sp-1); }
.gap-2  { gap: var(--sp-2); }
.gap-3  { gap: var(--sp-3); }
.gap-4  { gap: var(--sp-4); }
.gap-6  { gap: var(--sp-6); }
.gap-8  { gap: var(--sp-8); }

/* Grid */
.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

/* Spacing */
.mt-auto { margin-top: auto; }
.ml-auto { margin-left: auto; }

/* Text */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--muted); }
.text-sm     { font-size: var(--text-sm); }
.text-xs     { font-size: var(--text-xs); }
.text-lg     { font-size: var(--text-lg); }
.text-xl     { font-size: var(--text-xl); }
.font-medium { font-weight: var(--weight-medium); }
.font-semibold { font-weight: var(--weight-semibold); }
.font-bold   { font-weight: var(--weight-bold); }

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

/* Width */
.w-full  { width: 100%; }
.w-auto  { width: auto; }
.max-w-sm  { max-width: var(--max-w-sm); }
.max-w-md  { max-width: var(--max-w-md); }
.max-w-lg  { max-width: var(--max-w-lg); }
.max-w-xl  { max-width: var(--max-w-xl); }
.max-w-2xl { max-width: var(--max-w-2xl); }

/* Overflow */
.overflow-hidden { overflow: hidden; }
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


/* ── 6. Buttons ──────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-5);
  font-family: var(--font);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  line-height: 1.5;
  border-radius: var(--radius-md);
  border: 1.5px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
  transition:
    background-color var(--duration) var(--ease),
    border-color     var(--duration) var(--ease),
    color            var(--duration) var(--ease),
    box-shadow       var(--duration) var(--ease),
    opacity          var(--duration) var(--ease);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Primary */
.btn--primary {
  background-color: var(--indigo);
  border-color: var(--indigo);
  color: var(--white);
}
.btn--primary:hover {
  background-color: var(--indigo-600);
  border-color: var(--indigo-600);
  box-shadow: var(--shadow-md);
  text-decoration: none;
  color: var(--white);
}
.btn--primary:active {
  background-color: var(--indigo-700);
  border-color: var(--indigo-700);
  box-shadow: none;
}

/* Ghost / outline */
.btn--ghost {
  background-color: transparent;
  border-color: var(--border);
  color: var(--ink);
}
.btn--ghost:hover {
  background-color: var(--light);
  border-color: var(--muted);
  text-decoration: none;
  color: var(--ink);
}
.btn--ghost:active {
  background-color: var(--border);
}

/* Danger */
.btn--danger {
  background-color: var(--red);
  border-color: var(--red);
  color: var(--white);
}
.btn--danger:hover {
  background-color: var(--red-700);
  border-color: var(--red-700);
  box-shadow: var(--shadow-md);
  text-decoration: none;
  color: var(--white);
}

/* Success */
.btn--success {
  background-color: var(--green);
  border-color: var(--green);
  color: var(--white);
}
.btn--success:hover {
  background-color: var(--green-700);
  border-color: var(--green-700);
  box-shadow: var(--shadow-md);
  text-decoration: none;
  color: var(--white);
}

/* Gold / accent */
.btn--gold {
  background-color: var(--gold);
  border-color: var(--gold);
  color: var(--navy);
}
.btn--gold:hover {
  background-color: var(--gold-700);
  border-color: var(--gold-700);
  box-shadow: var(--shadow-md);
  text-decoration: none;
  color: var(--white);
}

/* Sizes */
.btn--sm {
  padding: var(--sp-1) var(--sp-3);
  font-size: var(--text-xs);
  border-radius: var(--radius);
}

.btn--lg {
  padding: var(--sp-3) var(--sp-8);
  font-size: var(--text-base);
  border-radius: var(--radius-lg);
}

.btn--xl {
  padding: var(--sp-4) var(--sp-10);
  font-size: var(--text-lg);
  border-radius: var(--radius-lg);
}

/* Full width */
.btn--block {
  width: 100%;
}

/* Icon-only button */
.btn--icon {
  padding: var(--sp-2);
  border-radius: var(--radius-md);
}

/* Loading state */
.btn.is-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}
.btn.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 1rem;
  height: 1rem;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: var(--radius-full);
  animation: spin 0.6s linear infinite;
  color: var(--white);
}


/* ── 7. Cards ────────────────────────────────────────────── */
.card {
  background-color: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card--hover {
  transition: box-shadow var(--duration-slow) var(--ease),
              transform  var(--duration-slow) var(--ease);
  cursor: pointer;
}
.card--hover:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.card__header {
  padding: var(--sp-4) var(--sp-6);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
}

.card__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--navy);
  margin: 0;
}

.card__body {
  padding: var(--sp-6);
}

.card__footer {
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--border);
  background-color: var(--light);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}


/* ── 8. Form elements ────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--ink);
}

.form-label--required::after {
  content: " *";
  color: var(--red);
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--muted);
  margin-top: var(--sp-1);
}

.form-error {
  font-size: var(--text-xs);
  color: var(--red);
  margin-top: var(--sp-1);
}

.input,
.select,
.textarea {
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  font-family: var(--font);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  color: var(--ink);
  background-color: var(--white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  transition:
    border-color var(--duration) var(--ease),
    box-shadow   var(--duration) var(--ease);
  appearance: none;
  -webkit-appearance: none;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--muted);
  opacity: 0.75;
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--muted);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px var(--indigo-100);
}

.input.is-error,
.select.is-error,
.textarea.is-error {
  border-color: var(--red);
}
.input.is-error:focus,
.select.is-error:focus,
.textarea.is-error:focus {
  box-shadow: 0 0 0 3px var(--red-100);
}

.input:disabled,
.select:disabled,
.textarea:disabled {
  background-color: var(--light);
  color: var(--muted);
  cursor: not-allowed;
}

.textarea {
  resize: vertical;
  min-height: 80px;
}

/* Select arrow */
.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--sp-3) center;
  padding-right: var(--sp-8);
}

/* Checkbox & radio */
.checkbox,
.radio {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--ink);
}

.checkbox input[type="checkbox"],
.radio   input[type="radio"] {
  width: 1rem;
  height: 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color var(--duration) var(--ease),
              border-color     var(--duration) var(--ease);
  background-color: var(--white);
}

.radio input[type="radio"] {
  border-radius: var(--radius-full);
}

.checkbox input[type="checkbox"]:checked {
  background-color: var(--indigo);
  border-color: var(--indigo);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M2 6l3 3 5-5' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
}

.radio input[type="radio"]:checked {
  background-color: var(--indigo);
  border-color: var(--indigo);
  box-shadow: inset 0 0 0 3px var(--white);
}

/* Input group (icon inside input) */
.input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.input-group .input {
  padding-left: var(--sp-9);
}

.input-group__icon {
  position: absolute;
  left: var(--sp-3);
  color: var(--muted);
  pointer-events: none;
  display: flex;
  align-items: center;
}

.input-group__suffix {
  position: absolute;
  right: var(--sp-3);
  color: var(--muted);
  display: flex;
  align-items: center;
}


/* ── 9. Badges ───────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 0.125rem var(--sp-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  line-height: 1.5;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.badge--default {
  background-color: var(--light);
  color: var(--muted);
  border: 1px solid var(--border);
}

.badge--indigo {
  background-color: var(--indigo-50);
  color: var(--indigo-600);
}

.badge--green {
  background-color: var(--green-50);
  color: var(--green-700);
}

.badge--red {
  background-color: var(--red-50);
  color: var(--red-700);
}

.badge--gold {
  background-color: var(--gold-50);
  color: var(--gold-700);
}

.badge--navy {
  background-color: var(--navy);
  color: var(--white);
}

/* Status dot */
.badge::before {
  content: none;
}
.badge--dot::before {
  content: "";
  display: inline-block;
  width: 0.4rem;
  height: 0.4rem;
  border-radius: var(--radius-full);
  background-color: currentColor;
}


/* ── 10. Toast notifications ─────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: var(--sp-4);
  right: var(--sp-4);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  pointer-events: none;
  max-width: min(calc(100vw - var(--sp-8)), 20rem);
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background-color: var(--navy);
  color: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  pointer-events: auto;
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
  opacity: 0;
  transform: translateX(100%);
  transition:
    opacity   var(--duration-slow) var(--ease),
    transform var(--duration-slow) var(--ease);
}

.toast.toast--visible {
  opacity: 1;
  transform: translateX(0);
}

.toast.toast--hiding {
  opacity: 0;
  transform: translateX(100%);
}

.toast__icon {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  margin-top: 0.1rem;
}

.toast__body {
  flex: 1;
  min-width: 0;
}

.toast__title {
  font-weight: var(--weight-semibold);
  margin-bottom: 0.125rem;
}

.toast__msg {
  opacity: 0.85;
  font-size: var(--text-xs);
}

.toast--success {
  background-color: var(--green);
}

.toast--error {
  background-color: var(--red);
}

.toast--warning {
  background-color: var(--gold);
  color: var(--navy);
}

.toast--info {
  background-color: var(--indigo);
}


/* ── 11. Loading spinner ─────────────────────────────────── */
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.spinner {
  display: inline-block;
  width: 1.5rem;
  height: 1.5rem;
  border: 2.5px solid var(--border);
  border-top-color: var(--indigo);
  border-radius: var(--radius-full);
  animation: spin 0.65s linear infinite;
  flex-shrink: 0;
}

.spinner--sm {
  width: 1rem;
  height: 1rem;
  border-width: 2px;
}

.spinner--lg {
  width: 2.5rem;
  height: 2.5rem;
  border-width: 3px;
}

.spinner--white {
  border-color: rgba(255,255,255,0.3);
  border-top-color: var(--white);
}

/* Page-level loading overlay */
.page-loading {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--white);
  z-index: var(--z-modal);
  transition: opacity var(--duration-slow) var(--ease);
}

.page-loading.is-done {
  opacity: 0;
  pointer-events: none;
}

/* Skeleton loader */
@keyframes shimmer {
  from { background-position: -200% 0; }
  to   { background-position:  200% 0; }
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--border) 25%,
    var(--light)  50%,
    var(--border) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: var(--radius);
}

.skeleton--text {
  height: 1em;
  border-radius: var(--radius-sm);
}

.skeleton--title {
  height: 1.5em;
  width: 60%;
  border-radius: var(--radius-sm);
}

.skeleton--avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-full);
}


/* ── 12. Data table ──────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  white-space: nowrap;
}

.data-table thead {
  background-color: var(--light);
}

.data-table th {
  padding: var(--sp-3) var(--sp-4);
  text-align: left;
  font-weight: var(--weight-semibold);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: var(--sp-3) var(--sp-4);
  color: var(--ink);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr {
  transition: background-color var(--duration-fast) var(--ease);
}

.data-table tbody tr:hover {
  background-color: var(--light);
}

.data-table tbody tr.is-selected {
  background-color: var(--indigo-50);
}

/* Sortable header */
.data-table th.is-sortable {
  cursor: pointer;
  user-select: none;
}
.data-table th.is-sortable:hover {
  color: var(--ink);
}

/* Empty state */
.table-empty {
  padding: var(--sp-12) var(--sp-4);
  text-align: center;
  color: var(--muted);
  font-size: var(--text-sm);
}


/* ── 13. Modal ───────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgb(0 0 0 / 0.5);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-slow) var(--ease);
}

.modal-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background-color: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: var(--max-w-lg);
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(var(--sp-4)) scale(0.98);
  transition: transform var(--duration-slow) var(--ease);
}

.modal-backdrop.is-open .modal {
  transform: translateY(0) scale(1);
}

.modal__header {
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
}

.modal__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--navy);
}

.modal__close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: var(--sp-1);
  border-radius: var(--radius);
  transition: color var(--duration) var(--ease),
              background-color var(--duration) var(--ease);
  display: flex;
  align-items: center;
}
.modal__close:hover {
  color: var(--ink);
  background-color: var(--light);
}

.modal__body {
  padding: var(--sp-6);
}

.modal__footer {
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-3);
}


/* ── 14. Alert / banner ──────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  border: 1px solid transparent;
}

.alert--info {
  background-color: var(--indigo-50);
  border-color: var(--indigo-100);
  color: var(--indigo-600);
}

.alert--success {
  background-color: var(--green-50);
  border-color: var(--green-100);
  color: var(--green-700);
}

.alert--warning {
  background-color: var(--gold-50);
  border-color: var(--gold-100);
  color: var(--gold-700);
}

.alert--error {
  background-color: var(--red-50);
  border-color: var(--red-100);
  color: var(--red-700);
}

.alert__icon {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
}

.alert__body { flex: 1; min-width: 0; }
.alert__title { font-weight: var(--weight-semibold); }


/* ── 15. Empty state ─────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-4);
  padding: var(--sp-16) var(--sp-8);
  text-align: center;
}

.empty-state__icon {
  font-size: 3rem;
  line-height: 1;
  opacity: 0.4;
}

.empty-state__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--navy);
}

.empty-state__desc {
  font-size: var(--text-sm);
  color: var(--muted);
  max-width: 24rem;
  line-height: var(--leading-relaxed);
}


/* ── 16. Avatar ──────────────────────────────────────────── */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background-color: var(--indigo-100);
  color: var(--indigo-600);
  font-weight: var(--weight-semibold);
  font-size: var(--text-sm);
  overflow: hidden;
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
}

.avatar--sm { width: 2rem;  height: 2rem;  font-size: var(--text-xs); }
.avatar--lg { width: 3rem;  height: 3rem;  font-size: var(--text-base); }
.avatar--xl { width: 4rem;  height: 4rem;  font-size: var(--text-lg); }

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}


/* ── 17. Stats / metric cards ────────────────────────────── */
.stat-card {
  background-color: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--sp-5) var(--sp-6);
  box-shadow: var(--shadow-sm);
}

.stat-card__label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: var(--sp-2);
}

.stat-card__value {
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  color: var(--navy);
  line-height: 1;
}

.stat-card__change {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  margin-top: var(--sp-2);
}

.stat-card__change--up   { color: var(--green); }
.stat-card__change--down { color: var(--red); }


/* ── 18. Divider with label ──────────────────────────────── */
.divider {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background-color: var(--border);
}


/* ── 19. Progress bar ────────────────────────────────────── */
.progress {
  width: 100%;
  height: 0.5rem;
  background-color: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress__bar {
  height: 100%;
  background-color: var(--indigo);
  border-radius: var(--radius-full);
  transition: width var(--duration-slow) var(--ease);
}

.progress__bar--green  { background-color: var(--green); }
.progress__bar--gold   { background-color: var(--gold); }
.progress__bar--red    { background-color: var(--red); }


/* ── 20. Tabs ────────────────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  gap: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex-shrink: 0;
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
  margin-bottom: -1px;
  font-family: var(--font);
  transition: color var(--duration) var(--ease),
              border-color var(--duration) var(--ease);
  white-space: nowrap;
}

.tab:hover {
  color: var(--ink);
}

.tab.is-active {
  color: var(--indigo);
  border-bottom-color: var(--indigo);
}

.tab-panel {
  display: none;
  padding-top: var(--sp-6);
}

.tab-panel.is-active {
  display: block;
}


/* ── 21. Dropdown menu ───────────────────────────────────── */
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown__menu {
  position: absolute;
  top: calc(100% + var(--sp-1));
  right: 0;
  min-width: 10rem;
  background-color: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-dropdown);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition:
    opacity   var(--duration) var(--ease),
    transform var(--duration) var(--ease);
}

.dropdown.is-open .dropdown__menu {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.dropdown__item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--text-sm);
  color: var(--ink);
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  font-family: var(--font);
  transition: background-color var(--duration-fast) var(--ease);
  text-decoration: none;
}

.dropdown__item:hover {
  background-color: var(--light);
  text-decoration: none;
  color: var(--ink);
}

.dropdown__item--danger {
  color: var(--red);
}
.dropdown__item--danger:hover {
  background-color: var(--red-50);
  color: var(--red);
}

.dropdown__divider {
  height: 1px;
  background-color: var(--border);
  margin: var(--sp-1) 0;
}


/* ── 22. Nav / header ────────────────────────────────────── */
.site-nav {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background-color: var(--white);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.site-nav__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  height: 3.5rem;
  padding-inline: var(--sp-4);
  max-width: var(--max-w-7xl);
  margin-inline: auto;
}

@media (min-width: 1024px) {
  .site-nav__inner { padding-inline: var(--sp-8); }
}

.site-nav__logo {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-weight: var(--weight-bold);
  color: var(--navy);
  text-decoration: none;
  font-size: var(--text-lg);
}

.site-nav__logo:hover {
  color: var(--indigo);
  text-decoration: none;
}

.site-nav__links {
  display: none;
}

@media (min-width: 768px) {
  .site-nav__links {
    display: flex;
    align-items: center;
    gap: var(--sp-1);
  }
}

.site-nav__link {
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--muted);
  border-radius: var(--radius-md);
  transition: color var(--duration) var(--ease),
              background-color var(--duration) var(--ease);
  text-decoration: none;
}

.site-nav__link:hover {
  color: var(--ink);
  background-color: var(--light);
  text-decoration: none;
}

.site-nav__link.is-active {
  color: var(--indigo);
  background-color: var(--indigo-50);
}

.site-nav__actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}


/* ── 23. Responsive helpers ──────────────────────────────── */
/* Show/hide at breakpoints */
.hide-mobile  { display: none !important; }
.show-mobile  { display: block !important; }

@media (min-width: 640px) {
  .hide-sm { display: none !important; }
  .show-sm { display: block !important; }
}

@media (min-width: 768px) {
  .hide-mobile  { display: initial !important; }
  .show-mobile  { display: none !important; }
  .hide-md { display: none !important; }
  .show-md { display: block !important; }
}

@media (min-width: 1024px) {
  .hide-lg { display: none !important; }
  .show-lg { display: block !important; }
}

/* Responsive grid */
@media (min-width: 640px) {
  .sm\:grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 768px) {
  .md\:grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
  .md\:grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1024px) {
  .lg\:grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
  .lg\:grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
}


/* ── 24. Miscellaneous utilities ─────────────────────────── */
.rounded-full { border-radius: var(--radius-full); }
.rounded      { border-radius: var(--radius); }
.rounded-lg   { border-radius: var(--radius-lg); }
.rounded-xl   { border-radius: var(--radius-xl); }

.shadow       { box-shadow: var(--shadow); }
.shadow-md    { box-shadow: var(--shadow-md); }
.shadow-lg    { box-shadow: var(--shadow-lg); }
.shadow-none  { box-shadow: none; }

.bg-white     { background-color: var(--white); }
.bg-light     { background-color: var(--light); }
.bg-navy      { background-color: var(--navy); }
.bg-indigo    { background-color: var(--indigo); }

.border       { border: 1px solid var(--border); }
.border-t     { border-top: 1px solid var(--border); }
.border-b     { border-bottom: 1px solid var(--border); }

.p-0 { padding: 0; }
.p-4 { padding: var(--sp-4); }
.p-6 { padding: var(--sp-6); }
.px-4 { padding-inline: var(--sp-4); }
.px-6 { padding-inline: var(--sp-6); }
.py-2 { padding-block: var(--sp-2); }
.py-4 { padding-block: var(--sp-4); }
.py-6 { padding-block: var(--sp-6); }

.m-0  { margin: 0; }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }
.mb-8 { margin-bottom: var(--sp-8); }
.mt-2 { margin-top: var(--sp-2); }
.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }
.mt-8 { margin-top: var(--sp-8); }
.mx-auto { margin-inline: auto; }

/* Cursor */
.cursor-pointer { cursor: pointer; }
.cursor-default { cursor: default; }
.select-none    { user-select: none; }

/* Position */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed    { position: fixed; }
.sticky   { position: sticky; }
.inset-0  { inset: 0; }

/* Opacity */
.opacity-0    { opacity: 0; }
.opacity-50   { opacity: 0.5; }
.opacity-75   { opacity: 0.75; }
.opacity-100  { opacity: 1; }

/* Line clamp */
.line-clamp-1 { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.line-clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* Transition */
.transition { transition: all var(--duration) var(--ease); }
