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

:root {
  /* Brand */
  --primary:        #4F46E5;
  --primary-hover:  #4338CA;
  --secondary:      #A855F7;

  /* Semantic */
  --success:        #10B981;
  --warning:        #F59E0B;
  --danger:         #DC2626;

  /* Neutral */
  --neutral-900:    #111827;
  --neutral-700:    #374151;
  --neutral-600:    #4B5563;
  --neutral-400:    #9CA3AF;
  --neutral-200:    #E5E7EB;
  --neutral-100:    #F3F4F6;
  --neutral-50:     #F9FAFB;
  --white:          #FFFFFF;

  /* Surfaces */
  --bg:             #F3F4F6;
  --surface:        #FFFFFF;
  --border:         #E5E7EB;
  --border-focus:   #4F46E5;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(17,24,39,0.08), 0 1px 2px rgba(17,24,39,0.04);
  --shadow-md:  0 4px 6px rgba(17,24,39,0.12);
  --shadow-lg:  0 10px 15px rgba(17,24,39,0.15);
  --shadow-xl:  0 24px 48px rgba(17,24,39,0.16), 0 8px 16px rgba(17,24,39,0.08);

  /* Geometry — sharp primary, subtle on inputs */
  --radius-sharp:  0px;
  --radius-subtle: 4px;

  /* Motion */
  --ease:     cubic-bezier(0.4, 0, 0.2, 1);
  --duration: 200ms;

  /* Legacy aliases — used in JS-generated markup */
  --blue:   #4F46E5;
  --green:  #10B981;
  --yellow: #F59E0B;
  --red:    #DC2626;
  --mauve:  #A855F7;
  --text:         var(--neutral-900);
  --subtext:      var(--neutral-600);
  --overlay:      var(--neutral-400);
  --mantle:       var(--white);
  --base:         var(--bg);
  --surface0:     var(--neutral-100);
  --surface1:     var(--neutral-200);
  --radius:       var(--radius-sharp);
}

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

body {
  background: var(--bg);
  color: var(--neutral-900);
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

/* ── Header ── */
header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo {
  font-size: 1.2em;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.03em;
}

.tagline {
  font-size: 0.82em;
  color: var(--neutral-600);
  font-weight: 400;
}

.app-version {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  font-size: 0.78em;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--neutral-600);
  background: var(--neutral-100);
  border: 1px solid var(--border);
  border-radius: var(--radius-sharp);
}

/* ── Main card ── */
main {
  max-width: 660px;
  margin: 40px auto;
  padding: 36px 40px;
  background: var(--white);
  border-radius: var(--radius-sharp);
  box-shadow: var(--shadow-md);
  border-top: 3px solid var(--primary);
}

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

.field-group label {
  display: block;
  font-size: 0.75em;
  font-weight: 700;
  color: var(--neutral-700);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 8px;
}

select,
input[type="email"],
input[type="password"],
input[type="text"] {
  width: 100%;
  height: 44px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-subtle);
  padding: 0 12px;
  color: var(--neutral-900);
  font-size: 0.9em;
  font-family: inherit;
  font-weight: 400;
  appearance: none;
  transition: border-color var(--duration) var(--ease),
              box-shadow var(--duration) var(--ease);
  cursor: pointer;
}

select:focus,
input:focus {
  outline: none;
  border: 2px solid var(--primary);
  box-shadow: 0 0 0 4px rgba(79,70,229,0.1);
}

select:hover,
input:hover {
  border-color: var(--neutral-400);
}

/* ── Mode toggle ── */
.mode-toggle {
  display: flex;
  gap: 0;
  margin-bottom: 28px;
  background: var(--neutral-100);
  border: 1px solid var(--border);
  border-radius: var(--radius-subtle);
  padding: 4px;
}

.mode-btn {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius-subtle);
  cursor: pointer;
  font-size: 0.88em;
  font-weight: 600;
  background: transparent;
  color: var(--neutral-600);
  font-family: inherit;
  transition: all var(--duration) var(--ease);
  letter-spacing: 0.01em;
}

.mode-btn:hover { background: var(--border); color: var(--neutral-900); }

.mode-btn.active {
  background: var(--white);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* ── Help box ── */
.help-box {
  background: #EEF2FF;
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius-subtle) var(--radius-subtle) 0;
  padding: 12px 16px;
  font-size: 0.875em;
  color: #3730A3;
  margin-bottom: 18px;
  line-height: 1.5;
}

/* ── Drop zone ── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-subtle);
  padding: 40px 28px;
  text-align: center;
  font-size: 0.9em;
  color: var(--neutral-600);
  cursor: pointer;
  margin-bottom: 14px;
  background: var(--neutral-50);
  transition: all var(--duration) var(--ease);
}

.drop-zone:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: #EEF2FF;
}

.file-link {
  color: var(--primary);
  cursor: pointer;
  text-decoration: underline;
  font-weight: 600;
}

/* ── File name display ── */
#file-name-display {
  font-size: 0.83em;
  color: var(--success);
  font-weight: 600;
  margin-bottom: 14px;
  padding: 8px 14px;
  background: #ECFDF5;
  border-left: 3px solid var(--success);
  border-radius: 0 var(--radius-subtle) var(--radius-subtle) 0;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

#file-name-display.file-empty {
  color: #92400E;
  background: #FEF3C7;
  border-left-color: var(--warning);
}

.row-count-badge {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  font-size: 0.85em;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 12px;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.row-count-empty {
  background: var(--warning);
  color: #111827;
}

/* ── Buttons ── */
.btn-primary {
  width: 100%;
  padding: 12px 20px;
  background: var(--primary);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sharp);
  font-size: 0.95em;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.01em;
  transition: background var(--duration) var(--ease),
              box-shadow var(--duration) var(--ease),
              transform var(--duration) var(--ease);
  box-shadow: var(--shadow-md);
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: var(--shadow-lg);
  transform: scale(1.02);
}

.btn-primary:active  { transform: scale(1); }
.btn-primary:focus   { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn-primary:disabled {
  background: var(--neutral-200);
  color: var(--neutral-400);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Inline variant — removes full-width so button sizes to its content */
.btn-primary.btn-inline {
  width: auto;
  padding: 8px 20px;
}

/* ── Status ── */
.status { margin-top: 16px; font-size: 0.875em; color: var(--neutral-600); min-height: 1.4em; }
.status-error { color: var(--danger); font-weight: 600; }

/* ── Bundle mode ── */
.bundle-section {
  background: var(--neutral-50);
  border: 1px solid var(--border);
  border-radius: var(--radius-subtle);
  padding: 18px 20px;
  margin-bottom: 18px;
}

.bundle-name {
  font-size: 0.9em;
  color: var(--neutral-900);
  margin-bottom: 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.75em;
}

.bundle-slot {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border-radius: var(--radius-subtle);
  padding: 11px 14px;
  font-size: 0.85em;
  cursor: pointer;
  margin-bottom: 8px;
  transition: all var(--duration) var(--ease);
}

.slot-loaded    { background: #ECFDF5; border: 1px solid #6EE7B7; }
.slot-empty     { background: var(--white); border: 1px dashed var(--border); }
.slot-error     { background: #FEF2F2; border: 1px solid #FCA5A5; }
.slot-drag-over { background: #EEF2FF; border: 1px dashed var(--primary-600); }
.slot-icon              { width: 16px; color: var(--success); font-size: 1em; flex-shrink: 0; margin-top: 1px; }
.slot-error .slot-icon  { color: var(--danger); }
.slot-label  { flex: 1; color: var(--neutral-900); font-weight: 600; }
.slot-file   { color: var(--neutral-600); font-size: 0.9em; word-break: break-all; }
.slot-error .slot-file { color: var(--danger); }
.slot-clear  { color: var(--neutral-400); cursor: pointer; flex-shrink: 0; }
.slot-clear:hover { color: var(--danger); }

/* ── Results screen ── */
#results-screen { max-width: 100%; margin: 28px 24px; padding: 0; }

.results-header {
  font-size: 1em;
  color: var(--neutral-600);
  margin-bottom: 18px;
  font-weight: 500;
}

.summary-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}

.chip {
  padding: 5px 14px;
  border-radius: var(--radius-sharp);
  font-size: 0.82em;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.chip-error  { background: #FEE2E2; border: 1px solid var(--danger);  color: var(--danger);  }
.chip-warn   { background: #FEF3C7; border: 1px solid var(--warning); color: #92400E;         }
.chip-pass   { background: #D1FAE5; border: 1px solid var(--success); color: #065F46;         }

.chip-actions { margin-left: auto; display: flex; gap: 8px; }

.btn-secondary {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sharp);
  padding: 6px 14px;
  font-size: 0.83em;
  font-weight: 600;
  color: var(--neutral-600);
  cursor: pointer;
  font-family: inherit;
  transition: all var(--duration) var(--ease);
}

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

.btn-secondary.danger:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: #FEF2F2;
}

/* ── Filter tabs ── */
.filter-tabs { display: flex; gap: 2px; margin-bottom: 0; border-bottom: 2px solid var(--border); }

.filter-tab {
  padding: 7px 18px;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  font-size: 0.83em;
  font-weight: 600;
  background: transparent;
  color: var(--neutral-600);
  font-family: inherit;
  transition: all var(--duration) var(--ease);
  letter-spacing: 0.01em;
}

.filter-tab:hover { color: var(--primary); background: #EEF2FF; }

.filter-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: transparent;
}

/* ── Results table ── */
.table-container {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 0 var(--radius-subtle) var(--radius-subtle) var(--radius-subtle);
  margin-top: 12px;
}

.results-table {
  border-collapse: collapse;
  font-size: 0.82em;
  min-width: 700px;
  table-layout: auto;
  width: 100%;
}

.results-table th:nth-child(1),
.results-table td:nth-child(1) { width: 56px; white-space: nowrap; }
.results-table th:nth-child(2),
.results-table td:nth-child(2) { width: 80px; white-space: nowrap; }
.results-table th:nth-child(3),
.results-table td:nth-child(3) { min-width: 260px; max-width: 400px; white-space: normal; word-wrap: break-word; overflow-wrap: break-word; }
.results-table th:nth-child(n+4),
.results-table td:nth-child(n+4) { white-space: nowrap; }
.results-table td:nth-child(n+4) .cell-val { display: block; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.results-table th {
  padding: 10px 12px;
  background: var(--neutral-100);
  color: var(--neutral-600);
  text-align: left;
  border-bottom: 2px solid var(--border);
  border-right: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.75em;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.results-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  color: var(--neutral-900);
  vertical-align: top;
}

.results-table tr:last-child td { border-bottom: none; }
.results-table td:last-child,
.results-table th:last-child { border-right: none; }

.row-error { background: #FFF5F5; }
.row-warn  { background: #FFFBEB; }
.row-pass  { background: var(--white); }

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-sharp);
  font-size: 0.78em;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.badge-error   { background: #FEE2E2; color: var(--danger);  border: 1px solid #FCA5A5; }
.badge-warning { background: #FEF3C7; color: #92400E;        border: 1px solid #FCD34D; }
.badge-pass    { background: #D1FAE5; color: #065F46;        border: 1px solid #6EE7B7; }

.cross-ref-tag { color: var(--secondary); font-size: 0.85em; margin-left: 4px; font-weight: 600; }
.table-count   { font-size: 0.78em; color: var(--neutral-400); margin-top: 10px; }

/* ── Bundle results ── */
.bundle-result-section {
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-subtle);
  background: var(--white);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.bundle-result-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  cursor: pointer;
  user-select: none;
  background: var(--neutral-50);
  transition: background var(--duration) var(--ease);
  border-left: 3px solid var(--primary);
}

.bundle-result-header:hover { background: var(--neutral-100); }

.bundle-toggle       { font-size: 0.75em; color: var(--neutral-600); flex-shrink: 0; width: 14px; }
.bundle-result-title { font-size: 0.92em; font-weight: 700; color: var(--neutral-900); }
.bundle-result-meta  { font-size: 0.78em; color: var(--neutral-600); }
.bundle-header-chips { display: flex; gap: 6px; margin-left: 4px; }
.bundle-header-chips .chip { padding: 2px 8px; font-size: 0.75em; }
.bundle-result-header .btn-secondary { margin-left: auto; flex-shrink: 0; font-size: 0.78em; padding: 4px 12px; }
.bundle-result-body { padding: 16px 20px; }
.bundle-result-section h3 { font-size: 0.95em; font-weight: 700; color: var(--neutral-900); margin-bottom: 14px; }

/* ── Admin ── */
#admin-tabs { display: flex; gap: 4px; margin-left: auto; }

.admin-tab {
  padding: 7px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sharp);
  cursor: pointer;
  font-size: 0.83em;
  font-weight: 600;
  background: var(--neutral-100);
  color: var(--neutral-600);
  font-family: inherit;
  transition: all var(--duration) var(--ease);
  letter-spacing: 0.01em;
}

.admin-tab:hover { background: var(--border); color: var(--neutral-900); }

.admin-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--white);
}

/* ── Admin panel headings ── */
h3 { font-size: 1em; color: var(--primary); margin: 18px 0 10px; font-weight: 700; }

/* ── Admin data tables (connections, analytics) ── */
.connections-table,
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.87em;
}

.connections-table th,
.data-table th {
  padding: 10px 14px;
  background: var(--neutral-100);
  color: var(--neutral-600);
  text-align: left;
  border-bottom: 2px solid var(--border);
  font-weight: 700;
  font-size: 0.75em;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.connections-table td,
.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--neutral-900);
}

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

.connections-table td:last-child { white-space: nowrap; }
.connections-table td:last-child button { margin-right: 4px; }
.connections-table td:last-child button:last-child { margin-right: 0; }

/* ── Admin action buttons (inline table buttons) ── */
.btn-action {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sharp);
  background: var(--white);
  color: var(--neutral-600);
  font-size: 0.78em;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
}

.btn-action:hover       { border-color: var(--primary); color: var(--primary); background: #EEF2FF; }
.btn-action.danger:hover { border-color: var(--danger);  color: var(--danger);  background: #FEF2F2; }
.btn-action:disabled    { opacity: 0.45; cursor: not-allowed; }

/* ── Analytics ── */
.analytics-summary { font-size: 0.875em; color: var(--neutral-600); margin-bottom: 18px; }

/* ── Rules manager ── */
.rules-dir { margin-bottom: 18px; }

.rules-dir-label {
  font-size: 0.72em;
  color: var(--neutral-600);
  font-weight: 700;
  margin-bottom: 8px;
  font-family: 'Cascadia Code', 'Fira Code', monospace;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.rules-file-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875em;
}

.rules-file-row span { flex: 1; font-family: 'Cascadia Code', 'Fira Code', monospace; color: var(--neutral-900); }

.json-editor {
  width: 100%;
  height: 420px;
  background: var(--neutral-50);
  color: var(--neutral-900);
  border: 1px solid var(--border);
  border-radius: var(--radius-subtle);
  padding: 14px;
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
  font-size: 0.84em;
  margin-top: 14px;
  resize: vertical;
  line-height: 1.65;
  transition: border-color var(--duration) var(--ease),
              box-shadow var(--duration) var(--ease);
}

.json-editor:focus {
  outline: none;
  border: 2px solid var(--primary);
  box-shadow: 0 0 0 4px rgba(79,70,229,0.1);
}

/* ── Rules Manager ── */

.rm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.rm-title {
  font-size: 1.15em;
  font-weight: 800;
  color: var(--neutral-900);
  letter-spacing: -0.01em;
}

.rm-count {
  display: inline-block;
  margin-left: 10px;
  font-size: 0.75em;
  font-weight: 700;
  color: var(--neutral-400);
  background: var(--neutral-100);
  border: 1px solid var(--border);
  padding: 2px 9px;
  vertical-align: middle;
  letter-spacing: 0.04em;
}

.rm-search-wrap {
  margin-bottom: 20px;
}

.rm-search {
  width: 100%;
  height: 44px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-subtle);
  font-size: 0.9em;
  font-family: inherit;
  color: var(--neutral-900);
  background: var(--white);
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

.rm-search:focus {
  outline: none;
  border: 2px solid var(--primary);
  box-shadow: 0 0 0 4px rgba(79,70,229,0.1);
}

.rm-empty {
  grid-column: 1 / -1;
  color: var(--neutral-400);
  font-size: 0.875em;
  padding: 48px 24px;
  text-align: center;
}

/* ── Template Cards ── */

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.template-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius-subtle) var(--radius-subtle) 0;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: box-shadow var(--duration) var(--ease), border-left-color var(--duration) var(--ease);
  overflow: hidden;
}

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

.template-card-orphan {
  border-left-color: var(--secondary);
}

.tc-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 10px;
}

.tc-scope {
  display: inline-block;
  font-size: 0.65em;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 2px 7px;
  border-radius: 0;
  flex-shrink: 0;
}

.tc-scope-global {
  background: #EEF2FF;
  color: var(--primary);
  border: 1px solid #C7D2FE;
}

.tc-scope-country {
  background: #F5F3FF;
  color: var(--secondary);
  border: 1px solid #DDD6FE;
}

.tc-name {
  font-size: 0.92em;
  font-weight: 700;
  color: var(--neutral-900);
  line-height: 1.3;
}

.tc-stats {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 12px;
}

.tc-stat {
  font-size: 0.75em;
  font-weight: 600;
  color: var(--neutral-600);
  background: var(--neutral-100);
  border: 1px solid var(--border);
  padding: 2px 8px;
  letter-spacing: 0.02em;
}

.tc-tag {
  font-size: 0.72em;
  font-weight: 700;
  padding: 2px 8px;
  letter-spacing: 0.03em;
}

.tag-dayforce { background: #EEF2FF; color: var(--primary); border: 1px solid #C7D2FE; }
.tag-crossref { background: #F5F3FF; color: var(--secondary); border: 1px solid #DDD6FE; }
.tag-pattern  { background: #ECFDF5; color: #065F46; border: 1px solid #6EE7B7; }
.tag-unique   { background: #FFF7ED; color: #92400E; border: 1px solid #FED7AA; }

.tc-overrides {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 16px;
  border-top: 1px solid var(--neutral-100);
  background: var(--neutral-50);
}

.tc-overrides-label {
  font-size: 0.7em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--neutral-400);
  margin-right: 2px;
}

.tc-override-chip {
  font-size: 0.7em;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  background: #F5F3FF;
  color: var(--secondary);
  border: 1px solid #DDD6FE;
  cursor: pointer;
  border-radius: 0;
  font-family: inherit;
  transition: all var(--duration) var(--ease);
}

.tc-override-chip:hover {
  background: var(--secondary);
  color: var(--white);
  border-color: var(--secondary);
}

.tc-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  margin-top: auto;
  background: var(--white);
}

/* ── Editor ── */

.editor-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  font-size: 0.85em;
}

.crumb-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--primary);
  font-family: inherit;
  font-size: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: color var(--duration) var(--ease);
}

.crumb-link:hover { color: var(--primary-hover); text-decoration: underline; }

.crumb-sep {
  color: var(--neutral-400);
  font-weight: 400;
}

.crumb-current {
  font-weight: 700;
  color: var(--neutral-900);
}

.editor-meta-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  background: var(--neutral-50);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  margin-bottom: 16px;
}

.editor-filepath {
  font-family: 'Cascadia Code', 'Fira Code', monospace;
  font-size: 0.78em;
  color: var(--neutral-600);
  background: var(--neutral-100);
  border: 1px solid var(--border);
  padding: 2px 8px;
}

.editor-upload-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.editor-upload-hint {
  font-size: 0.78em;
  color: var(--neutral-600);
}

.editor-section-label {
  font-size: 0.7em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--neutral-600);
  margin-bottom: 6px;
}

.editor-notice {
  font-size: 0.82em;
  color: var(--neutral-600);
  padding: 8px 12px;
  margin: 10px 0;
  border-left: 3px solid var(--border);
  background: var(--neutral-50);
}

.editor-notice-error {
  border-left-color: var(--danger);
  background: #FEF2F2;
  color: var(--danger);
  font-weight: 600;
}

.editor-notice-success {
  border-left-color: var(--success);
  background: #ECFDF5;
  color: #065F46;
  font-weight: 600;
}

.editor-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ── Sync progress modal ── */
@keyframes syncSpin {
  to { transform: rotate(360deg); }
}
@keyframes syncShimmer {
  0%   { background-position: -300% 0; }
  100% { background-position: 300% 0; }
}
@keyframes syncModalIn {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes syncRowIn {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes syncPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}
@keyframes syncDone {
  0%   { transform: scale(0.5); opacity: 0; }
  60%  { transform: scale(1.2); }
  100% { transform: scale(1);   opacity: 1; }
}

.sync-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--duration) var(--ease);
}

.sync-overlay.visible { opacity: 1; }

.sync-card {
  background: var(--white);
  border-radius: var(--radius-sharp);
  box-shadow: var(--shadow-xl);
  padding: 36px 40px 32px;
  width: 480px;
  max-width: calc(100vw - 32px);
  animation: syncModalIn 0.25s var(--ease) forwards;
  border-top: 4px solid var(--primary);
}

.sync-card-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.sync-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: syncSpin 0.75s linear infinite;
  flex-shrink: 0;
  transition: border-color 0.3s;
}

.sync-spinner.done  { border-color: var(--success); border-top-color: var(--success); animation: none; }
.sync-spinner.error { border-color: var(--danger);  border-top-color: var(--danger);  animation: none; }

.sync-card-title    { font-size: 1.05em; font-weight: 700; color: var(--neutral-900); }
.sync-card-subtitle { font-size: 0.8em; color: var(--neutral-600); margin-top: 2px; font-family: monospace; }

.sync-progress-wrap { margin-bottom: 20px; }

.sync-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.75em;
  color: var(--neutral-600);
  margin-bottom: 7px;
  font-weight: 600;
}

.sync-progress-track {
  height: 6px;
  background: var(--neutral-200);
  border-radius: 99px;
  overflow: hidden;
}

.sync-progress-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #4F46E5 0%, #818CF8 50%, #4F46E5 100%);
  background-size: 300% 100%;
  animation: syncShimmer 1.6s linear infinite;
  transition: width 0.4s var(--ease);
  width: 0%;
}

.sync-progress-fill.done { background: var(--success); animation: none; }

.sync-entity-list {
  border: 1px solid var(--border);
  border-radius: var(--radius-subtle);
  overflow: hidden;
  max-height: 240px;
  overflow-y: auto;
}

.sync-entity-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  font-size: 0.82em;
  border-bottom: 1px solid var(--border);
  animation: syncRowIn 0.2s var(--ease) forwards;
  background: var(--white);
}

.sync-entity-row:last-child { border-bottom: none; }
.sync-entity-row.pending { color: var(--neutral-400); background: var(--neutral-50); }
.sync-entity-row.syncing { color: var(--primary); }
.sync-entity-row.ok      { color: var(--neutral-900); }
.sync-entity-row.error   { color: var(--danger); background: #FEF2F2; }

.sync-entity-icon           { width: 16px; text-align: center; flex-shrink: 0; }
.sync-entity-icon.spinning  { animation: syncSpin 0.7s linear infinite; display: inline-block; }
.sync-entity-name           { flex: 1; text-transform: capitalize; font-weight: 500; }
.sync-entity-count          { font-family: monospace; font-size: 0.9em; color: var(--neutral-600); }
.sync-entity-count.ok       { color: var(--success); font-weight: 700; }
.sync-entity-count.error    { color: var(--danger); }

.sync-footer {
  margin-top: 16px;
  font-size: 0.75em;
  color: var(--neutral-400);
  text-align: center;
}

.sync-done-msg {
  text-align: center;
  font-size: 0.9em;
  font-weight: 700;
  color: var(--success);
  margin-top: 14px;
  animation: syncDone 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* ── Rules Manager V2 (master-detail layout) ─────────────────────────────── */

.rl-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.rl-layout {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-subtle);
  height: calc(100vh - 210px);
  min-height: 520px;
  overflow: hidden;
}

.rl-sidebar {
  width: 260px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  background: var(--neutral-50);
  display: flex;
  flex-direction: column;
}

.rl-search {
  width: 100%;
  box-sizing: border-box;
  padding: 16px 16px;
  border: none;
  border-bottom: 2px solid var(--border);
  font-family: var(--font-primary);
  font-size: 0.95em;
  background: var(--neutral-50);
  outline: none;
  position: sticky;
  top: 0;
  z-index: 1;
  height: 60px;
}

.rl-search:focus {
  border-bottom-color: var(--primary);
  background: white;
}

.rl-group-header {
  font-size: 0.68em;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--neutral-600);
  padding: 12px 14px 4px;
  user-select: none;
}

.rl-group-country { color: var(--secondary-500, #A855F7); }

.rl-item {
  padding: 8px 14px;
  font-size: 0.84em;
  color: var(--neutral-900);
  cursor: pointer;
  border-left: 3px solid transparent;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: background 150ms, color 150ms;
}

.rl-item:hover { background: #F3F4F6; }

.rl-item.rl-active {
  background: #EEF2FF;
  border-left-color: var(--primary);
  font-weight: 600;
  color: var(--primary);
}

.rl-override-marker {
  color: var(--secondary-500, #A855F7);
  font-size: 0.85em;
}

.rl-detail {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: white;
}

.rl-detail-centered {
  justify-content: center;
  align-items: center;
}

.rl-detail-empty {
  text-align: center;
  max-width: 300px;
}

.rl-empty-icon  { font-size: 2.4em; line-height: 1; margin-bottom: 8px; }
.rl-empty-title { font-size: 1em; font-weight: 700; color: var(--neutral-900); margin-bottom: 4px; }
.rl-empty-sub   { font-size: 0.84em; color: var(--neutral-600); line-height: 1.5; }

.rl-detail-name {
  font-size: 1.1em;
  font-weight: 800;
  color: var(--neutral-900);
  margin: 0;
  line-height: 1.3;
}

.rl-detail-meta {
  font-size: 0.8em;
  color: var(--neutral-600);
  margin-top: -4px;
}

.rl-detail-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.rl-detail-overrides {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78em;
}

.rl-detail-overrides-label {
  color: var(--neutral-600);
  font-weight: 600;
}

.rl-divider {
  height: 1px;
  background: var(--border);
  flex-shrink: 0;
}

.rl-detail-path {
  font-family: monospace;
  font-size: 0.78em;
  color: var(--neutral-600);
  margin-top: -4px;
}

.rl-detail-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
  flex-shrink: 0;
}

.rl-layout-toggle {
  font-size: 0.78em !important;
  padding: 6px 12px !important;
  color: var(--neutral-600) !important;
  white-space: nowrap;
}

/* Fullscreen expand */
.rl-layout.rl-expanded {
  position: fixed;
  inset: 0;
  z-index: 9000;
  height: 100dvh !important;
  border-radius: 0;
  border: none;
}

.rl-expand-btn {
  padding: 7px 10px !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Help / Guide button */
.rl-help-btn {
  padding: 7px 12px !important;
  font-size: 0.8em !important;
  text-decoration: none !important;
  display: inline-flex !important;
  align-items: center;
  gap: 5px;
  color: var(--primary) !important;
  border-color: var(--primary) !important;
}

/* Unsaved indicator */
.rl-dirty-badge {
  font-size: 0.75em;
  font-weight: 600;
  color: var(--warning);
}

/* Dirty-state modal */
.rl-dirty-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
  z-index: 9500;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rl-dirty-modal {
  background: white;
  border-radius: var(--radius-subtle);
  padding: 28px 28px 24px;
  width: 380px;
  box-shadow: 0 24px 64px rgba(17, 24, 39, 0.22);
}

.rl-dirty-title {
  font-size: 1em;
  font-weight: 800;
  color: var(--neutral-900);
  margin-bottom: 8px;
}

.rl-dirty-body {
  font-size: 0.84em;
  color: var(--neutral-600);
  line-height: 1.6;
  margin-bottom: 22px;
}

.rl-dirty-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* Editor fullscreen overlay */
.rl-editor-overlay {
  position: fixed;
  inset: 0;
  z-index: 9200;
  background: white;
  display: flex;
  flex-direction: column;
}

.rl-editor-overlay-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.rl-editor-overlay-title {
  font-size: 0.92em;
  font-weight: 700;
  color: var(--neutral-900);
  flex: 1;
}

.rl-editor-overlay-path {
  font-size: 0.78em;
  font-family: monospace;
  color: var(--neutral-600);
}

.rl-editor-overlay-close {
  background: none;
  border: none;
  font-size: 1.3em;
  cursor: pointer;
  color: var(--neutral-600);
  padding: 4px 8px;
  border-radius: 4px;
  line-height: 1;
}

.rl-editor-overlay-close:hover {
  background: var(--neutral-100);
  color: var(--neutral-900);
}

.rl-editor-overlay-body {
  flex: 1;
  padding: 12px 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.rl-editor-overlay-body .json-editor {
  flex: 1;
  height: 100%;
  resize: none;
}

.rl-editor-overlay-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  gap: 8px;
}

.rl-fs-btn {
  padding: 6px 10px !important;
  font-size: 0.78em !important;
  display: inline-flex !important;
  align-items: center;
  gap: 4px;
  color: var(--neutral-600) !important;
  border-color: var(--border) !important;
}
