:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --bg: #eef2f7;
  --surface: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --danger: #ef4444;
  --success: #10b981;
  --sidebar-top: #1e293b;
  --sidebar-bottom: #0f172a;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", Inter, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--danger); font-weight: 600; min-height: 1.2em; }

/* Login — miroir desktop */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 20% 0%, #c7d2fe 0%, transparent 50%),
    linear-gradient(180deg, #eef2f7 0%, #e2e8f0 100%);
}
.login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px 24px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
  text-align: center;
}
.inst-logo { width: 92px; height: 92px; object-fit: contain; margin-bottom: 10px; }
.inst-lines { margin-bottom: 14px; }
.l1 { font-size: 15px; font-weight: 800; letter-spacing: 0.02em; }
.l2 { font-size: 12px; color: var(--muted); margin-top: 2px; }
.l3 { font-size: 13px; font-weight: 700; color: var(--danger); margin-top: 4px; }
.login-card h1 { margin: 8px 0 4px; font-size: 22px; }
.login-card label {
  display: block; text-align: left; margin: 12px 0 6px; font-weight: 600; font-size: 13px;
}
.login-card input, .content input, .content select {
  width: 100%;
  padding: 11px 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
}
button {
  border: none; border-radius: 10px; padding: 11px 14px;
  font-weight: 700; cursor: pointer;
}
button.primary { background: var(--primary); color: #fff; width: 100%; margin-top: 14px; }
button.soft { background: #e0e7ff; color: var(--primary-dark); }
button.ghost { background: transparent; color: #e2e8f0; }
button.tab {
  background: #f1f5f9; color: var(--text); font-size: 12px; margin-right: 6px; margin-bottom: 6px;
}
button.tab.active { background: var(--primary); color: #fff; }

/* Shell desktop-like */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, var(--sidebar-top), var(--sidebar-bottom));
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 14px 10px;
}
.side-brand {
  display: flex; gap: 10px; align-items: center;
  padding: 8px 10px 16px; border-bottom: 1px solid rgba(255,255,255,.08);
}
.side-logo { width: 44px; height: 44px; object-fit: contain; border-radius: 50%; background: #fff; }
.side-title { font-weight: 800; font-size: 14px; }
.side-sub { font-size: 11px; opacity: .7; }
.side-nav {
  flex: 1; overflow-y: auto; margin-top: 12px;
  display: flex; flex-direction: column; gap: 4px;
}
.side-nav button {
  text-align: left; background: transparent; color: #cbd5e1;
  padding: 10px 12px; font-size: 13px; border-radius: 10px;
}
.side-nav button:hover { background: rgba(255,255,255,.06); }
.side-nav button.active { background: var(--primary); color: #fff; }
.side-user {
  border-top: 1px solid rgba(255,255,255,.08);
  padding-top: 12px; display: flex; flex-direction: column; gap: 8px;
}
.chip {
  background: rgba(255,255,255,.1); border-radius: 999px;
  padding: 8px 10px; font-size: 12px;
}
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 18px;
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
}
.top-inst { display: flex; gap: 12px; align-items: center; }
.top-logo { width: 52px; height: 52px; object-fit: contain; }
.page-title { font-weight: 800; font-size: 16px; color: var(--primary-dark); }
.content { padding: 16px 18px 28px; overflow: auto; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin: 12px 0;
}
.kpi {
  background: linear-gradient(135deg, #6366f1, #4338ca);
  color: #fff; border-radius: 14px; padding: 14px;
}
.kpi.emerald { background: linear-gradient(135deg, #10b981, #059669); }
.kpi.sky { background: linear-gradient(135deg, #0ea5e9, #0284c7); }
.kpi.amber { background: linear-gradient(135deg, #f59e0b, #d97706); }
.kpi.rose { background: linear-gradient(135deg, #f43f5e, #e11d48); }
.kpi .lbl { font-size: 11px; opacity: .9; text-transform: uppercase; }
.kpi .val { font-size: 18px; font-weight: 800; margin-top: 6px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  margin-top: 12px;
}
.panel h3 { margin: 0 0 10px; font-size: 15px; }
.tabs-row { margin-bottom: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 6px; border-bottom: 1px solid var(--border); text-align: left; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; }
.form-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px; margin-bottom: 12px;
}
.ok { color: var(--success); font-weight: 600; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.btn-row button { width: auto; margin-top: 0; }
.menu-toggle, .menu-close { display: none; }
.sidebar-backdrop { display: none; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .menu-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    position: fixed; top: 10px; left: 10px; z-index: 40;
    width: 44px; height: 44px; border-radius: 12px;
    background: var(--sidebar-bottom); color: #fff; font-size: 20px;
    box-shadow: 0 6px 18px rgba(15,23,42,.25);
  }
  .menu-close { display: inline-flex; margin-left: auto; color: #fff; font-size: 18px; padding: 6px 10px; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw);
    z-index: 50; transform: translateX(-105%);
    transition: transform .22s ease; box-shadow: 8px 0 24px rgba(0,0,0,.25);
  }
  .shell.nav-open .sidebar { transform: translateX(0); }
  .sidebar-backdrop {
    display: block; position: fixed; inset: 0; z-index: 45;
    background: rgba(15,23,42,.45); opacity: 0; pointer-events: none;
    transition: opacity .2s ease;
  }
  .shell.nav-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  .side-nav { flex-direction: column; overflow-y: auto; max-height: calc(100vh - 160px); }
  .side-nav button { white-space: normal; font-size: 14px; padding: 12px; }
  .main { padding-top: 8px; }
  .topbar {
    flex-direction: column; align-items: flex-start;
    padding: 14px 14px 12px 58px;
  }
  .top-inst .l1 { font-size: 12px; }
  .top-inst .l2 { font-size: 11px; }
  .top-logo { width: 40px; height: 40px; }
  .content { padding: 12px 12px 40px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi .val { font-size: 15px; }
  .form-grid { grid-template-columns: 1fr; }
  table { font-size: 12px; min-width: 520px; }
  .panel { padding: 12px; border-radius: 12px; }
  .login-card { padding: 22px 16px; }
  .inst-logo { width: 72px; height: 72px; }
}

@media (min-width: 901px) {
  .menu-toggle, .menu-close, .sidebar-backdrop { display: none !important; }
}
