:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --sb-bg: #0f172a;
  --sb-text: #e2e8f0;
  --border: #cbd5e1;
  --text: #0f172a;
  --muted: #64748b;
  --accent: #2563eb;
  --ok: #059669;
  --warn: #d97706;
  --err: #dc2626;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.hidden { display: none !important; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: #0f172a;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  padding: 28px;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-card h1 { margin: 0; font-size: 20px; }
.muted { margin: 0; font-size: 13px; color: var(--muted); }

.brand-badge {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

.app-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100vh;
}

.app-shell > * {
  min-width: 0;
}

@media (max-width: 820px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
}

.sidebar {
  background: var(--sb-bg);
  color: var(--sb-text);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sb-brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.sb-title { font-weight: 700; font-size: 15px; }
.sb-sub { font-size: 12px; color: #94a3b8; }

.sb-nav { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.nav-btn {
  background: transparent;
  color: #cbd5e1;
  border: 0;
  border-radius: 8px;
  padding: 10px 12px;
  text-align: left;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.nav-btn:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.nav-btn.active { background: var(--accent); color: #fff; }

.badge {
  background: var(--err);
  color: #fff;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
}

.workspace { padding: 24px; max-width: 1180px; width: 100%; min-width: 0; }
.tab-panel { min-width: 0; max-width: 100%; }
.panel-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.panel-head h2 { margin: 0; font-size: 22px; }
.list-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.list-head h3 { margin: 0; }
.search-input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: #fff;
  min-width: 210px;
  max-width: 100%;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 18px;
  min-width: 0;
  max-width: 100%;
}

.card h3 { margin: 0 0 12px; font-size: 16px; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}
.kpi-label { font-size: 12px; color: var(--muted); }
.kpi-val { font-size: 22px; font-weight: 800; margin-top: 4px; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; }
.field input, .field select, .inline-form input, .inline-form select {
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: #fff;
}

.form-grid { display: flex; flex-direction: column; gap: 14px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.three-col { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

@media (max-width: 720px) {
  .two-col, .three-col { grid-template-columns: 1fr; }
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 9px 16px;
  font-weight: 600;
  cursor: pointer;
}
.btn-secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-danger {
  background: var(--err);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.btn-ok {
  background: var(--ok);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.btn-ghost {
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  border: 0;
  border-radius: 8px;
  padding: 9px;
  cursor: pointer;
}

.table-wrap { overflow-x: auto; max-width: 100%; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid #e2e8f0; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
.pager-bar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 12px; font-size: 13px; color: var(--muted); }
.pager-actions { display: flex; gap: 8px; }

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: #e2e8f0;
}
.pill-finished, .pill-delivered, .pill-clean { background: #d1fae5; color: #065f46; }
.pill-aml_hold, .pill-confirming, .pill-pending { background: #fef3c7; color: #92400e; }
.pill-failed, .pill-aml_rejected, .pill-refunded { background: #fee2e2; color: #991b1b; }

.code-box {
  background: #0f172a;
  color: #e2e8f0;
  padding: 14px;
  border-radius: 10px;
  font-size: 12px;
  overflow-x: auto;
}

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; font-weight: 600; background: #dbeafe; color: #1e40af; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.flash.err, .err-box { background: #fee2e2; color: #991b1b; padding: 10px 14px; border-radius: 8px; font-size: 13px; }
.test-inv-out { margin-top: 12px; padding: 10px; background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; overflow-wrap: anywhere; word-break: break-word; }
.aml-item { border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 10px; min-width: 0; max-width: 100%; overflow-wrap: anywhere; word-break: break-word; }
.aml-item code { overflow-wrap: anywhere; word-break: break-word; }
.aml-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
