/* ============================================================
   SMART LEGAL PLATFORM — Dark Enterprise AI Theme v2
   Deep Navy · Glassmorphism · Cyan Glow
   ============================================================ */

/* --- 1. VARIABLES --- */
:root {
  --bg-body:    #080d1a;
  --bg-sidebar: #0b1120;
  --bg-main:    #0d1526;
  --bg-card:    rgba(255,255,255,0.04);
  --bg-card-2:  rgba(255,255,255,0.06);
  --bg-hover:   rgba(255,255,255,0.06);
  --bg-input:   rgba(255,255,255,0.06);
  --border:     rgba(255,255,255,0.08);
  --border-accent: rgba(0,212,170,0.3);

  --text-primary:   #f1f5f9;
  --text-secondary: #c4d0de;
  --text-muted:     #8a9db5;

  --cyan:   #00d4aa;
  --cyan2:  #06b6d4;
  --blue:   #0ea5e9;
  --purple: #8b5cf6;
  --gold:   #f59e0b;
  --red:    #ef4444;
  --green:  #22c55e;
  --orange: #f97316;

  --glow-cyan:   0 0 24px rgba(0,212,170,0.18), 0 0 48px rgba(0,212,170,0.08);
  --glow-blue:   0 0 24px rgba(14,165,233,0.18);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --sidebar-w: 256px;

  --transition: all 0.18s ease;
}

/* --- 2. RESET --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  background: var(--bg-body);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
}
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }

/* --- 3. SCROLLBAR --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,212,170,0.25); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,212,170,0.45); }

/* --- 4. LOGIN --- */
.login-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse at 20% 50%, rgba(0,212,170,0.06) 0%, transparent 60%),
              radial-gradient(ellipse at 80% 20%, rgba(14,165,233,0.06) 0%, transparent 60%),
              var(--bg-body);
}
.login-card {
  width: 100%; max-width: 1100px;
  display: grid; grid-template-columns: 1fr 1fr;
  border-radius: 28px; overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 32px 80px rgba(0,0,0,0.5), var(--glow-cyan);
}
.login-brand {
  background: linear-gradient(160deg, #0d2137 0%, #051525 50%, #0a1e1a 100%);
  padding: 56px 44px;
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 16px;
  text-align: center;
  position: relative; overflow: hidden;
}
.login-brand::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 40%, rgba(0,212,170,0.12) 0%, transparent 65%);
  pointer-events: none;
}
.login-mascot {
  width: 200px; max-width: 100%; object-fit: contain;
  animation: mascotFloat 2.6s ease-in-out infinite;
  filter: drop-shadow(0 12px 28px rgba(0,212,170,0.3));
  position: relative; z-index: 1;
}
.login-brand h1 { font-size: 30px; font-weight: 800; color: #f1f5f9; line-height: 1.2; position: relative; z-index: 1; }
.login-brand p  { font-size: 16px; color: var(--cyan); font-weight: 500; position: relative; z-index: 1; }
.org-name {
  font-size: 10px; letter-spacing: 1.8px; text-transform: uppercase;
  color: rgba(255,255,255,0.5); font-weight: 700; position: relative; z-index: 1;
}
.login-form {
  background: rgba(13,21,38,0.96);
  padding: 56px 48px;
  display: flex; flex-direction: column; justify-content: center;
}
.login-form h2 { font-size: 26px; font-weight: 800; color: var(--text-primary); margin-bottom: 6px; }
.muted { color: var(--text-secondary); margin-bottom: 28px; font-size: 13px; }
.login-form label { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin: 12px 0 5px; display: block; text-transform: uppercase; letter-spacing: 0.6px; }
.login-form input {
  width: 100%; padding: 12px 14px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--r-md); font-size: 14px; color: var(--text-primary);
  transition: var(--transition); outline: none; margin-bottom: 4px;
}
.login-form input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(0,212,170,0.12); }
.login-form button {
  margin-top: 20px; width: 100%; padding: 13px;
  background: linear-gradient(135deg, #00b894, #0097a7);
  color: #fff; font-weight: 700; font-size: 14px;
  border: none; border-radius: var(--r-md); cursor: pointer;
  box-shadow: 0 8px 24px rgba(0,212,170,0.25);
  transition: var(--transition);
}
.login-form button:hover { transform: translateY(-1px); box-shadow: 0 12px 32px rgba(0,212,170,0.35); }
.login-message { margin-top: 10px; color: var(--red); font-size: 13px; min-height: 18px; }

/* --- 5. APP SHELL --- */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
}

/* --- 6. SIDEBAR --- */
.sidebar {
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 20px 12px 16px;
  display: flex; flex-direction: column; justify-content: space-between;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand-block {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 6px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.sidebar-mascot {
  width: 42px; height: 42px; object-fit: contain; flex-shrink: 0;
  animation: mascotFloatSmall 3.6s ease-in-out infinite;
  filter: drop-shadow(0 4px 12px rgba(0,212,170,0.4));
}
.brand-title { font-size: 14px; font-weight: 800; color: var(--text-primary); line-height: 1.2; }
.brand-subtitle { font-size: 11px; color: var(--cyan); font-weight: 600; margin-top: 2px; }
.brand-unit { font-size: 9px; color: var(--text-muted); letter-spacing: 0.8px; text-transform: uppercase; margin-top: 2px; }

.nav-menu { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 10px 12px;
  background: transparent; border: none; border-radius: var(--r-md);
  color: var(--text-secondary); font-size: 13px; font-weight: 500;
  cursor: pointer; text-align: left;
  transition: var(--transition);
  position: relative;
}
.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.nav-item.active {
  background: rgba(0,212,170,0.1);
  color: var(--cyan);
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--cyan);
}
.nav-icon {
  width: 18px; height: 18px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.nav-icon svg {
  width: 16px; height: 16px;
  stroke: currentColor; fill: none;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.nav-item span:last-child { flex: 1; }

/* Sidebar footer / user row */
.sidebar-footer { padding-top: 12px; border-top: 1px solid var(--border); }
.user-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 6px;
}
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, #00b894, #0097a7);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; color: #fff;
  box-shadow: 0 0 12px rgba(0,212,170,0.3);
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.user-role { font-size: 11px; color: var(--text-muted); }
.btn-logout {
  width: 30px; height: 30px; padding: 0;
  background: rgba(239,68,68,0.12); border: 1px solid rgba(239,68,68,0.2);
  border-radius: var(--r-sm); color: var(--red);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: var(--transition); flex-shrink: 0;
  box-shadow: none;
}
.btn-logout:hover { background: rgba(239,68,68,0.22); transform: none; }
.btn-logout svg { stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Legacy - keep for JS compat */
.user-chip { display: none; }
.btn-secondary { background: rgba(255,255,255,0.08); border: 1px solid var(--border); color: var(--text-primary); }

/* --- 7. MAIN SHELL --- */
.main-shell {
  background: var(--bg-main);
  padding: 16px 20px;
  min-height: 100vh;
  overflow: hidden;
}

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px; padding-bottom: 14px; margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 22px; font-weight: 800; color: var(--text-primary); letter-spacing: -0.4px; }
.topbar p  { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.topbar-assistant {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-card); border: 1px solid var(--border);
  padding: 8px 14px; border-radius: var(--r-lg);
  backdrop-filter: blur(12px);
}
.topbar-mascot { width: 40px; height: 40px; object-fit: contain; animation: mascotPulse 2s ease-in-out infinite; }
.assistant-name { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.assistant-desc { font-size: 11px; color: var(--cyan); }

/* --- 8. CONTENT GRID --- */
.content-grid {
  display: grid;
  grid-template-columns: 0.72fr 1.78fr 0.55fr;
  gap: 16px;
  height: calc(100vh - 110px);
  align-items: stretch;
}
.panel {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 16px;
  min-height: 0;
  max-height: calc(100vh - 120px);
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: border-color 0.2s ease;
}
.panel:hover { border-color: rgba(255,255,255,0.12); }
.content-grid > .panel:first-child { overflow-y: auto; overflow-x: hidden; }
.module-block { min-height: 0; }
.module-block h2, .panel h2 {
  font-size: 16px; font-weight: 700; color: var(--text-primary);
  margin-bottom: 12px; padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.module-block h3 { font-size: 13px; font-weight: 600; color: var(--text-secondary); margin: 12px 0 6px; }

/* --- 9. FORM / BUTTON CHUNG --- */
label {
  display: block; font-size: 11px; font-weight: 600;
  color: var(--text-secondary); margin-bottom: 4px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
input, textarea, select {
  width: 100%;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 8px 11px;
  font-size: 13px; color: var(--text-primary);
  outline: none; transition: var(--transition); margin-bottom: 8px;
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }
input:focus, textarea:focus, select:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(0,212,170,0.1);
}
select option { background: #1a2535; color: var(--text-primary); }
textarea { resize: vertical; min-height: 70px; }
#studioInputBlock textarea { min-height: 65px; height: 65px; }
#studioInputBlock select, #studioInputBlock input { height: 38px; }

button {
  background: linear-gradient(135deg, #00b894, #0097a7);
  color: #fff; border: none; border-radius: var(--r-md);
  padding: 9px 16px; font-size: 13px; font-weight: 700;
  cursor: pointer; box-shadow: 0 4px 16px rgba(0,212,170,0.2);
  transition: var(--transition);
}
button:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(0,212,170,0.3); }
button:disabled, .btn-disabled {
  background: rgba(255,255,255,0.07) !important;
  color: var(--text-muted) !important;
  cursor: not-allowed !important;
  box-shadow: none !important;
  transform: none !important;
}
.button-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* --- 10. FORM DONG --- */
#dynamicFormBlock, #resultBlock, #analysisBlock, #libraryRightBlock { overflow-y: auto; padding-right: 4px; }
#dynamicForm { display: flex; flex-direction: column; gap: 6px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 6px 12px; width: 100%; }
.form-field { display: flex; flex-direction: column; }
.form-field.full-width, .form-field:has(.table-wrapper) { grid-column: 1 / -1; }
.form-group { margin-bottom: 0; }
.form-group label, .form-field label {
  font-size: 11px; font-weight: 600; color: var(--text-secondary); margin-bottom: 3px;
  text-transform: uppercase; letter-spacing: 0.5px;
}

/* --- 11. STATUS BOX --- */
.status-box {
  background: rgba(255,255,255,0.03); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 10px 12px; margin: 8px 0 10px;
}
.status-box div { margin-bottom: 4px; font-size: 13px; color: var(--text-secondary); }
.status-box b { color: var(--text-primary); }

/* --- 12. IMPORT / UPLOAD --- */
.import-box {
  margin-top: 8px; padding: 12px; border-radius: var(--r-lg);
  background: rgba(255,255,255,0.03); border: 1px solid var(--border);
}
.import-box h3 { font-size: 13px; margin-bottom: 6px; color: var(--text-primary); }
.import-desc { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; line-height: 1.4; }
.upload-label { display: block; font-size: 11px; font-weight: 700; color: var(--text-secondary); margin: 6px 0 3px; text-transform: uppercase; letter-spacing: 0.5px; }
.upload-input {
  width: 100%; padding: 8px; font-size: 12px; color: var(--text-secondary);
  background: rgba(255,255,255,0.03); border: 1px dashed rgba(0,212,170,0.25);
  border-radius: var(--r-md); cursor: pointer; margin-bottom: 8px;
}
.upload-input::-webkit-file-upload-button {
  background: rgba(0,212,170,0.15); border: 1px solid rgba(0,212,170,0.3);
  color: var(--cyan); border-radius: 6px; padding: 4px 10px;
  font-size: 11px; cursor: pointer; margin-right: 8px;
}
.import-actions { margin-top: 10px; }
.import-actions button:not(.btn-mini) { flex: 1; min-width: 110px; }
.import-note {
  padding: 8px 11px; margin-top: 6px; border-radius: var(--r-md);
  background: rgba(0,212,170,0.07); border: 1px solid rgba(0,212,170,0.15);
  color: var(--cyan); font-size: 12px; line-height: 1.4;
}
pre, pre#responsePreview {
  background: rgba(0,0,0,0.4); border: 1px solid var(--border);
  color: #86efac; border-radius: var(--r-lg);
  padding: 12px; min-height: 200px; max-height: 260px;
  overflow: auto; white-space: pre-wrap; word-break: break-word;
  font-size: 11px; font-family: "Consolas", monospace; line-height: 1.5;
}
.placeholder-note, .analysis-placeholder, .document-list-placeholder {
  background: rgba(255,255,255,0.03); border: 1px dashed rgba(255,255,255,0.1);
  border-radius: var(--r-lg); padding: 16px; color: var(--text-muted);
  line-height: 1.6; font-size: 13px;
}

/* --- 13. TABLE CHUNG --- */
.table-wrapper {
  width: 100%; overflow-x: auto; border-radius: var(--r-lg);
  border: 1px solid var(--border); background: transparent;
}
.dynamic-table {
  width: 100%; min-width: 860px; border-collapse: collapse;
}
.dynamic-table th {
  background: rgba(0,212,170,0.08); color: var(--cyan);
  font-size: 11px; font-weight: 700; text-align: center; text-transform: uppercase;
  padding: 9px 8px; border-bottom: 1px solid var(--border); letter-spacing: 0.5px;
}
.dynamic-table td {
  border-bottom: 1px solid var(--border);
  padding: 7px 8px; font-size: 13px; color: var(--text-primary); vertical-align: top;
}
.dynamic-table input {
  min-width: 120px; margin-bottom: 0; border-radius: 8px; padding: 6px 8px; font-size: 12px;
}

/* --- 14. GOLD MAIN TABLE (DataHub) --- */
#datahubCenterBlock { overflow: hidden; }
#datahubRightBlock { overflow-y: auto; overflow-x: hidden; padding-right: 6px; }

.gold-table-shell {
  width: 100%; max-height: calc(100vh - 245px); overflow: auto;
  border: 1px solid var(--border); border-radius: var(--r-xl);
  background: rgba(255,255,255,0.02);
}
.gold-main-table {
  width: 100%; min-width: 1850px; table-layout: fixed;
  border-collapse: separate; border-spacing: 0;
}
.gold-main-table th, .gold-main-table td {
  border-right: 1px solid rgba(255,255,255,0.05);
  border-bottom: 1px solid rgba(255,255,255,0.05);
  padding: 8px 10px; vertical-align: middle;
  font-size: 13px; color: var(--text-primary); font-weight: 400;
}
.gold-main-table th {
  position: sticky; top: 0; z-index: 3; height: 40px;
  background: rgba(0,212,170,0.08);
  color: var(--cyan); font-size: 11px; font-weight: 700;
  text-align: center; text-transform: uppercase; letter-spacing: 0.4px;
  backdrop-filter: blur(8px);
}
.gold-main-table thead tr:nth-child(2) th { top: 40px; z-index: 4; }
.gold-main-table td { height: 58px; background: transparent; }
.gold-main-table tr:hover td { background: rgba(255,255,255,0.03); }
.gold-main-table .col-id { width: 54px; text-align: center; }
.gold-main-table .col-file { width: 250px; }
.gold-main-table .col-branch { width: 185px; color: var(--cyan); font-weight: 600; }
.gold-main-table .col-period, .gold-main-table .col-fee,
.gold-main-table .col-number, .gold-main-table .col-location-count {
  width: 72px; text-align: center; white-space: nowrap;
}
.gold-main-table .total-cell { color: var(--cyan); font-weight: 600; }
.gold-main-table .col-location { width: 360px; white-space: normal; line-height: 1.4; font-size: 12px; }
.gold-main-table .col-status { width: 130px; min-width: 130px; text-align: center; }
.gold-main-table .col-user { width: 100px; text-align: center; }
.gold-main-table .col-time { width: 145px; font-size: 12px; line-height: 1.35; }
.gold-main-table .col-actions { width: 196px; min-width: 196px; text-align: center; padding: 5px 4px; }

/* --- 15. BTN-MINI (action buttons) --- */
.gold-main-table .col-actions .btn-mini, .btn-mini {
  width: 118px; height: 32px; margin: 3px 4px;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  border-radius: 9px;
  background: rgba(255,255,255,0.05); box-shadow: none; transform: none;
  font-size: 12px; font-weight: 500; padding: 0 8px; cursor: pointer;
  border: 1px solid rgba(255,255,255,0.1); color: var(--text-primary);
  transition: var(--transition);
}
.btn-mini:hover { background: rgba(255,255,255,0.1); transform: none; }
.btn-mini-icon, .btn-mini-icon svg { width: 13px; height: 13px; }
.btn-mini-icon svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-mini-view   { color: #60a5fa; border-color: rgba(96,165,250,0.3); background: rgba(96,165,250,0.08); }
.btn-mini-edit   { color: #22d3ee; border-color: rgba(34,211,238,0.3); background: rgba(34,211,238,0.08); }
.btn-mini-confirm{ color: #4ade80; border-color: rgba(74,222,128,0.3); background: rgba(74,222,128,0.08); }
.btn-mini-delete { color: #f87171; border-color: rgba(248,113,113,0.3); background: rgba(248,113,113,0.08); }
.btn-mini-disabled{ color: var(--text-muted); border-color: rgba(255,255,255,0.08); background: rgba(255,255,255,0.03); cursor: not-allowed; }
.dh-action-grid { display: grid; grid-template-columns: 88px 88px; gap: 4px; padding: 2px; justify-content: center; }
.dh-action-grid .btn-mini { width: 100%; margin: 0; min-width: 0; font-size: 11px; padding: 0 4px; height: 26px; border-radius: 7px; gap: 3px; }

/* --- 16. STATUS BADGE --- */
.status-badge {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 90px; min-height: 36px; padding: 5px 10px;
  border-radius: 9px; font-size: 12px; font-weight: 600;
  line-height: 1.25; white-space: normal; text-align: center;
}
.status-badge::before { content: "\25CF"; font-size: 8px; flex: 0 0 auto; }
.status-needs_review { background: rgba(245,158,11,0.12); color: #fbbf24; border: 1px solid rgba(245,158,11,0.25); }
.status-extracted    { background: rgba(34,197,94,0.1);  color: #4ade80; border: 1px solid rgba(34,197,94,0.25); }
.status-corrected    { background: rgba(96,165,250,0.1); color: #93c5fd; border: 1px solid rgba(96,165,250,0.25); }
.status-confirmed    { background: rgba(0,212,170,0.1);  color: var(--cyan); border: 1px solid rgba(0,212,170,0.25); }
.status-locked       { background: rgba(139,92,246,0.1); color: #c4b5fd; border: 1px solid rgba(139,92,246,0.25); }
.status-error        { background: rgba(239,68,68,0.1);  color: #fca5a5; border: 1px solid rgba(239,68,68,0.25); }
.status-processing   { background: rgba(14,165,233,0.12); color: #38bdf8; border: 1px solid rgba(14,165,233,0.3); animation: pulse-processing 1.4s ease-in-out infinite; }
@keyframes pulse-processing { 0%,100% { opacity:1; } 50% { opacity:0.5; } }

/* --- 17. DATAHUB RIGHT PANEL --- */
#datahubRightBlock .status-box { background: rgba(255,255,255,0.03); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 12px; }
#datahubRightBlock .placeholder-note { background: rgba(245,158,11,0.06); border: 1px solid rgba(245,158,11,0.2); color: #fbbf24; }
#datahubRightBlock h3 { font-size: 13px; margin: 4px 0 10px; color: var(--text-primary); }
#datahubRightBlock textarea { min-height: 280px; font-family: Consolas, monospace; font-size: 12px; resize: vertical; }
#goldReportJsonEdit[readonly] { background: rgba(255,255,255,0.02); color: var(--text-muted); cursor: not-allowed; }
#datahubRightBlock .form-field input[readonly] { background: rgba(255,255,255,0.02); color: var(--text-muted); cursor: not-allowed; border-color: rgba(255,255,255,0.06); }

/* --- 18. MASCOT EMPTY STATE --- */
.empty-mascot { display: block; width: 80px; margin: 20px auto 10px; opacity: 0.6; }
.document-viewer { height: 100%; display: flex; flex-direction: column; }
.viewer-placeholder { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-muted); gap: 12px; text-align: center; }

/* --- 19. ANIMATIONS --- */
@keyframes mascotFloat      { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes mascotFloatSmall { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes mascotPulse      { 0%,100% { transform: scale(1); } 50% { transform: scale(1.04); } }
@keyframes glowPulse        { 0%,100% { box-shadow: 0 0 16px rgba(0,212,170,0.15); } 50% { box-shadow: 0 0 32px rgba(0,212,170,0.35); } }
@keyframes fadeIn           { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ============================================================ */
/* DASHBOARD MODERN — full-width, config-driven layout           */
/* ============================================================ */

/* Khi dashboard module active, .content-grid chuyển 1 cột full-width */
.content-grid.dashboard-modern-mode {
  grid-template-columns: 1fr;
  height: auto;
}

.dash-modern {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px 22px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  min-height: calc(100vh - 110px);
  overflow-y: auto;
}

/* A. FILTER BAR */
.dash-filter-bar {
  display: flex;
  gap: 14px;
  align-items: end;
  padding: 14px 16px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  flex-wrap: wrap;
}
.dash-field { display: flex; flex-direction: column; gap: 4px; min-width: 200px; flex: 1; }
.dash-field label { font-size: 11px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.4px; }
.dash-field select, .dash-field input {
  height: 36px;
  padding: 0 10px;
  background: var(--bg-input, rgba(255,255,255,0.05));
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 13px;
}
.dash-status { font-size: 11px; color: var(--text-secondary); align-self: end; padding-bottom: 8px; }
.btn-primary {
  height: 36px; padding: 0 18px; border: none; border-radius: 6px;
  background: #00d4aa; color: #0f172a; font-weight: 600; cursor: pointer; font-size: 13px;
}
.btn-primary:hover { background: #00b894; }
.btn-ghost {
  height: 36px; padding: 0 14px; border: 1px solid var(--border); border-radius: 6px;
  background: transparent; color: var(--text-primary); cursor: pointer; font-size: 13px;
}
.btn-ghost:hover { background: rgba(255,255,255,0.04); }

/* B. KPI CARDS */
.dash-kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.dash-kpi-card {
  padding: 14px 16px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  min-width: 0;
}
.dash-kpi-label { font-size: 11px; color: #CBD5E1; text-transform: uppercase; letter-spacing: 0.4px; font-weight: 600; }
.dash-kpi-value { font-size: 28px; font-weight: 700; margin-top: 6px; line-height: 1.1; }
.dash-kpi-value.pos { color: #10b981; }
.dash-kpi-value.neg { color: #ef4444; }
.dash-kpi-value.warn { color: #f59e0b; }
.dash-kpi-value.info { color: #3b82f6; }
.dash-kpi-sub { font-size: 11px; color: #94A3B8; margin-top: 4px; }

/* Text override sáng cho dash-modern (dark theme readability) */
.dash-modern .dash-field label { color: #CBD5E1; font-weight: 500; }
.dash-modern .dash-status { color: #94A3B8; }
.dash-modern .dash-chart-title { color: #F8FAFC; font-weight: 700; }
.dash-modern .dash-table thead tr { background: rgba(31,95,166,0.25); }
.dash-modern .dash-table th { color: #F8FAFC; font-weight: 700; }
.dash-modern .dash-table td { color: #E2E8F0; }
.dash-modern .dash-table-footer { color: #CBD5E1; }
.dash-modern .dash-table-header input { color: #F8FAFC; }
.dash-modern .dash-table-header input::placeholder { color: #94A3B8; }

/* C. CHARTS */
.dash-charts-row {
  display: grid;
  grid-template-columns: 1.85fr 1fr;
  gap: 16px;
}
@media (max-width: 1100px) { .dash-charts-row { grid-template-columns: 1fr; } }
.dash-chart-card {
  padding: 12px 14px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  height: 320px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.dash-chart-card.compact { height: 320px; }
.dash-chart-card.mini { height: 260px; padding: 10px 14px; }
.dash-chart-card.mini .dash-chart-title { font-size: 11px; margin-bottom: 6px; }
.dash-chart-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}
.dash-chart-card img {
  width: 100%; border-radius: 4px; display: block;
  max-height: 100%; object-fit: contain;
}
/* Canvas wrapper — bắt buộc cho Chart.js responsive fit container */
.dash-chart-canvas-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
}
.dash-chart-canvas-wrap canvas { max-width: 100%; max-height: 100%; }

/* D. TABLE */
.dash-table-section {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px 16px;
}
.dash-table-header {
  display: flex; gap: 10px; align-items: center; margin-bottom: 10px;
}
.dash-table-header input {
  height: 32px; padding: 0 10px; background: var(--bg-input, rgba(255,255,255,0.05));
  border: 1px solid var(--border); border-radius: 6px; color: var(--text-primary);
  font-size: 13px; min-width: 260px;
}
.dash-table-wrap { overflow-x: auto; }
.dash-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.dash-table thead tr {
  background: rgba(31,95,166,0.15); border-bottom: 2px solid #1f5fa6;
}
.dash-table th {
  text-align: left; padding: 10px 12px; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.3px; color: var(--text-primary);
  font-weight: 600;
}
.dash-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); }
.dash-table tbody tr:hover { background: rgba(255,255,255,0.03); }
.dash-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.dash-table .pos { color: #10b981; font-weight: 600; }
.dash-table .neg { color: #ef4444; font-weight: 600; }
.dash-table .status-confirmed { color: #10b981; }
.dash-table .status-pending { color: #f59e0b; }
.dash-table .status-error { color: #ef4444; }

.dash-table-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-secondary); gap: 12px; flex-wrap: wrap;
}
.dash-table-footer select {
  background: var(--bg-input, rgba(255,255,255,0.05));
  border: 1px solid var(--border); color: var(--text-primary); padding: 2px 6px;
  border-radius: 4px;
}
.dash-pagination { display: flex; gap: 4px; }
.dash-pagination button {
  min-width: 28px; height: 28px; border: 1px solid var(--border);
  background: transparent; color: var(--text-primary); border-radius: 4px;
  cursor: pointer; font-size: 12px;
}
.dash-pagination button.active { background: #00d4aa; color: #0f172a; font-weight: 600; border-color: #00d4aa; }
.dash-pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

/* --- 20. RESPONSIVE --- */
@media (max-width: 1400px) { .content-grid { grid-template-columns: 0.78fr 1.55fr 0.67fr; } }
@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .content-grid { grid-template-columns: 1fr; height: auto; }
  .panel { max-height: none; }
  .login-card { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .sidebar { position: static; height: auto; }
}
