:root {
  --ink: #211710;
  --muted: #806f64;
  --line: #e6ddd4;
  --cream: #faf7f2;
  --paper: #fffdfa;
  --espresso: #21150f;
  --espresso-soft: #332117;
  --copper: #c8752a;
  --copper-dark: #9c4f17;
  --gold: #e5b957;
  --green: #3b8a5a;
  --danger: #c54c43;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--espresso);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: #20130e; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); padding: 10px 11px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--copper); box-shadow: 0 0 0 3px rgba(200,117,42,.14); }
textarea { min-height: 74px; resize: vertical; }
label { display: grid; gap: 7px; color: #6c5b50; font-size: 12px; font-weight: 750; letter-spacing: .02em; }

.is-hidden { display: none !important; }
.button { border: 0; min-height: 38px; border-radius: 10px; padding: 0 14px; font-weight: 800; transition: transform .15s ease, background .15s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { color: #fff9ee; background: linear-gradient(135deg, var(--copper), var(--copper-dark)); box-shadow: 0 8px 20px rgba(132,63,18,.18); }
.button-quiet { border: 1px solid #dacabe; color: #6d4b37; background: #fffaf5; }
.text-button { border: 0; padding: 7px 3px; color: var(--copper-dark); background: transparent; font-weight: 750; }
.icon-button { display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 9px; color: #70594b; background: white; font-size: 22px; line-height: 1; }
.form-message { min-height: 19px; margin: 8px 0 0; color: #9d4a3e; font-size: 12px; font-weight: 650; }
.form-message.is-success { color: var(--green); }

.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; color: #fff8ed; background: radial-gradient(circle at 50% 15%, #684125 0, #321e16 37%, #160d0b 100%); }
.auth-card { width: min(100%, 400px); padding: 42px; border: 1px solid rgba(255,255,255,.13); border-radius: 22px; background: rgba(34,21,15,.83); box-shadow: 0 28px 70px rgba(0,0,0,.4); }
.brand-logo { width: 34px; height: 34px; object-fit: contain; }
.auth-logo { width: 56px; height: 56px; margin-bottom: 15px; }
.product-name { margin: 0 0 7px; color: #e3b96f; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; font-size: 11px; }
.auth-card h1 { margin: 0; font-size: 31px; letter-spacing: -.04em; }
.auth-copy { margin: 10px 0 26px; color: #d6c5b7; line-height: 1.5; }
.auth-form { display: grid; gap: 15px; }
.auth-form label { color: #ead8c7; }
.auth-form input { border-color: rgba(255,255,255,.16); color: #fff; background: rgba(255,255,255,.09); }
.auth-form .button { margin-top: 4px; }
.auth-divider { display: flex; align-items: center; gap: 10px; margin: 18px 0 13px; color: #cdb9aa; font-size: 11px; text-transform: uppercase; letter-spacing: .12em; }
.auth-divider span { flex: 1; height: 1px; background: rgba(255,255,255,.15); }
.auth-divider em { font-style: normal; }
.auth-link-button { width: 100%; color: #f4dfc4; border-color: rgba(236,195,139,.45); background: rgba(255,255,255,.08); }
.auth-help { margin: 10px 2px 0; color: #cbb8a9; font-size: 12px; line-height: 1.4; }
.mfa-intro { margin: 0; color: #dfcfc1; font-size: 14px; line-height: 1.45; }

.dashboard { min-height: 100vh; display: grid; grid-template-columns: 232px minmax(0, 1fr); background: var(--cream); }
.sidebar { min-height: 100vh; display: flex; flex-direction: column; gap: 34px; padding: 26px 15px 18px; color: #f7ecde; background: linear-gradient(180deg, #291811 0%, #1a100e 100%); }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 0 9px; font-size: 20px; font-weight: 850; letter-spacing: -.035em; }
.sidebar-nav { display: grid; gap: 5px; }
.nav-item { display: flex; align-items: center; gap: 11px; min-height: 42px; border: 0; border-radius: 10px; padding: 0 12px; color: #d5beb0; background: transparent; font-size: 14px; font-weight: 700; text-align: left; }
.nav-item span { width: 16px; color: #c68a52; font-size: 17px; text-align: center; }
.nav-item:hover, .nav-item.is-active { color: #fff8ef; background: rgba(255,255,255,.095); }
.nav-item.is-active { box-shadow: inset 3px 0 0 var(--copper); }
.sidebar-foot { margin-top: auto; }

.workspace { min-width: 0; background: var(--cream); }
.topbar { min-height: 88px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 30px; border-bottom: 1px solid var(--line); background: rgba(255,253,250,.94); }
.topbar-title { margin: 0; font-size: 20px; font-weight: 850; letter-spacing: -.03em; }
.topbar-subtitle { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.search-field { position: relative; display: flex; align-items: center; width: min(29vw, 355px); min-width: 215px; }
.search-field span { position: absolute; z-index: 1; left: 11px; color: #8a7363; font-size: 21px; }
.search-field input { padding-left: 34px; background: #f9f5f0; }
.profile-button { display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 50%; color: #fff; background: #64442e; font-weight: 850; }

.view { padding: 28px 30px; }
.catalog-view { padding-top: 20px; }
.catalog-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 17px; }
.filter-group { display: flex; flex-wrap: wrap; gap: 7px; }
.filter-button { border: 1px solid #e3d9cf; border-radius: 999px; padding: 7px 11px; color: #785e4d; background: #fffdfa; font-size: 12px; font-weight: 750; }
.filter-button:hover, .filter-button.is-active { border-color: #d29459; color: #8d4a18; background: #fff0df; }
.catalog-count { margin: 0; color: #806f64; font-size: 12px; white-space: nowrap; }
.catalog-shell { overflow: hidden; border: 1px solid #ded4ca; border-radius: 16px; background: white; box-shadow: 0 13px 28px rgba(70,45,25,.07); }
.table-wrap { position: relative; min-width: 0; min-height: 590px; overflow: auto; }
.catalog-table { width: 100%; border-collapse: collapse; white-space: nowrap; }
.catalog-table th { position: sticky; top: 0; z-index: 2; padding: 13px 11px; border-bottom: 1px solid var(--line); color: #846f60; background: #f7f1eb; font-size: 10px; font-weight: 850; letter-spacing: .08em; text-align: left; text-transform: uppercase; }
.catalog-table td { padding: 10px 11px; border-bottom: 1px solid #f0e9e3; color: #5e4c41; font-size: 12px; vertical-align: middle; }
.catalog-table tbody tr { cursor: pointer; transition: background .13s ease; }
.catalog-table tbody tr:hover, .catalog-table tbody tr.is-selected { background: #fff7ec; }
.catalog-table tbody tr.is-selected { box-shadow: inset 3px 0 0 var(--copper); }
.catalog-table tbody tr.catalog-inspector-row { cursor: default; background: #fffdfa; }
.catalog-table tbody tr.catalog-inspector-row:hover { background: #fffdfa; }
.catalog-inspector-row > td { padding: 0; white-space: normal; }
.bottle-thumb { width: 34px; height: 42px; display: grid; place-items: center; overflow: hidden; border: 1px solid #eadfd5; border-radius: 7px; color: #9e6d43; background: #f5ede6; }
.bottle-thumb img { width: 100%; height: 100%; object-fit: contain; }
.bottle-thumb .fallback-logo { width: 76%; height: 76%; }
.bottle-name { max-width: 220px; overflow: hidden; color: #251a15; font-weight: 800; text-overflow: ellipsis; }
.bottle-key { display: block; margin-top: 3px; color: #a08e81; font-size: 10px; }
.rarity-pill { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 4px 7px; color: #8d541f; background: #f7eadc; font-size: 10px; font-weight: 850; }
.rarity-pill::before { content: "✦"; color: #cf7b2a; }
.table-footer { display: flex; justify-content: flex-end; align-items: center; gap: 14px; padding: 13px 2px 0; color: #806f64; font-size: 12px; }
.empty-state { position: absolute; inset: 0; display: grid; place-content: center; gap: 5px; padding: 40px; color: #816e61; text-align: center; }
.empty-state strong { color: #403027; }
.empty-state span { font-size: 13px; }

.inspector { border-top: 1px solid #eadfd5; background: #fffdfa; }
.inspector-empty { display: grid; place-content: center; gap: 9px; min-height: 180px; padding: 36px; color: #917d6e; text-align: center; }
.inspector-empty strong { color: #5c4537; }
.inspector-empty p { margin: 0; font-size: 13px; line-height: 1.45; }
.inspector-symbol { color: #ca8b50; font-size: 38px; }
.inspector-head { display: flex; justify-content: space-between; gap: 10px; padding: 20px 20px 13px; }
.dialog-label { margin: 0 0 4px; color: #b16a2d; font-size: 10px; font-weight: 850; letter-spacing: .1em; text-transform: uppercase; }
.inspector-head h2, .modal-card h2 { margin: 0; color: #2a1b14; font-size: 19px; letter-spacing: -.025em; }
.inspector-head p:not(.dialog-label) { margin: 4px 0 0; color: #8a7769; font-size: 11px; }
.inspector-image { position: relative; display: grid; place-items: center; height: 136px; margin: 0 20px 15px; overflow: hidden; border: 1px solid #eadfd5; border-radius: 13px; background: linear-gradient(145deg, #faf2e9, #f1e4d6); }
.inspector-image img { width: 88px; height: 104px; object-fit: contain; }
.image-fallback { display: grid; place-items: center; width: 76px; height: 76px; border-radius: 50%; background: #fff8ef; }
.image-fallback img { width: 100%; height: 100%; object-fit: contain; }
.upload-control { position: absolute; right: 9px; bottom: 9px; display: inline-flex; width: auto; border-radius: 7px; padding: 6px 8px; color: #724a31; background: rgba(255,253,250,.94); box-shadow: 0 2px 8px rgba(68,38,20,.1); font-size: 10px; }
.upload-control input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.inspector-form { display: grid; gap: 10px; padding: 0 20px 18px; }
.inspector-form label { font-size: 11px; }
.inspector-form input, .inspector-form select, .inspector-form textarea { padding: 8px 9px; border-radius: 8px; font-size: 12px; }
.inspector-form textarea { min-height: 58px; }
.compact-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.key-link { display: flex; justify-content: space-between; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 8px 9px; color: #765238; background: #fbf7f2; font-size: 11px; font-weight: 700; text-align: left; }
.key-link span { max-width: 190px; overflow: hidden; color: #6e5b4e; text-overflow: ellipsis; }
.key-link::after { content: "Change"; color: var(--copper-dark); font-size: 10px; }
.key-link [data-field] + * { display: none; }
.inspector-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.inspector-section { border-top: 1px solid var(--line); padding: 17px 20px; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.section-heading h3 { margin: 0; color: #533d2e; font-size: 13px; }
.section-heading span { color: #987f6f; font-size: 10px; }
.barcode-list, .history-list { display: grid; gap: 7px; }
.barcode-row, .history-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; border: 1px solid #eee5de; border-radius: 9px; padding: 8px; color: #705d50; background: #fff; font-size: 11px; }
.barcode-value { color: #3b2b22; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 750; }
.barcode-meta, .history-row small { display: block; margin-top: 2px; color: #9b897c; font-size: 10px; }
.delete-barcode { border: 0; padding: 4px; color: var(--danger); background: transparent; font-size: 16px; }
.history-row { align-items: flex-start; }
.history-row strong { display: block; color: #5e4636; font-size: 11px; }

.overview-intro { max-width: 750px; padding: 14px 0 28px; }
.overview-intro h2 { margin: 0; color: #2b1a12; font-size: clamp(28px, 4vw, 42px); letter-spacing: -.055em; }
.overview-intro p { max-width: 540px; color: #806e61; line-height: 1.55; }
.overview-list { display: grid; max-width: 640px; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.overview-row { display: grid; min-height: 174px; align-content: start; gap: 8px; border: 1px solid #e6d9ce; border-radius: 16px; padding: 22px; color: #6f5340; background: #fffdfa; text-align: left; box-shadow: 0 10px 25px rgba(73,45,23,.06); }
.overview-row:hover { border-color: #d39965; }
.overview-row > span { font-weight: 750; }
.overview-row strong { margin-top: 12px; color: #2b1b14; font-size: 32px; letter-spacing: -.04em; }
.overview-row small { color: #9a8475; }
.directory-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.directory-card { min-height: 150px; border: 1px solid #e5d9cf; border-radius: 15px; padding: 19px; background: #fffdfa; box-shadow: 0 8px 20px rgba(73,45,23,.04); }
.directory-card h3 { margin: 0; color: #2c1b13; font-size: 16px; }
.directory-card p { margin: 8px 0; color: #806f63; font-size: 12px; line-height: 1.4; }
.directory-card footer { display: flex; justify-content: space-between; gap: 10px; color: #a06a42; font-size: 11px; font-weight: 750; }
.feature-placeholder { display: grid; place-content: center; justify-items: center; min-height: 430px; max-width: 680px; margin: 0 auto; color: #806d60; text-align: center; }
.feature-placeholder span { color: #c77b34; font-size: 44px; }
.feature-placeholder h2 { margin: 12px 0 6px; color: #342219; }
.feature-placeholder p { max-width: 470px; margin: 0 0 20px; line-height: 1.5; }

.modal { width: min(94vw, 700px); border: 0; border-radius: 18px; padding: 0; color: var(--ink); background: transparent; box-shadow: 0 20px 70px rgba(0,0,0,.36); }
.modal::backdrop { background: rgba(28,17,12,.55); backdrop-filter: blur(3px); }
.modal-card { display: grid; gap: 16px; max-height: min(88vh, 800px); overflow: auto; border: 1px solid #e6dacf; border-radius: 18px; padding: 24px; background: #fffcf8; }
.modal-card header, .modal-card footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-small { width: min(94vw, 510px); }
.modal-copy { margin: -3px 0 0; color: #7c695d; font-size: 13px; line-height: 1.45; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.full-span { grid-column: 1 / -1; }

@media (max-width: 860px) {
  .dashboard { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 4; min-height: auto; flex-direction: row; align-items: center; gap: 12px; padding: 10px 14px; overflow-x: auto; }
  .sidebar-brand { padding: 0; }
  .sidebar-nav { display: flex; gap: 4px; }
  .nav-item { min-width: max-content; min-height: 34px; padding: 0 8px; font-size: 12px; }
  .sidebar-foot { margin: 0 0 0 auto; }
  .topbar { align-items: flex-start; flex-direction: column; padding: 16px 20px; }
  .topbar-actions { width: 100%; flex-wrap: wrap; }
  .search-field { flex: 1; width: auto; }
  .view { padding: 20px; }
  .overview-list { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .sidebar-brand span:last-child, .nav-item span { display: none; }
  .sidebar { gap: 6px; }
  .sidebar-nav { flex: 1; justify-content: space-around; }
  .nav-item { padding: 0 7px; }
  .topbar-actions .button-quiet { display: none; }
  .catalog-toolbar { align-items: flex-start; flex-direction: column; }
  .catalog-count { white-space: normal; }
  .table-wrap { min-height: 440px; }
  .form-grid { grid-template-columns: 1fr; }
  .full-span { grid-column: auto; }
  .modal-card { padding: 18px; }
}
