:root {
  --bg-root: #F8FAFC;
  --bg-surface: #FFFFFF;
  --bg-surface-hover: #F1F5F9;
  --border-subtle: #E2E8F0;
  --border-highlight: #CBD5E1;
  --text-main: #0F172A;
  --text-muted: #64748B;
  --text-dark: #94A3B8;
  --brand-primary: #0284C7;
  --brand-secondary: #0EA5E9;
  --brand-glow: rgba(2, 132, 199, 0.15);
  --success: #10B981;
  --warning: #F59E0B;
  --error: #EF4444;
  --font-display: 'Clash Display', sans-serif;
  --font-body: 'Satoshi', sans-serif;
  --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
  --ease-smooth: cubic-bezier(0.2, 0.0, 0.2, 1);
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

.dark {
  --bg-root: #0B1120;
  --bg-surface: #1E293B;
  --bg-surface-hover: #334155;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-highlight: rgba(255, 255, 255, 0.15);
  --text-main: #F8FAFC;
  --text-muted: #94A3B8;
  --text-dark: #64748B;
  --brand-primary: #38BDF8;
  --brand-secondary: #7DD3FC;
  --brand-glow: rgba(56, 189, 248, 0.2);
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
  --shadow-card: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}

* { margin: 0; padding: 0; box-sizing: border-box; outline: none; }

body {
  background-color: var(--bg-root);
  color: var(--text-main);
  font-family: var(--font-body);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s, color 0.3s;
}

/* Login Layout */
.main-layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
}

@media (max-width: 1024px) {
  .main-layout { grid-template-columns: 1fr; }
}

.panel-visual {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 80px;
  position: relative;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
}

.panel-visual::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top left, var(--brand-glow), transparent 60%);
  z-index: 0;
}

.panel-content {
  position: relative;
  z-index: 1;
  max-width: 600px;
  margin: 0 auto;
}

@media (max-width: 1024px) {
  .panel-visual { display: none; }
}

.brand-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 100px;
  width: fit-content;
  margin-bottom: 32px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  box-shadow: var(--shadow-card);
}

.brand-tag i { color: var(--brand-primary); }

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(40px, 4vw, 64px);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: 24px;
  color: var(--text-main);
}

.hero-desc {
  font-size: 16px;
  color: var(--text-muted);
  max-width: 480px;
  line-height: 1.6;
  margin-bottom: 48px;
}

.feature-list { display: flex; gap: 48px; }
.feature-item { display: flex; flex-direction: column; gap: 8px; }
.feature-num { font-family: var(--font-display); font-size: 28px; color: var(--brand-primary); font-weight: 600; }
.feature-text { font-size: 13px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; }

.panel-login {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  background-color: var(--bg-root);
}

.theme-toggle-container { position: absolute; top: 32px; right: 32px; }

.btn-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  font-size: 18px;
}

.btn-icon:hover {
  background: var(--bg-surface-hover);
  color: var(--text-main);
  transform: translateY(-2px);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 24px;
  padding: 40px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
  transition: transform 0.4s var(--ease-spring), box-shadow 0.3s ease;
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, var(--brand-primary), var(--brand-secondary));
}

.card-header { margin-bottom: 32px; text-align: center; }

.app-icon {
  width: 64px; height: 64px;
  background: var(--bg-root);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  font-size: 28px;
  color: var(--brand-primary);
}

.card-title { font-family: var(--font-display); font-size: 24px; font-weight: 600; margin-bottom: 8px; color: var(--text-main); }
.card-subtitle { font-size: 14px; color: var(--text-muted); }

.form-group { margin-bottom: 24px; }
.label-row { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 13px; }
.label-title { font-weight: 600; color: var(--text-main); }
.label-hint { color: var(--text-muted); font-size: 12px; }

.input-container { position: relative; transition: transform 0.2s; }

.form-input {
  width: 100%;
  height: 50px;
  background: var(--bg-root);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 0 16px 0 44px;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 15px;
  transition: all 0.2s var(--ease-smooth);
}

.form-input:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px var(--brand-glow);
  background: var(--bg-surface);
}

.input-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  transition: color 0.2s;
}

.form-input:focus ~ .input-icon { color: var(--brand-primary); }

.toggle-pass {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  cursor: pointer;
  background: none;
  border: none;
  transition: color 0.2s;
}

.toggle-pass:hover { color: var(--text-main); }

.btn-login {
  width: 100%;
  height: 50px;
  background: var(--brand-primary);
  color: #FFFFFF;
  border: none;
  border-radius: 12px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.3s var(--ease-spring);
  position: relative;
  overflow: hidden;
}

.btn-login:hover {
  background: var(--brand-secondary);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px -4px var(--brand-glow);
}

.btn-login:active { transform: scale(0.98); }
.btn-login.loading { color: transparent; pointer-events: none; }

.spinner {
  position: absolute;
  width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: none;
}

.btn-login.loading .spinner { display: block; }

@keyframes spin { to { transform: rotate(360deg); } }

.help-text { margin-top: 32px; text-align: center; font-size: 13px; color: var(--text-muted); }
.help-link { color: var(--brand-primary); text-decoration: none; font-weight: 600; margin-left: 4px; transition: opacity 0.2s; }
.help-link:hover { opacity: 0.8; }

/* Dashboard Layout */
.app-container { max-width: 1400px; margin: 0 auto; padding: 0 24px; position: relative; z-index: 1; }

header {
  padding: 24px 0;
  margin-bottom: 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
  background: transparent;
}

.brand { display: flex; align-items: center; gap: 16px; }

.brand-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 18px;
  box-shadow: var(--shadow-md);
}

.brand-info h1 { font-family: var(--font-display); font-size: 18px; font-weight: 600; line-height: 1.2; }
.brand-info span { font-size: 12px; color: var(--text-muted); display: block; margin-top: 2px; }

.header-controls { display: flex; align-items: center; gap: 12px; }

.opd-badge {
  padding: 8px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.opd-badge i { color: var(--brand-primary); }

.btn-control {
  height: 40px;
  padding: 0 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}

.btn-control:hover {
  background: var(--bg-surface-hover);
  color: var(--text-main);
  border-color: var(--border-highlight);
  transform: translateY(-1px);
}

/* Stats Grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; margin-bottom: 32px; }

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  transition: transform 0.2s;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.stat-card::before {
  content: '';
  position: absolute;
  left: 0; top: 16px; bottom: 16px;
  width: 4px;
  border-radius: 0 4px 4px 0;
}

.stat-card.blue::before { background: var(--brand-primary); }
.stat-card.green::before { background: var(--success); }
.stat-card.red::before { background: var(--error); }
.stat-card.orange::before { background: var(--warning); }

.stat-content { display: flex; flex-direction: column; justify-content: center; }
.stat-value { font-family: var(--font-display); font-size: 28px; font-weight: 600; color: var(--text-main); line-height: 1.1; margin-bottom: 4px; }
.stat-label { font-size: 13px; color: var(--text-muted); font-weight: 500; }

/* Content Card */
.content-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  overflow: hidden;
  min-height: 500px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  margin-bottom: 40px;
}

.toolbar {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--bg-surface);
}

@media (min-width: 768px) {
  .toolbar { flex-direction: row; justify-content: space-between; align-items: center; }
}

.table-title h2 { font-family: var(--font-display); font-size: 18px; font-weight: 600; margin-bottom: 4px; color: var(--text-main); }
.table-title p { font-size: 13px; color: var(--text-muted); }

.search-wrapper { position: relative; width: 100%; max-width: 320px; }

.search-input {
  width: 100%;
  height: 40px;
  background: var(--bg-root);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 0 16px 0 40px;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 13px;
  transition: all 0.2s;
}

.search-input:focus {
  border-color: var(--brand-primary);
  background: var(--bg-surface-hover);
  box-shadow: 0 0 0 3px var(--bg-surface-hover);
}

.search-icon {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 16px;
}

/* Table */
.table-container { flex: 1; overflow-x: auto; }

table { width: 100%; border-collapse: collapse; white-space: nowrap; }

th {
  text-align: left;
  padding: 16px 24px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg-surface-hover);
  border-bottom: 1px solid var(--border-subtle);
}

td {
  padding: 16px 24px;
  font-size: 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-muted);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-root); color: var(--text-main); }

.cell-primary { color: var(--text-main); font-weight: 600; }
.cell-mono { font-family: monospace; color: var(--text-dark); font-size: 13px; }

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}

.status-badge.success { background: rgba(16, 185, 129, 0.1); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.2); }
.status-badge.warning { background: rgba(245, 158, 11, 0.1); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.2); }
.status-badge.error { background: rgba(239, 68, 68, 0.1); color: var(--error); border: 1px solid rgba(239, 68, 68, 0.2); }
.status-badge i { font-size: 10px; }

/* Checkbox */
.custom-checkbox {
  width: 20px; height: 20px;
  border: 2px solid var(--border-highlight);
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  transition: all 0.2s;
  display: inline-block;
}

.custom-checkbox:hover { border-color: var(--brand-primary); }
.custom-checkbox.checked { background: var(--brand-primary); border-color: var(--brand-primary); }
.custom-checkbox.disabled { opacity: 0.4; cursor: not-allowed; background: var(--bg-surface-hover); border-color: var(--border-subtle); }
.custom-checkbox i { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); color: white; font-size: 12px; opacity: 0; }
.custom-checkbox.checked i { opacity: 1; }

/* Footer & Pagination */
.footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-surface);
}

.pagination { display: flex; gap: 8px; }

.page-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 13px;
}

.page-btn:hover:not(:disabled) { background: var(--bg-surface-hover); color: var(--text-main); border-color: var(--border-highlight); }
.page-btn.active { background: var(--brand-primary); color: white; border-color: var(--brand-primary); }
.page-btn:disabled { opacity: 0.3; cursor: default; }

/* Loading Overlay */
.loader-overlay {
  position: fixed; inset: 0;
  background: var(--bg-root);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 999;
  transition: opacity 0.3s;
}

.loader-overlay.hidden { opacity: 0; pointer-events: none; }

.spinner-modern {
  width: 32px; height: 32px;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--brand-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Empty State */
.empty-state {
  display: none;
  padding: 64px;
  text-align: center;
  flex-direction: column;
  align-items: center;
}

.empty-state.visible { display: flex; }

.empty-icon {
  width: 56px; height: 56px;
  background: var(--bg-surface-hover);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  color: var(--text-dark);
  margin-bottom: 16px;
}

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  opacity: 0; pointer-events: none;
  transition: all 0.3s;
}

.modal-backdrop.visible { opacity: 1; pointer-events: auto; }

.modal-box {
  width: 90%; max-width: 400px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 32px;
  transform: scale(0.95);
  transition: all 0.3s var(--ease-spring);
  box-shadow: 0 24px 48px rgba(0,0,0,0.2);
}

.modal-backdrop.visible .modal-box { transform: scale(1); }

.modal-icon {
  width: 56px; height: 56px;
  background: rgba(59, 130, 246, 0.1);
  color: var(--brand-primary);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  margin: 0 auto 20px;
}

.modal-title { font-family: var(--font-display); font-size: 20px; font-weight: 600; text-align: center; margin-bottom: 8px; color: var(--text-main); }
.modal-text { text-align: center; color: var(--text-muted); font-size: 14px; margin-bottom: 24px; line-height: 1.5; }
.modal-actions { display: flex; gap: 12px; }

.btn-modal {
  flex: 1;
  height: 44px;
  border-radius: 10px;
  border: none;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-cancel { background: var(--bg-root); color: var(--text-muted); border: 1px solid var(--border-subtle); }
.btn-cancel:hover { background: var(--bg-surface-hover); color: var(--text-main); }
.btn-confirm { background: var(--brand-primary); color: white; }
.btn-confirm:hover { background: var(--brand-secondary); }

/* Toast */
.toast {
  position: fixed; bottom: 32px; right: 32px;
  padding: 14px 24px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 100px;
  display: flex; align-items: center; gap: 12px;
  color: var(--text-main);
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 12px 32px rgba(0,0,0,0.15);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.4s var(--ease-spring);
  z-index: 1100;
}

.toast.visible { transform: translateY(0); opacity: 1; }
.toast.success i { color: var(--success); }
.toast.error i { color: var(--error); }
.toast.info i { color: var(--brand-primary); }

@media (max-width: 768px) {
  .app-container { padding: 0 16px; }
  .header-controls span { display: none; }
  .btn-control { padding: 0 10px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
