/* ---------- Base ---------- */
body {
  font-family: system-ui, Arial, sans-serif;
  margin: 2rem;
  max-width: 1100px;
}

a { color: #5b4bff; }

.muted { color: #666; }

/* ---------- Header ---------- */
#appHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  background: #f5f5f5;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.95rem;
}

#appHeader a {
  text-decoration: none;
  font-weight: 600;
  margin-left: 1rem;
}

.pill {
  margin-left: 0.5rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: #f3f3f3;
  border: 1px solid #e5e5e5;
  font-size: 0.85rem;
}

/* ---------- Common UI ---------- */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.card {
  border: 1px solid #e5e5e5;
  border-radius: 12px;
  padding: 1rem;
  background: #fff;
}

.card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
}

.big {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.1;
}

/* Forms */
label { font-weight: 600; }
input, select, button { padding: 0.65rem; font-size: 1rem; }
button { cursor: pointer; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.55rem 0.4rem; border-bottom: 1px solid #eee; text-align: left; }
th { font-size: 0.85rem; color: #555; }

/* Messages */
.msg { margin-top: 1rem; padding: 0.75rem; border-radius: 8px; display: none; }
.msg.ok { background: #e8fff0; border: 1px solid #6bd68a; }
.msg.err { background: #ffecec; border: 1px solid #ff6b6b; }

/* Pretty alerts (login + forms) */
.alert {
  display: none;
  border: 1px solid #e5e5e5;
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  background: #fff;
  margin-top: 0.75rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.alert.show { display: flex; gap: 0.65rem; align-items: flex-start; }

.alert .icon {
  width: 34px; height: 34px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  border: 1px solid #e5e5e5;
  flex: 0 0 auto;
  font-weight: 800;
}

.alert .content { flex: 1 1 auto; }
.alert .title { font-weight: 800; margin: 0; line-height: 1.2; }
.alert .text  { margin: 0.15rem 0 0; color: #555; }

.alert.err {
  border-color: #ffcccc;
  background: #fff6f6;
}
.alert.err .icon {
  border-color: #ffcccc;
  background: #ffeaea;
}

.alert.ok {
  border-color: #bfe8c9;
  background: #f3fff7;
}
.alert.ok .icon {
  border-color: #bfe8c9;
  background: #eafff0;
}

@keyframes alertPop {
  from { transform: translateY(-4px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.alert.show { animation: alertPop 140ms ease-out; }


/* Responsive */
@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
}

/* ---------- Nav Menu ---------- */
#appHeader .left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

#appHeader .right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.nav-link {
  display: inline-block;
  padding: 0.35rem 0.6rem;
  border-radius: 8px;
  border: 1px solid transparent;
}

.nav-link:hover {
  background: #ffffff;
  border-color: #e5e5e5;
}

.nav-link.active {
  background: #ffffff;
  border-color: #cfcfcf;
}

.brand {
  font-weight: 800;
  letter-spacing: 0.2px;
  margin-right: 0.25rem;
}

/* Stack nicely on small screens */
@media (max-width: 700px) {
  #appHeader {
    align-items: flex-start;
    gap: 0.75rem;
  }
  #appHeader .right {
    width: 100%;
  }
}

/* ---------- Nav Dropdowns (click) ---------- */
#appHeader .left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

#appHeader .right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.brand {
  font-weight: 800;
  letter-spacing: 0.2px;
  margin-right: 0.25rem;
}

.nav-link, .nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.6rem;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  font: inherit;
}

.nav-link:hover, .nav-btn:hover {
  background: #ffffff;
  border-color: #e5e5e5;
}

.nav-link.active, .nav-btn.active {
  background: #ffffff;
  border-color: #cfcfcf;
}

.nav-btn {
  cursor: pointer;
}

.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 210px;
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.08);
  padding: 0.35rem;
  display: none;
  z-index: 999;
}

.dropdown.open .dropdown-menu {
  display: block;
}

.dropdown-item {
  display: block;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
}

.dropdown-item:hover {
  background: #f5f5f5;
}

.dropdown-sep {
  height: 1px;
  background: #eee;
  margin: 0.35rem 0;
}

.chev {
  display: inline-block;
  transform: translateY(-1px);
  font-size: 0.85em;
  opacity: 0.8;
}

/* Responsive */
@media (max-width: 700px) {
  #appHeader { align-items: flex-start; gap: 0.75rem; }
  #appHeader .right { width: 100%; }
  .dropdown-menu { left: 0; right: auto; }
}

/* ---------- Mobile Nav Toggle ---------- */
.nav-toggle {
  display: none;
  padding: 0.35rem 0.6rem;
  border-radius: 8px;
  border: 1px solid #e5e5e5;
  background: #ffffff;
  cursor: pointer;
  font: inherit;
}

@media (max-width: 700px) {
  .nav-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
  }

  /* Right side becomes a collapsible panel */
  #appHeader .right {
    display: none;
    width: 100%;
    padding-top: 0.5rem;
    border-top: 1px solid #e5e5e5;
  }

  #appHeader.nav-open .right {
    display: flex;
  }

  /* Make links/buttons full width on mobile */
  #appHeader .right > a,
  #appHeader .right > .dropdown,
  #appHeader .right .nav-btn,
  #appHeader .right .nav-link {
    width: 100%;
    justify-content: space-between;
  }

  /* Dropdown menu should flow in doc on mobile */
  .dropdown-menu {
    position: static;
    box-shadow: none;
    border-radius: 10px;
    margin-top: 0.35rem;
  }
}
