/* ═══════════════════════════════════════════════════════════
   AML Risk Scoring – Design System
   Czysty CSS, zero frameworków
═══════════════════════════════════════════════════════════ */

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

:root {
  --bg:        #f0f2f5;
  --surface:   #ffffff;
  --border:    #e4e7ec;
  --border-2:  #d0d5dd;
  --text:      #101828;
  --text-2:    #475467;
  --text-3:    #98a2b3;
  --accent:    #16a34a;
  --accent-2:  #15803d;
  --accent-bg: #f0fdf4;
  --danger:    #dc2626;
  --danger-bg: #fef2f2;
  --warn:      #d97706;
  --warn-bg:   #fffbeb;
  --info:      #2563eb;
  --info-bg:   #eff6ff;
  --sidebar-w: 240px;
  --radius:    10px;
  --radius-lg: 16px;
  --shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 16px rgba(0,0,0,.10);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.14);
  --font:      'Outfit', system-ui, sans-serif;
  --font-mono: 'DM Mono', monospace;
  --transition: .15s ease;
}

html, body { height: 100%; font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }

.hidden { display: none !important; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 99px; }

/* ═══════════════════════════════════════════════ LOGIN */
.page-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a2f 50%, #0f172a 100%);
  position: relative;
  overflow: hidden;
}
.page-login::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(22,163,74,.15) 0%, transparent 70%);
  top: -200px; right: -200px;
}
.login-card {
  background: rgba(255,255,255,.97);
  border-radius: 20px;
  padding: 44px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
}
.login-logo { text-align: center; margin-bottom: 36px; }
.login-logo h1 { font-size: 26px; font-weight: 800; color: var(--text); margin: 12px 0 4px; letter-spacing: -.5px; }
.login-logo p { color: var(--text-3); font-size: 13px; }
.logo-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px; height: 52px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  border-radius: 14px;
  letter-spacing: 1px;
  box-shadow: 0 4px 14px rgba(22,163,74,.35);
}
.field { margin-bottom: 18px; }
.field label { display: block; font-weight: 600; font-size: 12px; color: var(--text-2); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
.field input {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 14px;
  font-family: var(--font);
  color: var(--text);
  background: #fff;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(22,163,74,.12); }
.error-msg { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; border-radius: var(--radius); padding: 10px 14px; font-size: 13px; margin-bottom: 16px; }

/* ═══════════════════════════════════════════════ BUTTONS */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: #fff;
  border: none; border-radius: var(--radius); padding: 11px 20px;
  font-size: 14px; font-weight: 600; font-family: var(--font);
  cursor: pointer; transition: background var(--transition), transform var(--transition);
  text-decoration: none;
}
.btn-primary:hover { background: var(--accent-2); }
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-full { width: 100%; }

.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: #fff; color: var(--text-2);
  border: 1.5px solid var(--border); border-radius: var(--radius); padding: 10px 18px;
  font-size: 14px; font-weight: 600; font-family: var(--font);
  cursor: pointer; transition: all var(--transition); text-decoration: none;
}
.btn-secondary:hover { border-color: var(--border-2); background: var(--bg); color: var(--text); }

.btn-danger {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--danger); color: #fff;
  border: none; border-radius: var(--radius); padding: 10px 18px;
  font-size: 13px; font-weight: 600; font-family: var(--font);
  cursor: pointer; transition: opacity var(--transition);
}
.btn-danger:hover { opacity: .85; }

.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; color: var(--text-2);
  border: none; border-radius: var(--radius); padding: 8px 12px;
  font-size: 13px; font-weight: 500; font-family: var(--font);
  cursor: pointer; transition: all var(--transition);
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.btn-sm { padding: 6px 12px !important; font-size: 12px !important; }

/* ═══════════════════════════════════════════════ APP LAYOUT */
.app { display: flex; height: 100vh; overflow: hidden; }

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  transition: width var(--transition);
  z-index: 10;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-logo .logo-badge { width: 34px; height: 34px; font-size: 11px; border-radius: 9px; flex-shrink: 0; }
.logo-text { font-weight: 800; font-size: 15px; letter-spacing: -.3px; color: var(--text); }
.sidebar-nav { flex: 1; padding: 12px 8px; }
.nav-section-label {
  font-size: 10px; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 1px;
  padding: 4px 8px 8px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius);
  color: var(--text-2); font-weight: 500; font-size: 13.5px;
  cursor: pointer; transition: all var(--transition);
  text-decoration: none; border: none; background: none;
  width: 100%; text-align: left;
  margin-bottom: 2px;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--accent-bg); color: var(--accent); font-weight: 600; }
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.user-avatar {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--accent-bg); color: var(--accent);
  font-weight: 700; font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-weight: 600; font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-3); }
.btn-logout { background: none; border: none; cursor: pointer; color: var(--text-3); padding: 4px; border-radius: 6px; display: flex; }
.btn-logout:hover { color: var(--danger); background: var(--danger-bg); }
.btn-logout svg { width: 15px; height: 15px; }
.btn-sidebar-toggle { background: none; border: none; cursor: pointer; color: var(--text-2); padding: 6px; border-radius: 7px; display: flex; }
.btn-sidebar-toggle:hover { background: var(--bg); }
.btn-sidebar-toggle svg { width: 18px; height: 18px; }

/* ── TOPBAR ── */
.topbar {
  height: 56px; background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; flex-shrink: 0;
  position: sticky; top: 0; z-index: 5;
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.page-title { font-weight: 700; font-size: 15px; color: var(--text); }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.status-text { font-size: 12px; color: var(--text-3); font-weight: 500; }

/* ── MAIN ── */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.content { flex: 1; overflow-y: auto; padding: 28px 28px; }

/* ═══════════════════════════════════════════════ CARDS */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow);
}
.card-title { font-size: 13px; font-weight: 700; color: var(--text-2); margin-bottom: 16px; }

/* ── STAT CARDS ── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px 22px;
  box-shadow: var(--shadow);
  display: flex; justify-content: space-between; align-items: flex-start;
}
.stat-label { font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 6px; }
.stat-value { font-size: 30px; font-weight: 800; color: var(--text); line-height: 1; letter-spacing: -1px; }
.stat-sub { font-size: 11px; color: var(--text-3); margin-top: 4px; }
.stat-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px; }

/* ─ CHARTS GRID ─ */
.charts-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 24px; }
.chart-wrap { position: relative; height: 220px; }

/* ═══════════════════════════════════════════════ PAGE HEADER */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; }
.page-header h1 { font-size: 22px; font-weight: 800; color: var(--text); letter-spacing: -.5px; }
.page-header p { font-size: 13px; color: var(--text-3); margin-top: 2px; }

/* ═══════════════════════════════════════════════ FILTERS */
.filters { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.filters input, .filters select {
  border: 1.5px solid var(--border); border-radius: var(--radius);
  padding: 9px 14px; font-size: 13px; font-family: var(--font);
  color: var(--text); background: var(--surface);
  outline: none; transition: border-color var(--transition), box-shadow var(--transition);
}
.filters input { flex: 1; min-width: 200px; }
.filters input:focus, .filters select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(22,163,74,.1); }

/* ═══════════════════════════════════════════════ TABLE */
.table-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; }
thead tr { background: #f8fafc; border-bottom: 1px solid var(--border); }
th {
  text-align: left; padding: 11px 16px;
  font-size: 11px; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .5px;
  white-space: nowrap;
}
td { padding: 13px 16px; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--text-2); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafafa; }
.td-main { font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 8px; }
.td-mono { font-family: var(--font-mono); font-size: 12px; color: var(--text-3); }
.table-footer { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.table-count { font-size: 12px; color: var(--text-3); }
.td-actions { display: flex; gap: 6px; }

/* ═══════════════════════════════════════════════ BADGES */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 99px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge-green  { background: #dcfce7; color: #15803d; }
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-yellow { background: #fef3c7; color: #b45309; }
.badge-red    { background: #fee2e2; color: #b91c1c; }
.badge-gray   { background: #f1f5f9; color: #64748b; }

.risk-bar { display: flex; align-items: center; gap: 8px; }
.risk-bar-inner { height: 6px; width: 60px; background: var(--border); border-radius: 99px; overflow: hidden; }
.risk-bar-fill { height: 100%; border-radius: 99px; }
.risk-val { font-family: var(--font-mono); font-size: 12px; font-weight: 600; color: var(--text); }

/* ═══════════════════════════════════════════════ MODAL */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 100; backdrop-filter: blur(2px);
}
.modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%);
  z-index: 101; background: var(--surface);
  border-radius: var(--radius-lg); width: 100%; max-width: 500px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg); padding: 28px;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.modal-header h2 { font-size: 17px; font-weight: 700; color: var(--text); }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-3); font-size: 20px; line-height: 1; padding: 2px 6px; border-radius: 6px; }
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-footer { display: flex; gap: 10px; margin-top: 24px; }
.modal-footer .btn-secondary, .modal-footer .btn-primary { flex: 1; justify-content: center; }
.info-box { background: var(--accent-bg); border: 1px solid #bbf7d0; border-radius: var(--radius); padding: 12px 14px; font-size: 12px; color: #15803d; margin: 16px 0; }
.warn-box { background: var(--warn-bg); border: 1px solid #fde68a; border-radius: var(--radius); padding: 12px 14px; font-size: 12px; color: #92400e; margin: 10px 0; }
.info-row { display: flex; gap: 12px; font-size: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.info-row:last-child { border-bottom: none; }
.info-row .lbl { color: var(--text-3); width: 110px; flex-shrink: 0; }
.info-row .val { color: var(--text); font-weight: 500; }

/* ═══════════════════════════════════════════════ TOAST */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--text); color: #fff;
  padding: 12px 20px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-md); z-index: 200;
  animation: slideUp .2s ease;
}
.toast.toast-success { background: var(--accent); }
.toast.toast-error   { background: var(--danger); }
@keyframes slideUp { from { opacity:0; transform: translateY(8px); } to { opacity:1; transform: translateY(0); } }

/* ═══════════════════════════════════════════════ SCORE BAR */
.score-breakdown { display: flex; flex-direction: column; gap: 12px; }
.score-row { }
.score-row-header { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-2); margin-bottom: 5px; }
.score-row-header span:last-child { font-weight: 700; color: var(--text); }
.score-track { height: 8px; background: var(--border); border-radius: 99px; overflow: hidden; }
.score-fill { height: 100%; border-radius: 99px; transition: width .6s cubic-bezier(.4,0,.2,1); }

/* ═══════════════════════════════════════════════ DETAIL PANEL */
.detail-tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab-btn {
  padding: 10px 16px; font-size: 13px; font-weight: 600;
  color: var(--text-3); background: none; border: none;
  border-bottom: 2px solid transparent; cursor: pointer;
  transition: all var(--transition); margin-bottom: -1px;
}
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-btn:hover:not(.active) { color: var(--text); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ═══════════════════════════════════════════════ EXPIRING LIST */
.expiring-list { display: flex; flex-direction: column; gap: 0; }
.expiring-item { display: flex; align-items: center; justify-content: space-between; padding: 11px 0; border-bottom: 1px solid var(--border); }
.expiring-item:last-child { border-bottom: none; }
.expiring-name { font-weight: 600; font-size: 13px; color: var(--text); }
.expiring-date { font-size: 11px; color: var(--text-3); margin-top: 1px; }

/* ═══════════════════════════════════════════════ EMPTY STATE */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-3); }
.empty-state svg { width: 48px; height: 48px; margin: 0 auto 16px; opacity: .3; }
.empty-state h3 { font-size: 15px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.empty-state p { font-size: 13px; }

/* ═══════════════════════════════════════════════ RESPONSIVE */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { position: fixed; left: -240px; height: 100%; transition: left var(--transition); }
  .sidebar.open { left: 0; box-shadow: var(--shadow-lg); }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .content { padding: 16px; }
}
