:root {
  --bg: #f0f4f8;
  --card: #fff;
  --primary: #1a3a5c;
  --primary-hover: #254d78;
  --border: #d8e2ec;
  --text: #1e293b;
  --muted: #64748b;
  --u0: #dc2626;
  --u1: #ea580c;
  --u2: #ca8a04;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

header {
  background: var(--primary);
  color: #fff;
  padding: 1.5rem 2rem 0;
}

.app-nav {
  display: flex;
  gap: 0.25rem;
  margin-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  padding-top: 0.5rem;
}

.app-nav .tab {
  color: rgba(255, 255, 255, 0.75);
  text-decoration: none;
  padding: 0.6rem 1.25rem;
  border-radius: 8px 8px 0 0;
  font-size: 0.95rem;
  font-weight: 500;
}

.app-nav .tab:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.app-nav .tab.active {
  color: var(--primary);
  background: var(--bg);
}

header h1 { font-size: 1.5rem; }
.subtitle { opacity: 0.85; font-size: 0.95rem; margin-top: 0.25rem; }

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

.user-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
  flex-wrap: wrap;
}

.user-bar a.btn {
  text-decoration: none;
  color: var(--text);
}

.app-nav.hidden {
  display: none;
}

.btn.small { padding: 0.35rem 0.75rem; font-size: 0.85rem; }

.hidden { display: none !important; }

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.login-card {
  width: 100%;
  max-width: 400px;
}

.login-card h1 { margin-bottom: 0.25rem; color: var(--primary); }

.login-card label {
  display: block;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.login-card input[type="text"],
.login-card input[type="password"] {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
}

.hp { position: absolute; left: -9999px; opacity: 0; height: 0; width: 0; }

.btn.full { width: 100%; margin-top: 0.5rem; }

.login-error {
  color: #b91c1c;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.user-form { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.user-form h3 { font-size: 1rem; margin-bottom: 0.75rem; }
.form-row { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.form-row input, .form-row select {
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.btn-link.danger { color: #b91c1c; }

.guides-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
}
.guides-list li {
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.guides-list li:last-child { border-bottom: none; }

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.card h2 { font-size: 1.1rem; margin-bottom: 0.75rem; }

.hint { color: var(--muted); font-size: 0.9rem; margin-bottom: 1rem; }
.hint code { background: #f1f5f9; padding: 0.1rem 0.35rem; border-radius: 4px; }

.stats { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.stat strong { font-size: 1.4rem; display: block; }
.stat.ok strong { color: #16a34a; }
.stat.warn strong { color: #ea580c; }

.actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.5rem; }

.btn {
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  text-decoration: none;
  display: inline-block;
}

.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.secondary { background: #e2e8f0; color: var(--text); }
.btn.secondary:hover { background: #cbd5e1; }

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  text-decoration: underline;
}

.progress { margin-top: 1rem; }
.bar {
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
}
.fill {
  height: 100%;
  background: var(--primary);
  width: 0;
  transition: width 0.3s;
}
#progress-text { font-size: 0.85rem; color: var(--muted); margin-top: 0.4rem; }

.hidden { display: none !important; }

.table-wrap { overflow-x: auto; margin-top: 1rem; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 0.6rem 0.75rem; text-align: left; border-bottom: 1px solid var(--border); }
th { background: #f8fafc; font-weight: 600; }
tr.error td { color: #dc2626; }

.badge {
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.8rem;
  color: #fff;
}
.badge.u0 { background: var(--u0); }
.badge.u1 { background: var(--u1); }
.badge.u2 { background: var(--u2); }

.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.preview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 0.75rem;
}

@media (max-width: 700px) {
  .preview-grid { grid-template-columns: 1fr; }
}

figure { margin: 0; }
figcaption { font-size: 0.85rem; color: var(--muted); margin-bottom: 0.4rem; }
td.comment { max-width: 320px; font-size: 0.85rem; }

figure img {
  width: 100%;
  max-height: 400px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #f8fafc;
}
