/* ============================================================
   BLOCKSWIFT OPS — DESIGN SYSTEM v3
   Matching portal.html design: DM Sans, lavender/purple theme
   Light mode default, dark mode toggle
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&family=DM+Mono:wght@400;500&display=swap');

:root {
  --accent:      #a553f6;
  --accent-dim:  #f3e8ff;
  --accent-glow: rgba(165,83,246,0.3);
  --accent-dim2: rgba(165,83,246,0.08);

  --bg:       #ede9fb;
  --bg2:      #e4dff8;
  --surface:  #ffffff;
  --surface2: #f5f3fc;
  --border:   rgba(165,83,246,0.15);
  --border2:  rgba(165,83,246,0.08);

  --t1: #1a1035;
  --t2: #5a4f7a;
  --t3: #9b8dbf;

  --success:  #16a34a;
  --warn:     #d97706;
  --danger:   #dc2626;
  --info:     #2563eb;

  --green:     #16a34a;
  --green-dim: #dcfce7;
  --amber:     #d97706;
  --amber-dim: #fef3c7;
  --red:       #dc2626;
  --red-dim:   #fee2e2;
  --blue:      #2563eb;
  --blue-dim:  #dbeafe;

  --text-1: var(--t1);
  --text-2: var(--t2);
  --text-3: var(--t3);

  --font: 'DM Sans', sans-serif;
  --mono: 'DM Mono', monospace;

  --sidebar-w: 220px;
  --topbar-h:  52px;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

[data-theme="dark"] {
  --bg:       #0f0a1e;
  --bg2:      #1a1035;
  --surface:  #1e1540;
  --surface2: #261b4a;
  --border:   rgba(165,83,246,0.2);
  --border2:  rgba(165,83,246,0.1);
  --t1: #ede9fb;
  --t2: #9b8dbf;
  --t3: #5a4f7a;
  --accent-dim: rgba(165,83,246,0.15);
  --accent-dim2: rgba(165,83,246,0.08);
  --green-dim: rgba(22,163,74,0.15);
  --amber-dim: rgba(217,119,6,0.15);
  --red-dim:   rgba(220,38,38,0.15);
  --blue-dim:  rgba(37,99,235,0.15);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 13px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--t1);
  line-height: 1.5;
  transition: background 0.2s, color 0.2s;
}

/* ── LAYOUT ── */
#app { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: fixed;
  left: 0; top: 0;
  z-index: 100;
  transition: transform 0.25s;
}

.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── SIDEBAR LOGO ── */
.sidebar-logo {
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-logo img { width: 32px; height: 32px; }
.logo-name { font-size: 14px; font-weight: 600; color: var(--t1); }
.logo-version { font-size: 10px; color: var(--t3); font-family: var(--mono); }

/* ── SIDEBAR NAV ── */
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 8px; }
.nav-group { margin-bottom: 16px; }
.nav-group-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--t3);
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 0 8px;
  margin-bottom: 4px;
}
.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--t3);
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 8px 8px 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: var(--radius-md);
  background: none;
  color: var(--t2);
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  text-align: left;
}
.nav-item:hover { background: var(--accent-dim2); color: var(--accent); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); font-weight: 500; }
.nav-icon { font-size: 14px; width: 18px; text-align: center; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  font-size: 10px;
  font-family: var(--mono);
  padding: 1px 6px;
  border-radius: 20px;
  font-weight: 600;
}
.nav-badge.amber { background: var(--amber-dim); color: var(--amber); }
.nav-badge.red { background: var(--red-dim); color: var(--red); }

/* ── SIDEBAR FOOTER ── */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.api-status { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
}
.status-dot.green { background: var(--green); box-shadow: 0 0 4px var(--green); }
.status-dot.amber { background: var(--amber); }
.status-dot.red { background: var(--red); }
.status-text { font-size: 11px; color: var(--t2); }
.api-url { font-size: 10px; color: var(--t3); font-family: var(--mono); }

/* ── TOPBAR ── */
.topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--surface);
  flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.page-title { font-size: 15px; font-weight: 500; color: var(--t1); }
.topbar-date { font-size: 11px; color: var(--t3); }
.topbar-status { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--t2); }
.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--t2);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
}

/* Theme toggle */
.theme-toggle {
  background: var(--accent-dim2);
  border: 1px solid var(--border);
  color: var(--accent);
  width: 32px; height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}
.theme-toggle:hover { background: var(--accent-dim); }

/* User pill */
.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 20px;
  background: var(--accent-dim2);
  border: 1px solid var(--border);
  cursor: pointer;
}
.av {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
}
.av-name { font-size: 12px; color: var(--t1); font-weight: 500; }

/* ── PAGE CONTENT ── */
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: var(--bg);
}

/* ── CARDS ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 16px;
}
.card-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title { font-size: 13px; font-weight: 500; color: var(--t1); }
.card-body { padding: 16px; }

/* ── GRID ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; }
.kpi-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; margin-bottom: 20px; }

/* ── KPI CARDS ── */
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.kpi-label { font-size: 11px; color: var(--t3); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.kpi-value { font-size: 22px; font-weight: 600; color: var(--t1); font-family: var(--mono); }
.kpi-value.text-green { color: var(--green); }
.kpi-value.text-amber { color: var(--amber); }
.kpi-value.text-blue { color: var(--blue); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-md);
  border: none;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { opacity: 0.9; }
.btn-ghost { background: var(--accent-dim2); color: var(--t2); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--accent-dim); color: var(--accent); }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover:not(:disabled) { opacity: 0.9; }
.btn-sm { padding: 4px 10px; font-size: 11px; }
.btn-lg { padding: 10px 20px; font-size: 13px; }
.btn-full { width: 100%; justify-content: center; }

/* ── BADGES ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
}
.badge-green { background: var(--green-dim); color: var(--green); }
.badge-amber { background: var(--amber-dim); color: var(--amber); }
.badge-red { background: var(--red-dim); color: var(--red); }
.badge-blue { background: var(--blue-dim); color: var(--blue); }
.badge-gray { background: var(--surface2); color: var(--t3); border: 1px solid var(--border); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ── FORMS ── */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 11px; font-weight: 500; color: var(--t2); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .05em; }
.form-input, .form-select {
  width: 100%;
  padding: 8px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--t1);
  font-family: var(--font);
  font-size: 12px;
  transition: border-color 0.15s;
}
.form-input:focus, .form-select:focus { outline: none; border-color: var(--accent); }
.form-input.mono, .mono { font-family: var(--mono); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
textarea.form-input { resize: vertical; }

/* ── TABLES ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead tr { border-bottom: 1px solid var(--border); }
th { padding: 10px 12px; text-align: left; font-size: 10px; font-weight: 600; color: var(--t3); text-transform: uppercase; letter-spacing: .07em; white-space: nowrap; }
td { padding: 10px 12px; font-size: 12px; border-bottom: 1px solid var(--border2); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--accent-dim2); }
.td-a { font-family: var(--mono); color: var(--accent); font-size: 11px; }
.td-m { font-family: var(--mono); }
.td-p { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 10px; background: var(--accent-dim); color: var(--accent); font-size: 10px; font-weight: 500; }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  width: 100%; max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
}
.modal-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; font-weight: 500; }

/* ── LOADER ── */
.loader-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex; align-items: center; justify-content: center;
}
.loader-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  width: 300px;
  text-align: center;
}
.loader-title { font-size: 14px; font-weight: 500; color: var(--t1); margin-bottom: 8px; }
.loader-msg { font-size: 12px; color: var(--t2); margin-bottom: 16px; }
.loader-bar { height: 3px; background: var(--border); border-radius: 3px; overflow: hidden; margin-bottom: 6px; }
.loader-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.3s; width: 0; }
.loader-pct { font-size: 11px; color: var(--t3); font-family: var(--mono); }

/* ── TOAST ── */
.toast-container {
  position: fixed; bottom: 20px; right: 20px;
  z-index: 3000;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 500;
  max-width: 320px;
  animation: slideIn 0.2s ease;
  border: 1px solid transparent;
}
.toast.success { background: var(--green-dim); color: var(--green); border-color: rgba(22,163,74,0.3); }
.toast.error { background: var(--red-dim); color: var(--red); border-color: rgba(220,38,38,0.3); }
.toast.info { background: var(--blue-dim); color: var(--blue); border-color: rgba(37,99,235,0.3); }

/* ── SPINNER ── */
.spin {
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

/* ── STEPS ── */
.steps-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 8px;
}
.step-item {
  flex: 1;
  padding: 7px 10px;
  border-radius: var(--radius-md);
  font-size: 11px;
  font-weight: 500;
  color: var(--t3);
  text-align: center;
  cursor: default;
}
.step-item.active { background: var(--accent); color: #fff; }
.step-item.done { background: var(--accent-dim); color: var(--accent); }

/* ── MISC ── */
.flex-b { display: flex; align-items: center; justify-content: space-between; }
.flex-c { display: flex; align-items: center; }
.flex-end { display: flex; justify-content: flex-end; }
.gap-4 { gap: 4px; } .gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-10 { gap: 10px; } .gap-16 { gap: 16px; }
.mb-4 { margin-bottom: 4px; } .mb-6 { margin-bottom: 6px; } .mb-8 { margin-bottom: 8px; }
.mb-10 { margin-bottom: 10px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; }
.mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; }
.text-xs { font-size: 11px; } .text-sm { font-size: 12px; }
.text-mono { font-family: var(--mono); }
.text-green { color: var(--green); } .text-amber { color: var(--amber); }
.text-blue { color: var(--blue); } .text-red { color: var(--red); }
.fw-500 { font-weight: 500; } .fw-600 { font-weight: 600; }
.sep { height: 1px; background: var(--border); margin: 12px 0; }

/* ── UPLOAD ZONE ── */
.upload-zone {
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  color: var(--t3);
  font-size: 12px;
}
.upload-zone:hover { border-color: var(--accent); background: var(--accent-dim2); color: var(--accent); }
.upload-zone-label { font-size: 12px; }

/* ── DOC ROW ── */
.doc-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border2); }
.doc-row:last-child { border-bottom: none; }
.doc-row-label { font-size: 12px; color: var(--t2); }

/* ── AI BOX ── */
.ai-box {
  background: rgba(165,83,246,0.05);
  border: 1px solid rgba(165,83,246,0.2);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}
.ai-box-header { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 500; color: var(--accent); margin-bottom: 4px; }
.ai-text { font-size: 11px; color: var(--t3); }
.ai-pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: pulse 1.5s infinite; flex-shrink: 0; }

/* ── RESUMEN ── */
.resumen-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 1px; background: var(--border); }
.resumen-cell { background: var(--surface); padding: 10px 12px; }
.resumen-label { font-size: 10px; color: var(--t3); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 3px; }
.resumen-value { font-size: 12px; color: var(--t1); font-weight: 500; }

/* ── WALLET ── */
.wallet-item { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px; background: var(--surface2); border-radius: var(--radius-md); margin-bottom: 5px; font-family: var(--mono); font-size: 11px; color: var(--t2); }
.wallet-item .remove { background: none; border: none; color: var(--red); cursor: pointer; font-size: 14px; padding: 0 4px; }

/* ── ANIMATIONS ── */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.4; } }
@keyframes slideIn { from { transform: translateX(20px); opacity:0; } to { transform: translateX(0); opacity:1; } }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .menu-toggle { display: flex; }
  .grid-2, .grid-3, .grid-4, .kpi-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}
