@import url('https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,500;0,600;0,700;1,500&family=IBM+Plex+Sans:wght@400;500;600&display=swap');

:root {
  --paper: #F5F5F4;
  --card: #FFFFFF;
  --ink: #222221;
  --ink-soft: #6C767D;
  --line: #E2E3E4;
  --slate: #6C767D;
  --slate-dark: #4E565C;
  --red: #C30730;
  --red-dark: #9C0527;
  --red-bg: #FBE9EC;
}

[data-theme="dark"] {
  --paper: #17181B;
  --card: #212327;
  --ink: #F1F1F0;
  --ink-soft: #9BA1A7;
  --line: #34373C;
  --slate: #9BA1A7;
  --slate-dark: #C7CBCF;
  --red: #E23A5D;
  --red-dark: #F0577A;
  --red-bg: #3A1620;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--line);
  border-radius: 3px;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink-soft);
  font-size: 15px;
  flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--slate); }
[data-theme="light"] .icon-to-light { display: none; }
[data-theme="dark"] .icon-to-dark { display: none; }
.theme-toggle-fixed { position: fixed; top: 20px; right: 20px; }

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

h1, h2, h3, .display {
  font-family: 'Lora', serif;
  font-weight: 600;
  margin: 0;
  color: var(--ink);
}

a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Top bar */
.topbar {
  border-bottom: 1px solid var(--line);
  background: var(--card);
}
.topbar .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { height: 30px; width: auto; display: block; }
.wordmark {
  font-family: 'Lora', serif;
  font-weight: 700;
  font-size: 18px;
  color: var(--ink);
  line-height: 1.2;
}
.nav-links { display: flex; align-items: center; gap: 22px; font-size: 14px; }
.nav-links a { color: var(--ink-soft); }
.nav-links a.active { color: var(--red); font-weight: 600; }
.nav-user { font-size: 14px; color: var(--ink-soft); display: flex; align-items: center; gap: 14px; }
.btn-link {
  background: none; border: none; font: inherit; color: var(--ink-soft);
  cursor: pointer; padding: 0; text-decoration: underline;
}

main { padding: 40px 0 80px; }

/* Buttons */
.btn {
  display: inline-block;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 3px;
  border: 1px solid var(--red);
  background: var(--red);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--red-dark); border-color: var(--red-dark); text-decoration: none; }
.btn-ghost {
  background: transparent; color: var(--slate-dark); border: 1px solid var(--line);
}
.btn-ghost:hover { background: var(--card); border-color: var(--slate); text-decoration: none; }
.btn-danger { background: transparent; border: 1px solid var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red); border-color: var(--red); color: #fff; }
.btn-block { display: block; width: 100%; text-align: center; }

/* Forms */
label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin: 0 0 6px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], select, textarea {
  width: 100%;
  font: inherit;
  font-size: 15px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--card);
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--red);
  outline-offset: 1px;
}
.field { margin-bottom: 18px; }
.field-row { display: flex; gap: 16px; }
.field-row .field { flex: 1; }
textarea { min-height: 90px; resize: vertical; }
input[type=file] { font-size: 14px; }

.auth-card {
  max-width: 380px;
  margin: 60px auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 32px;
}
.auth-mark { height: 40px; width: auto; display: block; margin: 0 0 24px; }
.auth-card h1 { margin-bottom: 6px; }
.auth-card .sub { color: var(--ink-soft); font-size: 14px; margin-bottom: 26px; }
.auth-switch { margin-top: 18px; font-size: 14px; color: var(--ink-soft); text-align: center; }

.error-box {
  background: var(--red-bg);
  border: 1px solid #EFC2CB;
  color: var(--red-dark);
  padding: 10px 14px;
  border-radius: 3px;
  font-size: 14px;
  margin-bottom: 18px;
}

/* Dashboard */
.page-head {
  display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 32px;
}
.stat-hero { margin-bottom: 40px; }
.stat-figure {
  font-family: 'Lora', serif;
  font-weight: 700;
  font-size: 52px;
  color: var(--ink);
  line-height: 1;
}
.stat-label { color: var(--ink-soft); font-size: 15px; margin-top: 8px; }

.ledger { border-top: 1px solid var(--line); }
.ledger-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0; border-bottom: 1px solid var(--line);
}
.ledger-row .name { font-weight: 500; }
.ledger-row .meta { color: var(--ink-soft); font-size: 14px; }
.ledger-row .value { font-family: 'Lora', serif; font-weight: 600; color: var(--ink); font-size: 17px; }

.section-title { font-size: 14px; font-weight: 600; color: var(--ink-soft); margin: 0 0 14px; }

/* Items list */
.toolbar { display: flex; gap: 12px; align-items: end; margin-bottom: 28px; flex-wrap: wrap; }
.toolbar form { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; flex: 1; }
.toolbar .field { margin-bottom: 0; min-width: 140px; }
.toolbar .field.grow { flex: 1; min-width: 180px; }

.item-row {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 0; border-bottom: 1px solid var(--line);
}
.item-select { width: 18px; height: 18px; flex-shrink: 0; cursor: pointer; accent-color: var(--red); }
.item-row-link {
  display: flex; align-items: center; gap: 16px; flex: 1; min-width: 0;
  text-decoration: none; color: inherit;
}
.item-thumb {
  width: 52px; height: 52px; border-radius: 3px; object-fit: cover;
  background: var(--line); flex-shrink: 0;
}
.item-thumb.placeholder { display: flex; align-items: center; justify-content: center; color: var(--ink-soft); font-size: 20px; }
.item-info { flex: 1; min-width: 0; }
.item-info .name { font-weight: 600; }
.item-info .meta { color: var(--ink-soft); font-size: 13px; margin-top: 2px; }
.item-value { font-family: 'Lora', serif; font-weight: 600; color: var(--ink); font-size: 16px; white-space: nowrap; }

.bulk-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 16px; margin-bottom: 4px;
  background: var(--card); border: 1px solid var(--line); border-radius: 4px;
}
.bulk-select-all { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-soft); cursor: pointer; white-space: nowrap; }
.bulk-select-all input { width: 16px; height: 16px; accent-color: var(--red); }
.bulk-bar input[type=text] { width: auto; flex: 1; min-width: 160px; font-size: 14px; padding: 8px 10px; }
.bulk-bar .btn { white-space: nowrap; }
.bulk-bar .btn:disabled { opacity: 0.5; cursor: not-allowed; }

.empty-state {
  text-align: center; padding: 70px 20px; color: var(--ink-soft);
  border: 1px dashed var(--line); border-radius: 4px;
}
.empty-state h2 { margin-bottom: 8px; color: var(--ink); }

/* Item detail */
.detail-grid { display: flex; gap: 32px; flex-wrap: wrap; }
.detail-photo { width: 240px; height: 240px; object-fit: cover; border-radius: 4px; background: var(--line); flex-shrink: 0; }
.detail-info { flex: 1; min-width: 240px; }
.detail-info dl { margin: 0; }
.detail-info dt { font-size: 12px; color: var(--ink-soft); margin-top: 14px; }
.detail-info dt:first-child { margin-top: 0; }
.detail-info dd { margin: 2px 0 0; font-size: 16px; }
.detail-actions { display: flex; gap: 10px; margin-top: 28px; }

footer.confirm { display: inline; }

@media (max-width: 640px) {
  .nav-links { display: none; }
  .field-row { flex-direction: column; gap: 0; }
  .detail-grid { flex-direction: column; }
  .detail-photo { width: 100%; height: 200px; }
  .stat-figure { font-size: 40px; }
}
