:root {
  --primary: #185FA5;
  --primary-dark: #134d8a;
  --primary-light: #e8f0fb;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
}

* { box-sizing: border-box; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #f1f5f9;
  margin: 0;
  overflow-x: hidden;
}

/* Layout */
#app { display: flex; min-height: 100vh; }

#sidebar {
  width: 240px;
  min-height: 100vh;
  background: var(--primary);
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

#main-content {
  margin-left: 240px;
  flex: 1;
  min-height: 100vh;
  padding: 0;
}

/* Sidebar */
.sidebar-logo {
  padding: 1.5rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.15);
}
.sidebar-logo h1 { font-size: 1.1rem; font-weight: 700; margin: 0 0 .25rem; }
.sidebar-logo p  { font-size: .75rem; opacity: .7; margin: 0; }

.sidebar-nav { padding: .75rem 0; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1.25rem;
  cursor: pointer;
  color: rgba(255,255,255,.8);
  text-decoration: none;
  font-size: .9rem;
  transition: background .15s, color .15s;
  border-left: 3px solid transparent;
}
.nav-item:hover  { background: rgba(255,255,255,.1); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.18); color: #fff; border-left-color: #fff; font-weight: 600; }
.nav-item svg    { width: 1.1rem; height: 1.1rem; flex-shrink: 0; }

/* Page header */
.page-header {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  padding: 1.25rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.page-header h2 { margin: 0; font-size: 1.3rem; color: #1e293b; }
.page-header p  { margin: .25rem 0 0; font-size: .85rem; color: #64748b; }

.page-body { padding: 1.5rem 2rem; }

/* Cards */
.card {
  background: #fff;
  border-radius: .75rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}
.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: #1e293b;
  margin: 0 0 1rem;
}

/* Stat cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: #fff;
  border-radius: .75rem;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  display: flex;
  align-items: center;
  gap: 1rem;
}
.stat-icon {
  width: 3rem; height: 3rem;
  border-radius: .6rem;
  background: var(--primary-light);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 1.5rem; height: 1.5rem; color: var(--primary); }
.stat-label { font-size: .8rem; color: #64748b; margin-bottom: .25rem; }
.stat-value { font-size: 1.6rem; font-weight: 700; color: #1e293b; line-height: 1; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .6rem 1.2rem;
  border-radius: .5rem;
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: opacity .15s, transform .1s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:active  { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg     { width: 1rem; height: 1rem; }

.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover  { background: var(--primary-dark); }
.btn-success  { background: var(--success); color: #fff; }
.btn-success:hover  { opacity: .88; }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover   { opacity: .88; }
.btn-outline  { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover  { background: var(--primary-light); }
.btn-ghost    { background: transparent; color: #64748b; border: 1.5px solid #e2e8f0; }
.btn-ghost:hover    { background: #f8fafc; }
.btn-sm { padding: .4rem .8rem; font-size: .8rem; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: .875rem; font-weight: 500; color: #374151; margin-bottom: .4rem; }
.form-control {
  width: 100%;
  padding: .55rem .85rem;
  border: 1.5px solid #d1d5db;
  border-radius: .5rem;
  font-size: .9rem;
  color: #1e293b;
  background: #fff;
  transition: border-color .15s;
  outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(24,95,165,.12); }
.form-control[readonly] { background: #f8fafc; color: #64748b; }

/* Table */
.table-wrap { overflow-x: auto; border-radius: .6rem; border: 1px solid #e2e8f0; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th {
  background: #f8fafc;
  padding: .75rem 1rem;
  text-align: left;
  font-weight: 600;
  color: #475569;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}
tbody td {
  padding: .7rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  color: #1e293b;
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: .2rem .6rem;
  border-radius: 9999px;
  font-size: .75rem;
  font-weight: 500;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info    { background: #dbeafe; color: #1e40af; }

/* Drop zone */
.drop-zone {
  border: 2px dashed #cbd5e1;
  border-radius: .75rem;
  padding: 2.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  background: #fafbfc;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}
.drop-zone svg   { width: 3rem; height: 3rem; color: #94a3b8; margin-bottom: 1rem; }
.drop-zone p     { margin: .5rem 0; color: #64748b; font-size: .9rem; }
.drop-zone small { color: #94a3b8; font-size: .8rem; }

/* Steps */
.steps {
  display: flex;
  align-items: center;
  margin-bottom: 2rem;
}
.step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  position: relative;
}
.step-item:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 1.1rem;
  left: calc(50% + 1.1rem);
  right: calc(-50% + 1.1rem);
  height: 2px;
  background: #e2e8f0;
  z-index: 0;
}
.step-item.done:not(:last-child)::after  { background: var(--primary); }
.step-num {
  width: 2.2rem; height: 2.2rem;
  border-radius: 50%;
  background: #e2e8f0;
  color: #94a3b8;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .9rem;
  position: relative; z-index: 1;
  transition: background .2s, color .2s;
}
.step-item.active .step-num { background: var(--primary); color: #fff; }
.step-item.done .step-num   { background: var(--success); color: #fff; }
.step-label { font-size: .75rem; color: #94a3b8; margin-top: .4rem; text-align: center; }
.step-item.active .step-label { color: var(--primary); font-weight: 600; }
.step-item.done .step-label   { color: var(--success); }

/* Progress */
.progress-bar-wrap { background: #e2e8f0; border-radius: 9999px; height: .6rem; overflow: hidden; }
.progress-bar { height: 100%; background: var(--primary); border-radius: 9999px; transition: width .3s; }

/* Toast */
#toast-container {
  position: fixed;
  bottom: 1.5rem; right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  pointer-events: none;
}
.toast {
  background: #1e293b;
  color: #fff;
  padding: .85rem 1.25rem;
  border-radius: .6rem;
  font-size: .875rem;
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
  min-width: 240px;
  max-width: 380px;
  pointer-events: all;
  animation: slideIn .25s ease;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.toast.success { background: #166534; }
.toast.error   { background: #991b1b; }
.toast.warning { background: #92400e; }
@keyframes slideIn { from { opacity:0; transform:translateY(1rem); } to { opacity:1; transform:translateY(0); } }

/* Modal */
#modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
#modal-overlay.open { display: flex; }
.modal-box {
  background: #fff;
  border-radius: .75rem;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { margin: 0; font-size: 1.1rem; }
.modal-close { background: none; border: none; cursor: pointer; color: #64748b; font-size: 1.3rem; padding: .25rem; }
.modal-body   { padding: 1.5rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid #e2e8f0; display: flex; gap: .75rem; justify-content: flex-end; }

/* Tabs */
.tabs { display: flex; border-bottom: 2px solid #e2e8f0; margin-bottom: 1.5rem; gap: .25rem; }
.tab-btn {
  padding: .7rem 1.25rem;
  background: none;
  border: none;
  cursor: pointer;
  font-size: .9rem;
  color: #64748b;
  border-bottom: 2.5px solid transparent;
  margin-bottom: -2px;
  transition: color .15s;
  font-weight: 500;
}
.tab-btn:hover  { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Status dot */
.dot { width: .5rem; height: .5rem; border-radius: 50%; display: inline-block; }
.dot-success { background: var(--success); }
.dot-danger  { background: var(--danger); }
.dot-warning { background: var(--warning); }

/* Match table */
.match-ok   { color: var(--success); font-weight: 500; }
.match-warn { color: var(--warning); }

/* Quick action cards */
.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.quick-card {
  background: #fff;
  border-radius: .75rem;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  cursor: pointer;
  transition: box-shadow .15s, transform .1s;
  border: 1.5px solid transparent;
  text-decoration: none;
  display: block;
}
.quick-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.12); transform: translateY(-2px); border-color: var(--primary-light); }
.quick-card-icon { width: 2.5rem; height: 2.5rem; background: var(--primary-light); border-radius: .5rem; display: flex; align-items: center; justify-content: center; margin-bottom: 1rem; }
.quick-card-icon svg { width: 1.3rem; height: 1.3rem; color: var(--primary); }
.quick-card h4 { margin: 0 0 .4rem; font-size: 1rem; color: #1e293b; }
.quick-card p  { margin: 0; font-size: .8rem; color: #64748b; }

/* Responsive */
@media (max-width: 768px) {
  #sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; }
  #main-content { margin-left: 0; }
  .sidebar-nav { display: flex; overflow-x: auto; padding: .5rem; flex: none; width: 100%; }
  .nav-item { border-left: none; border-bottom: 2px solid transparent; padding: .6rem 1rem; }
  .nav-item.active { border-left: none; border-bottom-color: #fff; }
  .page-body { padding: 1rem; }
  .page-header { padding: 1rem; }
}

/* Utility */
.text-right { text-align: right; }
.text-money { font-variant-numeric: tabular-nums; }
.text-muted { color: #64748b; font-size: .85rem; }
.gap-2 { gap: .5rem; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.mt-1 { margin-top: .25rem; }
.mb-1 { margin-bottom: .25rem; }
.mb-2 { margin-bottom: .5rem; }
.mb-4 { margin-bottom: 1rem; }
.hidden { display: none !important; }
.w-full { width: 100%; }
