:root {
  --ink: #211E1A;
  --paper: #EAE5DA;
  --surface: #FFFFFF;
  --surface-2: #F4F0E7;
  --line: #D8D0BF;
  --rust: #C1502E;
  --rust-dark: #A33F22;
  --steel: #3D5A6C;
  --muted: #6B6459;
  --shadow: 0 1px 0 rgba(33,30,26,0.06);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 980px; margin: 0 auto; padding: 28px 20px 80px; }

header.top {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 16px; padding-bottom: 22px; border-bottom: 3px solid var(--ink);
  margin-bottom: 22px; flex-wrap: wrap;
}
header.top .title-block { max-width: 560px; }
h1 {
  font-family: 'Archivo', sans-serif; font-weight: 800;
  font-size: clamp(28px, 5vw, 40px); letter-spacing: -0.01em;
  margin: 0 0 6px; line-height: 1.02;
}
.subtitle { color: var(--muted); font-size: 14.5px; margin: 0; max-width: 46ch; }
.top-actions { display: flex; align-items: center; gap: 14px; }
.top-actions a { color: var(--muted); font-size: 13px; text-decoration: none; }
.top-actions a:hover { color: var(--ink); }

.stat-row { display: flex; gap: 18px; font-family: 'IBM Plex Mono', monospace; }
.stat { text-align: right; }
.stat .num { font-size: 26px; font-weight: 500; display: block; line-height: 1; }
.stat .lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 20px; }
.search {
  flex: 1; min-width: 180px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 3px; padding: 11px 14px; font-size: 14.5px; color: var(--ink); font-family: inherit;
}
.search:focus { outline: 2px solid var(--steel); outline-offset: -1px; }
select.filter {
  background: var(--surface); border: 1px solid var(--line); border-radius: 3px;
  padding: 11px 12px; font-size: 14px; color: var(--ink); font-family: inherit;
}
button.add-btn {
  background: var(--rust); color: #fff; border: none; border-radius: 3px;
  padding: 11px 18px; font-size: 14.5px; font-weight: 600; font-family: inherit;
  cursor: pointer; white-space: nowrap;
}
button.add-btn:hover { background: var(--rust-dark); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 4px; overflow: hidden;
  box-shadow: var(--shadow); display: flex; flex-direction: column; cursor: pointer;
  transition: border-color .15s ease;
}
.card:hover { border-color: var(--steel); }
.card .photo {
  width: 100%; aspect-ratio: 4/3; background: var(--surface-2); display: flex;
  align-items: center; justify-content: center; overflow: hidden; border-bottom: 1px solid var(--line);
}
.card .photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .photo .placeholder { color: var(--muted); font-size: 12px; font-family: 'IBM Plex Mono', monospace; }
.card .body { padding: 12px 13px 14px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card .name { font-weight: 600; font-size: 15px; line-height: 1.25; }
.card .meta { font-size: 12.5px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; font-family: 'IBM Plex Mono', monospace; }
.card .cat-tag {
  align-self: flex-start; font-size: 11px; color: var(--steel); border: 1px solid var(--steel);
  border-radius: 20px; padding: 2px 9px; margin-top: 2px;
}

.empty { border: 1.5px dashed var(--line); border-radius: 4px; padding: 60px 20px; text-align: center; color: var(--muted); }
.empty p { margin: 0 0 14px; font-size: 15px; }

.overlay {
  position: fixed; inset: 0; background: rgba(20,18,15,0.55); display: none;
  align-items: flex-start; justify-content: center; padding: 5vh 16px; overflow-y: auto; z-index: 50;
}
.overlay.open { display: flex; }
.modal {
  background: var(--surface); border-radius: 6px; width: 100%; max-width: 480px;
  padding: 26px 24px 24px; box-shadow: 0 12px 40px rgba(0,0,0,0.25);
}
.modal h2 { font-family: 'Archivo', sans-serif; font-weight: 700; font-size: 21px; margin: 0 0 18px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.field input[type=text], .field input[type=number], .field input[type=date], .field input[type=password], .field textarea, .field select {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line); border-radius: 3px;
  padding: 10px 11px; font-size: 14.5px; color: var(--ink); font-family: inherit;
}
.field textarea { resize: vertical; min-height: 60px; }
.field input:focus, .field textarea:focus, .field select:focus { outline: 2px solid var(--steel); outline-offset: -1px; }

.photo-input-row { display: flex; gap: 10px; align-items: center; }
.photo-preview {
  width: 74px; height: 74px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--line);
  overflow: hidden; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
}
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.photo-preview .ph { font-size: 10px; color: var(--muted); }
.file-btn { background: var(--surface-2); border: 1px solid var(--line); border-radius: 3px; padding: 9px 13px; font-size: 13.5px; cursor: pointer; font-family: inherit; }
input[type=file] { display: none; }

.modal-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; gap: 10px; }
.btn { border: none; border-radius: 3px; padding: 10px 16px; font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit; }
.btn-primary { background: var(--rust); color: #fff; }
.btn-primary:hover { background: var(--rust-dark); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--ink); }
.btn-delete { background: transparent; color: var(--rust); border: 1px solid var(--rust); }
.btn-delete:hover { background: var(--rust); color: #fff; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--paper); padding: 11px 20px; border-radius: 4px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Logo */
.brand-logo { display: block; height: 72px; width: auto; }
.brand-logo.header { height: 72px; flex-shrink: 0; }
.login-card .brand-logo { height: 92px; }

/* Login page */
.login-wrap { max-width: 360px; margin: 12vh auto 0; padding: 0 20px; }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 30px 26px; text-align: center; }
.login-card .brand-logo { margin: 0 auto 14px; }
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-card p.subtitle { margin-bottom: 20px; }
.error-msg { color: var(--rust-dark); font-size: 13.5px; margin: -6px 0 14px; }
.login-card form { text-align: left; }

@media (max-width: 480px) {
  .wrap { padding: 20px 14px 70px; }
  header.top { align-items: flex-start; }
  .brand-logo.header { height: 36px; }
}
