/* ============================================================
   iCRM Design System — public/css/app.css
   ============================================================ */

/* ── Design Tokens ────────────────────────────────────────── */
:root {
  /* Sidebar */
  --sidebar-width:        220px;
  --sidebar-bg:           #1a1d2e;
  --sidebar-hover-bg:     #22263a;
  --sidebar-active-bg:    #22263a;
  --sidebar-text:         #8b92b5;
  --sidebar-text-hover:   #d4d8f0;
  --sidebar-text-active:  #ffffff;
  --sidebar-section-text: #464d6d;
  --sidebar-border:       #22263a;
  --sidebar-accent:       #5b6cf0;

  /* Topbar */
  --topbar-bg:            #ffffff;
  --topbar-border:        #eaecf0;
  --topbar-height:        56px;

  /* App */
  --body-bg:              #f5f6f9;

  /* Text */
  --text-primary:         #111827;
  --text-secondary:       #4b5563;
  --text-muted:           #9ca3af;
  --text-disabled:        #d1d5db;

  /* Surfaces */
  --surface:              #ffffff;
  --surface-alt:          #f9fafb;
  --surface-hover:        #f3f4f6;

  /* Borders */
  --border:               #e5e7eb;
  --border-strong:        #d1d5db;

  /* Brand */
  --brand:                #1a1d2e;
  --brand-hover:          #22263a;

  /* Accent (interactive highlights) */
  --accent:               #5b6cf0;
  --accent-hover:         #4a5bde;
  --accent-light:         #eef0fd;
  --accent-text:          #3730a3;

  /* Status — green */
  --green:                #16a34a;
  --green-bg:             #dcfce7;
  --green-border:         #bbf7d0;
  --green-text:           #15803d;

  /* Status — red */
  --red:                  #dc2626;
  --red-bg:               #fee2e2;
  --red-border:           #fecaca;
  --red-text:             #b91c1c;

  /* Status — yellow */
  --yellow:               #d97706;
  --yellow-bg:            #fef3c7;
  --yellow-border:        #fde68a;
  --yellow-text:          #92400e;

  /* Status — blue */
  --blue:                 #2563eb;
  --blue-bg:              #dbeafe;
  --blue-border:          #bfdbfe;
  --blue-text:            #1d4ed8;

  /* Status — gray */
  --gray-bg:              #f3f4f6;
  --gray-text:            #6b7280;
  --gray-border:          #d1d5db;

  /* Typography */
  --font:                 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:            ui-monospace, 'SFMono-Regular', 'JetBrains Mono', monospace;
  --font-size-base:       13px;
  --line-height:          1.5;

  /* Spacing */
  --s1:  4px;
  --s2:  8px;
  --s3:  12px;
  --s4:  16px;
  --s5:  20px;
  --s6:  24px;
  --s8:  32px;

  /* Radii */
  --r-sm:   4px;
  --r:      6px;
  --r-lg:   10px;
  --r-full: 9999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow:    0 4px 6px rgba(0,0,0,.06), 0 2px 4px rgba(0,0,0,.04);
  --shadow-md: 0 10px 15px rgba(0,0,0,.08), 0 4px 6px rgba(0,0,0,.04);

  /* Transitions */
  --t-fast: 0.12s ease;
  --t:      0.18s ease;
}

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: var(--font-size-base);
  line-height: var(--line-height);
  color: var(--text-primary);
  background: var(--body-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { font-family: inherit; }
code, pre {
  font-family: var(--font-mono);
  font-size: .875em;
}
code {
  background: var(--gray-bg);
  color: var(--text-secondary);
  padding: 1px 5px;
  border-radius: var(--r-sm);
}
pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: var(--s4);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--red);
  font-size: 12px;
}

/* ── Layout ───────────────────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #2c304a transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: #2c304a; border-radius: 4px; }

.sidebar-logo {
  padding: 0 20px;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.03em;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
  gap: 10px;
}
.sidebar-logo-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--sidebar-accent);
  flex-shrink: 0;
}

.sidebar-nav {
  padding: 6px 0 24px;
  flex: 1;
}

.sidebar-section {
  padding: 18px 20px 5px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--sidebar-section-text);
  user-select: none;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 20px;
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 450;
  border-left: 2px solid transparent;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
  margin: 1px 0;
}
.sidebar-nav a:hover {
  background: var(--sidebar-hover-bg);
  color: var(--sidebar-text-hover);
}
.sidebar-nav a.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-text-active);
  border-left-color: var(--sidebar-accent);
  font-weight: 500;
}

/* Main area */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

/* Topbar */
.topbar {
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  height: var(--topbar-height);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow-xs);
}
.topbar-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  letter-spacing: -.01em;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
}
.topbar-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent-text);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0;
  flex-shrink: 0;
}
.topbar-name {
  font-weight: 500;
  color: var(--text-primary);
}
.topbar-logout-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: var(--r-sm);
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.topbar-logout-btn:hover {
  background: var(--surface-alt);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

/* Content area */
.content {
  padding: 24px;
  flex: 1;
  overflow-y: auto;
}

/* ── Flash Messages ────────────────────────────────────────── */
.flash-success,
.flash-error,
.flash-info {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--r);
  font-size: 13px;
  font-weight: 450;
  line-height: 1.5;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.flash-success {
  background: var(--green-bg);
  border-color: var(--green-border);
  color: var(--green-text);
}
.flash-error {
  background: var(--red-bg);
  border-color: var(--red-border);
  color: var(--red-text);
}
.flash-info {
  background: var(--blue-bg);
  border-color: var(--blue-border);
  color: var(--blue-text);
}

/* ── Page Header ───────────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header h1,
.page-header h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.03em;
  line-height: 1.2;
}
.page-header-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
  font-weight: 400;
}
.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
  color: var(--text-muted);
}
.breadcrumb a {
  color: var(--text-muted);
  transition: color var(--t-fast);
}
.breadcrumb a:hover { color: var(--text-primary); }
.breadcrumb-sep { color: var(--text-disabled); }
.breadcrumb-current {
  font-weight: 600;
  color: var(--text-secondary);
}

/* Back link */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 14px;
  transition: color var(--t-fast);
}
.back-link:hover { color: var(--text-primary); }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-xs);
  padding: 20px;
  margin-bottom: 16px;
}
.card:last-child { margin-bottom: 0; }

/* Card internal header / title */
.card-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* ── KPI / Metric Cards ────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 18px 20px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--t);
}
.kpi-card:hover { box-shadow: var(--shadow-sm); }
.kpi-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
}
.kpi-value.green  { color: var(--green); }
.kpi-value.red    { color: var(--red); }
.kpi-value.accent { color: var(--accent); }
.kpi-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 5px;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 15px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast);
  line-height: 1;
}
.btn:disabled, .btn[disabled] {
  opacity: .55;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}
.btn-primary:hover {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
}

.btn-accent {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-accent:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text-secondary);
  border-color: var(--border-strong);
}
.btn-secondary:hover {
  background: var(--surface-alt);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-danger {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--surface-alt);
  color: var(--text-primary);
}

.btn-link {
  background: transparent;
  border: none;
  color: var(--accent);
  padding: 0;
  font-size: inherit;
  font-weight: 400;
}
.btn-link:hover { text-decoration: underline; }

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}
.btn-lg {
  padding: 10px 20px;
  font-size: 14px;
}
.btn-block {
  width: 100%;
}

/* ── Tables ────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--r);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table thead {
  background: var(--surface-alt);
}
.table th {
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  text-align: left;
}
.table td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text-primary);
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr {
  transition: background var(--t-fast);
}
.table tbody tr:hover td { background: var(--surface-hover); }
.table-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 32px 16px;
}

/* ── Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge-active    { background: var(--green-bg);  border-color: var(--green-border);  color: var(--green-text); }
.badge-inactive  { background: var(--gray-bg);   border-color: var(--gray-border);   color: var(--gray-text); }
.badge-success   { background: var(--green-bg);  border-color: var(--green-border);  color: var(--green-text); }
.badge-pending   { background: var(--yellow-bg); border-color: var(--yellow-border); color: var(--yellow-text); }
.badge-error     { background: var(--red-bg);    border-color: var(--red-border);    color: var(--red-text); }
.badge-info      { background: var(--blue-bg);   border-color: var(--blue-border);   color: var(--blue-text); }
.badge-accent    { background: var(--accent-light); border-color: #c7d0f8; color: var(--accent-text); }
.badge-sold      { background: var(--green-bg);  border-color: var(--green-border);  color: var(--green-text); }
.badge-archived  { background: var(--yellow-bg); border-color: var(--yellow-border); color: var(--yellow-text); }
.badge-new       { background: var(--accent-light); border-color: #c7d0f8; color: var(--accent-text); }

/* ── Forms ─────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}
.form-group:last-child { margin-bottom: 0; }

label, .form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
  letter-spacing: .01em;
}

input[type=text],
input[type=email],
input[type=password],
input[type=number],
input[type=tel],
input[type=url],
input[type=date],
input[type=search],
select,
textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  font-size: 13px;
  font-family: var(--font);
  color: var(--text-primary);
  background: var(--surface);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  line-height: 1.5;
  appearance: none;
  -webkit-appearance: none;
}
input[type=text]:focus,
input[type=email]:focus,
input[type=password]:focus,
input[type=number]:focus,
input[type=tel]:focus,
input[type=url]:focus,
input[type=date]:focus,
input[type=search]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91,108,240,.12);
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239ca3af' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
textarea {
  resize: vertical;
  min-height: 80px;
}
input[type=checkbox],
input[type=radio] {
  width: auto;
}
.form-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}
.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.checkbox-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.checkbox-group input { margin: 0; }
.checkbox-group label { margin: 0; font-weight: 400; font-size: 13px; color: var(--text-primary); }

/* ── Filters Bar ───────────────────────────────────────────── */
.filters-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px 16px;
  box-shadow: var(--shadow-xs);
}
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.filter-group label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin: 0;
}
.filter-group input,
.filter-group select {
  padding: 6px 10px;
  font-size: 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  min-width: 140px;
  width: auto;
}

/* ── Timeline ──────────────────────────────────────────────── */
.timeline {
  position: relative;
  padding-left: 28px;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 6px;
  bottom: 6px;
  width: 1px;
  background: var(--border);
}
.tl-item {
  position: relative;
  margin-bottom: 18px;
}
.tl-item:last-child { margin-bottom: 0; }
.tl-dot {
  position: absolute;
  left: -24px;
  top: 4px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  background: var(--text-muted);
  box-shadow: 0 0 0 1px rgba(0,0,0,.08);
}
.tl-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.tl-body {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.5;
}
.tl-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Danger Zone ───────────────────────────────────────────── */
.danger-zone {
  background: var(--surface);
  border: 1px solid var(--red-border);
  border-radius: var(--r);
  padding: 20px;
  margin-top: 16px;
}
.danger-zone h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--red-text);
  margin-bottom: 6px;
}
.danger-zone p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 14px;
  line-height: 1.5;
}

/* ── Pagination ────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 16px;
  font-size: 13px;
}
.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  background: var(--surface);
  transition: background var(--t-fast), color var(--t-fast);
  font-weight: 500;
}
.pagination a:hover {
  background: var(--surface-alt);
  color: var(--text-primary);
}
.pagination .current {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}
.pagination .disabled {
  opacity: .4;
  pointer-events: none;
}

/* ── Auth pages (standalone, no layout) ──────────────────── */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  background: var(--body-bg);
}
.auth-panel-left {
  width: 420px;
  background: var(--brand);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 60px 48px;
  flex-shrink: 0;
}
.auth-panel-left .auth-logo {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.04em;
  margin-bottom: 32px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.auth-panel-left .auth-logo-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--sidebar-accent);
  flex-shrink: 0;
}
.auth-panel-left h2 {
  font-size: 26px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.03em;
  line-height: 1.25;
  margin-bottom: 14px;
}
.auth-panel-left p {
  font-size: 14px;
  color: #8b92b5;
  line-height: 1.6;
}
.auth-panel-right {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
}
.auth-form-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 36px 32px;
  box-shadow: var(--shadow-md);
}
.auth-form-card h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.02em;
  margin-bottom: 6px;
}
.auth-form-card .auth-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
  line-height: 1.5;
}
.auth-form-card label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}
.auth-form-card input[type=email],
.auth-form-card input[type=password] {
  margin-bottom: 14px;
}
.auth-links {
  margin-top: 16px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}
.auth-links a {
  color: var(--accent);
  font-weight: 500;
  transition: color var(--t-fast);
}
.auth-links a:hover { text-decoration: underline; }

/* ── Error Pages ───────────────────────────────────────────── */
.error-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--body-bg);
  font-family: var(--font);
  padding: 40px 24px;
}
.error-box {
  text-align: center;
  max-width: 480px;
  width: 100%;
}
.error-code {
  font-size: 80px;
  font-weight: 800;
  color: var(--border-strong);
  line-height: 1;
  letter-spacing: -.06em;
}
.error-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 12px;
  letter-spacing: -.02em;
}
.error-message {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 8px;
  line-height: 1.6;
}
.error-detail {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
  margin-top: 20px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--red-text);
  text-align: left;
  white-space: pre-wrap;
  word-break: break-all;
  box-shadow: var(--shadow-xs);
}
.error-box .btn { margin-top: 24px; }

/* ── Misc utilities ────────────────────────────────────────── */
.text-muted   { color: var(--text-muted); }
.text-sm      { font-size: 12px; }
.text-xs      { font-size: 11px; }
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.font-mono    { font-family: var(--font-mono); }
.truncate     { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1  { gap: 4px; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.gap-4  { gap: 16px; }
.flex-1 { flex: 1; }

.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }

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

/* Quick links grid (dashboard) */
.quick-links {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}
.quick-link {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  text-decoration: none;
  transition: background var(--t-fast), box-shadow var(--t-fast), border-color var(--t-fast);
}
.quick-link:hover {
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
  color: var(--accent-text);
}
.quick-link-icon {
  font-size: 20px;
  line-height: 1;
}

/* Info row (key → value pairs in detail views) */
.info-row {
  display: flex;
  font-size: 13px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.info-row:last-child { border-bottom: none; }
.info-key {
  width: 130px;
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  padding-top: 1px;
}
.info-val {
  flex: 1;
  color: var(--text-primary);
  word-break: break-word;
}

/* Modal overlay */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 28px;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow-md);
}
.modal h4 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 10px;
}
.modal p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 20px;
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ── DataTables Overrides ────────────────────────────────── */
.dataTables_wrapper { font-family: 'Inter', sans-serif; font-size: 13px; }
.dataTables_wrapper .dt-top,
.dataTables_wrapper .dt-bottom {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0;
}
.dataTables_wrapper .dataTables_filter input {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  outline: none;
  background: var(--surface);
  color: var(--text-primary);
}
.dataTables_wrapper .dataTables_filter input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
}
.dataTables_wrapper .dataTables_length select {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 13px;
  background: var(--surface);
  color: var(--text-primary);
}
.dataTables_wrapper .dataTables_paginate .paginate_button {
  padding: 4px 10px !important;
  border: 1px solid var(--border) !important;
  border-radius: 6px;
  margin: 0 2px;
  cursor: pointer;
  background: var(--surface) !important;
  color: var(--text-primary) !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: var(--accent) !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled,
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover {
  opacity: .4; cursor: default;
  background: var(--surface) !important;
  color: var(--text-muted) !important;
}
.dataTables_wrapper .dataTables_info {
  font-size: 12px; color: var(--text-muted);
}
table.dataTable thead th {
  border-bottom: 1px solid var(--border) !important;
}
table.dataTable.no-footer {
  border-bottom: none;
}

/* ── Form Cards (used on AI, edit pages) ──────────────────── */
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-xs);
  padding: 24px;
  margin-bottom: 20px;
}
.form-section {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  letter-spacing: -.01em;
}
.form-card .hint,
.form-card .form-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.4;
}
.form-card .hint code {
  font-size: 11px;
  background: var(--surface-alt);
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--border);
}
.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.toggle-row label {
  display: inline;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0;
  cursor: pointer;
}
.toggle-row input[type=checkbox] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* ── AI Nav Tabs ──────────────────────────────────────────── */
.ai-nav {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--border);
}
.ai-nav a {
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}
.ai-nav a:hover {
  color: var(--text-primary);
}
.ai-nav a.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── Alert banners ────────────────────────────────────────── */
.alert-success {
  background: var(--green-bg);
  border: 1px solid var(--green-border);
  color: var(--green-text);
  padding: 10px 16px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 16px;
}
.alert-error,
.alert-danger {
  background: var(--red-bg);
  border: 1px solid var(--red-border);
  color: var(--red-text);
  padding: 10px 16px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 16px;
}
.alert-info {
  background: var(--blue-bg);
  border: 1px solid var(--blue-border);
  color: var(--blue-text);
  padding: 10px 16px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 16px;
}

/* ── AI Badge styles ──────────────────────────────────────── */
.badge-enabled  { background: var(--green-bg);  border: 1px solid var(--green-border);  color: var(--green-text);  font-size: 11px; padding: 2px 8px; border-radius: 3px; font-weight: 600; }
.badge-disabled { background: var(--gray-bg);   border: 1px solid var(--gray-border);   color: var(--gray-text);   font-size: 11px; padding: 2px 8px; border-radius: 3px; font-weight: 600; }
.provider-pill  { background: var(--accent-light); border: 1px solid #c7d0f8; color: var(--accent-text); font-size: 11px; padding: 2px 8px; border-radius: 3px; font-weight: 600; }

/* ── Filter bar ───────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
  padding: 12px 16px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.filter-bar a {
  color: var(--accent);
  text-decoration: none;
}
.filter-bar a:hover {
  text-decoration: underline;
}
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.filter-group label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 0;
}
.filter-group select,
.filter-group input {
  width: auto;
  min-width: 140px;
  padding: 6px 10px;
  font-size: 12px;
}

/* ── Summary bar ──────────────────────────────────────────── */
.summary-bar {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
  font-weight: 500;
}

/* ── Empty state ──────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 14px;
}
