:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #d1d5db;
  --primary: #1d4ed8;
  --primary-ink: #ffffff;
  --danger: #b91c1c;
  --ok-bg: #ecfdf5;
  --ok-ink: #065f46;
  --err-bg: #fef2f2;
  --err-ink: #991b1b;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  font-size: 17px;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--ink);
  color: #fff;
}
.brand { color: #fff; font-weight: 700; text-decoration: none; font-size: 1.15rem; }
.nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; align-items: center; margin-left: auto; }
.nav a { color: #e5e7eb; text-decoration: none; padding: 0.4rem 0.2rem; }
.nav a:hover { color: #fff; text-decoration: underline; }
.logout { margin-left: 0.5rem; }
.link-btn { background: none; border: 1px solid #374151; color: #e5e7eb; padding: 0.45rem 0.7rem; border-radius: 8px; cursor: pointer; }

.container { max-width: 880px; margin: 0 auto; padding: 1rem 1rem 3rem; }
h1 { font-size: 1.5rem; margin: 0.6rem 0 0.4rem; }
h2 { font-size: 1.15rem; margin: 1.4rem 0 0.4rem; }
.muted { color: var(--muted); }
.prewrap { white-space: pre-wrap; }
.crumbs { color: var(--muted); margin: 0.5rem 0; }
.crumbs a { color: var(--primary); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem; margin: 1rem 0; }
.card.narrow { max-width: 420px; margin: 2rem auto; }

label { display: block; margin: 0.9rem 0 0.3rem; font-weight: 600; }
input, textarea, select, button {
  font: inherit;
}
input[type=text], input[type=password], input[type=file], textarea, select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
textarea { resize: vertical; }

.btn {
  display: inline-block;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  min-height: 44px;
}
.btn-lg { width: 100%; padding: 0.95rem; font-size: 1.1rem; margin-top: 1.2rem; }
.btn-primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn-secondary { background: #eef2ff; border-color: #c7d2fe; }
.btn-small { padding: 0.5rem 0.7rem; min-height: 40px; font-size: 0.95rem; }
.btn-danger { color: var(--danger); border-color: #fca5a5; }
.inline { display: inline; }

.alert { padding: 0.8rem 1rem; border-radius: 10px; background: #fff7ed; border: 1px solid #fed7aa; margin: 0.8rem 0; }
.alert-error { background: var(--err-bg); border-color: #fecaca; color: var(--err-ink); }
.alert-ok { background: var(--ok-bg); border-color: #a7f3d0; color: var(--ok-ink); }

.tiles { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 1rem; }
.tile { display: flex; flex-direction: column; gap: 0.25rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem; text-decoration: none; color: var(--ink); min-height: 120px; }
.tile:hover { border-color: var(--primary); }
.tile-title { font-size: 1.2rem; font-weight: 700; }
.tile-sub { color: var(--muted); font-size: 0.9rem; }
.tile-cta { margin-top: auto; color: var(--primary); font-weight: 600; }

.list { list-style: none; padding: 0; }
.list-item { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: space-between; padding: 0.9rem 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 0.6rem; text-decoration: none; color: var(--ink); }
.list-item:hover { border-color: var(--primary); }
.list-main { display: flex; flex-direction: column; }
.list-meta { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.badge { display: inline-block; background: #eef2ff; color: #3730a3; border-radius: 6px; padding: 0.1rem 0.5rem; font-size: 0.85rem; }

.notice { background: #fffbeb; border: 2px solid #f59e0b; border-radius: var(--radius); padding: 1rem 1.2rem; margin: 1rem 0; }
.notice-strong { font-weight: 700; font-size: 1.1rem; margin: 0 0 0.3rem; }
.notice details { margin-top: 0.4rem; }
.notice summary { cursor: pointer; color: #92400e; font-weight: 600; }

.dims { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.8rem 1rem 1rem; margin-top: 1rem; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); margin-top: 1rem; }
legend { font-weight: 700; padding: 0 0.4rem; }
.dim-row { display: grid; grid-template-columns: 1.3fr 0.8fr 0.7fr 1.3fr; gap: 0.5rem; margin-bottom: 0.5rem; }
.dim-row input, .dim-row select { margin: 0; }

.row-form { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.row-form input { flex: 1 1 180px; width: auto; }
.actions { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.actions .mini { width: 140px; }

.table { width: 100%; border-collapse: collapse; margin: 0.6rem 0; background: var(--surface); }
.table th, .table td { text-align: left; padding: 0.6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { background: #f9fafb; }

.stats { display: flex; flex-wrap: wrap; gap: 1rem; margin: 1rem 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.4rem; flex: 1 1 140px; text-align: center; }
.stat-num { display: block; font-size: 1.8rem; font-weight: 700; }
.stat-lbl { color: var(--muted); font-size: 0.9rem; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.6rem; }
.gallery img { width: 100%; height: 140px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }

.footer { text-align: center; color: var(--muted); padding: 1.5rem 1rem; font-size: 0.9rem; }

@media (max-width: 560px) {
  .dim-row { grid-template-columns: 1fr 1fr; }
  .nav { width: 100%; }
}
