:root {
  --ink: #1f2b26;
  --muted: #68736f;
  --paper: #f6f2ea;
  --card: #fffdf8;
  --line: #ddd7cc;
  --forest: #334a40;
  --forest-dark: #1f2b26;
  --brown: #9a6038;
  --brown-dark: #744323;
  --lime: #75bd3f;
  --rust: #df2925;
  --shadow: 0 13px 35px rgba(30, 45, 39, .10);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: radial-gradient(circle at 8% 2%, #fffdfa 0, transparent 30rem), var(--paper); }
button, input, select { font: inherit; }
button { color: inherit; }
.hero { color: var(--ink); background: rgba(246, 242, 234, .96); border-bottom: 1px solid rgba(36, 49, 43, .14); }
.hero__inner, main { width: min(1500px, calc(100% - 40px)); margin: 0 auto; }
.hero__inner { min-height: 230px; display: grid; grid-template-columns: minmax(320px, 560px) 1fr auto; align-items: center; gap: 30px; padding: 34px 0; }
.brand-logo { width: 100%; max-width: 560px; height: auto; display: block; }
.hero__title { min-width: 310px; }
.eyebrow { margin: 0 0 9px; color: var(--brown-dark); text-transform: uppercase; letter-spacing: .15em; font-size: .74rem; font-weight: 800; }
h1 { margin: 0; color: var(--ink); font-family: Georgia, "Times New Roman", serif; font-size: clamp(2.5rem, 4.4vw, 4.6rem); line-height: .98; letter-spacing: -.045em; }
.subtitle { margin: 13px 0 0; color: #53625c; font-size: 1rem; }
.updated { max-width: 250px; padding: 10px 14px; border: 1px solid rgba(36,49,43,.2); border-radius: 999px; color: #46564f; background: rgba(255,255,255,.5); font-size: .82rem; text-align: center; }
.hero__actions { display: grid; justify-items: stretch; gap: 9px; }
.logout-link { padding: 10px 14px; border: 1px solid rgba(36,49,43,.2); border-radius: 999px; color: var(--brown-dark); background: rgba(255,255,255,.7); font-size: .82rem; font-weight: 750; text-decoration: none; }
.logout-link:hover { border-color: var(--brown); background: #fff; }
main { padding: 0 0 70px; }
.toolbar { position: relative; z-index: 2; margin-top: -1px; padding: 24px; background: var(--card); border-radius: 0 0 18px 18px; box-shadow: var(--shadow); }
.search { height: 58px; display: flex; align-items: center; gap: 12px; padding: 0 18px; border: 2px solid #ccd5d0; border-radius: 12px; background: #fff; transition: .2s; }
.search:focus-within { border-color: var(--brown); box-shadow: 0 0 0 4px rgba(154,96,56,.1); }
.search span { color: var(--brown); font-size: 2rem; line-height: 1; transform: rotate(-20deg); }
.search input { width: 100%; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 1.05rem; }
.quick-filters { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 18px; }
.chip { padding: 9px 13px; border: 1px solid #cbd2ce; border-radius: 999px; background: #fff; cursor: pointer; font-size: .86rem; font-weight: 700; transition: .15s; }
.chip:hover { border-color: var(--brown); transform: translateY(-1px); }
.chip.is-active { color: #fff; border-color: var(--brown); background: var(--brown); }
.selects { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 20px; }
.selects label { color: var(--muted); font-size: .73rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.selects select { width: 100%; margin-top: 6px; padding: 11px 36px 11px 12px; border: 1px solid #cbd2ce; border-radius: 9px; color: var(--ink); background: #fff; text-transform: none; letter-spacing: normal; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 25px 0 30px; }
.stat { display: flex; flex-direction: column; min-height: 92px; justify-content: center; padding: 18px 20px; background: rgba(255,255,255,.72); border: 1px solid rgba(31,92,72,.12); border-radius: 13px; }
.stat strong { color: var(--brown-dark); font-size: 1.7rem; letter-spacing: -.03em; }
.stat span { margin-top: 4px; color: var(--muted); font-size: .8rem; }
.result-line { display: flex; justify-content: space-between; align-items: center; gap: 15px; margin: 0 2px 16px; color: var(--muted); font-size: .87rem; }
.result-line strong { color: var(--ink); font-size: 1rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 24px; }
.material-card { min-width: 0; overflow: hidden; background: var(--card); border: 1px solid #e0e3df; border-radius: 16px; box-shadow: 0 4px 14px rgba(35,48,43,.05); transition: transform .18s, box-shadow .18s; }
.material-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.card-open { width: 100%; height: 100%; display: flex; flex-direction: column; padding: 0; border: 0; background: transparent; text-align: left; cursor: pointer; }
.image-wrap { position: relative; width: 100%; aspect-ratio: 16 / 9; overflow: hidden; background: #e6e6df; }
.image-wrap img { width: 100%; height: 100%; display: block; object-fit: cover; transition: transform .3s; }
.material-card:hover img { transform: scale(1.025); }
.source-badges { position: absolute; top: 11px; left: 11px; display: flex; flex-wrap: wrap; gap: 6px; }
.badge { padding: 5px 8px; color: #fff; background: rgba(21,62,50,.9); border-radius: 5px; font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; backdrop-filter: blur(4px); }
.badge--rest { background: rgba(184,91,57,.92); }
.badge--type { color: var(--ink); background: rgba(246,242,234,.94); }
.card-body { width: 100%; flex: 1; display: flex; flex-direction: column; padding: 22px 23px 23px; }
.material-code { margin: 0 0 7px; color: var(--brown-dark); font-size: .8rem; font-weight: 850; letter-spacing: .055em; overflow-wrap: anywhere; }
.material-description { min-height: 2.4em; margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 1.25rem; line-height: 1.2; }
.card-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.metric { padding: 11px 12px; background: #f2eee6; border-radius: 8px; }
.metric strong, .metric span { display: block; }
.metric strong { font-size: .94rem; }
.metric span { margin-top: 2px; color: var(--muted); font-size: .67rem; }
.formats-preview { min-height: 2.6em; margin: 13px 0 0; color: var(--muted); font-size: .78rem; line-height: 1.4; }
.details-link { display: flex; justify-content: space-between; margin-top: auto; padding-top: 17px; color: var(--brown-dark); font-size: .82rem; font-weight: 800; }
.details-link span { font-size: 1.1rem; }
.empty { padding: 70px 20px; color: var(--muted); text-align: center; }
.empty h2 { color: var(--ink); }
.modal { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 25px; }
.modal[hidden] { display: none; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(11,25,20,.72); backdrop-filter: blur(4px); }
.modal__panel { position: relative; width: min(1050px, 100%); max-height: min(860px, calc(100vh - 40px)); overflow: auto; padding: 28px; background: var(--card); border-radius: 18px; box-shadow: 0 25px 80px rgba(0,0,0,.35); }
.modal__close { position: sticky; z-index: 2; top: 0; float: right; width: 38px; height: 38px; border: 0; border-radius: 50%; color: #fff; background: var(--forest-dark); cursor: pointer; font-size: 1.6rem; line-height: 1; }
.modal-head { display: grid; grid-template-columns: 260px 1fr; gap: 24px; margin-bottom: 22px; }
.modal-head img { width: 100%; aspect-ratio: 16/10; object-fit: cover; border-radius: 12px; background: #eee; }
.modal-head h2 { margin: 4px 45px 7px 0; font-size: 1.7rem; }
.modal-head p { margin: 0; color: var(--muted); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 11px; }
table { width: 100%; border-collapse: collapse; font-size: .82rem; }
th { position: sticky; top: 0; padding: 11px 10px; color: #fff; background: var(--forest-dark); text-align: left; white-space: nowrap; }
td { padding: 11px 10px; border-top: 1px solid var(--line); vertical-align: top; }
tr:nth-child(even) td { background: #f6f6f1; }
.code-cell { max-width: 230px; overflow-wrap: anywhere; font-weight: 700; }
body.modal-open { overflow: hidden; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-shell { width: min(560px, 100%); padding: 0; }
.login-card { padding: 38px; border: 1px solid rgba(31,92,72,.14); border-radius: 20px; background: var(--card); box-shadow: var(--shadow); }
.login-logo { width: 100%; max-width: 390px; height: auto; margin-bottom: 28px; }
.login-card h1 { font-size: clamp(2.1rem, 7vw, 3.2rem); line-height: 1; white-space: nowrap; }
.login-intro { margin: 16px 0 25px; color: var(--muted); line-height: 1.5; }
.login-card form { display: grid; gap: 17px; }
.login-card label { color: var(--muted); font-size: .78rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.login-card input { width: 100%; margin-top: 7px; padding: 13px 14px; border: 1px solid #cbd2ce; border-radius: 9px; color: var(--ink); background: #fff; text-transform: none; letter-spacing: normal; }
.login-card input:focus { outline: 0; border-color: var(--brown); box-shadow: 0 0 0 4px rgba(154,96,56,.1); }
.login-card button { padding: 13px 18px; border: 0; border-radius: 9px; color: #fff; background: var(--brown); cursor: pointer; font-weight: 800; }
.login-card button:hover { background: var(--brown-dark); }
.login-message { margin: 0 0 20px; padding: 13px 14px; border-radius: 9px; font-size: .86rem; line-height: 1.45; }
.login-message--warning { color: #6c4817; background: #fff1c8; border: 1px solid #e8c66b; }
.login-message--error { color: #7a211e; background: #fde4e2; border: 1px solid #e2a3a0; }

@media (max-width: 780px) {
  .hero__inner { min-height: 165px; display: flex; align-items: start; flex-direction: column; padding: 26px 0; }
  .brand-logo { max-width: 620px; }
  .updated { text-align: left; }
  .selects { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .modal-head { grid-template-columns: 1fr; }
  .modal-head img { max-height: 250px; }
}

@media (max-width: 480px) {
  .hero__inner, main { width: min(100% - 22px, 1500px); }
  .toolbar { padding: 15px; }
  .search { height: 52px; }
  .stats { gap: 8px; }
  .stat { padding: 13px; }
  .stat strong { font-size: 1.35rem; }
  .grid { grid-template-columns: 1fr; }
  .modal { padding: 8px; }
  .modal__panel { max-height: calc(100vh - 16px); padding: 16px; border-radius: 12px; }
  .login-page { padding: 12px; }
  .login-card { padding: 26px 22px; }
  .login-card h1 { font-size: clamp(1.9rem, 9vw, 2.35rem); }
}
