/* Personal Inventory — clean, modern, calm. */
:root {
  --bg: #F5F7F8;
  --surface: #FFFFFF;
  --surface-2: #FAFBFC;
  --ink: #1B2A32;
  --ink-2: #46555E;
  --ink-3: #7A8892;
  --line: #DFE5E8;
  --line-soft: #EAEFF1;
  --accent: #0B6E55;
  --accent-strong: #095A45;
  --accent-soft: #E3F1EC;
  --warn: #9A5B00;
  --warn-soft: #FBF1DE;
  --danger: #B3362E;
  --danger-soft: #F9E9E7;
  --info-soft: #E8EEF6;
  --info-ink: #2B527F;
  --ok-soft: #E3F1EC;
  --ok-ink: #0B6E55;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(27, 42, 50, .05), 0 4px 14px rgba(27, 42, 50, .06);
  --font-ui: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-serif: "Source Serif 4", Georgia, serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 {
  font-family: var(--font-serif);
  font-size: 1.7rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
h2 { font-size: 1.05rem; font-weight: 600; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { width: 1.1em; height: 1.1em; stroke: currentColor; fill: none;
      stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.18em; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
  max-width: 100vw;
}
.skip {
  position: absolute; left: -999px; top: 8px; z-index: 50;
  background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 8px;
}
.skip:focus { left: 8px; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidenav {
  width: 248px; flex: 0 0 248px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 20px 14px;
  position: sticky; top: 0; height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 600; font-size: 1.02rem; color: var(--ink);
  padding: 4px 8px 18px; text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand svg { width: 26px; height: 26px; color: var(--accent); stroke-width: 1.4; }
.sidenav-nav { display: flex; flex-direction: column; gap: 2px; }
.navlink {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: var(--ink-2); font-weight: 500; text-decoration: none;
  font-size: .95rem;
}
.navlink svg { width: 18px; height: 18px; color: var(--ink-3); }
.navlink:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.navlink.is-active { background: var(--accent-soft); color: var(--accent-strong); }
.navlink.is-active svg { color: var(--accent-strong); }
.side-foot {
  margin-top: auto; padding-top: 14px;
  border-top: 1px solid var(--line-soft);
  display: flex; flex-direction: column; gap: 8px;
}
.userchip { display: flex; align-items: center; gap: 10px; padding: 2px 4px; min-width: 0; }
.avatar {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: .95rem;
}
.userchip-names { display: flex; flex-direction: column; min-width: 0; }
.userchip-names strong { font-size: .88rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.userchip-names span { font-size: .76rem; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.content {
  flex: 1; min-width: 0;
  padding: 30px clamp(18px, 4vw, 44px) 60px;
  max-width: 1160px;
}

/* ---------- page headers ---------- */
.pagehead {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 18px; flex-wrap: wrap; margin-bottom: 22px;
}
.pagehead-text > p { color: var(--ink-2); margin-top: 6px; max-width: 70ch; }
.pagehead-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { font-size: .86rem; color: var(--ink-3); }
.crumbs a { color: var(--ink-3); }
.crumbs a:hover { color: var(--accent); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  font: inherit; font-size: .92rem; font-weight: 600;
  padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer;
  text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { border-color: var(--ink-3); background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: #F2D9D6; }
.btn-sm { padding: 6px 12px; font-size: .85rem; }
.btn-block { width: 100%; justify-content: center; }
.btn svg { width: 16px; height: 16px; }

.iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  color: var(--ink-3); border: 1px solid transparent;
}
.iconbtn svg { width: 17px; height: 17px; }
.iconbtn:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.iconbtn-danger:hover { background: var(--danger-soft); color: var(--danger); }
.inlineform { display: inline; margin: 0; }

/* ---------- flash ---------- */
.flash {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 14px; border-radius: var(--radius);
  margin-bottom: 18px; font-size: .92rem; font-weight: 500;
  border: 1px solid var(--line);
}
.flash svg { flex: 0 0 auto; margin-top: 2px; }
.flash-success { background: var(--ok-soft); color: var(--ok-ink); border-color: #CBE4DB; }
.flash-error { background: var(--danger-soft); color: var(--danger); border-color: #EFCFCC; }
.flash-info { background: var(--info-soft); color: var(--info-ink); border-color: #D3DDEC; }

/* ---------- auth ---------- */
.authwrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.authcard {
  width: 100%; max-width: 400px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow);
  padding: 34px 32px 28px;
}
.authbrand { display: flex; gap: 13px; align-items: flex-start; margin-bottom: 24px; }
.authbrand svg { width: 34px; height: 34px; color: var(--accent); stroke-width: 1.3; flex: 0 0 auto; margin-top: 3px; }
.authbrand h1 { font-size: 1.35rem; }
.authbrand p { color: var(--ink-2); font-size: .92rem; margin-top: 3px; }
.authswap { margin-top: 18px; text-align: center; font-size: .9rem; color: var(--ink-2); }

/* ---------- forms ---------- */
.stack { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label { font-size: .86rem; font-weight: 600; color: var(--ink-2); }
.req { font-weight: 500; color: var(--ink-3); font-size: .78rem; }
.field input, .field select, .field textarea {
  font: inherit; font-size: .95rem; color: var(--ink);
  padding: 9px 12px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--surface);
  width: 100%;
}
.field textarea { resize: vertical; min-height: 90px; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent);
}
.field input[aria-invalid="true"] { border-color: var(--danger); background: #FEFBFA; }
.field input:disabled { background: var(--surface-2); color: var(--ink-3); }
.field-error { color: var(--danger); font-size: .84rem; font-weight: 500; }
.hint { color: var(--ink-3); font-size: .8rem; }

.cardform {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 26px 28px; max-width: 760px;
}
.sectiontitle { font-size: 1rem; margin-bottom: -4px; }
.formgrid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 20px;
}
.field-wide { grid-column: 1 / -1; }
.formfoot { display: flex; gap: 10px; margin-top: 4px; }

/* ---------- stats ---------- */
.statrow {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px; margin-bottom: 22px;
}
.statrow-report { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 18px;
  display: flex; flex-direction: column; gap: 3px;
  text-decoration: none;
}
.stat-label { font-size: .78rem; font-weight: 600; color: var(--ink-3); letter-spacing: .02em; }
.stat-value { font-family: var(--font-serif); font-size: 1.45rem; font-weight: 600; color: var(--ink); }
.stat-link { transition: border-color .15s; }
.stat-link:hover { border-color: var(--accent); text-decoration: none; }
.stat-cta { color: var(--accent); }

/* ---------- toolbar ---------- */
.toolbar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  margin-bottom: 18px;
}
.search { position: relative; flex: 1 1 260px; min-width: 220px; }
.search svg {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 17px; height: 17px; color: var(--ink-3); pointer-events: none;
}
.search input {
  font: inherit; font-size: .93rem; width: 100%;
  padding: 9px 12px 9px 36px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface);
}
.search input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.toolbar select {
  font: inherit; font-size: .93rem;
  padding: 9px 30px 9px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
}

/* ---------- tables ---------- */
.tablewrap {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}
.itemtable { width: 100%; border-collapse: collapse; font-size: .92rem; }
.itemtable th {
  text-align: left; font-size: .76rem; font-weight: 600;
  letter-spacing: .05em; text-transform: uppercase;
  color: var(--ink-3); padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.itemtable td { padding: 12px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.itemtable tbody tr:last-child td { border-bottom: 0; }
.itemtable tbody tr:hover { background: var(--surface-2); }
.itemtable th.col-num, .itemtable td.col-num { text-align: right; font-variant-numeric: tabular-nums; }
.itemtable td.col-num strong { font-weight: 600; }
.col-item { min-width: 240px; }
.col-actions { width: 84px; text-align: right; white-space: nowrap; }
.itemname { font-weight: 600; color: var(--ink); }
.itemname:hover { color: var(--accent); }
.serial { display: block; font-size: .78rem; color: var(--ink-3); font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.serialmono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .88rem; }
.hasnote { color: var(--ink-3); font-size: .85rem; margin-left: 4px; }
.totalrow td { border-top: 2px solid var(--line); font-weight: 700; background: var(--surface-2); }
.dim { color: var(--ink-3); }

.cat {
  display: inline-block; font-size: .8rem; font-weight: 500;
  color: var(--ink-2);
}
.cat[data-cat="electronics"] { color: #1D5F9E; }
.cat[data-cat="furniture"] { color: #7A4E2D; }
.cat[data-cat="appliances"] { color: #0E7490; }
.cat[data-cat="kitchen"] { color: #9A5B00; }
.cat[data-cat="clothing"] { color: #8A3E85; }
.cat[data-cat="jewellery"] { color: #A0741C; }
.cat[data-cat="tools"] { color: #5B5F6B; }
.cat[data-cat="sports"] { color: #147A4B; }
.cat[data-cat="books"] { color: #3E5C76; }
.cat[data-cat="art"] { color: #A34A3A; }
.cat[data-cat="instruments"] { color: #6D4FA1; }
.cat[data-cat="other"] { color: var(--ink-3); }

/* ---------- badges ---------- */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: .76rem; font-weight: 600; white-space: nowrap;
}
.badge-ok { background: var(--ok-soft); color: var(--ok-ink); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-muted { background: #EEF1F2; color: var(--ink-3); font-weight: 500; }

/* ---------- empty state ---------- */
.emptystate {
  background: var(--surface); border: 1px dashed var(--line);
  border-radius: var(--radius); padding: 48px 24px;
  text-align: center; color: var(--ink-2);
}
.emptystate svg { width: 30px; height: 30px; color: var(--ink-3); stroke-width: 1.4; margin-bottom: 10px; }
.emptystate h2 { font-family: var(--font-serif); font-size: 1.25rem; margin-bottom: 6px; }
.emptystate p { max-width: 46ch; margin: 0 auto 18px; font-size: .94rem; }
.empty-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---------- detail page ---------- */
.detailgrid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.detailcard {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 22px;
}
.detailcard h2 {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-3); margin-bottom: 12px;
}
.detailcard-wide { grid-column: 1 / -1; }
.detailrows { display: flex; flex-direction: column; }
.detailrow {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 7px 0; border-bottom: 1px solid var(--line-soft);
  font-size: .92rem;
}
.detailrow:last-child { border-bottom: 0; }
.detailrow span:first-child { color: var(--ink-2); }
.notesbody { font-family: var(--font-serif); font-size: 1rem; line-height: 1.7; color: var(--ink); max-width: 75ch; white-space: pre-wrap; }
.up { color: var(--ok-ink); }
.down { color: var(--danger); }

/* ---------- report ---------- */
.reportsection { margin-top: 26px; }
.reportsection h2 { font-family: var(--font-serif); font-size: 1.15rem; margin-bottom: 12px; }
.reporthead { margin-bottom: 8px; }
.report-note {
  margin-top: 12px; font-size: .9rem; color: var(--warn);
  background: var(--warn-soft); border: 1px solid #EFDCBA;
  border-radius: var(--radius-sm); padding: 10px 14px; max-width: 72ch;
}
.reporttable td, .reporttable th { font-size: .9rem; }

@media print {
  .print-hide, .sidenav { display: none !important; }
  body { background: #fff; font-size: 12px; }
  .content { padding: 0; max-width: none; }
  .stat, .tablewrap, .detailcard { box-shadow: none; border-color: #C9D2D6; }
  .statrow-report { grid-template-columns: repeat(3, 1fr); }
  .itemtable tbody tr:hover { background: none; }
  h1 { font-size: 1.5rem; }
  .reporthead { margin-top: 4px; }
}

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .shell { display: block; }
  .sidenav {
    position: sticky; top: 0; z-index: 30; height: auto;
    width: 100%; flex-direction: row; align-items: center;
    padding: 10px 14px; gap: 8px;
    border-right: 0; border-bottom: 1px solid var(--line);
  }
  .brand { padding: 0 6px 0 0; }
  .brand span { display: none; }
  .sidenav-nav { flex-direction: row; flex: 1; overflow-x: auto; gap: 4px; }
  .navlink { padding: 8px 11px; font-size: .88rem; }
  .side-foot { margin: 0; padding: 0; border: 0; flex-direction: row; align-items: center; }
  .userchip { display: none; }
  .content { padding: 22px 16px 48px; }
  .statrow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detailgrid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .formgrid { grid-template-columns: 1fr; }
  .pagehead { align-items: flex-start; flex-direction: column; }
  .cardform { padding: 20px 18px; }
  .col-warranty, .itemtable th:nth-child(2) { display: none; }
  .itemtable td { padding: 11px 12px; }
  .itemtable th { padding: 10px 12px; }
  .toolbar select { flex: 1 1 40%; }
  .statrow { gap: 8px; }
  .stat { padding: 12px 14px; }
  .stat-value { font-size: 1.2rem; }
  .itemtable { min-width: 560px; }
}
