:root {
  --ink: #101513;
  --muted: #68716d;
  --paper: #f3f5f1;
  --card: #fff;
  --line: #dce1dc;
  --lime: #c8f135;
  --lime-dark: #91b300;
  --danger: #b62d2d;
  --shadow: 0 18px 50px rgba(16, 21, 19, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-size: 16px;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--paper); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.topbar {
  height: 78px; padding: 0 max(24px, calc((100vw - 1280px) / 2));
  display: flex; align-items: center; justify-content: space-between;
  background: var(--ink); color: #fff; border-bottom: 1px solid #29302d;
}
.brand { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 12px; }
.brand > span:last-child { display: grid; line-height: 1.05; }
.brand strong { font-size: 1.05rem; letter-spacing: -.02em; }
.brand small { margin-top: 5px; color: #9fa7a3; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; }
.brand-mark { width: 40px; height: 40px; border-radius: 9px; display: grid; place-items: center; background: var(--lime); color: var(--ink); font-size: 1.3rem; font-weight: 900; overflow: hidden; }
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.companion-state { color: #bbc2be; font-size: .82rem; margin-right: 10px; }
.companion-state i { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 0 4px rgba(200, 241, 53, .1); }

.button { min-height: 42px; border: 1px solid transparent; border-radius: 8px; padding: 0 18px; font-weight: 750; transition: .18s ease; }
.button:hover { transform: translateY(-1px); }
.button.primary { color: var(--ink); background: var(--lime); box-shadow: 0 5px 16px rgba(145, 179, 0, .16); }
.button.primary:hover { background: #d5fa4e; }
.button.ghost { border-color: #3a423e; color: inherit; background: transparent; }
.button.ghost:hover { border-color: #747d78; }

main { min-height: calc(100vh - 78px); }
.hero { background: var(--ink); color: #fff; padding: 64px max(24px, calc((100vw - 1280px) / 2)) 82px; display: flex; align-items: flex-end; justify-content: space-between; gap: 50px; }
.eyebrow { margin: 0 0 12px; font-size: .73rem; font-weight: 850; letter-spacing: .16em; color: var(--lime-dark); }
.hero .eyebrow { color: var(--lime); }
h1 { margin: 0; font-size: clamp(3rem, 6vw, 5.3rem); line-height: .96; letter-spacing: -.065em; }
h1 em { font-family: Georgia, serif; font-weight: 400; color: var(--lime); }
.lead { max-width: 630px; margin: 25px 0 0; color: #aab2ae; font-size: 1.05rem; line-height: 1.65; }
.stats { display: flex; flex: 0 0 auto; border: 1px solid #333b37; border-radius: 12px; overflow: hidden; }
.stats div { min-width: 125px; padding: 22px 24px; border-right: 1px solid #333b37; }
.stats div:last-child { border: 0; }
.stats span, .stats small { display: block; }
.stats span { font-size: 1.8rem; font-weight: 800; }
.stats small { margin-top: 4px; color: #8e9893; font-size: .75rem; }

.workspace { max-width: 1280px; margin: -32px auto 0; padding: 0 24px 70px; position: relative; }
.toolbar { min-height: 68px; padding: 12px; display: grid; grid-template-columns: minmax(280px, 1fr) 220px 220px; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.search { display: flex; align-items: center; gap: 8px; padding: 0 14px; background: #f7f8f6; border: 1px solid #e8ebe7; border-radius: 8px; }
.search span { font-size: 1.5rem; transform: rotate(-15deg); color: #7d8581; }
.search input { width: 100%; border: 0; outline: 0; background: transparent; }
select, input, textarea { color: var(--ink); background: #fff; border: 1px solid #d6dcd7; border-radius: 8px; outline: none; }
select { padding: 0 38px 0 13px; appearance: none; background-image: linear-gradient(45deg, transparent 50%, #59615d 50%), linear-gradient(135deg, #59615d 50%, transparent 50%); background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
input:focus, select:focus, textarea:focus { border-color: #98bd0c; box-shadow: 0 0 0 3px rgba(200, 241, 53, .22); }
.section-heading { margin: 45px 2px 22px; display: flex; align-items: flex-end; justify-content: space-between; }
.section-heading h2, dialog h2 { margin: 0; font-size: 1.8rem; letter-spacing: -.04em; }
.section-heading > span { color: var(--muted); font-size: .88rem; }

.inventory-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.item-card { min-width: 0; padding: 20px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; transition: .2s ease; }
.item-card:hover { border-color: #bdc5bf; box-shadow: 0 12px 30px rgba(16, 21, 19, .07); transform: translateY(-2px); }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.category-pill { display: inline-block; max-width: 100%; padding: 5px 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-radius: 5px; background: #eff5da; color: #5e700d; font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.item-card h3 { margin: 12px 0 5px; font-size: 1.12rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-id { color: #929995; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .76rem; }
.quantity { min-width: 58px; text-align: right; }
.quantity strong, .quantity small { display: block; }
.quantity strong { font-size: 1.55rem; line-height: 1; }
.quantity small { margin-top: 4px; color: var(--muted); font-size: .72rem; }
.card-meta { margin: 20px 0 16px; padding-top: 16px; border-top: 1px solid #edf0ed; display: grid; gap: 8px; color: var(--muted); font-size: .82rem; }
.card-meta span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-actions { display: flex; gap: 8px; }
.card-actions button { min-height: 36px; padding: 0 11px; border: 1px solid #dfe3df; border-radius: 7px; background: #fff; color: #353c38; font-size: .79rem; font-weight: 750; }
.card-actions button:first-child { flex: 1; background: var(--ink); color: #fff; border-color: var(--ink); }
.card-actions button:hover { border-color: #9ba39e; }
.menu-button { width: 32px; height: 32px; border: 0; border-radius: 6px; background: #f4f6f3; font-weight: 900; }
.empty-state { padding: 80px 20px; text-align: center; border: 1px dashed #cbd1cc; border-radius: 12px; }
.empty-icon { width: 58px; height: 58px; display: grid; place-items: center; margin: 0 auto 16px; background: #e8ecd8; border-radius: 50%; font-size: 2rem; }
.empty-state h3 { margin: 0; }
.empty-state p { margin: 8px 0 22px; color: var(--muted); }

dialog { width: min(660px, calc(100% - 28px)); padding: 0; border: 0; border-radius: 14px; color: var(--ink); box-shadow: 0 30px 90px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(8, 12, 10, .72); backdrop-filter: blur(3px); }
dialog form, .label-dialog { padding: 26px; }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 25px; }
.icon-button { width: 36px; height: 36px; border: 1px solid var(--line); background: #fff; border-radius: 50%; font-size: 1.4rem; line-height: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid label, .copies-row label { display: grid; gap: 7px; color: #3d4541; font-size: .82rem; font-weight: 750; }
.form-grid input, .form-grid textarea, .copies-row input { width: 100%; min-height: 44px; padding: 10px 12px; }
.form-grid textarea { resize: vertical; }
.span-2 { grid-column: span 2; }
.dialog-actions { margin-top: 24px; display: flex; justify-content: flex-end; gap: 10px; }
dialog .button.ghost { border-color: var(--line); color: var(--ink); }
.logo-upload { display: flex; align-items: center; gap: 18px; margin-bottom: 22px; padding: 16px; background: #f4f6f2; border-radius: 10px; }
.logo-upload p { margin: 4px 0 12px; color: var(--muted); font-size: .8rem; }
.logo-preview { flex: 0 0 82px; width: 82px; height: 82px; display: grid; place-items: center; overflow: hidden; border-radius: 10px; background: var(--ink); color: var(--lime); font-size: 2rem; font-weight: 900; }
.logo-preview img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.file-button { display: inline-grid; place-items: center; min-height: 36px; font-size: .77rem; }
.file-button input { display: none; }
.label-dialog img { width: 100%; border: 1px solid #cdd2ce; background: #fff; image-rendering: auto; }
.copies-row { display: flex; align-items: end; gap: 18px; margin-top: 18px; }
.copies-row label { width: 120px; }
.copies-row p { margin: 0 0 10px; color: var(--muted); font-size: .82rem; }
.toast { position: fixed; left: 50%; bottom: 25px; z-index: 20; transform: translate(-50%, 30px); padding: 12px 18px; border-radius: 8px; background: var(--ink); color: #fff; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: .25s ease; font-size: .86rem; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.error { background: var(--danger); }

@media (max-width: 920px) {
  .hero { align-items: flex-start; flex-direction: column; }
  .stats { width: 100%; }
  .stats div { min-width: 0; flex: 1; }
  .toolbar { grid-template-columns: 1fr 1fr; }
  .search { grid-column: span 2; min-height: 46px; }
  .inventory-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .companion-state { display: none; }
}
@media (max-width: 620px) {
  .topbar { height: auto; min-height: 72px; padding: 12px 16px; }
  .brand small, #settingsButton { display: none; }
  .header-actions .button { padding: 0 12px; }
  .hero { padding: 45px 18px 65px; }
  h1 { font-size: 3.2rem; }
  .stats { flex-direction: column; }
  .stats div { display: flex; align-items: center; justify-content: space-between; border-right: 0; border-bottom: 1px solid #333b37; padding: 14px 18px; }
  .stats small { margin: 0; }
  .workspace { padding-left: 12px; padding-right: 12px; }
  .toolbar { grid-template-columns: 1fr; }
  .search { grid-column: auto; }
  .toolbar select { min-height: 44px; }
  .inventory-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .logo-upload { align-items: flex-start; }
  .copies-row { align-items: flex-start; flex-direction: column; }
}
