/* ============================================================
   LeaveFlow LMS — Main Stylesheet
   Google Fonts: Noto Sans Thai + Geist Mono
   ============================================================ */

/* ---------- FONTS ---------- */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Thai:wght@300;400;500;600;700;800&family=Geist+Mono:wght@400;500&display=swap');

/* ---------- CSS VARIABLES ---------- */
:root {
  /* Colors */
  --primary: #2563EB;
  --primary-hover: #1D4ED8;
  --primary-light: #EFF6FF;
  --primary-ring: rgba(37, 99, 235, .18);

  --success: #16A34A;
  --success-light: #F0FDF4;
  --success-ring: #BBF7D0;

  --warning: #D97706;
  --warning-light: #FFFBEB;
  --warning-ring: #FDE68A;

  --danger: #DC2626;
  --danger-light: #FEF2F2;
  --danger-ring: #FECACA;

  --info: #0891B2;
  --info-light: #ECFEFF;
  --info-ring: #A5F3FC;

  /* Neutrals - Light */
  --bg: #F8FAFC;
  --bg-card: #FFFFFF;
  --bg-input: #F8FAFC;
  --bg-hover: #F1F5F9;
  --bg-muted: #F1F5F9;

  --border: #E2E8F0;
  --border-strong: #CBD5E1;

  --text: #0F172A;
  --text-secondary: #475569;
  --text-muted: #94A3B8;
  --text-disabled: #CBD5E1;

  /* Sidebar */
  --sidebar-bg: #0F172A;
  --sidebar-hover: rgba(255, 255, 255, .07);
  --sidebar-active: rgba(37, 99, 235, .2);
  --sidebar-text: #94A3B8;
  --sidebar-text-active: #93C5FD;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .05);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .07), 0 1px 2px rgba(0, 0, 0, .05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, .05), 0 2px 4px rgba(0, 0, 0, .04);
  --shadow-lg: 0 10px 24px rgba(0, 0, 0, .08), 0 4px 8px rgba(0, 0, 0, .04);
  --shadow-xl: 0 20px 50px rgba(0, 0, 0, .12);

  /* Radius */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;
  --r-2xl: 24px;
  --r-full: 9999px;

  /* Typography */
  --font-sans: 'Noto Sans Thai', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'Geist Mono', 'Fira Code', monospace;

  /* Transitions */
  --trans: all .18s ease;
  --trans-fast: all .1s ease;

  /* Layout */
  --sidebar-w: 248px;
  --topbar-h: 56px;
  --content-max: 1280px;
}

/* ---------- DARK MODE ---------- */
.dark {
  --primary: #3B82F6;
  --primary-hover: #2563EB;
  --primary-light: #1E3A5F;
  --primary-ring: rgba(59, 130, 246, .2);

  --success-light: #052E16;
  --success-ring: #14532D;
  --warning-light: #431407;
  --warning-ring: #451A03;
  --danger-light: #450A0A;
  --danger-ring: #7F1D1D;
  --info-light: #082F49;
  --info-ring: #164E63;

  --bg: #0F172A;
  --bg-card: #1E293B;
  --bg-input: #0F172A;
  --bg-hover: #1E293B;
  --bg-muted: #1E293B;

  --border: #334155;
  --border-strong: #475569;

  --text: #F1F5F9;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --text-disabled: #475569;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .3), 0 1px 2px rgba(0, 0, 0, .2);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, .25), 0 2px 4px rgba(0, 0, 0, .2);
  --shadow-lg: 0 10px 24px rgba(0, 0, 0, .35), 0 4px 8px rgba(0, 0, 0, .2);
}

/* ---------- RESET ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background .2s, color .2s;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

img,
svg {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  font-family: inherit;
}

ul,
ol {
  list-style: none;
}

code {
  font-family: var(--font-mono);
}

/* ---------- LAYOUT ---------- */
#sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  min-height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  transition: transform .25s cubic-bezier(.4, 0, .2, 1);
  border-right: 1px solid rgba(255, 255, 255, .04);
}

.sidebar-logo {
  padding: 18px 16px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(37, 99, 235, .35);
}

.sidebar-logo-text {
  font-weight: 800;
  color: #fff;
  font-size: 15px;
  letter-spacing: -.3px;
}

.sidebar-logo-sub {
  font-size: 10px;
  color: rgba(255, 255, 255, .35);
  margin-top: 1px;
}

.sidebar-user {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #7C3AED);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-role {
  font-size: 11px;
  color: rgba(255, 255, 255, .35);
}

.sidebar-nav {
  flex: 1;
  padding: 10px 10px;
  overflow-y: auto;
}

.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .1);
  border-radius: 4px;
}

.nav-group {
  margin-bottom: 6px;
}

.nav-group-label {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255, 255, 255, .25);
  text-transform: uppercase;
  letter-spacing: .1em;
  padding: 8px 10px 3px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  color: var(--sidebar-text);
  transition: var(--trans);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-link i {
  width: 16px;
  text-align: center;
  font-size: 12px;
  opacity: .7;
  flex-shrink: 0;
}

.nav-link:hover {
  background: var(--sidebar-hover);
  color: #E2E8F0;
}

.nav-link:hover i {
  opacity: 1;
}

.nav-link.active {
  background: var(--sidebar-active);
  color: var(--sidebar-text-active);
}

.nav-link.active i {
  opacity: 1;
  color: var(--primary);
}

.nav-link.danger {
  color: #F87171;
}

.nav-link.danger:hover {
  background: rgba(239, 68, 68, .1);
}

.sidebar-bottom {
  padding: 10px;
  border-top: 1px solid rgba(255, 255, 255, .06);
}

/* MAIN */
.main-wrap {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* TOPBAR */
.topbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
  padding: 0 24px;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.topbar-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.2px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* CONTENT */
.page-content {
  flex: 1;
  padding: 24px;
  padding-bottom: 88px;
  max-width: var(--content-max);
  width: 100%;
}

/* OVERLAY */
#overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  z-index: 40;
  backdrop-filter: blur(2px);
}

/* ---------- COMPONENTS ---------- */

/* CARD */
.card {
  background: var(--bg-card);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: var(--trans);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-body {
  padding: 20px;
}

.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.1px;
}

.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-muted);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--r-md);
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--trans);
  font-family: var(--font-sans);
  white-space: nowrap;
  letter-spacing: -.1px;
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0);
  transition: background .15s;
}

.btn:hover::after {
  background: rgba(255, 255, 255, .06);
}

.btn:active::after {
  background: rgba(0, 0, 0, .06);
}

.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px var(--primary-ring);
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px var(--primary-ring);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--bg-muted);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-success {
  background: var(--success-light);
  color: var(--success);
  border: 1px solid var(--success-ring);
}

.btn-success:hover {
  background: #DCFCE7;
}

.btn-danger {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid var(--danger-ring);
}

.btn-danger:hover {
  background: #FEE2E2;
}

.btn-warning {
  background: var(--warning-light);
  color: var(--warning);
  border: 1px solid var(--warning-ring);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.btn-sm {
  padding: 5px 11px;
  font-size: 12px;
  border-radius: var(--r-sm);
  gap: 5px;
}

.btn-lg {
  padding: 11px 22px;
  font-size: 15px;
}

.btn-full {
  width: 100%;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--r-md);
}

.btn-icon-sm {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: var(--r-sm);
}

/* ICON BTN */
.icon-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-md);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--trans);
  font-size: 14px;
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

/* BADGES */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .01em;
}

.badge-primary {
  background: var(--primary-light);
  color: var(--primary);
}

.badge-success {
  background: var(--success-light);
  color: var(--success);
}

.badge-danger {
  background: var(--danger-light);
  color: var(--danger);
}

.badge-warning {
  background: var(--warning-light);
  color: var(--warning);
}

.badge-info {
  background: var(--info-light);
  color: var(--info);
}

.badge-secondary {
  background: var(--bg-muted);
  color: var(--text-secondary);
}

.badge-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
}

/* FORMS */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.form-label .required {
  color: var(--danger);
}

.form-label .hint {
  color: var(--text-muted);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  font-size: 11px;
}

.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  padding: 9px 13px;
  font-size: 14px;
  color: var(--text);
  font-family: var(--font-sans);
  transition: var(--trans);
  -webkit-appearance: none;
}

.form-control::placeholder {
  color: var(--text-muted);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
  background: var(--bg-card);
}

.form-control:disabled {
  opacity: .6;
  cursor: not-allowed;
}

.form-control.error {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(220, 38, 38, .12);
}

select.form-control {
  appearance: none;
  /* background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%2394A3B8' d='M5 6L0 0h10z'/%3E%3C/svg%3E"); */
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
  cursor: pointer;
}

.dark select.form-control {
  /* background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%2364748B' d='M5 6L0 0h10z'/%3E%3C/svg%3E"); */
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

.input-group {
  display: flex;
  align-items: stretch;
}

.input-group .form-control {
  flex: 1;
  border-radius: var(--r-md) 0 0 var(--r-md);
}

.input-group .btn {
  border-radius: 0 var(--r-md) var(--r-md) 0;
}

.input-icon {
  position: relative;
}

.input-icon .form-control {
  padding-left: 38px;
}

.input-icon i {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 13px;
  pointer-events: none;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
}

.form-check input[type=checkbox] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--primary);
}

.form-text {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-error {
  font-size: 11px;
  color: var(--danger);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* TABLE */
.table-wrap {
  overflow-x: auto;
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

.table-wrap:not(.card .table-wrap) {
  border-radius: var(--r-lg);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  text-align: left;
  padding: 10px 14px;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  border-bottom: 1px solid var(--border);
  background: var(--bg-muted);
  white-space: nowrap;
}

thead th:first-child {
  border-radius: var(--r-sm) 0 0 0;
}

thead th:last-child {
  border-radius: 0 var(--r-sm) 0 0;
}

tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr {
  transition: background .12s;
}

tbody tr:hover td {
  background: var(--bg-hover);
}

.td-actions {
  white-space: nowrap;
}

/* MODAL */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(3px);
  animation: fadeIn .15s ease;
}

.modal-overlay.open {
  display: flex;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal {
  background: var(--bg-card);
  border-radius: var(--r-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border);
  animation: slideUp .2s cubic-bezier(.4, 0, .2, 1);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-sm {
  max-width: 380px;
}

.modal-lg {
  max-width: 680px;
}

.modal-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ALERTS / FLASH */
.alert {
  padding: 12px 16px;
  border-radius: var(--r-md);
  font-size: 13px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid;
}

.alert i {
  margin-top: 1px;
  flex-shrink: 0;
}

.alert-success {
  background: var(--success-light);
  color: var(--success);
  border-color: var(--success-ring);
}

.alert-danger {
  background: var(--danger-light);
  color: var(--danger);
  border-color: var(--danger-ring);
}

.alert-warning {
  background: var(--warning-light);
  color: var(--warning);
  border-color: var(--warning-ring);
}

.alert-info {
  background: var(--info-light);
  color: var(--info);
  border-color: var(--info-ring);
}

/* STATS */
.stat-card {
  background: var(--bg-card);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: var(--trans);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-icon {
  width: 46px;
  height: 46px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.stat-val {
  font-size: 26px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.5px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 3px;
  font-weight: 500;
}

.stat-trend {
  font-size: 11px;
  margin-top: 4px;
  font-weight: 600;
}

/* CHIPS */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--r-md);
  font-size: 11px;
  font-weight: 500;
  background: var(--bg-muted);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

/* DIVIDER */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* TABS */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-muted);
  border-radius: var(--r-lg);
  padding: 4px;
  border: 1px solid var(--border);
}

.tab-item {
  flex: 1;
  text-align: center;
  padding: 8px 14px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: var(--trans);
  cursor: pointer;
  white-space: nowrap;
  border: none;
  background: none;
  font-family: var(--font-sans);
}

.tab-item:hover {
  color: var(--text);
}

.tab-item.active {
  background: var(--bg-card);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* PROGRESS */
.progress {
  background: var(--bg-muted);
  border-radius: var(--r-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: var(--r-full);
  transition: width .6s cubic-bezier(.4, 0, .2, 1);
}

/* FILE DROP */
.file-drop {
  border: 2px dashed var(--border);
  border-radius: var(--r-lg);
  padding: 22px 16px;
  text-align: center;
  cursor: pointer;
  transition: var(--trans);
}

.file-drop:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.file-drop i {
  font-size: 26px;
  color: var(--text-muted);
  display: block;
  margin-bottom: 8px;
}

.file-drop.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}

/* CODE */
.code-block {
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.8;
  overflow-x: auto;
  color: var(--text-secondary);
}

.code-block .kw {
  color: var(--primary);
}

.code-block .str {
  color: var(--success);
}

.code-block .cm {
  color: var(--text-muted);
}

/* SKELETON */
.skeleton {
  background: linear-gradient(90deg, var(--bg-muted) 25%, var(--border) 50%, var(--bg-muted) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--r-sm);
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

/* TOOLTIP */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #0F172A;
  color: #fff;
  padding: 5px 10px;
  border-radius: var(--r-sm);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s;
  z-index: 200;
}

[data-tooltip]:hover::after {
  opacity: 1;
}

/* BOTTOM NAV */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  z-index: 30;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, .06);
}

.bottom-nav-inner {
  display: flex;
  height: 58px;
}

.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  gap: 3px;
  transition: var(--trans);
  letter-spacing: .02em;
}

.bottom-nav a i {
  font-size: 19px;
}

.bottom-nav a.active,
.bottom-nav a:hover {
  color: var(--primary);
}

.bottom-nav a.active i {
  filter: drop-shadow(0 0 4px var(--primary-ring));
}

/* APPROVAL TIMELINE */
.timeline {
  display: flex;
  flex-direction: column;
}

.timeline-item {
  display: flex;
  gap: 12px;
}

.timeline-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 12px;
}

.timeline-line {
  width: 2px;
  background: var(--border);
  margin: 4px auto;
  flex: 1;
  min-height: 12px;
}

.timeline-content {
  flex: 1;
  padding-bottom: 12px;
}

/* RING CHART */
.ring-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ring-label {
  position: absolute;
  font-size: 11px;
  font-weight: 800;
  color: var(--text);
}

/* GRID HELPERS */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

/* FLEX HELPERS */
.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.flex-wrap {
  flex-wrap: wrap;
}

.items-center {
  align-items: center;
}

.items-start {
  align-items: flex-start;
}

.justify-between {
  justify-content: space-between;
}

.justify-end {
  justify-content: flex-end;
}

.justify-center {
  justify-content: center;
}

.flex-1 {
  flex: 1;
}

.gap-1 {
  gap: 4px;
}

.gap-2 {
  gap: 8px;
}

.gap-3 {
  gap: 12px;
}

.gap-4 {
  gap: 16px;
}

/* SPACING */
.mb-2 {
  margin-bottom: 8px;
}

.mb-3 {
  margin-bottom: 12px;
}

.mb-4 {
  margin-bottom: 16px;
}

.mb-5 {
  margin-bottom: 20px;
}

.mb-6 {
  margin-bottom: 24px;
}

.mt-2 {
  margin-top: 8px;
}

.mt-3 {
  margin-top: 12px;
}

.mt-4 {
  margin-top: 16px;
}

.ml-auto {
  margin-left: auto;
}

/* TEXT */
.text-xs {
  font-size: 11px;
}

.text-sm {
  font-size: 13px;
}

.text-base {
  font-size: 14px;
}

.text-lg {
  font-size: 16px;
}

.text-xl {
  font-size: 18px;
}

.text-2xl {
  font-size: 22px;
}

.font-medium {
  font-weight: 500;
}

.font-semibold {
  font-weight: 600;
}

.font-bold {
  font-weight: 700;
}

.font-extrabold {
  font-weight: 800;
}

.text-muted {
  color: var(--text-muted);
}

.text-secondary {
  color: var(--text-secondary);
}

.text-primary {
  color: var(--primary);
}

.text-success {
  color: var(--success);
}

.text-danger {
  color: var(--danger);
}

.text-warning {
  color: var(--warning);
}

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* MISC */
.rounded {
  border-radius: var(--r-md);
}

.rounded-full {
  border-radius: var(--r-full);
}

.overflow-hidden {
  overflow: hidden;
}

.w-full {
  width: 100%;
}

.h-full {
  height: 100%;
}

.relative {
  position: relative;
}

.pointer {
  cursor: pointer;
}

.select-none {
  user-select: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.no-wrap {
  white-space: nowrap;
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 1024px) {
  #sidebar {
    transform: translateX(-100%);
  }

  #sidebar.open {
    transform: translateX(0);
  }

  #overlay.show {
    display: block;
  }

  .main-wrap {
    margin-left: 0;
  }

  .bottom-nav {
    display: block;
  }

  .page-content {
    padding: 16px;
    padding-bottom: 76px;
  }

  .topbar {
    padding: 0 16px;
  }

  #menuBtn {
    display: flex !important;
  }
}

@media (max-width: 768px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-3 {
    grid-template-columns: repeat(2, 1fr);
  }

  .hide-mobile {
    display: none !important;
  }
}

@media (max-width: 480px) {

  .grid-4,
  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .hide-sm {
    display: none !important;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .modal {
    max-height: 95vh;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
  }

  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
}

/* ---------- PRINT ---------- */
@media print {

  #sidebar,
  .topbar,
  .bottom-nav,
  .btn,
  .modal-overlay {
    display: none !important;
  }

  .main-wrap {
    margin-left: 0 !important;
  }

  body {
    background: #fff;
    color: #000;
  }
}

/* ---------- ANIMATIONS ---------- */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.spin {
  animation: spin 1s linear infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: .5;
  }
}

.pulse {
  animation: pulse 2s infinite;
}

.fade-in {
  animation: fadeIn .3s ease;
}

.slide-up {
  animation: slideUp .25s cubic-bezier(.4, 0, .2, 1);
}

/* ---------- EMPTY STATE ---------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  color: var(--text-muted);
  text-align: center;
}

.empty-state i {
  font-size: 40px;
  opacity: .35;
  margin-bottom: 12px;
}

.empty-state p {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-secondary);
}

.empty-state span {
  font-size: 13px;
  margin-top: 4px;
}