/* Warranty Wallet - visual identity: slate #2F3E46 + teal #52B69A on off-white, ledger table, slide-in drawer, mono serials */
:root {
  --slate: #2F3E46;
  --slate-deep: #22303A;
  --slate-soft: #4A5C66;
  --teal: #52B69A;
  --teal-dark: #3B9B80;
  --teal-tint: #E3F4EE;
  --offwhite: #F6F7F4;
  --paper: #FFFFFF;
  --ink: #1D272C;
  --muted: #5F6E75;
  --line: #D8DEDB;
  --line-strong: #B9C3BF;
  --amber: #C7830A;
  --amber-tint: #FBF1DC;
  --red: #B9463C;
  --red-tint: #F9E4E1;
  --focus: #1F8A70;
  --radius: 10px;
  --shadow: 0 12px 32px rgba(34, 48, 58, 0.22);
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --drawer-w: 480px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--offwhite);
  min-height: 100vh;
}
body.drawer-open { overflow: hidden; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
p { margin: 0; }
button { font: inherit; }
code, .mono { font-family: var(--mono); font-variant-ligatures: none; letter-spacing: 0.01em; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--paper); color: var(--slate); padding: 8px 12px; border-radius: 6px; z-index: 50; }
.skip-link:focus { left: 8px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--paper); color: var(--slate); cursor: pointer; font-weight: 600; font-size: 14px;
  min-height: 38px;
}
.btn:hover { border-color: var(--slate-soft); background: #FBFCFA; }
.btn-primary { background: var(--teal); border-color: var(--teal); color: #0F2A22; }
.btn-primary:hover { background: var(--teal-dark); border-color: var(--teal-dark); color: #FFFFFF; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: rgba(47, 62, 70, 0.08); border-color: transparent; }
.btn-danger-text { color: var(--red); }
.link-btn { background: none; border: 0; padding: 0; color: var(--teal-dark); text-decoration: underline; cursor: pointer; font-weight: 600; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--paper);
  color: var(--slate); font-size: 24px; line-height: 1; cursor: pointer;
}
.icon-btn:hover { background: var(--teal-tint); }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px clamp(14px, 3vw, 32px);
  background: var(--slate-deep); color: #FFFFFF;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: 0.01em; }
.brand img { display: block; }
.toolbar { display: flex; gap: 6px; flex-wrap: wrap; }
.toolbar .btn { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.22); color: #FFFFFF; }
.toolbar .btn:hover { background: rgba(255, 255, 255, 0.16); }
.toolbar .btn-primary { background: var(--teal); border-color: var(--teal); color: #0F2A22; }
.toolbar .btn-primary:hover { background: #6BC7AE; }
.toolbar .btn-ghost { background: transparent; border-color: transparent; color: rgba(255, 255, 255, 0.85); }
.toolbar .btn-danger-text { color: #F4B7AF; }

/* ---------- hero: the search bar ---------- */
.hero {
  background: var(--slate);
  color: #FFFFFF;
  padding: clamp(22px, 4vw, 44px) clamp(14px, 3vw, 32px) clamp(20px, 3vw, 30px);
  background-image: linear-gradient(135deg, rgba(82, 182, 154, 0.18), rgba(82, 182, 154, 0) 55%);
}
.hero-title { font-size: clamp(20px, 2.6vw, 28px); font-weight: 700; margin-bottom: 14px; }
.search { max-width: 900px; }
.search-label { display: block; font-size: 13px; color: rgba(255, 255, 255, 0.82); margin-bottom: 8px; }
.search-box {
  position: relative; display: flex; align-items: center;
  background: var(--paper); border-radius: 14px; border: 2px solid transparent;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}
.search-box:focus-within { border-color: var(--teal); }
.search-icon { width: 24px; height: 24px; margin-left: 16px; color: var(--slate-soft); flex: none; }
#search-input {
  flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink);
  font: inherit; font-size: clamp(17px, 2.2vw, 22px); padding: 16px 14px; border-radius: 14px;
}
#search-input:focus { outline: none; }
#search-input::-webkit-search-cancel-button { display: none; }
.search-clear {
  width: 36px; height: 36px; margin-right: 8px; border-radius: 50%; border: 0; background: var(--offwhite);
  color: var(--slate); font-size: 22px; line-height: 1; cursor: pointer; flex: none;
}
.search-clear:hover { background: var(--teal-tint); }
.search-hint { margin-top: 8px; font-size: 13px; color: rgba(255, 255, 255, 0.72); }
.search-hint kbd { font-family: var(--mono); background: rgba(255, 255, 255, 0.14); padding: 1px 6px; border-radius: 4px; }
.hero-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; max-width: 900px; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.3); background: rgba(255, 255, 255, 0.08); color: #FFFFFF;
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.chip:hover { background: rgba(255, 255, 255, 0.18); }
.chip[aria-pressed="true"] { background: var(--paper); color: var(--slate); border-color: var(--paper); }
.chip-count { font-family: var(--mono); font-size: 12px; padding: 1px 7px; border-radius: 999px; background: rgba(0, 0, 0, 0.25); }
.chip[aria-pressed="true"] .chip-count { background: var(--slate); color: #FFFFFF; }
.chip-active[aria-pressed="true"] .chip-count { background: var(--teal-dark); }
.chip-expiring[aria-pressed="true"] .chip-count { background: var(--amber); }
.chip-expired[aria-pressed="true"] .chip-count { background: var(--red); }
.hero-stat { font-size: 13px; color: rgba(255, 255, 255, 0.85); }

/* ---------- main / empty ---------- */
.main { padding: clamp(16px, 3vw, 28px) clamp(14px, 3vw, 32px) 40px; }
.empty {
  max-width: 640px; margin: 24px auto; padding: 32px; background: var(--paper);
  border: 1px dashed var(--line-strong); border-radius: var(--radius); text-align: center;
}
.empty h2 { font-size: 22px; margin-bottom: 10px; color: var(--slate); }
.empty p { color: var(--muted); margin-bottom: 20px; }
.empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }

/* ---------- ledger table ---------- */
.ledger { max-width: 1280px; margin: 0 auto; }
.ledger-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px 18px; margin-bottom: 12px; }
.ledger-head h2 { font-size: 18px; color: var(--slate); text-transform: uppercase; letter-spacing: 0.08em; }
.ledger-count { color: var(--muted); font-size: 14px; flex: 1; }
.sort { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.sort select { font: inherit; font-size: 14px; padding: 6px 8px; border-radius: 6px; border: 1px solid var(--line-strong); background: var(--paper); color: var(--ink); }
.table-wrap { overflow-x: auto; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(34, 48, 58, 0.06); }
.ledger-table { width: 100%; border-collapse: collapse; min-width: 320px; }
.ledger-table th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--slate-soft);
  padding: 12px 14px; border-bottom: 2px solid var(--line); background: #FBFCFA; white-space: nowrap;
}
.ledger-table td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.ledger-table tr:last-child td { border-bottom: 0; }
.row { cursor: pointer; transition: background-color 120ms ease; }
.row:hover { background: var(--teal-tint); }
.row.is-selected { background: var(--teal-tint); }
.row td:first-child { box-shadow: inset 4px 0 0 var(--line-strong); }
.row-active td:first-child { box-shadow: inset 4px 0 0 var(--teal); }
.row-expiring td:first-child { box-shadow: inset 4px 0 0 var(--amber); }
.row-expired td:first-child { box-shadow: inset 4px 0 0 var(--red); }
.row.is-selected td:first-child { box-shadow: inset 4px 0 0 var(--slate); }
.row-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
  background: none; border: 0; padding: 2px 0; color: var(--ink); cursor: pointer; width: 100%;
}
.row-name { font-weight: 600; color: var(--slate); }
.row-sub { font-size: 12.5px; color: var(--muted); }
.row-sub-serial { display: none; font-size: 12.5px; color: var(--slate-soft); }
.col-serial, .col-purchased, .col-end { white-space: nowrap; font-size: 14px; }
.col-serial { color: var(--slate); }
.pill {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.pill-active { background: var(--teal-tint); color: #1F6B57; }
.pill-expiring { background: var(--amber-tint); color: #7A4F00; }
.pill-expired { background: var(--red-tint); color: #8A2A22; }
.pill-unknown { background: var(--line); color: var(--muted); }
.no-results { margin-top: 14px; color: var(--muted); }

/* ---------- drawer ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(34, 48, 58, 0.5); z-index: 30; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(var(--drawer-w), 100vw);
  background: var(--paper); z-index: 40; box-shadow: var(--shadow);
  transform: translateX(105%); visibility: hidden;
  transition: transform 220ms ease, visibility 0s linear 220ms;
  display: flex; flex-direction: column;
}
.drawer.is-open { transform: translateX(0); visibility: visible; transition: transform 220ms ease; }
.drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 18px 20px 14px; border-bottom: 1px solid var(--line); background: var(--offwhite);
}
.drawer-kicker { font-family: var(--mono); font-size: 12px; color: var(--teal-dark); letter-spacing: 0.06em; text-transform: uppercase; }
.drawer-title { font-size: 20px; color: var(--slate); margin-top: 2px; overflow-wrap: anywhere; }
.drawer-body { padding: 18px 20px 28px; overflow-y: auto; flex: 1; }
.status-banner { padding: 10px 12px; border-radius: 8px; font-weight: 600; margin-bottom: 16px; border-left: 4px solid var(--line-strong); background: var(--offwhite); }
.status-active { background: var(--teal-tint); border-left-color: var(--teal); color: #1F6B57; }
.status-expiring { background: var(--amber-tint); border-left-color: var(--amber); color: #7A4F00; }
.status-expired { background: var(--red-tint); border-left-color: var(--red); color: #8A2A22; }
.detail-list { display: grid; grid-template-columns: minmax(110px, 36%) 1fr; gap: 8px 12px; margin: 0 0 18px; }
.detail-list dt { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding-top: 2px; }
.detail-list dd { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.detail-list dd.mono { font-size: 14.5px; color: var(--slate); }
.drawer-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.claim-heading { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 22px 0 6px; }
.claim-text {
  margin: 0; padding: 12px; background: var(--offwhite); border: 1px solid var(--line); border-radius: 8px;
  font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--slate);
}

/* ---------- form ---------- */
.item-form .field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; min-width: 0; }
.field label, .field-set legend { font-size: 13px; font-weight: 600; color: var(--slate); }
.field input, .field textarea, .dialog textarea, .dialog input[type="file"] {
  font: inherit; font-size: 15px; padding: 9px 10px; border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--paper); color: var(--ink); width: 100%; min-width: 0;
}
.field input.mono, .dialog textarea.mono { font-family: var(--mono); font-size: 14.5px; }
.field input[aria-invalid="true"] { border-color: var(--red); background: #FFF8F7; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.field-set { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px 2px; margin: 0 0 12px; }
.field-set legend { padding: 0 6px; }
.field-hint { font-size: 12.5px; color: var(--muted); margin: -4px 0 8px; }
.field-error { font-size: 12.5px; color: var(--red); font-weight: 600; }
.form-error { padding: 10px 12px; border-radius: 8px; background: var(--red-tint); color: #8A2A22; font-weight: 600; margin-bottom: 12px; }
.req { color: var(--red); }
.radio { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; margin-bottom: 8px; font-weight: 400; }
.radio input { width: auto; margin-top: 3px; }

/* ---------- dialog ---------- */
.dialog { border: 0; border-radius: var(--radius); padding: 22px 24px; width: min(560px, calc(100vw - 24px)); box-shadow: var(--shadow); color: var(--ink); }
.dialog::backdrop { background: rgba(34, 48, 58, 0.5); }
.dialog h2 { font-size: 20px; color: var(--slate); margin-bottom: 6px; }
.dialog-text { color: var(--muted); margin-bottom: 14px; }
.dialog .field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }

/* ---------- toast / footer ---------- */
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 20px);
  background: var(--slate-deep); color: #FFFFFF; padding: 10px 16px; border-radius: 8px; font-size: 14px;
  opacity: 0; pointer-events: none; z-index: 60; max-width: calc(100vw - 32px); box-shadow: var(--shadow);
  transition: opacity 160ms ease, transform 160ms ease;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.footer { padding: 16px clamp(14px, 3vw, 32px) 28px; color: var(--muted); font-size: 12.5px; text-align: center; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .col-retailer { display: none; }
}
@media (max-width: 680px) {
  .col-purchased { display: none; }
  .field-row { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .col-serial { display: none; }
  .row-sub-serial { display: inline; }
  .ledger-table th, .ledger-table td { padding: 10px 10px; }
  .toolbar .btn { padding: 7px 10px; font-size: 13px; min-height: 34px; }
  .detail-list { grid-template-columns: 1fr; gap: 2px 0; }
  .detail-list dd { margin-bottom: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .drawer, .drawer.is-open, .toast, .row { transition: none; }
}

/* ---------- print: the ledger as a paper record ---------- */
@media print {
  body { background: #FFFFFF; color: #000000; font-size: 11pt; }
  .topbar, .skip-link, .search-hint, .hero-meta, .backdrop, .drawer, .dialog, .toast, .footer, .sort, .no-results, .row-btn .row-sub-serial { display: none !important; }
  .hero { background: none; color: #000000; padding: 0 0 8pt; }
  .hero-title { font-size: 16pt; }
  .search-box { box-shadow: none; border: 1px solid #999999; }
  .search-label { color: #333333; }
  .main { padding: 0; }
  .table-wrap { border: 0; box-shadow: none; overflow: visible; }
  .ledger-table th, .ledger-table td { padding: 5pt 6pt; border-bottom: 1px solid #999999; }
  .col-retailer, .col-purchased, .col-serial { display: table-cell !important; }
  .row { break-inside: avoid; box-shadow: none; }
  .pill { border: 1px solid #666666; background: none !important; color: #000000 !important; }
  .row-btn { color: #000000; }
}
