:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --border: #2d3a4f;
  --text: #e8edf4;
  --muted: #8b9bb4;
  --primary: #f59e0b;
  --primary-dim: #d97706;
  --danger: #ef4444;
  --ok: #22c55e;
  --warn: #eab308;
  --radius: 10px;
  --font: 'Segoe UI', system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); font-size: 0.9rem; }

.login-body { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem;
  background: radial-gradient(ellipse at top, #1e3a5f 0%, var(--bg) 55%); }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; width: 100%; max-width: 400px; box-shadow: 0 20px 50px rgba(0,0,0,.35); }
.login-logo { text-align: center; margin-bottom: 1rem; }
.login-logo-img { max-width: min(140px, 46vw); height: auto; display: inline-block; vertical-align: middle; object-fit: contain; }
.login-brand { font-size: 1.5rem; font-weight: 700; color: var(--primary); text-align: center; }
.login-back { text-align: center; margin: 1rem 0 0; }
.login-back-link { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.9rem; color: var(--muted); text-decoration: none; }
.login-back-link:hover { color: var(--primary); }
.login-back-link .fa-arrow-left { font-size: 0.85em; opacity: 0.9; }
.login-sub { text-align: center; color: var(--muted); margin: 0.5rem 0 1.5rem; }
.login-form label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.35rem; }
.login-form input { width: 100%; padding: 0.65rem 0.85rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface2); color: var(--text); margin-bottom: 1rem; }
.login-hint { font-size: 0.75rem; color: var(--muted); margin-top: 1.25rem; text-align: center; }
.login-foot { font-size: 0.75rem; color: var(--muted); margin: 0.5rem 0 0; text-align: center; }
.input-select { width: 100%; padding: 0.65rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface2); color: var(--text); }

.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 250px; background: var(--surface); border-right: 1px solid var(--border); flex-shrink: 0; display: flex; flex-direction: column; }
.sidebar-brand { padding: 1.25rem; font-weight: 700; color: var(--primary); font-size: 1.1rem; border-bottom: 1px solid var(--border); }
.sidebar-tenant { padding: 0.75rem 1.25rem; font-size: 0.8rem; color: var(--muted); border-bottom: 1px solid var(--border); }
.sidebar-nav { padding: 0.75rem 0; flex: 1; overflow-y: auto; }
.sidebar-nav a { display: flex; align-items: center; gap: 0.6rem; padding: 0.65rem 1.25rem; color: var(--text); font-size: 0.92rem; border-left: 3px solid transparent; }
.sidebar-nav a:hover { background: var(--surface2); text-decoration: none; border-left-color: var(--primary); }
.main-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 0.85rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-user small { color: var(--muted); }
.main-content { padding: 1.5rem; flex: 1; }

.page-header h1 { margin: 0 0 0.25rem; font-size: 1.5rem; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 1rem; margin-top: 1.25rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; text-align: center; }
.stat-card.accent { border-color: var(--primary); }
.stat-card.warn { border-color: var(--warn); }
.stat-val { font-size: 1.75rem; font-weight: 800; color: var(--primary); }
.stat-label { font-size: 0.8rem; color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.card-title { margin: 0 0 1rem; font-size: 1.1rem; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th, .data-table td { padding: 0.65rem 0.75rem; text-align: left; border-bottom: 1px solid var(--border); }
.data-table th { color: var(--muted); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; }
.badge { display: inline-block; padding: 0.2rem 0.5rem; border-radius: 6px; background: var(--surface2); font-size: 0.75rem; }

.btn { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.55rem 1rem; border-radius: 8px; border: none; cursor: pointer; font-weight: 600; font-size: 0.9rem; font-family: inherit; }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-dim)); color: #111; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 0.35rem 0.65rem; font-size: 0.8rem; }
.btn-block { width: 100%; justify-content: center; }

.alert { padding: 0.85rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.alert-error { background: rgba(239,68,68,.15); border: 1px solid var(--danger); color: #fecaca; }
.alert-ok { background: rgba(34,197,94,.15); border: 1px solid var(--ok); color: #bbf7d0; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
.form-group label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.35rem; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 0.55rem 0.75rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface2); color: var(--text); font-family: inherit; }
.form-actions { margin-top: 1.25rem; display: flex; gap: 0.75rem; flex-wrap: wrap; }

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: none; align-items: center; justify-content: center; z-index: 100; padding: 1rem; }
.modal-overlay.open { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); max-width: 520px; width: 100%; max-height: 90vh; overflow-y: auto; padding: 1.25rem; }
.modal h2 { margin: 0 0 1rem; font-size: 1.15rem; }
.modal-close { float: right; background: none; border: none; color: var(--muted); font-size: 1.5rem; cursor: pointer; line-height: 1; }

@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; }
  .sidebar-nav { display: flex; flex-wrap: wrap; padding: 0.5rem; }
  .sidebar-nav a { padding: 0.5rem 0.75rem; border-left: none; border-radius: 6px; }
}
