/* ================================================================
   Tapal Letter Tracking System — Premium CSS (Professional Dark Slate)
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  --bg-base: #0d1117;
  --bg-surface: #161b22;
  --bg-elevated: #1c2230;
  --bg-card: #1e2a3a;
  --bg-input: #192132;
  --border: rgba(99, 130, 167, 0.18);
  --border-focus: #4f8ef7;
  --sidebar-bg: #101720;
  --sidebar-hover: rgba(79, 142, 247, 0.12);
  --sidebar-active: rgba(79, 142, 247, 0.22);
  --primary: #4f8ef7;
  --primary-dark: #2563eb;
  --primary-glow: rgba(79, 142, 247, 0.25);
  --accent: #06b6d4;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --muted: #f97316;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);
  --sidebar-w: 260px;
  --header-h: 64px;
  --transition: 0.2s ease;
}

/* ── Light Mode Overrides ────────────────────────────────────── */
body.light-mode {
  --bg-base: #f0f2f5;
  --bg-surface: #ffffff;
  --bg-elevated: #f8fafc;
  --bg-card: #ffffff;
  --bg-input: #ffffff;
  --border: rgba(0, 0, 0, 0.08);
  --border-focus: #4f8ef7;
  --sidebar-bg: #ffffff;
  --sidebar-hover: rgba(79, 142, 247, 0.08);
  --sidebar-active: rgba(79, 142, 247, 0.12);
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-glow: rgba(37, 99, 235, 0.15);
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
}

body.light-mode ::-webkit-scrollbar-track {
  background: #f1f5f9;
}

body.light-mode ::-webkit-scrollbar-thumb {
  background: #cbd5e1;
}

body.light-mode ::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 14px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  color: var(--accent);
}

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-base);
}

::-webkit-scrollbar-thumb {
  background: #2d3748;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #4a5568;
}

/* ── Layout Shell ──────────────────────────────────────────── */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 1000;
  transition: transform var(--transition);
}

.sidebar-brand {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand .brand-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 0 12px var(--primary-glow);
}

.sidebar-brand .brand-text {
  line-height: 1.2;
}

.sidebar-brand .brand-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.sidebar-brand .brand-sub {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 12px 20px 6px;
}

.nav-item {
  display: flex;
  flex-direction: column;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  border-radius: 0;
  transition: all var(--transition);
  position: relative;
  cursor: pointer;
  border: none;
  background: none;
  text-align: left;
  width: 100%;
}

.nav-link:hover {
  background: var(--sidebar-hover);
  color: var(--text-primary);
}

.nav-link.active {
  background: var(--sidebar-active);
  color: var(--primary);
}

.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--primary);
  border-radius: 0 2px 2px 0;
}

.nav-link .nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav-link .nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

.sidebar-user:hover {
  background: var(--sidebar-hover);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-dark), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 10px;
  color: var(--text-muted);
}

.user-logout {
  color: var(--text-muted);
  font-size: 14px;
}

.user-logout:hover {
  color: var(--danger);
}

/* ── Top Header ────────────────────────────────────────────── */
.app-header {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  height: var(--header-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  z-index: 999;
  gap: 12px;
}

.header-title {
  flex: 1;
}

.header-title h1 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.header-title .breadcrumb-text {
  font-size: 12px;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  font-size: 15px;
  position: relative;
}

.btn-icon:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--danger);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Main Content ──────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  margin-top: var(--header-h);
  padding: 24px;
  min-height: calc(100vh - var(--header-h));
  flex: 1;
}

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: 16px 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: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .card-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

.card-body {
  padding: 20px;
}

/* ── KPI Cards ─────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: transform var(--transition), box-shadow var(--transition);
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.kpi-icon.blue {
  background: rgba(79, 142, 247, 0.15);
  color: var(--primary);
}

.kpi-icon.green {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
}

.kpi-icon.amber {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
}

.kpi-icon.red {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

.kpi-icon.cyan {
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent);
}

.kpi-icon.purple {
  background: rgba(139, 92, 246, 0.15);
  color: #8b5cf6;
}

.kpi-data {
  flex: 1;
}

.kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 4px;
}

.kpi-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.kpi-trend {
  font-size: 11px;
  margin-top: 6px;
}

.kpi-trend.up {
  color: var(--success);
}

.kpi-trend.down {
  color: var(--danger);
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  line-height: 1;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.btn-success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}

.btn-success:hover {
  opacity: 0.85;
}

.btn-warning {
  background: var(--warning);
  color: #0d1117;
  border-color: var(--warning);
}

.btn-warning:hover {
  opacity: 0.85;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-danger:hover {
  opacity: 0.85;
}

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-sm {
  padding: 5px 11px;
  font-size: 12px;
}

.btn-lg {
  padding: 11px 22px;
  font-size: 14px;
}

/* ── Forms ─────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.form-label .required {
  color: var(--danger);
  margin-left: 2px;
}

.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  padding: 9px 12px;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  -webkit-appearance: none;
}

.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(79, 142, 247, 0.15);
}

.form-control::placeholder {
  color: var(--text-muted);
}

.form-control[readonly] {
  opacity: 0.7;
  cursor: not-allowed;
}

select.form-control {
  cursor: pointer;
}

select.form-control option {
  background: var(--bg-card);
  color: var(--text-primary);
}

textarea.form-control {
  resize: vertical;
  min-height: 90px;
}

.form-row {
  display: grid;
  gap: 16px;
}

.form-row.cols-2 {
  grid-template-columns: 1fr 1fr;
}

.form-row.cols-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.form-row.cols-4 {
  grid-template-columns: 1fr 1fr 1fr 1fr;
}

.form-text {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* File upload */
.file-drop {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}

.file-drop:hover,
.file-drop.dragover {
  border-color: var(--primary);
  background: rgba(79, 142, 247, 0.05);
}

.file-drop .drop-icon {
  font-size: 32px;
  margin-bottom: 8px;
  color: var(--text-muted);
}

.file-drop .drop-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.file-drop .drop-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.data-table thead th {
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 11px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table.data-table tbody tr {
  border-bottom: 1px solid rgba(99, 130, 167, 0.08);
  transition: background var(--transition);
}

table.data-table tbody tr:hover {
  background: rgba(79, 142, 247, 0.04);
}

table.data-table tbody tr:last-child {
  border-bottom: none;
}

table.data-table td {
  padding: 12px 16px;
  color: var(--text-primary);
  vertical-align: middle;
}

/* ── Status Badges ─────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.badge-received {
  background: rgba(79, 142, 247, 0.15);
  color: var(--primary);
}

.badge-assigned {
  background: rgba(139, 92, 246, 0.15);
  color: #8b5cf6;
}

.badge-processing {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
}

.badge-completed {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
}

.badge-returned {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

.badge-archived {
  background: rgba(107, 114, 128, 0.2);
  color: #9ca3af;
}

.badge::before {
  content: '●';
  font-size: 6px;
}

/* ── Timeline ───────────────────────────────────────────────── */
.timeline {
  position: relative;
  padding-left: 24px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  padding-bottom: 20px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -20px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--bg-card);
  z-index: 1;
}

.timeline-item.success::before {
  background: var(--success);
}

.timeline-item.warning::before {
  background: var(--warning);
}

.timeline-item.danger::before {
  background: var(--danger);
}

.timeline-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.timeline-content {
  font-size: 13px;
  color: var(--text-primary);
}

.timeline-actor {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.timeline-comment {
  margin-top: 6px;
  padding: 8px 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary);
  font-size: 12px;
  color: var(--text-secondary);
  font-style: italic;
}

/* ── Modals ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.modal-overlay.show {
  opacity: 1;
  pointer-events: all;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform var(--transition);
}

.modal-overlay.show .modal-box {
  transform: translateY(0);
}

.modal-box.modal-lg {
  max-width: 860px;
}

.modal-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
  transition: color var(--transition);
}

.modal-close:hover {
  color: var(--danger);
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ── Notifications Dropdown ────────────────────────────────── */
.notif-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 340px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 1500;
  display: none;
}

.notif-dropdown.show {
  display: block;
}

.notif-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
}

.notif-list {
  max-height: 320px;
  overflow-y: auto;
}

.notif-item {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(99, 130, 167, 0.08);
  cursor: pointer;
  transition: background var(--transition);
}

.notif-item:hover {
  background: var(--sidebar-hover);
}

.notif-item.unread {
  border-left: 3px solid var(--primary);
}

.notif-item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.notif-item-msg {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.notif-item-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Urgency Row Coloring ──────────────────────────────────── */
tr.urgent-high td {
  color: #fca5a5 !important;
}

tr.urgent-med td {
  color: #fcd34d !important;
}

/* ── Section Dividers ──────────────────────────────────────── */
.section-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 16px;
}

.section-divider span {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  white-space: nowrap;
}

.section-divider::before,
.section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Alerts ────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}

.alert-icon {
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}

.alert-info {
  background: rgba(79, 142, 247, 0.1);
  border: 1px solid rgba(79, 142, 247, 0.3);
  color: #93c5fd;
}

.alert-success {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #6ee7b7;
}

.alert-warning {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fcd34d;
}

.alert-danger {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

/* ── Page Header ───────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 12px;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ── Empty State ───────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state .empty-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
}

.empty-state .empty-text {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ── Login Page ────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(79, 142, 247, 0.12), transparent),
    var(--bg-base);
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px;
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo .logo-icon {
  width: 60px;
  height: 60px;
  margin: 0 auto 14px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  box-shadow: 0 0 30px var(--primary-glow);
}

.login-logo h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.login-logo p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── DataTables overrides ──────────────────────────────────── */
div.dataTables_wrapper {
  color: var(--text-primary);
}

div.dataTables_length select,
div.dataTables_filter input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 5px 10px;
  font-size: 13px;
}

div.dataTables_info,
div.dataTables_length label,
div.dataTables_filter label {
  color: var(--text-secondary);
  font-size: 12px;
}

.dataTables_paginate .paginate_button {
  background: var(--bg-elevated) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  color: var(--text-secondary) !important;
  font-size: 12px !important;
  padding: 4px 10px !important;
}

.dataTables_paginate .paginate_button.current {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #fff !important;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .form-row.cols-4 {
    grid-template-columns: 1fr 1fr;
  }

  .form-row.cols-3 {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .app-header {
    left: 0;
  }

  .main-content {
    margin-left: 0;
  }

  .form-row.cols-2,
  .form-row.cols-3,
  .form-row.cols-4 {
    grid-template-columns: 1fr;
  }

  .kpi-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* ── Utility ───────────────────────────────────────────────── */
.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.text-muted {
  color: var(--text-muted);
}

.text-success {
  color: var(--success);
}

.text-danger {
  color: var(--danger);
}

.text-warning {
  color: var(--warning);
}

.text-primary-color {
  color: var(--primary);
}

.mt-1 {
  margin-top: 4px;
}

.mt-2 {
  margin-top: 8px;
}

.mt-3 {
  margin-top: 16px;
}

.mt-4 {
  margin-top: 24px;
}

.mb-1 {
  margin-bottom: 4px;
}

.mb-2 {
  margin-bottom: 8px;
}

.mb-3 {
  margin-bottom: 16px;
}

.mb-4 {
  margin-bottom: 24px;
}

.gap-2 {
  gap: 8px;
}

.flex {
  display: flex;
}

.flex-center {
  display: flex;
  align-items: center;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.flex-wrap {
  flex-wrap: wrap;
}

.d-none {
  display: none !important;
}

/* Print Styles */
@media print {

  .sidebar,
  .app-header,
  .page-header .btn,
  .header-actions {
    display: none !important;
  }

  .main-content {
    margin: 0;
    padding: 0;
  }

  body {
    background: #fff;
    color: #000;
  }

  .card {
    border: 1px solid #ccc;
    box-shadow: none;
  }

  table.data-table thead th,
  table.data-table td {
    color: #000;
    border-color: #ccc;
  }
}

/* ── HRM Specific Styles ────────────────────────────────────── */
.card-tabs {
  display: flex;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.tab-link {
  flex: 1;
  padding: 15px 20px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: all var(--transition);
  white-space: nowrap;
}

.tab-link:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.02);
}

.tab-link.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: rgba(79, 142, 247, 0.05);
}

.tab-content {
  display: none;
  animation: tabFadeIn 0.3s ease;
}

.tab-content.active {
  display: block;
}

@keyframes tabFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.photo-preview-box {
  width: 100px;
  height: 100px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.family-member-row, .history-row {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  margin-bottom: 16px;
  background: rgba(255, 255, 255, 0.01);
}

.family-member-row:hover, .history-row:hover {
  background: rgba(255, 255, 255, 0.02);
}

.remove-row-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 4px 8px;
  font-size: 10px;
}

.hrm-status-bar {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  height: 6px;
  border-radius: 3px;
  margin-bottom: 4px;
  overflow: hidden;
}

.hrm-status-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* ── Select2 Theme Override ─────────────────────────────────── */
.select2-container--default .select2-selection--single {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  height: 36px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
  color: var(--text-primary);
  font-size: 13px;
  font-family: 'Inter', system-ui, sans-serif;
  padding: 0;
  line-height: 1;
}
.select2-container--default .select2-selection--single .select2-selection__placeholder {
  color: var(--text-muted);
}
.select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 34px;
  right: 8px;
}
.select2-container--default .select2-selection--single .select2-selection__arrow b {
  border-color: var(--text-muted) transparent transparent;
}
.select2-container--default.select2-container--open .select2-selection--single {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(79,142,247,0.15);
}
.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b {
  border-color: transparent transparent var(--text-muted);
}
.select2-container--default .select2-selection--single .select2-selection__clear {
  color: var(--text-muted);
  font-size: 16px;
  margin-right: 4px;
}
.select2-container--default .select2-selection--single .select2-selection__clear:hover {
  color: var(--danger);
}
.select2-dropdown {
  background: var(--bg-elevated);
  border: 1px solid var(--border-focus);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 13px;
  z-index: 99999;
}
.select2-container--default .select2-search--dropdown .select2-search__field {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  padding: 6px 10px;
  font-family: inherit;
  outline: none;
}
.select2-container--default .select2-search--dropdown .select2-search__field:focus {
  border-color: var(--border-focus);
}
.select2-container--default .select2-results__option {
  color: var(--text-secondary);
  padding: 8px 12px;
}
.select2-container--default .select2-results__option--highlighted {
  background: var(--sidebar-hover);
  color: var(--text-primary);
}
.select2-container--default .select2-results__option[aria-selected=true] {
  background: rgba(79,142,247,0.15);
  color: var(--primary);
  font-weight: 600;
}
.select2-container--default .select2-results__option[aria-disabled=true] {
  color: var(--text-muted);
}
body.light-mode .select2-dropdown {
  background: #fff;
}
body.light-mode .select2-container--default .select2-search--dropdown .select2-search__field {
  background: #f8fafc;
}

/* ── DMS Custom Modals ────────────────────────────────────── */
.dms-modal {
  display: none !important;
  position: fixed !important;
  z-index: 10000 !important;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.7) !important;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
}
.dms-modal.show {
  display: flex !important;
}
.dms-modal-content {
  background: var(--bg-card) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 500px;
  box-shadow: var(--shadow-lg);
  animation: dmsModalSlide 0.3s ease-out;
}
@keyframes dmsModalSlide {
  from { transform: translateY(-30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.dms-modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.dms-modal-title {
  font-weight: 700;
  font-size: 16px;
  color: var(--text-primary);
}
.dms-modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
}
.dms-modal-body {
  padding: 20px;
}
.dms-modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
