/* ═══════════════════════════════════════════════════════════════════════════════
   Pemi AI – Policy Indexing Dashboard Styles
   Design system inspired by the Pemi frontend template
   ═══════════════════════════════════════════════════════════════════════════════ */

/* ── Google Font ─────────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

/* ── CSS Custom Properties ───────────────────────────────────────────────────── */
:root {
  /* Brand */
  --color-primary: #E11D48;
  --color-primary-hover: #BE123C;
  --color-primary-light: #FFF1F2;
  --color-primary-glow: rgba(225, 29, 72, 0.15);
  --color-primary-ring: rgba(225, 29, 72, 0.25);

  /* Neutrals */
  --color-white: #FFFFFF;
  --color-bg: #FAFAFA;
  --color-surface: #FFFFFF;
  --color-border: #E5E7EB;
  --color-border-hover: #D1D5DB;
  --color-text-primary: #111827;
  --color-text-secondary: #6B7280;
  --color-text-muted: #9CA3AF;
  --color-text-invert: #FFFFFF;

  /* Status */
  --color-success: #059669;
  --color-success-bg: #ECFDF5;
  --color-warning: #D97706;
  --color-warning-bg: #FFFBEB;
  --color-error: #DC2626;
  --color-error-bg: #FEF2F2;
  --color-info: #2563EB;
  --color-info-bg: #EFF6FF;
  --color-pending: #8B5CF6;
  --color-pending-bg: #F5F3FF;

  /* Layout */
  --max-width: 1200px;
  --nav-height: 64px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.08);
  --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.1);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-card-hover: 0 10px 40px rgba(0, 0, 0, 0.08);

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Font */
  --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-family-body: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Reset ───────────────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family-body);
  background: var(--color-bg);
  color: var(--color-text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

::selection {
  background: var(--color-primary);
  color: var(--color-text-invert);
}

/* ── Navbar ──────────────────────────────────────────────────────────────────── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--color-border);
  height: var(--nav-height);
}

.nav__inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.nav__logo {
  width: 36px;
  height: 36px;
  background: var(--color-primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-invert);
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.5px;
}

.nav__title {
  font-family: var(--font-family);
  font-size: 18px;
  font-weight: 700;
  color: var(--color-text-primary);
  letter-spacing: -0.3px;
}

.nav__links {
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
}

.nav__link {
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.nav__link:hover {
  color: var(--color-text-primary);
  background: var(--color-bg);
}

.nav__link--active {
  color: var(--color-primary);
  background: var(--color-primary-light);
}

.nav__cta {
  padding: 8px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-invert);
  background: var(--color-primary);
  border: none;
  border-radius: var(--radius-full);
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.nav__cta:hover {
  background: var(--color-primary-hover);
  box-shadow: 0 4px 14px var(--color-primary-glow);
}

/* ── Page Layout ─────────────────────────────────────────────────────────────── */
.page {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 40px 24px 80px;
}

/* ── Page Header ─────────────────────────────────────────────────────────────── */
.page-header {
  margin-bottom: 40px;
}

.page-header__badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 16px;
  letter-spacing: 0.01em;
}

.page-header__badge svg {
  width: 14px;
  height: 14px;
}

.page-header__title {
  font-family: var(--font-family);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1.3;
  color: var(--color-text-primary);
  margin-bottom: 3px;
}

.page-header__desc {
  font-size: 13px;
  color: var(--color-text-secondary);
  max-width: 600px;
  line-height: 1.5;
}

/* ── Card Container ──────────────────────────────────────────────────────────── */
.dashboard {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  align-items: start;
}

@media (max-width: 900px) {
  .dashboard {
    grid-template-columns: 1fr;
  }
}

/* ── Card ────────────────────────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: box-shadow var(--transition-base);
}

.card:hover {
  box-shadow: var(--shadow-card-hover);
}

.card__header {
  padding: 24px 28px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card__title {
  font-family: var(--font-family);
  font-size: 18px;
  font-weight: 700;
  color: var(--color-text-primary);
  letter-spacing: -0.2px;
}

.card__icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.card__icon svg {
  width: 20px;
  height: 20px;
}

.card__body {
  padding: 24px 28px 28px;
}

/* ── Upload Zone ─────────────────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-base);
  background: var(--color-bg);
  position: relative;
}

.upload-zone:hover,
.upload-zone--active {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.upload-zone--active {
  box-shadow: 0 0 0 4px var(--color-primary-ring);
}

.upload-zone__icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  border-radius: var(--radius-lg);
  background: var(--color-primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary);
  transition: transform var(--transition-base);
}

.upload-zone:hover .upload-zone__icon {
  transform: translateY(-2px);
}

.upload-zone__icon svg {
  width: 28px;
  height: 28px;
}

.upload-zone__text {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 4px;
}

.upload-zone__text span {
  color: var(--color-primary);
}

.upload-zone__hint {
  font-size: 13px;
  color: var(--color-text-muted);
}

.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* ── File Preview ────────────────────────────────────────────────────────────── */
.file-preview {
  display: none;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-top: 16px;
  animation: slideUp 0.3s ease;
}

.file-preview--visible {
  display: flex;
}

.file-preview__icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  background: var(--color-primary-light);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.file-preview__icon svg {
  width: 20px;
  height: 20px;
}

.file-preview__info {
  flex: 1;
  min-width: 0;
}

.file-preview__name {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-preview__size {
  font-size: 12px;
  color: var(--color-text-muted);
}

.file-preview__remove {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.file-preview__remove:hover {
  background: var(--color-error-bg);
  color: var(--color-error);
}

.file-preview__remove svg {
  width: 16px;
  height: 16px;
}

/* ── Form ────────────────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 20px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 500px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}

.form-label .required {
  color: var(--color-primary);
  margin-left: 2px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  font-family: var(--font-family);
  color: var(--color-text-primary);
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  outline: none;
  transition: all var(--transition-fast);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--color-text-muted);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-ring);
}

.form-select {
  appearance: none;
  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='%239CA3AF' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

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

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-family);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  letter-spacing: 0.01em;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--color-primary);
  color: var(--color-text-invert);
  width: 100%;
}

.btn--primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
  box-shadow: 0 4px 14px var(--color-primary-glow);
  transform: translateY(-1px);
}

.btn--primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn--ghost {
  background: transparent;
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}

.btn--ghost:hover {
  background: var(--color-bg);
  border-color: var(--color-border-hover);
}

.btn--sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn--icon {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: var(--radius-sm);
}

.btn svg {
  width: 16px;
  height: 16px;
}

/* ── Spinner inside button ───────────────────────────────────────────────────── */
.btn__spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: none;
}

.btn--loading .btn__spinner {
  display: block;
}


/* ── Progress Bar ────────────────────────────────────────────────────────────── */
.progress-section {
  display: none;
  margin-top: 20px;
  animation: slideUp 0.3s ease;
}

.progress-section--visible {
  display: block;
}

.progress-bar {
  height: 8px;
  background: var(--color-bg);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-bar__fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--color-primary), #F43F5E);
  border-radius: var(--radius-full);
  transition: width 0.5s ease;
}

.progress-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.progress-message {
  font-size: 13px;
  color: var(--color-text-secondary);
  font-weight: 500;
}

.progress-percent {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-primary);
}

/* ── Table ───────────────────────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.table th {
  text-align: left;
  padding: 12px 16px;
  font-weight: 600;
  color: var(--color-text-secondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.table th:first-child {
  border-radius: var(--radius-md) 0 0 0;
}

.table th:last-child {
  border-radius: 0 var(--radius-md) 0 0;
}

.table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-primary);
  vertical-align: middle;
}

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

.table tr {
  transition: background var(--transition-fast);
}

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

.table__title {
  font-weight: 600;
  color: var(--color-text-primary);
}

.table__meta {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* ── Status Badge ────────────────────────────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.status-badge--indexed {
  background: var(--color-success-bg);
  color: var(--color-success);
}

.status-badge--indexing {
  background: var(--color-info-bg);
  color: var(--color-info);
}

.status-badge--pending {
  background: var(--color-pending-bg);
  color: var(--color-pending);
}

.status-badge--failed {
  background: var(--color-error-bg);
  color: var(--color-error);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-badge--indexing .status-dot {
  animation: pulse 1.5s ease-in-out infinite;
}

/* ── Empty State ─────────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
}

.empty-state__icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: var(--radius-lg);
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
}

.empty-state__icon svg {
  width: 28px;
  height: 28px;
}

.empty-state__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 4px;
}

.empty-state__desc {
  font-size: 13px;
  color: var(--color-text-muted);
}

/* ── Stats Row ───────────────────────────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

@media (max-width: 860px) {
  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .stats-row {
    grid-template-columns: 1fr;
  }
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  transition: all var(--transition-base);
}

.stat-card:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-2px);
}

.stat-card__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.stat-card__value {
  font-family: var(--font-family);
  font-size: 30px;
  font-weight: 800;
  color: var(--color-text-primary);
  letter-spacing: -0.5px;
  line-height: 1.1;
}

.stat-card__value--primary {
  color: var(--color-primary);
}

/* ── Toast / Alert ───────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: calc(var(--nav-height) + 16px);
  right: 24px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 320px;
  max-width: 420px;
  animation: slideInRight 0.35s ease;
  font-size: 14px;
}

.toast--success {
  border-left: 4px solid var(--color-success);
}

.toast--error {
  border-left: 4px solid var(--color-error);
}

.toast--info {
  border-left: 4px solid var(--color-info);
}

.toast__icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

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

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

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

.toast__message {
  flex: 1;
  font-weight: 500;
  color: var(--color-text-primary);
}

.toast__close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.toast__close:hover {
  background: var(--color-bg);
  color: var(--color-text-primary);
}

/* ── Delete confirmation modal ───────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-overlay--visible {
  display: flex;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 400px;
  width: 90%;
  box-shadow: var(--shadow-xl);
  animation: scaleIn 0.25s ease;
}

.modal__title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.modal__desc {
  font-size: 14px;
  color: var(--color-text-secondary);
  line-height: 1.6;
  margin-bottom: 24px;
}

.modal__actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.btn--danger {
  background: var(--color-error);
  color: var(--color-text-invert);
}

.btn--danger:hover {
  background: #B91C1C;
}

/* ── Tags input ──────────────────────────────────────────────────────────────── */
.tags-input {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  min-height: 42px;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: text;
  transition: all var(--transition-fast);
}

.tags-input:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-ring);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  animation: scaleIn 0.2s ease;
}

.tag__remove {
  background: none;
  border: none;
  color: var(--color-primary);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  opacity: 0.6;
  transition: opacity var(--transition-fast);
}

.tag__remove:hover {
  opacity: 1;
}

.tag__remove svg {
  width: 12px;
  height: 12px;
}

.tags-input__field {
  border: none;
  outline: none;
  font-size: 14px;
  font-family: var(--font-family);
  color: var(--color-text-primary);
  min-width: 80px;
  flex: 1;
  background: transparent;
}

.tags-input__field::placeholder {
  color: var(--color-text-muted);
}

/* ── Animations ──────────────────────────────────────────────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* Skeleton row animation */
.skeleton-row td {
  position: relative;
  overflow: hidden;
}

.skeleton {
  display: block;
  height: 14px;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  border-radius: var(--radius-sm);
  animation: shimmer 1.5s infinite;
}

.skeleton--sm {
  width: 60px;
}

.skeleton--md {
  width: 120px;
}

.skeleton--lg {
  width: 180px;
}

/* ── App Shell (sidebar layout) ─────────────────────────────────────────────── */
:root {
  --sidebar-width: 240px;
  --topbar-height: 64px;
}

.app-layout {
  display: flex;
  min-height: 100vh;
  background: #F4F6FA;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 200;
  transition: transform var(--transition-base);
  overflow-y: auto;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  padding: 0 24px;
  height: var(--topbar-height);
  border-bottom: 1px solid var(--color-border);
  text-decoration: none;
  flex-shrink: 0;
}

.sidebar__nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
}

.sidebar__section {
  margin-bottom: 4px;
}

.sidebar__section + .sidebar__section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}

.sidebar__section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-muted);
  padding: 0 12px;
  margin-bottom: 6px;
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-secondary);
  text-decoration: none;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  margin-bottom: 2px;
}

.sidebar__link svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.sidebar__link:hover {
  background: #F4F6FA;
  color: var(--color-text-primary);
}

.sidebar__link:hover svg {
  opacity: 1;
}

.sidebar__link--active {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 600;
}

.sidebar__link--active svg {
  opacity: 1;
}

.sidebar__link--active:hover {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.sidebar__footer {
  padding: 16px 12px;
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}

/* ── Sidebar overlay (mobile) ────────────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 199;
}

.sidebar-overlay--visible {
  display: block;
}

/* ── Main content area ───────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  min-width: 0;
  background: #F4F6FA;
}

/* ── Topbar ──────────────────────────────────────────────────────────────────── */
.topbar {
  width: 100%;
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 16px;
}

.topbar__left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.topbar__title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text-primary);
}

.topbar__breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--color-text-muted);
}

.topbar__breadcrumb a {
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.topbar__breadcrumb a:hover { color: var(--color-text-primary); }

.topbar__breadcrumb-sep { opacity: 0.4; }

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.topbar__avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.topbar__icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.topbar__icon-btn:hover {
  background: #F4F6FA;
  color: var(--color-text-primary);
}

/* ── Sidebar toggle (mobile hamburger) ───────────────────────────────────────── */
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-secondary);
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.sidebar-toggle:hover {
  background: #F4F6FA;
  color: var(--color-text-primary);
}

/* ── Page content wrapper ────────────────────────────────────────────────────── */
.page-content,
.page-body {
  flex: 1;
  padding: 32px 36px 60px;
  max-width: 1280px;
  width: 100%;
}

/* ── Mobile sidebar ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar--open {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
  }

  .main-content {
    margin-left: 0;
  }

  .sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .page-content,
  .page-body {
    padding: 20px 16px 60px;
  }
}

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .page {
    padding: 24px 16px 60px;
  }
  .card__body {
    padding: 20px;
  }
  .card__header {
    padding: 20px 20px 0;
  }
  .stats-row {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .stat-card__value {
    font-size: 22px;
  }
  .nav__links {
    display: none;
  }
}
