:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --sidebar-w: 240px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

/* Auth pages */
.auth-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.auth-card {
  background: var(--card); border-radius: 12px; padding: 40px;
  box-shadow: 0 4px 24px rgba(0,0,0,.08); width: 100%; max-width: 420px;
}
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo h1 { font-size: 1.5rem; color: var(--primary); font-weight: 700; }
.auth-logo p { color: var(--muted); font-size: .875rem; margin-top: 4px; }

/* App layout */
#app { display: none; min-height: 100vh; }
.sidebar {
  position: fixed; top: 0; left: 0; width: var(--sidebar-w); height: 100vh;
  background: #1e293b; color: #fff; display: flex; flex-direction: column; z-index: 100;
}
.sidebar-header { padding: 20px; border-bottom: 1px solid #334155; }
.sidebar-header h2 { font-size: .95rem; font-weight: 700; color: #f8fafc; }
.sidebar-header p { font-size: .75rem; color: #94a3b8; margin-top: 2px; }
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-section { padding: 8px 16px 4px; font-size: .7rem; color: #64748b; text-transform: uppercase; letter-spacing: .08em; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; cursor: pointer; color: #94a3b8;
  font-size: .875rem; transition: all .15s; border: none; background: none;
  width: 100%; text-align: left;
}
.nav-item:hover, .nav-item.active { background: #334155; color: #f8fafc; }
.nav-item .icon { font-size: 1rem; width: 20px; text-align: center; }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid #334155; }
.sidebar-footer .user-info { font-size: .8rem; color: #94a3b8; margin-bottom: 8px; }
.sidebar-footer .user-name { color: #f8fafc; font-weight: 600; }
.logout-btn {
  width: 100%; padding: 8px; background: #334155; color: #94a3b8;
  border: none; border-radius: 6px; cursor: pointer; font-size: .8rem; transition: all .15s;
}
.logout-btn:hover { background: #475569; color: #f8fafc; }

.main { margin-left: var(--sidebar-w); padding: 32px; min-height: 100vh; }
.page { display: none; }
.page.active { display: block; }

/* Page header */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-header h2 { font-size: 1.5rem; font-weight: 700; }
.page-header p { color: var(--muted); font-size: .875rem; margin-top: 2px; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: var(--card); border-radius: 10px; padding: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06); border: 1px solid var(--border);
}
.stat-card .label { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.stat-card .value { font-size: 2rem; font-weight: 700; margin-top: 4px; }
.stat-card.pending .value { color: var(--warning); }
.stat-card.approved .value { color: var(--success); }
.stat-card.rejected .value { color: var(--danger); }
.stat-card.total .value { color: var(--primary); }

/* Cards / Tables */
.card {
  background: var(--card); border-radius: 10px; padding: 24px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06); border: 1px solid var(--border); margin-bottom: 20px;
}
.card h3 { font-size: 1rem; font-weight: 600; margin-bottom: 16px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 10px 12px; border-bottom: 1px solid var(--border); }
td { padding: 12px; border-bottom: 1px solid var(--border); font-size: .875rem; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }
.clickable-row { cursor: pointer; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 9999px; font-size: .75rem; font-weight: 600;
}
.badge.pending { background: #fef3c7; color: #92400e; }
.badge.approved { background: #dcfce7; color: #166534; }
.badge.rejected { background: #fee2e2; color: #991b1b; }

/* Forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid.full { grid-template-columns: 1fr; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.span2 { grid-column: span 2; }
label { font-size: .8rem; font-weight: 600; color: var(--muted); }
input, select, textarea {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: .9rem; color: var(--text); background: #fff; transition: border-color .15s;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
textarea { resize: vertical; min-height: 100px; }
.form-hint { font-size: .75rem; color: var(--muted); }

/* File upload */
.file-drop {
  border: 2px dashed var(--border); border-radius: 8px; padding: 24px;
  text-align: center; cursor: pointer; transition: all .15s; position: relative;
}
.file-drop:hover, .file-drop.dragover { border-color: var(--primary); background: #eff6ff; }
.file-drop input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-drop .drop-icon { font-size: 2rem; margin-bottom: 8px; }
.file-drop p { color: var(--muted); font-size: .85rem; }
.file-list { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.file-item {
  display: flex; align-items: center; justify-content: space-between;
  background: #f8fafc; border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px; font-size: .8rem;
}
.file-item .remove { cursor: pointer; color: var(--danger); font-size: 1rem; padding: 0 4px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px; border-radius: 8px; font-size: .875rem; font-weight: 600;
  cursor: pointer; border: none; transition: all .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: #f8fafc; }
.btn-sm { padding: 6px 14px; font-size: .8rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Detail view */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.detail-item { display: flex; flex-direction: column; gap: 4px; }
.detail-item .label { font-size: .75rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.detail-item .value { font-size: .95rem; }

.approval-actions { display: flex; gap: 12px; margin-top: 20px; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; z-index: 200;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--card); border-radius: 12px; padding: 28px; width: 100%; max-width: 500px;
  box-shadow: 0 20px 60px rgba(0,0,0,.15); transform: translateY(10px); transition: transform .2s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* Alerts */
.alert { padding: 12px 16px; border-radius: 8px; font-size: .875rem; margin-bottom: 16px; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }

/* Tabs */
.tabs { display: flex; gap: 4px; margin-bottom: 20px; background: #f1f5f9; padding: 4px; border-radius: 8px; width: fit-content; }
.tab { padding: 8px 18px; border-radius: 6px; cursor: pointer; font-size: .875rem; font-weight: 500; color: var(--muted); border: none; background: none; }
.tab.active { background: #fff; color: var(--primary); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.1); }

.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state .icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state p { font-size: .9rem; }

/* Attachments */
.attachment-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.attachment-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: #f1f5f9; border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 12px; font-size: .8rem; color: var(--text); text-decoration: none;
}
.attachment-chip:hover { background: #e2e8f0; }

/* OTP input */
#otp-input {
  width: 100%; text-align: center; font-size: 2rem;
  letter-spacing: 10px; font-weight: 700; color: var(--primary);
  border: 2px solid var(--border); border-radius: 12px; padding: 16px;
}
#otp-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }

@media (max-width: 768px) {
  .sidebar { width: 200px; }
  .main { margin-left: 200px; padding: 20px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-group.span2 { grid-column: span 1; }
  .detail-grid { grid-template-columns: 1fr; }
}
