*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --navy: #1A3A5C;
  --navy-dark: #122840;
  --green: #1E6E32;
  --gray-bg: #F3F4F6;
  --gray-text: #6B7280;
  --gray-border: #E5E7EB;
  --red: #DC2626;
}

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-bg);
  color: #111827;
  min-height: 100vh;
}

#app {
  min-height: 100vh;
}

/* ── LOGIN ─────────────────────────────────────────────────── */
.login-layout {
  display: flex;
  min-height: 100vh;
}

.login-left {
  width: 40%;
  background: var(--navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 48px 40px;
}

.login-left-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: .5px;
}

.login-left-brand span.leaf {
  font-size: 32px;
}

.login-left-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 24px;
}

.login-left-title {
  font-size: 30px;
  font-weight: 700;
  line-height: 1.25;
}

.login-left-title span {
  color: #93C5FD;
}

.login-bullets {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-bullets li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: #CBD5E1;
}

.login-bullets li::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #93C5FD;
  flex-shrink: 0;
}

.login-left-footer {
  font-size: 12px;
  color: #64748B;
}

.login-right {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  background: #fff;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0,0,0,.08), 0 1px 4px rgba(0,0,0,.04);
  padding: 40px 36px;
}

.login-card-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 6px;
}

.login-card-sub {
  font-size: 14px;
  color: var(--gray-text);
  margin-bottom: 32px;
}

.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--gray-border);
  border-radius: 8px;
  font-size: 14px;
  color: #111827;
  outline: none;
  transition: border-color .15s;
}

.form-input:focus {
  border-color: var(--navy);
}

.btn-login {
  width: 100%;
  padding: 12px;
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-login:hover {
  background: var(--navy-dark);
}

.btn-login:disabled {
  opacity: .6;
  cursor: not-allowed;
}

.login-error {
  display: none;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  color: var(--red);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  margin-top: 14px;
}

.login-error.visible {
  display: block;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

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

/* ── PORTAL ────────────────────────────────────────────────── */
.portal-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.portal-header {
  background: #fff;
  border-bottom: 1px solid var(--gray-border);
  padding: 0 32px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.portal-header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  color: var(--navy);
}

.portal-header-brand .leaf {
  font-size: 24px;
}

.portal-header-brand .sep {
  color: var(--gray-border);
  font-weight: 300;
}

.portal-header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.portal-user-name {
  font-size: 14px;
  color: #374151;
  font-weight: 500;
}

.btn-logout {
  padding: 7px 16px;
  border: 1.5px solid var(--gray-border);
  border-radius: 7px;
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}

.btn-logout:hover {
  background: var(--gray-bg);
  border-color: #D1D5DB;
}

.portal-main {
  flex: 1;
  padding: 40px 32px;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

.portal-greeting {
  margin-bottom: 32px;
}

.portal-greeting-title {
  font-size: 26px;
  font-weight: 700;
  color: #111827;
  margin-bottom: 4px;
}

.portal-greeting-sub {
  font-size: 14px;
  color: var(--gray-text);
}

.apps-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

/* ── APP CARD ──────────────────────────────────────────────── */
.app-card {
  background: #fff;
  border-radius: 14px;
  padding: 28px 24px 24px;
  border: 1.5px solid var(--gray-border);
  position: relative;
  transition: transform .15s, box-shadow .15s, border-color .15s;
  cursor: pointer;
  overflow: hidden;
}

.app-card.accessible:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,.1);
  border-color: #D1D5DB;
}

.app-card.locked {
  cursor: default;
  opacity: .55;
  filter: grayscale(.4);
}

.app-card.coming-soon {
  cursor: default;
}

.app-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.app-emoji {
  font-size: 44px;
  line-height: 1;
}

.app-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 99px;
  letter-spacing: .3px;
}

.badge-soon {
  background: #FEF3C7;
  color: #92400E;
}

.badge-locked {
  background: #F3F4F6;
  color: #6B7280;
}

.badge-active {
  background: #ECFDF5;
  color: #065F46;
}

.app-name {
  font-size: 17px;
  font-weight: 700;
  color: #111827;
  margin-bottom: 6px;
}

.app-desc {
  font-size: 13px;
  color: var(--gray-text);
  line-height: 1.5;
}

.app-card-accent {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  border-radius: 14px 14px 0 0;
}

.lock-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  background: rgba(255,255,255,.4);
  border-radius: 14px;
}

/* ── RESPONSIVE ────────────────────────────────────────────── */
@media (max-width: 900px) {
  .apps-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .login-layout {
    flex-direction: column;
  }
  .login-left {
    width: 100%;
    padding: 28px 24px;
  }
  .login-left-center {
    padding: 24px 0;
  }
  .login-card {
    padding: 28px 20px;
  }
  .apps-grid {
    grid-template-columns: 1fr;
  }
  .portal-main {
    padding: 24px 16px;
  }
  .portal-header {
    padding: 0 16px;
  }
}

/* ── ADMIN PANEL ───────────────────────────────────────────── */
.role-select:focus {
  outline: 2px solid #1A3A5C;
  border-color: transparent;
}

#modal-new-user input:focus,
#modal-new-user select:focus {
  outline: 2px solid #1A3A5C;
  border-color: transparent;
}
