:root {
  color-scheme: light;
  --ink: #16212a;
  --muted: #68747d;
  --paper: #f4f0e7;
  --surface: #fffdf8;
  --line: #dcd5c7;
  --accent: #147d78;
  --accent-dark: #0c5b58;
  --sun: #e9a23b;
  --danger: #a33b35;
  --shadow: 0 18px 50px rgba(31, 39, 43, .09);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--paper); color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: inherit; }
.site-header { min-height: 72px; padding: 0 max(24px, calc((100vw - 1180px) / 2)); display: flex; align-items: center; gap: 20px; border-bottom: 1px solid var(--line); background: rgba(255,253,248,.9); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-size: 20px; font-weight: 800; letter-spacing: -.03em; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: white; }
.tagline { color: var(--muted); font-size: 14px; }
.admin-link { margin-left: auto; color: var(--accent-dark); font-size: 14px; font-weight: 750; text-decoration: none; }
.logout-form { margin-left: auto; display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.logout-form button { padding: 8px 11px; background: #e7e1d6; color: var(--ink); font-size: 12px; }
.page-shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 54px 0 70px; }
.hero { display: grid; grid-template-columns: .95fr 1.05fr; gap: 56px; align-items: center; padding: 48px; border-radius: 28px; background: var(--ink); color: white; box-shadow: var(--shadow); }
.eyebrow { margin: 0 0 9px; color: var(--sun); font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 18px; font-size: clamp(36px, 5vw, 58px); line-height: .98; letter-spacing: -.055em; }
.intro { max-width: 540px; margin-bottom: 0; color: #cbd3d7; font-size: 18px; line-height: 1.6; }
.fetch-stack { display: grid; gap: 14px; }
.fetch-form { padding: 26px; border: 1px solid rgba(255,255,255,.12); border-radius: 19px; background: rgba(255,255,255,.07); }
.fetch-form label { display: block; margin-bottom: 10px; font-size: 14px; font-weight: 750; }
.input-row { display: flex; gap: 9px; }
input { min-width: 0; flex: 1; padding: 15px 17px; border: 1px solid transparent; border-radius: 10px; background: white; color: var(--ink); font: inherit; font-size: 16px; outline: none; }
input:focus { border-color: var(--sun); box-shadow: 0 0 0 3px rgba(233,162,59,.22); }
button, .button-link { border: 0; border-radius: 10px; padding: 15px 18px; background: var(--sun); color: #2d2417; font: inherit; font-weight: 800; cursor: pointer; text-decoration: none; white-space: nowrap; }
button:hover, .button-link:hover { filter: brightness(1.06); }
button:disabled { cursor: wait; filter: grayscale(.5); opacity: .65; }
.fetch-form small { display: block; margin-top: 11px; color: #b7c2c7; }
.fetch-form .check-option { display: flex; align-items: center; gap: 9px; margin: 13px 0 0; color: #dbe3e6; font-size: 13px; font-weight: 650; cursor: pointer; }
.fetch-form .check-option input { width: 17px; height: 17px; min-width: 17px; flex: 0 0 auto; margin: 0; padding: 0; accent-color: var(--sun); }
.fetch-form .check-option small { display: inline; margin: 0; color: #aebbc0; font-size: 11px; font-weight: 500; }
.import-status { display: grid; grid-template-columns: 1fr minmax(180px, 320px); align-items: center; gap: 28px; margin-top: 22px; padding: 20px 24px; border: 1px solid #9bc8b6; border-radius: 14px; background: #e4f4ec; color: #185b40; }
.import-status[hidden] { display: none; }
.import-status .eyebrow { margin-bottom: 5px; color: var(--accent-dark); }
.import-status strong, .import-status small { display: block; }
.import-status small { margin-top: 5px; }
.import-status progress { width: 100%; height: 12px; accent-color: var(--accent); }
.notice, .setup-card { margin-bottom: 22px; padding: 17px 20px; border-radius: 12px; }
.notice-success { border: 1px solid #9bc8b6; background: #e4f4ec; color: #185b40; }
.notice-error { border: 1px solid #dab1ab; background: #fae9e6; color: var(--danger); }
.setup-card { margin-top: 22px; border: 1px solid #e6c991; background: #fff6df; color: #624918; }
.setup-card p { margin: 5px 0 0; }
code { padding: 2px 5px; border-radius: 4px; background: rgba(0,0,0,.07); }
.collection { padding-top: 60px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.section-heading h2 { margin: 0; font-size: 31px; letter-spacing: -.04em; }
.count { color: var(--muted); font-size: 14px; }
.collection-toolbar { display: flex; align-items: end; justify-content: flex-end; gap: 12px; flex-wrap: wrap; }
.collection-toolbar .count { align-self: center; margin-right: 5px; }
.view-control { display: grid; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 750; letter-spacing: .03em; }
.view-control[hidden] { display: none; }
.view-control select { min-width: 112px; padding: 9px 32px 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--ink); font: inherit; font-size: 13px; font-weight: 700; outline: none; cursor: pointer; }
.view-control select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(20,125,120,.14); }
.card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.card-grid[data-view="gallery"][data-columns="4"] { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 17px; }
.card-grid[data-view="gallery"][data-columns="5"] { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
.set-card { min-width: 0; overflow: hidden; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: 0 7px 26px rgba(31,39,43,.04); text-decoration: none; transition: transform .18s ease, box-shadow .18s ease; }
.set-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.image-wrap { position: relative; min-width: 0; height: 230px; overflow: hidden; flex: 0 0 auto; display: grid; place-items: center; padding: 24px; background: white; border-bottom: 1px solid var(--line); }
.image-wrap img, .detail-image img { display: block; min-width: 0; min-height: 0; max-width: 100%; max-height: 100%; width: 100%; height: 100%; object-fit: contain; }
.image-placeholder { color: var(--muted); }
.card-body { min-width: 0; flex: 1; display: flex; flex-direction: column; padding: 20px; }
.set-number { color: var(--accent); font-size: 13px; font-weight: 800; letter-spacing: .06em; }
.card-body h3 { overflow-wrap: anywhere; margin: 7px 0 6px; font-size: 21px; letter-spacing: -.025em; }
.card-body p { min-height: 40px; color: var(--muted); font-size: 14px; line-height: 1.4; }
.stats { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }
.stats span { padding: 6px 9px; border-radius: 7px; background: #e8f2f0; color: var(--accent-dark); font-size: 12px; font-weight: 750; }
.card-grid[data-view="gallery"][data-columns="3"] .image-wrap { height: 260px; }
.card-grid[data-view="gallery"][data-columns="4"] .image-wrap { height: 210px; padding: 20px; }
.card-grid[data-view="gallery"][data-columns="5"] .image-wrap { height: 175px; padding: 16px; }
.card-grid[data-view="gallery"][data-columns="4"] .card-body { padding: 17px; }
.card-grid[data-view="gallery"][data-columns="5"] .card-body { padding: 15px; }
.card-grid[data-view="gallery"][data-columns="4"] .card-body h3 { font-size: 18px; }
.card-grid[data-view="gallery"][data-columns="5"] .card-body h3 { font-size: 16px; }
.card-grid[data-view="gallery"][data-columns="5"] .card-body p { min-height: 34px; font-size: 12px; }
.card-grid[data-view="gallery"][data-columns="5"] .stats { gap: 5px; }
.card-grid[data-view="gallery"][data-columns="5"] .stats span { padding: 5px 7px; font-size: 10px; }
.card-grid[data-view="list"] { display: flex; flex-direction: column; gap: 12px; }
.card-grid[data-view="list"] .set-card { min-height: 150px; display: grid; grid-template-columns: 180px minmax(0, 1fr); }
.card-grid[data-view="list"] .set-card:hover { transform: translateX(3px); }
.card-grid[data-view="list"] .image-wrap { width: 180px; height: 100%; min-height: 150px; padding: 16px; border-right: 1px solid var(--line); border-bottom: 0; }
.card-grid[data-view="list"] .card-body { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "number stats" "title stats" "meta stats"; align-content: center; column-gap: 24px; padding: 19px 22px; }
.card-grid[data-view="list"] .set-number { grid-area: number; }
.card-grid[data-view="list"] .card-body h3 { grid-area: title; margin: 5px 0; }
.card-grid[data-view="list"] .card-body p { grid-area: meta; min-height: 0; margin-bottom: 0; }
.card-grid[data-view="list"] .stats { grid-area: stats; align-self: center; justify-content: flex-end; margin-top: 0; }
.empty-state { padding: 70px 24px; border: 1px dashed #c7bdac; border-radius: 18px; text-align: center; color: var(--muted); }
.empty-state > span { display: inline-grid; place-items: center; width: 48px; height: 48px; margin-bottom: 15px; border-radius: 14px; background: #e5ded1; color: var(--ink); font-size: 25px; }
.empty-state h3, .empty-state h1 { margin-bottom: 8px; color: var(--ink); font-size: 24px; letter-spacing: -.03em; }
.standalone { max-width: 620px; margin: 60px auto; }
.standalone p { margin-bottom: 28px; }
.back-link { display: inline-block; margin-bottom: 22px; color: var(--accent-dark); font-weight: 750; text-decoration: none; }
.detail-card { display: grid; grid-template-columns: minmax(300px, .9fr) 1.1fr; overflow: hidden; border: 1px solid var(--line); border-radius: 25px; background: var(--surface); box-shadow: var(--shadow); }
.detail-image { min-height: 590px; display: grid; place-items: center; padding: 50px; background: white; border-right: 1px solid var(--line); }
.detail-content { padding: 48px; }
.detail-content h1 { margin-bottom: 35px; font-size: clamp(38px, 5vw, 60px); }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin: 0; border-top: 1px solid var(--line); }
.facts div { padding: 16px 10px 16px 0; border-bottom: 1px solid var(--line); }
.facts dt { margin-bottom: 5px; color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; }
.facts dd { margin: 0; font-weight: 720; }
.contents { display: flex; align-items: stretch; gap: 10px; margin-top: 30px; }
.contents h2 { align-self: center; margin: 0 auto 0 0; font-size: 20px; }
.content-stat { min-width: 105px; padding: 14px; border-radius: 12px; background: #e8f2f0; text-align: center; }
.content-stat strong { display: block; color: var(--accent-dark); font-size: 25px; }
.content-stat span { color: var(--muted); font-size: 12px; }
.stored-at { margin-top: 30px; color: var(--muted); font-size: 12px; }
.stored-at a { color: var(--accent-dark); }
.inventory-card { margin-top: 24px; padding: 28px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: 0 7px 26px rgba(31,39,43,.04); }
.inventory-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.inventory-heading h2 { margin: 0; font-size: 29px; letter-spacing: -.035em; }
.inventory-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 22px; }
.inventory-summary div { padding: 15px; border-radius: 12px; background: #e8f2f0; }
.inventory-summary strong { display: block; color: var(--accent-dark); font-size: 24px; }
.inventory-summary span { color: var(--muted); font-size: 11px; }
.inventory-tools { display: flex; align-items: end; gap: 14px; margin-bottom: 16px; }
.inventory-tools > label:first-child { flex: 1; }
.inventory-tools label > span:first-child { display: block; margin-bottom: 6px; color: var(--muted); font-size: 11px; font-weight: 750; }
.inventory-tools input[type="search"] { width: 100%; padding: 11px 13px; border-color: var(--line); font-size: 14px; }
.inventory-spare-toggle { display: flex; align-items: center; gap: 7px; min-height: 43px; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; background: white; cursor: pointer; }
.inventory-tools .inventory-spare-toggle > span { display: inline; margin: 0; color: var(--ink); font-size: 12px; }
.inventory-spare-toggle input { width: 15px; height: 15px; min-width: 15px; flex: 0 0 auto; margin: 0; padding: 0; accent-color: var(--accent); }
.inventory-tools > .count { align-self: center; min-width: 125px; text-align: right; }
.inventory-table-wrap { max-height: 680px; border: 1px solid var(--line); border-radius: 13px; }
.inventory-table { min-width: 760px; }
.inventory-table thead { position: sticky; top: 0; z-index: 1; background: var(--surface); }
.inventory-table td { height: 67px; }
.inventory-table tr[hidden] { display: none; }
.inventory-table td:nth-child(4) { width: 80px; text-align: center; }
.inventory-table td:nth-child(5) { width: 110px; }
.inventory-table td strong { display: block; }
.inventory-table td small { display: block; margin-top: 4px; color: var(--muted); }
.part-image-cell { width: 72px; }
.part-image-cell img, .part-image-placeholder { width: 48px; height: 48px; display: grid; place-items: center; object-fit: contain; border-radius: 8px; background: white; }
.part-image-placeholder { border: 1px dashed var(--line); color: var(--muted); }
.color-swatch { display: inline-block; width: 15px; height: 15px; margin-right: 7px; border: 1px solid rgba(0,0,0,.18); border-radius: 50%; background: var(--part-color, #ddd); vertical-align: -2px; }
.status-pill.regular { background: #e8f2f0; color: var(--accent-dark); }
.status-pill.spare { background: #fff0d7; color: #765218; }
.inventory-empty { padding: 34px; border: 1px dashed #c7bdac; border-radius: 14px; text-align: center; color: var(--muted); }
.inventory-empty strong { color: var(--ink); }
.inventory-empty p { max-width: 650px; margin: 8px auto 0; line-height: 1.5; }
footer { padding: 30px max(20px, calc((100vw - 1180px) / 2)); border-top: 1px solid var(--line); background: #ebe5da; color: var(--muted); font-size: 11px; line-height: 1.5; }
footer p { margin: 4px 0; }
.admin-heading { margin-bottom: 28px; }
.admin-heading h1 { margin-bottom: 14px; color: var(--ink); }
.intro-dark { max-width: 720px; color: var(--muted); font-size: 17px; line-height: 1.6; }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }
.admin-card, .admin-table-card { padding: 26px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: 0 7px 26px rgba(31,39,43,.04); }
.admin-card h2, .admin-table-card h2 { margin-bottom: 20px; font-size: 22px; }
.admin-card label { display: block; margin: 13px 0 7px; font-size: 13px; font-weight: 750; }
.admin-card input { width: 100%; border-color: var(--line); }
.admin-card button { margin-top: 16px; }
.admin-summary { display: grid; grid-template-columns: repeat(3, 1fr); align-items: center; gap: 12px; }
.admin-summary h2 { grid-column: 1 / -1; }
.admin-summary div { padding: 18px 10px; border-radius: 12px; background: #e8f2f0; text-align: center; }
.admin-summary strong { display: block; color: var(--accent-dark); font-size: 30px; }
.admin-summary span { color: var(--muted); font-size: 12px; }
.admin-table-card { margin-bottom: 24px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.status-pill { display: inline-block; padding: 5px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.status-pill.active { background: #daf0e4; color: #17633f; }
.status-pill.inactive { background: #f5dfdc; color: #8b302a; }
.small-button { margin: 0; padding: 8px 10px; font-size: 11px; }
.danger-button { background: #eed1cc; color: #762923; }
.table-empty { padding: 30px; color: var(--muted); text-align: center; }
.url-cell { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.log-heading h2 { margin-bottom: 0; }
.log-hint { margin: 10px 0 16px; color: var(--muted); font-size: 13px; }
.log-output { height: 330px; margin: 0; overflow: auto; padding: 16px; border-radius: 12px; background: #10191f; color: #d8e4e8; font: 12px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.login-shell { min-height: 650px; display: grid; grid-template-columns: 1fr 1fr; overflow: hidden; border-radius: 26px; background: var(--surface); box-shadow: var(--shadow); }
.login-aside { padding: 60px; background: var(--ink); color: white; }
.login-icon { display: grid; place-items: center; width: 52px; height: 52px; margin-bottom: 65px; border-radius: 15px; background: var(--accent); font-size: 25px; }
.login-aside h1 { margin-bottom: 22px; }
.login-aside > p:last-of-type { max-width: 500px; color: #cbd3d7; font-size: 17px; line-height: 1.6; }
.login-aside ul { margin: 34px 0 0; padding: 0; list-style: none; color: #dbe2e5; }
.login-aside li { margin: 13px 0; }
.login-aside li::before { content: "✓"; margin-right: 10px; color: var(--sun); font-weight: 900; }
.login-form { align-self: center; padding: 58px; }
.login-form h2 { margin-bottom: 9px; font-size: 34px; letter-spacing: -.04em; }
.login-hint { margin-bottom: 28px; color: var(--muted); line-height: 1.5; }
.login-form label { display: block; margin: 15px 0 7px; font-size: 13px; font-weight: 800; }
.login-form input { width: 100%; border-color: var(--line); background: white; }
.login-form button { width: 100%; margin-top: 22px; }
.login-form button:disabled { cursor: not-allowed; filter: grayscale(1); opacity: .55; }
.login-back { display: block; margin-top: 22px; color: var(--accent-dark); text-align: center; text-decoration: none; font-size: 13px; font-weight: 700; }

@media (max-width: 1050px) {
  .card-grid[data-view="gallery"][data-columns] { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 17px; }
  .card-grid[data-view="gallery"][data-columns] .image-wrap { height: 220px; padding: 20px; }
  .card-grid[data-view="gallery"][data-columns] .card-body { padding: 17px; }
  .card-grid[data-view="gallery"][data-columns] .card-body h3 { font-size: 18px; }
  .card-grid[data-view="gallery"][data-columns] .card-body p { min-height: 40px; font-size: 13px; }
  .card-grid[data-view="gallery"][data-columns] .stats { gap: 7px; }
  .card-grid[data-view="gallery"][data-columns] .stats span { padding: 6px 8px; font-size: 11px; }
}

@media (max-width: 850px) {
  .hero, .detail-card { grid-template-columns: 1fr; }
  .admin-grid { grid-template-columns: 1fr; }
  .login-shell { grid-template-columns: 1fr; }
  .login-aside { padding: 35px; }
  .login-icon { margin-bottom: 30px; }
  .section-heading { align-items: start; }
  .collection-toolbar { max-width: 390px; }
  .card-grid[data-view="gallery"][data-columns] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card-grid[data-view="list"] .set-card { grid-template-columns: 150px minmax(0, 1fr); }
  .card-grid[data-view="list"] .image-wrap { width: 150px; }
  .card-grid[data-view="list"] .card-body { grid-template-columns: 1fr; grid-template-areas: "number" "title" "meta" "stats"; }
  .card-grid[data-view="list"] .stats { justify-content: flex-start; margin-top: 12px; }
  .detail-image { min-height: 360px; border-right: 0; border-bottom: 1px solid var(--line); }
  .inventory-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inventory-tools { align-items: stretch; flex-wrap: wrap; }
  .inventory-tools > label:first-child { flex-basis: 100%; }
  .inventory-tools > .count { margin-left: auto; }
}
@media (max-width: 580px) {
  .page-shell { width: min(100% - 24px, 1180px); padding-top: 24px; }
  .site-header { padding: 0 16px; }
  .tagline { display: none; }
  .hero { gap: 30px; padding: 28px 20px; border-radius: 19px; }
  .input-row { flex-direction: column; }
  .import-status { grid-template-columns: 1fr; }
  .section-heading { align-items: stretch; flex-direction: column; }
  .collection-toolbar { justify-content: flex-start; max-width: none; }
  .collection-toolbar .count { width: 100%; }
  .view-control { flex: 1; }
  .view-control select { width: 100%; }
  .card-grid[data-view="gallery"][data-columns] { grid-template-columns: 1fr; }
  .card-grid[data-view="gallery"][data-columns] .image-wrap { height: 250px; }
  .card-grid[data-view="list"] .set-card { min-height: 112px; grid-template-columns: 112px minmax(0, 1fr); }
  .card-grid[data-view="list"] .image-wrap { width: 112px; min-height: 112px; padding: 10px; }
  .card-grid[data-view="list"] .card-body { padding: 14px; }
  .card-grid[data-view="list"] .card-body h3 { font-size: 17px; }
  .card-grid[data-view="list"] .card-body p { font-size: 12px; }
  .facts { grid-template-columns: 1fr; }
  .detail-content { padding: 28px 22px; }
  .detail-image { min-height: 300px; padding: 28px; }
  .inventory-card { padding: 20px 14px; }
  .inventory-heading { align-items: start; flex-direction: column; }
  .inventory-summary { gap: 7px; }
  .inventory-summary div { padding: 12px; }
  .inventory-summary strong { font-size: 20px; }
  .inventory-spare-toggle { flex: 1; }
  .inventory-tools > .count { width: 100%; margin-left: 0; text-align: left; }
  .contents { flex-wrap: wrap; }
  .contents h2 { width: 100%; margin-bottom: 5px; }
}
