:root {
  --ink: #173029;
  --muted: #62706b;
  --green: #183d31;
  --green-2: #2f6d55;
  --mint: #dff3e9;
  --cream: #f7f4eb;
  --paper: #fff;
  --gold: #f0b84b;
  --danger: #ad342f;
  --line: #d8dfdb;
  --shadow: 0 14px 35px rgba(23, 48, 41, .10);
  --radius: 18px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { color-scheme: light; scroll-behavior: smooth; }
body { margin: 0; background: var(--cream); color: var(--ink); font: 16px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
a { color: var(--green-2); text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; }
button, .button, input, select { min-height: 44px; }
img { max-width: 100%; }
h1, h2 { line-height: 1.13; letter-spacing: -.025em; }
h1 { margin: .2rem 0 .7rem; font-size: clamp(2rem, 5vw, 3.6rem); }
h2 { font-size: 1.3rem; }
p { margin: .45rem 0 1rem; }
.skip-link { position: fixed; left: 1rem; top: -5rem; z-index: 100; background: #fff; padding: .75rem; }
.skip-link:focus { top: 1rem; }
.site-header { min-height: 70px; padding: .8rem max(1rem, calc((100vw - 1180px)/2)); background: var(--green); color: white; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.site-header a, .site-header button { color: white; text-decoration: none; }
.site-header nav { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: .8rem; }
.brand { display: inline-flex; align-items: center; gap: .65rem; font-weight: 800; font-size: 1.12rem; white-space: nowrap; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: var(--gold); color: var(--green); font-size: .8rem; letter-spacing: .08em; }
.inline-form { display: inline; }
.link-button { border: 0; background: transparent; padding: 0; min-height: auto; cursor: pointer; }
.identity { padding: .4rem max(1rem, calc((100vw - 1180px)/2)); background: #e4eee9; color: var(--green); text-align: right; font-size: .88rem; }
.container { width: min(1180px, calc(100% - 2rem)); margin: 0 auto; padding: clamp(1.2rem, 4vw, 3rem) 0 4rem; min-height: calc(100vh - 160px); }
.back-nav { margin-bottom: 1.2rem; }
footer { padding: 1.5rem; background: #102b22; color: #d7e5df; text-align: center; }
.eyebrow { margin: 0; color: var(--green-2); font-weight: 800; letter-spacing: .12em; text-transform: uppercase; font-size: .76rem; }
.muted { color: var(--muted); }
.hero { padding: clamp(2.2rem, 7vw, 5rem); border-radius: 28px; color: white; background: radial-gradient(circle at 85% 15%, #3b7961, var(--green) 50%); box-shadow: var(--shadow); }
.hero .eyebrow { color: #c9eadc; }
.hero p { max-width: 680px; font-size: 1.15rem; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; }
.button { display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 12px; padding: .68rem 1rem; font-weight: 750; text-decoration: none; cursor: pointer; }
.button.primary { color: white; background: var(--green-2); }
.hero .button.primary { background: var(--gold); color: var(--green); }
.button.secondary { color: var(--green); background: white; border-color: var(--green-2); }
.button.ghost { color: var(--green-2); background: transparent; border-color: var(--line); }
.button.success { color: white; background: #167149; }
.button.small { min-height: 36px; padding: .3rem .7rem; }
.button.full { width: 100%; }
.button:disabled { cursor: not-allowed; opacity: .55; }
.button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.feature-grid, .quick-grid, .stats-grid, .catalog-grid, .split-grid { display: grid; gap: 1rem; margin: 1.2rem 0 2rem; }
.feature-grid { grid-template-columns: repeat(3, 1fr); }
.feature { padding: 1.4rem; background: white; border-radius: var(--radius); box-shadow: var(--shadow); }
.feature > span { display: grid; place-items: center; width: 34px; height: 34px; background: var(--mint); border-radius: 50%; font-weight: 800; }
.feature h2 { margin-bottom: .25rem; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-heading h1 { font-size: clamp(2rem, 4vw, 3rem); }
.quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.quick-card { padding: 1.4rem; border-radius: var(--radius); background: white; color: var(--ink); box-shadow: var(--shadow); text-decoration: none; display: grid; gap: .25rem; }
.quick-card.accent { background: var(--green); color: white; }
.quick-card strong { font-size: 1.2rem; }
.quick-card small { opacity: .78; }
.quick-icon { font-size: 1.8rem; }
.card-list { display: grid; gap: .75rem; }
.book-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem 1.2rem; background: white; border: 1px solid var(--line); border-radius: 14px; }
.book-row p { margin: .2rem 0; color: var(--muted); }
.empty { grid-column: 1/-1; padding: 2rem; color: var(--muted); text-align: center; background: rgba(255,255,255,.55); border: 1px dashed #aab8b1; border-radius: var(--radius); }
.form-card { max-width: 820px; margin: 0 auto; padding: clamp(1.2rem, 4vw, 2.2rem); background: white; border-radius: var(--radius); box-shadow: var(--shadow); }
.form-card.narrow { max-width: 570px; }
form p { display: grid; gap: .35rem; }
label { font-weight: 700; }
input:not([type="checkbox"]):not([type="radio"]), select, textarea { width: 100%; border: 1px solid #aebbb5; border-radius: 10px; padding: .65rem .72rem; background: #fff; color: var(--ink); }
input[type="checkbox"] { width: 18px; height: 18px; }
.helptext { color: var(--muted); font-size: .86rem; }
.errorlist { padding: .7rem 1rem .7rem 2rem; background: #fbe8e7; color: #842a25; border-radius: 9px; }
.alert { margin-bottom: 1rem; padding: .9rem 1rem; border-radius: 12px; border: 1px solid; background: white; }
.alert-success { color: #145b3d; border-color: #6eb693; background: #e6f5ed; }
.alert-error { color: #842a25; border-color: #df8a85; background: #fbe8e7; }
.alert-warning { color: #714d04; border-color: #e2bd62; background: #fff5d6; }
.search { padding: 1rem; background: white; border-radius: 14px; }
.search > div { display: flex; gap: .6rem; margin-top: .4rem; }
.catalog-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.book-card { overflow: hidden; background: white; border-radius: var(--radius); box-shadow: var(--shadow); }
.book-card > img, .book-card > .cover-placeholder, .book-card > .generated-cover { width: 100%; aspect-ratio: 4/2.7; object-fit: cover; }
.book-card > div:last-child { padding: 1.1rem; }
.book-card h2 { margin: .3rem 0; }
.cover-placeholder { display: grid; place-items: center; background: linear-gradient(145deg, var(--green), var(--green-2)); color: var(--gold); font-size: 2rem; font-weight: 900; }
.generated-cover { display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; padding: clamp(1rem, 4vw, 1.7rem); background: linear-gradient(150deg, #173f32 0%, #2f6d55 72%, #183d31 100%); color: white; border-radius: 14px; }
.generated-cover.catalog-cover { padding: 1rem; border-radius: 0; }
.generated-cover.catalog-cover .generated-cover-body { gap: .35rem; }
.generated-cover.catalog-cover .generated-cover-title { font-size: clamp(1rem, 1.7vw, 1.25rem); -webkit-line-clamp: 2; }
.generated-cover.catalog-cover .generated-cover-author { font-size: .8rem; -webkit-line-clamp: 1; }
.generated-cover.catalog-cover .generated-cover-footer { margin-top: .5rem; }
.generated-cover.catalog-cover .generated-cover-footer > strong { font-size: .75rem; }
.generated-cover.catalog-cover .generated-cover-logo { width: 40px; height: 40px; font-size: .7rem; }
.generated-cover-body { display: grid; gap: .65rem; min-height: 0; }
.generated-cover-title { display: -webkit-box; overflow: hidden; color: white; font-size: clamp(1.05rem, 2.3vw, 1.65rem); line-height: 1.08; letter-spacing: -.02em; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.generated-cover-author { display: -webkit-box; overflow: hidden; color: #d9eee5; font-size: clamp(.78rem, 1.6vw, 1rem); -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.generated-cover-footer { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-top: 1rem; }
.generated-cover-footer > strong { font-size: clamp(.72rem, 1.5vw, .95rem); }
.generated-cover-logo { display: grid; place-items: center; flex: 0 0 auto; width: 54px; height: 54px; border-radius: 50%; background: var(--gold); color: var(--green); font-size: .9rem; font-weight: 950; letter-spacing: .08em; box-shadow: 0 5px 14px rgba(0, 0, 0, .18); }
.generated-cover.detail-cover { min-height: 360px; }
.generated-cover.detail-cover .generated-cover-title { font-size: clamp(1.35rem, 3vw, 2rem); -webkit-line-clamp: 6; }
.generated-cover.detail-cover .generated-cover-author { font-size: 1.05rem; -webkit-line-clamp: 4; }
.availability { display: inline-block; padding: .2rem .6rem; border-radius: 999px; background: #f5e1df; color: var(--danger); font-size: .83rem; font-weight: 750; }
.availability.available { background: var(--mint); color: #15583c; }
.detail-card { display: grid; grid-template-columns: minmax(180px, 300px) 1fr; gap: clamp(1.5rem, 5vw, 4rem); padding: clamp(1.2rem, 4vw, 2.5rem); background: white; border-radius: 24px; box-shadow: var(--shadow); }
.detail-cover { width: 100%; aspect-ratio: 2/3; object-fit: cover; border-radius: 14px; }
.notice { padding: .8rem 1rem; background: var(--mint); border-radius: 10px; }
.scan-form { max-width: 720px; margin: 0 auto; display: grid; gap: 1rem; }
.scan-step { display: grid; grid-template-columns: 44px 1fr; gap: 1rem; padding: 1.2rem; background: white; border: 1px solid var(--line); border-radius: var(--radius); }
.scan-step > div { min-width: 0; }
.scan-step h2 { margin: 0; }
.step-number { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--green); color: white; font-weight: 900; }
.manual { display: grid; gap: .3rem; margin-top: .8rem; color: var(--muted); font-size: .86rem; }
.field-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: .75rem; }
.field-section { display: grid; gap: .75rem; margin: 1.3rem 0; padding: 1rem; border: 1px solid var(--line); border-radius: 14px; background: #f8faf9; }
.field-section h2 { margin: 0; }
.scan-step.compact { grid-template-columns: 1fr; padding: .85rem 1rem; }
.scan-step.compact p { margin: 0; }
.scanner-panel { padding: 1rem; background: #0e1814; color: white; border-radius: var(--radius); }
#scanner-reader { overflow: hidden; border-radius: 12px; }
.metadata-card { display: grid; grid-template-columns: 118px minmax(0, 1fr); gap: 1.25rem; align-items: start; width: 100%; margin: 1rem 0; padding: 1rem; border: 1px solid #9bc9b4; border-radius: 14px; background: var(--mint); }
.metadata-card.no-cover { grid-template-columns: minmax(0, 1fr); }
.metadata-card img { width: 118px; max-height: 176px; object-fit: contain; background: white; border-radius: 8px; }
.metadata-content { min-width: 0; }
.metadata-content > strong { display: block; margin-bottom: .65rem; font-size: 1.02rem; }
.metadata-summary { display: grid; gap: .35rem; margin: 0; }
.metadata-summary div { display: grid; grid-template-columns: minmax(82px, 25%) minmax(0, 1fr); gap: .65rem; }
.metadata-summary dt { font-weight: 700; }
.metadata-summary dd { min-width: 0; margin: 0; overflow-wrap: anywhere; }
.isbn-lookup-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin: -.35rem 0 1.2rem; }
.admin-nav { display: flex; gap: .35rem; overflow-x: auto; margin: -1rem 0 2rem; padding: .4rem; background: white; border-radius: 12px; box-shadow: 0 4px 15px rgba(23,48,41,.06); }
.admin-nav a { flex: 0 0 auto; padding: .65rem .8rem; border-radius: 9px; text-decoration: none; font-weight: 700; }
.admin-nav a:hover { background: var(--mint); }
.stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stats-grid article { padding: 1.2rem; background: white; border-radius: 15px; box-shadow: var(--shadow); display: grid; }
.stats-grid strong { font-size: 2.1rem; }
.stats-grid span { color: var(--muted); }
.stats-grid .danger-stat { border-left: 5px solid var(--danger); }
.table-wrap { overflow-x: auto; background: white; border-radius: 14px; border: 1px solid var(--line); -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: .75rem .8rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--green); background: #eef4f1; white-space: nowrap; }
td { overflow-wrap: anywhere; }
.shelf-card { display: grid; grid-template-columns: 140px 1fr; align-items: center; gap: 1rem; padding: 1rem; background: white; border-radius: var(--radius); }
.shelf-card img { width: 140px; }
.row-form { display: flex; align-items: center; gap: .5rem; }
.row-form select { width: auto; }
.row-form label { white-space: nowrap; }
.filters { display: grid; grid-template-columns: 1.2fr 1.5fr 1fr 1fr auto; align-items: end; gap: .7rem; padding: 1rem; background: white; border-radius: 14px; }
.filters label { display: grid; gap: .3rem; font-size: .85rem; }
.export-actions { margin: 1rem 0; }
.split-grid { grid-template-columns: repeat(2, 1fr); }
.split-grid .form-card { width: 100%; }
.simple-list { margin-top: 1.2rem; padding-left: 1.2rem; }
.holiday-sync-form { display: grid; grid-template-columns: minmax(150px, 1fr) auto; align-items: end; gap: .75rem; margin: 1rem 0; }
.holiday-sync-form label { display: block; margin-bottom: .35rem; font-weight: 700; }
.holiday-sync-form input { width: 100%; }
.settings-divider { height: 1px; margin: 1.5rem 0; background: var(--line); }
.holiday-list li { margin-bottom: .45rem; }
.settings-grid .policy-card { grid-column: 1 / -1; max-width: none; }
.policy-form { max-width: 520px; }
.holiday-years { display: grid; gap: 1rem; }
.holiday-year { padding: 1rem; border: 1px solid var(--line); border-radius: 12px; background: #f8faf9; }
.holiday-year h4 { margin: 0; font-size: 1.15rem; }
.holiday-year .simple-list { margin-bottom: 0; }

@media (max-width: 820px) {
  .feature-grid, .catalog-grid, .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { grid-template-columns: repeat(2, 1fr); }
  .detail-card { grid-template-columns: 180px 1fr; }
}
@media (max-width: 620px) {
  .site-header { align-items: flex-start; }
  .site-header nav { gap: .55rem; font-size: .88rem; }
  .identity { text-align: left; }
  .container { width: min(100% - 1.2rem, 1180px); }
  .feature-grid, .quick-grid, .catalog-grid, .stats-grid, .split-grid { grid-template-columns: 1fr; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .book-row { align-items: stretch; flex-direction: column; }
  .book-row .button { width: 100%; }
  .detail-card { grid-template-columns: 1fr; }
  .detail-card > div:first-child { max-width: 230px; }
  .filters { grid-template-columns: 1fr; }
  .row-form { align-items: stretch; flex-direction: column; }
  .row-form select { width: 100%; }
  .holiday-sync-form { grid-template-columns: 1fr; }
  .holiday-sync-form .button { width: 100%; }
  .search > div { flex-direction: column; }
  .shelf-card { grid-template-columns: 110px 1fr; }
  .shelf-card img { width: 110px; }
  .admin-nav { margin-bottom: 1.25rem; font-size: .84rem; }
  .admin-nav a { padding: .55rem .65rem; }
  .table-wrap { overflow: visible; border: 0; background: transparent; }
  .responsive-table, .responsive-table tbody, .responsive-table tr, .responsive-table td { display: block; width: 100%; }
  .responsive-table { font-size: .82rem; }
  .responsive-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .responsive-table tr { margin-bottom: .85rem; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: white; box-shadow: 0 5px 14px rgba(23,48,41,.05); }
  .responsive-table td { display: grid; grid-template-columns: minmax(90px, 32%) minmax(0, 1fr); gap: .65rem; padding: .62rem .75rem; border-bottom: 1px solid #e7ece9; }
  .responsive-table td:last-child { border-bottom: 0; }
  .responsive-table td::before { content: attr(data-label); color: var(--green); font-weight: 800; }
  .responsive-table td:not([data-label]) { display: block; }
  .responsive-table td:not([data-label])::before { display: none; }
  .responsive-table .row-form { width: 100%; }
  .responsive-table .button { width: 100%; }
}

@media (max-width: 480px) {
  .book-form-card { padding: 1.15rem; }
  .metadata-card { grid-template-columns: 86px minmax(0, 1fr); gap: .9rem; padding: .9rem; }
  .metadata-card.no-cover { grid-template-columns: minmax(0, 1fr); }
  .metadata-card img { width: 86px; max-height: 132px; }
  .metadata-summary div { grid-template-columns: 1fr; gap: 0; }
  .metadata-summary div + div { padding-top: .25rem; border-top: 1px solid rgba(24, 61, 49, .12); }
}

@media print {
  .site-header, .identity, footer, .admin-nav, .back-nav, .actions, button { display: none !important; }
  body { background: white; }
  .container { width: 100%; padding: 0; }
}
