:root {
  --green: #386b45;
  --green-dark: #21432d;
  --green-soft: #e9f3e7;
  --gold: #f3c32d;
  --gold-soft: #fff4c7;
  --blue: #365fb2;
  --ink: #241f1b;
  --muted: #6d655c;
  --line: #e0d8ca;
  --panel: #fffdf8;
  --paper: #f7f2e7;
  --danger: #b83a27;
  --danger-soft: #fff0ec;
  --shadow: 0 18px 45px rgba(40, 34, 25, .12);
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Arial, Helvetica, sans-serif;
}

.hidden { display: none !important; }

.portal-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
}

.side-panel {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
  background: #fffaf0;
  border-right: 1px solid var(--line);
}

.brand {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 14px;
  align-items: center;
}

.brand img {
  width: 78px;
  height: 78px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 6px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--green);
  font-size: .76rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 1.28rem; }
h2 { margin-bottom: 10px; font-size: 1.75rem; }
h3 { margin-bottom: 8px; font-size: 1.08rem; }
p { line-height: 1.45; }

.security-note,
.status-card,
.setup-warning {
  border: 1px solid #d7b657;
  border-radius: var(--radius);
  background: var(--gold-soft);
  padding: 13px 14px;
}

.security-note,
.setup-warning {
  display: grid;
  gap: 5px;
}

.security-note span,
.setup-warning span,
.copyright span {
  color: var(--muted);
  line-height: 1.35;
}

.auth-card,
.user-card,
.hero > div:first-child,
.library,
.admin-summary {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.auth-form {
  display: grid;
  gap: 10px;
}

label {
  font-size: .82rem;
  font-weight: 800;
  color: #493d32;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 11px 12px;
  font: inherit;
  background: #fff;
}

button,
.download-btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 42px;
  border: 1px solid var(--green);
  border-radius: 7px;
  padding: 10px 14px;
  background: var(--green);
  color: #fff;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

button.secondary,
.download-btn.secondary {
  background: #fff;
  color: var(--green-dark);
}

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

.divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: .8rem;
  margin: 12px 0;
}

.divider::before,
.divider::after {
  content: "";
  height: 1px;
  background: var(--line);
}

.copyright {
  margin-top: auto;
  display: grid;
  gap: 6px;
  font-size: .84rem;
}

.main-panel {
  padding: 28px;
  display: grid;
  gap: 20px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 350px;
  gap: 18px;
  align-items: start;
}

.status-card {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: 12px;
}

.status-card p {
  margin-bottom: 0;
  color: var(--muted);
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: var(--gold);
  margin-top: 4px;
  box-shadow: 0 0 0 5px rgba(243, 195, 45, .16);
}

.status-card.ready {
  border-color: #bad7bb;
  background: var(--green-soft);
}

.status-card.ready .status-dot {
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(56, 107, 69, .13);
}

.status-card.error {
  border-color: #e0a599;
  background: var(--danger-soft);
}

.status-card.error .status-dot {
  background: var(--danger);
  box-shadow: 0 0 0 5px rgba(184, 58, 39, .12);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.release-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green-dark);
  font-size: .82rem;
  font-weight: 800;
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.app-card,
.empty-state,
.control-grid div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 16px;
}

.app-card {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 14px;
}

.app-icon {
  width: 58px;
  height: 58px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  background: var(--green);
  color: #fff;
  font-weight: 900;
}

.app-type {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 800;
  text-transform: uppercase;
}

dl {
  display: grid;
  gap: 7px;
  margin: 12px 0;
}

dl div {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 8px;
  font-size: .9rem;
}

dt { color: var(--muted); font-weight: 800; }
dd { margin: 0; }

.admin-summary {
  display: grid;
  grid-template-columns: 310px 1fr;
  gap: 18px;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.control-grid div {
  display: grid;
  gap: 6px;
}

.control-grid span {
  color: var(--muted);
  line-height: 1.35;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(80px);
  max-width: min(560px, calc(100vw - 28px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 10;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

code {
  font-family: Consolas, Monaco, monospace;
  background: #fff;
  border: 1px solid var(--line);
  padding: 1px 4px;
  border-radius: 4px;
}

@media (max-width: 980px) {
  .portal-shell,
  .hero,
  .admin-summary {
    grid-template-columns: 1fr;
  }

  .side-panel {
    position: static;
    height: auto;
  }

  .app-grid,
  .control-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .main-panel,
  .side-panel {
    padding: 16px;
  }

  .brand {
    grid-template-columns: 58px 1fr;
  }

  .brand img {
    width: 58px;
    height: 58px;
  }

  h2 { font-size: 1.35rem; }

  .app-card {
    grid-template-columns: 1fr;
  }
}
