:root {
  --bg: #121212;
  --surface: #1e1e1e;
  --surface2: #2a2a2a;
  --text: #f5f5f5;
  --muted: #b0b0b0;
  --primary: #90caf9;
  --danger: #ef9a9a;
  --ok: #a5d6a7;
  --border: #333;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, sans-serif; }

.hidden { display: none !important; }

#login-screen {
  min-height: 100%;
  padding: 1.5rem;
  max-width: 420px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.75rem;
}

h1 { font-size: 1.35rem; margin: 0 0 0.5rem; }
h2 { font-size: 1.1rem; margin: 0 0 0.75rem; }
.sub { color: var(--muted); font-size: 0.9rem; margin: 0 0 1rem; }

.lang-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.lang-row select,
.lang-select {
  width: auto;
  min-width: 4.5rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.85rem;
}

input, textarea, select, button {
  font: inherit;
  border-radius: 10px;
  border: 1px solid var(--border);
}
input, textarea, select {
  width: 100%;
  padding: 0.65rem 0.75rem;
  background: var(--surface2);
  color: var(--text);
}
button {
  padding: 0.55rem 0.9rem;
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
}
button.primary { background: #1565c0; border-color: #1565c0; color: #fff; }
button.danger { background: #5d1f1f; border-color: #7a2e2e; }
button.ghost { background: transparent; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

#app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding-bottom: calc(var(--nav-h) + var(--safe-b));
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.app-header h1 { font-size: 1.05rem; margin: 0; flex: 1; }
.header-actions { display: flex; gap: 0.35rem; flex-wrap: wrap; }

#main { flex: 1; padding: 0.75rem 1rem 1rem; max-width: 960px; width: 100%; margin: 0 auto; }

.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  z-index: 20;
}
.nav-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  font-size: 0.68rem;
  padding: 0.35rem;
}
.nav-btn.active { color: var(--primary); }
.nav-btn span.icon { font-size: 1.15rem; line-height: 1; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem;
  margin-bottom: 0.75rem;
}
.card h3 { margin: 0 0 0.35rem; font-size: 1rem; }
.meta { color: var(--muted); font-size: 0.85rem; line-height: 1.35; }
.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.5rem 0; }
.chip {
  font-size: 0.75rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: var(--surface2);
  border: 1px solid var(--border);
}
.row-btns { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.65rem; }
.row-btns.col { flex-direction: column; align-items: stretch; }
.btn-block { width: 100%; justify-content: center; }
.card label { display: block; font-size: 0.8rem; color: var(--muted); margin: 0.5rem 0 0.15rem; }
.card label:first-child { margin-top: 0; }
.banner-warn {
  background: #3d2f00;
  border: 1px solid #665200;
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
  color: #ffe082;
}
.readiness-ok { color: var(--ok); }
.readiness-bad { color: var(--danger); }

.fab {
  position: fixed;
  right: 1rem;
  bottom: calc(var(--nav-h) + 1rem + var(--safe-b));
  z-index: 15;
  border-radius: 999px;
  padding: 0.75rem 1rem;
  background: #1565c0;
  border: none;
  color: #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
}

.error { color: var(--danger); margin: 0.5rem 0; }
.empty { color: var(--muted); text-align: center; padding: 2rem 1rem; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 30;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  width: 100%; max-width: 720px; max-height: 85vh;
  overflow: auto; padding: 1rem;
  border: 1px solid var(--border);
}
.modal h2 { margin-top: 0; }

.filters { margin-bottom: 0.75rem; }
.filters label { display: block; font-size: 0.8rem; color: var(--muted); margin: 0.35rem 0 0.15rem; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + 1.25rem + var(--safe-b));
  background: #333; color: #fff; padding: 0.55rem 0.9rem;
  border-radius: 8px; z-index: 40; font-size: 0.9rem;
}

.chip-row { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.35rem; }
.chip {
  border: 1px solid var(--border);
  background: var(--surface-2, #1e1e1e);
  color: var(--text);
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  font-size: 0.82rem;
  cursor: pointer;
}
.chip-on {
  border-color: var(--accent, #7c9cff);
  background: color-mix(in srgb, var(--accent, #7c9cff) 18%, transparent);
}

@media (min-width: 768px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: 16px; }
}
