:root {
  --bg: #f7f5f1;
  --card: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --accent: #b45309;
  --accent-soft: #fde68a;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.04);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ---------- Page header ---------- */
.site-header {
  text-align: center;
  padding: 32px 16px 16px;
}

.site-header img.logo {
  width: 168px;
  height: 168px;
  object-fit: contain;
  display: block;
  margin: 0 auto 12px;
}

.site-header h1 {
  font-size: 1.6rem;
  margin: 8px 0 4px;
  letter-spacing: -.01em;
}

.site-header p.tagline {
  margin: 0;
  color: var(--muted);
  font-size: .95rem;
}

/* ---------- Tile grid ---------- */
main.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  padding: 16px 0 32px;
}

.tile {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-height: 160px;
  transition: transform .15s ease, box-shadow .15s ease;
  cursor: pointer;
  border: 1px solid rgba(0,0,0,.04);
}

.tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 2px 6px rgba(0,0,0,.08), 0 12px 24px rgba(0,0,0,.06);
}

.tile-icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent);
  overflow: hidden;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.tile-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tile-title {
  font-weight: 600;
  font-size: .95rem;
  line-height: 1.3;
  margin-bottom: 4px;
}

.tile-desc {
  font-size: .8rem;
  color: var(--muted);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- States ---------- */
.empty, .error, .loading {
  text-align: center;
  color: var(--muted);
  padding: 48px 16px;
}

.error { color: #b91c1c; }

/* ---------- Footer ---------- */
.site-footer {
  text-align: center;
  padding: 24px 16px 32px;
  color: var(--muted);
  font-size: .8rem;
}

.site-footer a {
  color: var(--muted);
  text-decoration: underline;
}

/* ---------- Admin ---------- */
.admin-shell {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

.admin-shell h2 {
  margin-top: 0;
}

.login-card {
  max-width: 360px;
  margin: 64px auto;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-card h2 {
  margin: 0 0 16px;
}

label {
  display: block;
  font-size: .85rem;
  color: var(--muted);
  margin-top: 12px;
  margin-bottom: 4px;
}

input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}

textarea { min-height: 60px; resize: vertical; }

button, .btn {
  appearance: none;
  background: var(--ink);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: .95rem;
  font-weight: 500;
  cursor: pointer;
  margin-top: 12px;
  transition: opacity .15s ease;
}

button:hover, .btn:hover { opacity: .85; }

button.secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid #d1d5db;
}

button.danger {
  background: #b91c1c;
}

.row-actions { display: inline-flex; gap: 6px; }
.row-actions button { margin-top: 0; padding: 6px 10px; font-size: .8rem; }

.sort-cell { display: inline-flex; align-items: center; gap: 4px; }
.sort-num { min-width: 20px; text-align: center; font-variant-numeric: tabular-nums; color: var(--muted); font-size: .85rem; }
.sort-btn { margin-top: 0; padding: 2px 6px; font-size: .7rem; line-height: 1; min-width: 22px; }
.sort-btn:disabled { opacity: .3; cursor: not-allowed; }

.session-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
  font-size: .9rem;
}

.session-bar button { margin: 0; }

.section-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

.section-card h3 { margin: 0 0 12px; font-size: 1.05rem; }

.tiles-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}

.tiles-table th, .tiles-table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid #eee;
  vertical-align: middle;
}

.tiles-table th { font-weight: 600; color: var(--muted); font-size: .8rem; text-transform: uppercase; }

.tiles-table td.url-col { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }

.inline-form { display: grid; gap: 8px; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row.three { grid-template-columns: 1fr 1fr 1fr; }

.flash {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: .9rem;
}
.flash.ok { background: #d1fae5; color: #065f46; }
.flash.err { background: #fee2e2; color: #991b1b; }

@media (max-width: 600px) {
  .field-row, .field-row.three { grid-template-columns: 1fr; }
  .tiles-table thead { display: none; }
  .tiles-table tr { display: block; padding: 12px 0; border-bottom: 1px solid #eee; }
  .tiles-table td { display: block; border: none; padding: 4px 0; }
  .tiles-table td.url-col { max-width: 100%; white-space: normal; word-break: break-all; }
}
