:root {
  --primary: #10B981;
  --primary-dark: #059669;
  --bg: #f9fafb;
  --surface: #ffffff;
  --text: #111827;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --danger: #dc2626;
  --warning: #b45309;
  --success: #059669;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); }

.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.req { color: var(--danger); }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 6px; border: 1px solid transparent; cursor: pointer; font-size: 14px; font-weight: 500; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: 4px 8px; font-size: 12px; }
.btn-block { display: block; width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-weight: 500; font-size: 13px; margin-bottom: 4px; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; font-family: inherit; }
.form-group input:focus { outline: none; border-color: var(--primary); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.form-grid .full { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; }

.error-msg { color: var(--danger); font-size: 13px; margin-top: 8px; min-height: 16px; }
.feedback { margin-left: 8px; font-size: 13px; }

/* LOGIN */
.screen { min-height: 100vh; }
#loginScreen { display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%); padding: 16px; }
.login-box { background: white; padding: 32px; border-radius: 12px; width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15); }
.login-logo { width: 56px; height: 56px; background: var(--primary); color: white; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 26px; margin-bottom: 16px; }
.login-box h2 { font-size: 22px; margin-bottom: 4px; }

/* APP SHELL */
#appShell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

.sidebar { background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.brand-block { padding: 16px; border-bottom: 1px solid var(--border); display: flex; gap: 12px; align-items: center; }
.brand-block img { object-fit: contain; max-width: 60px; }
.brand-name { font-weight: 700; font-size: 16px; line-height: 1.2; }
.nav-list { flex: 1; padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 6px; color: var(--text); text-decoration: none; font-size: 14px; }
.nav-item:hover { background: var(--bg); }
.nav-item.active { background: var(--primary); color: white; }
.nav-item i { width: 16px; text-align: center; }
.sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--border); }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 12px 24px; display: flex; justify-content: space-between; align-items: center; }
#topbarTitle { font-weight: 600; font-size: 18px; }
.topbar-right { display: flex; gap: 16px; align-items: center; }
.float-pill { background: var(--bg); padding: 6px 14px; border-radius: 20px; display: flex; gap: 8px; align-items: baseline; }

.page { padding: 24px; }

.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat-card { background: var(--surface); padding: 16px; border-radius: 8px; border: 1px solid var(--border); }
.stat-label { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-weight: 700; font-size: 24px; margin-top: 4px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-header h3 { font-size: 16px; }
.card-body { padding: 20px; }

.table-responsive { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; }
.data-table th { font-weight: 600; color: var(--text-muted); text-transform: uppercase; font-size: 11px; letter-spacing: 0.5px; }
.data-table tr:hover td { background: var(--bg); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.badge-success { background: #d1fae5; color: #059669; }
.badge-danger { background: #fee2e2; color: #dc2626; }
.badge-warning { background: #fef3c7; color: #b45309; }
.badge-info { background: #dbeafe; color: #2563eb; }

/* MODAL */
.modal { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.5); }
.modal-content { position: relative; background: var(--surface); border-radius: 8px; max-width: 500px; width: 95%; max-height: 90vh; overflow-y: auto; box-shadow: 0 25px 60px rgba(0, 0, 0, 0.25); }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 20px; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.modal-close { background: none; border: none; cursor: pointer; font-size: 16px; color: var(--text-muted); }

/* TOAST */
#toastContainer { position: fixed; bottom: 24px; right: 24px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--text); color: white; padding: 12px 20px; border-radius: 6px; max-width: 360px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2); animation: slideIn 0.2s; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: #2563eb; }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

pre { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 12px; overflow-x: auto; font-size: 12px; }
code { font-family: ui-monospace, Menlo, Consolas, monospace; }
h4 { margin: 14px 0 6px; font-size: 14px; }

@media (max-width: 768px) {
  #appShell { grid-template-columns: 60px 1fr; }
  .sidebar .brand-name, .sidebar .brand-tagline, .nav-item span, .sidebar-footer { display: none; }
  .form-grid { grid-template-columns: 1fr; }
}
