/* Kozy Homes CRM — walnut, brass and paper. */
:root {
  --paper: #FCFBF8; --sand: #EEE6D8; --linen: #E3DACB; --charcoal: #2A2927; --stone: #7A736A;
  --walnut: #4B3526; --walnut-dark: #3A291D; --brass: #A8874F; --brass-light: #D9C7A2;
  --sage: #5E7058; --rust: #9A4234; --amber: #B07A2A; --white: #fff;
  --display: "Cormorant Garamond", Georgia, serif; --sans: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r: 5px;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; }
body { margin: 0; background: var(--paper); color: var(--charcoal); font: 14px/1.5 var(--sans); font-variant-numeric: tabular-nums; }
a { color: var(--walnut); }
h1, h2, h3 { font-family: var(--display); font-weight: 600; margin: 0; line-height: 1.15; }
h1 { font-size: 34px; } h2 { font-size: 21px; } h3 { font-size: 17px; }
p { margin: 0; }
.muted { color: var(--stone); } .small { font-size: 12px; } .right { text-align: right; } .nowrap { white-space: nowrap; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.icon { width: 17px; height: 17px; flex: none; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Sidebar */
.sidebar { position: fixed; inset: 0 auto 0 0; width: 256px; background: var(--walnut-dark); color: var(--paper); display: flex; flex-direction: column; z-index: 50; transition: transform .2s; }
.brand { padding: 28px 24px 24px; }
.brand-name { font-family: var(--display); font-size: 26px; font-weight: 600; letter-spacing: .02em; line-height: 1; }
.brand-sub { margin-top: 6px; font-size: 12px; color: rgba(217,199,162,.8); }
.sidebar nav { flex: 1; overflow-y: auto; padding: 0 12px 24px; display: flex; flex-direction: column; gap: 20px; }
.nav-label { padding: 0 12px 6px; font-size: 11px; font-weight: 500; letter-spacing: .03em; color: rgba(252,251,248,.45); }
.sidebar ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: var(--r); color: rgba(252,251,248,.75); text-decoration: none; font-size: 14px; }
.nav-item span { flex: 1; }
.nav-item:hover { background: rgba(252,251,248,.06); color: var(--paper); }
.nav-item.active { background: rgba(252,251,248,.1); color: var(--paper); box-shadow: inset 2px 0 0 var(--brass); }
.nav-item.soon { opacity: .55; cursor: not-allowed; }
.nav-item.soon:hover { background: none; }
.nav-item em { font-style: normal; font-size: 10px; padding: 1px 6px; border-radius: 3px; background: rgba(252,251,248,.1); }
.menu-btn { display: none; position: fixed; top: 12px; left: 12px; z-index: 40; background: var(--walnut); color: var(--paper); border: 0; border-radius: var(--r); padding: 8px; cursor: pointer; }
.scrim { display: none; }

/* Main */
.main { padding-left: 256px; }
.topbar { position: sticky; top: 0; z-index: 30; height: 64px; display: flex; align-items: center; gap: 16px; padding: 0 32px; background: rgba(252,251,248,.95); backdrop-filter: blur(6px); border-bottom: 1px solid var(--linen); }
.search { flex: 1; max-width: 440px; }
.search input { width: 100%; height: 36px; border: 1px solid var(--linen); border-radius: var(--r); padding: 0 12px; background: var(--white); font: inherit; cursor: not-allowed; }
.me { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.me-text { text-align: right; text-decoration: none; color: inherit; line-height: 1.25; }
.me-text strong { display: block; font-weight: 600; font-size: 14px; } .me-text small { color: var(--stone); font-size: 12px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--sand); color: var(--walnut); display: grid; place-items: center; font-family: var(--display); font-weight: 700; }
.icon-btn { background: none; border: 0; padding: 8px; border-radius: var(--r); color: var(--stone); cursor: pointer; display: inline-flex; }
.icon-btn:hover { background: var(--sand); color: var(--charcoal); }
.content { max-width: 1400px; margin: 0 auto; padding: 32px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
.page-head p { margin-top: 4px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: var(--r); border: 1px solid transparent; font: 500 14px var(--sans); cursor: pointer; text-decoration: none; white-space: nowrap; background: var(--walnut); color: var(--paper); }
.btn:hover { background: var(--walnut-dark); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-outline { background: var(--white); color: var(--charcoal); border-color: var(--linen); }
.btn-outline:hover { background: var(--paper); border-color: var(--brass); }
.btn-ghost { background: none; color: var(--charcoal); }
.btn-ghost:hover { background: var(--sand); }
.btn-danger-text { background: none; color: var(--rust); } .btn-danger-text:hover { background: rgba(154,66,52,.08); }
.btn[disabled], .btn.disabled { opacity: .5; pointer-events: none; }
.btn .icon { width: 15px; height: 15px; }

label.lbl { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
label.lbl .req { color: var(--brass); margin-left: 2px; }
.input, select.input, textarea.input { width: 100%; height: 40px; border: 1px solid var(--linen); border-radius: var(--r); background: var(--white); padding: 0 12px; font: inherit; color: var(--charcoal); }
textarea.input { height: auto; min-height: 88px; padding: 8px 12px; line-height: 1.6; resize: vertical; }
select.input { appearance: none; padding-right: 36px; background: var(--white) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237A736A' stroke-width='2'><path d='m6 9 6 6 6-6'/></svg>") no-repeat right 12px center; }
.input:focus { border-color: var(--brass); outline: none; box-shadow: 0 0 0 3px rgba(168,135,79,.2); }
.input:disabled { background: var(--paper); color: var(--stone); }
.input.invalid { border-color: var(--rust); }
.uppercase { text-transform: uppercase; }
.hint { margin-top: 5px; font-size: 12px; color: var(--stone); }
.err { margin-top: 5px; font-size: 12px; color: var(--rust); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.check input { width: 16px; height: 16px; accent-color: var(--walnut); }
.grid { display: grid; gap: 20px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span2 { grid-column: 1 / -1; }
.form-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* Cards, tables, badges */
.card { background: var(--white); border: 1px solid var(--linen); border-radius: 6px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 16px 20px; border-bottom: 1px solid var(--linen); }
.card-head p { margin-top: 2px; font-size: 13px; }
.card-body { padding: 20px; }
.card.alert { border-color: rgba(154,66,52,.35); }
.layout-2 { display: grid; gap: 24px; grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.layout-split { display: grid; gap: 24px; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.stack { display: flex; flex-direction: column; gap: 24px; }
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { background: var(--paper); text-align: left; font-size: 12px; font-weight: 600; color: var(--stone); padding: 10px 16px; border-bottom: 1px solid var(--linen); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--linen); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: rgba(252,251,248,.7); }
.table .sub { font-size: 12px; color: var(--stone); }
.table tr.dim td { opacity: .55; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 3px; font-size: 12px; font-weight: 500; background: var(--sand); }
.badge-good { background: rgba(94,112,88,.13); color: var(--sage); }
.badge-bad { background: rgba(154,66,52,.1); color: var(--rust); }
.badge-warn { background: rgba(176,122,42,.13); color: var(--amber); }
.badge-brass { background: rgba(217,199,162,.5); color: var(--walnut); }
.badge-muted { background: var(--paper); color: var(--stone); border: 1px solid var(--linen); }
.empty { text-align: center; padding: 56px 24px; }
.empty h2, .empty .title { font-family: var(--display); font-size: 19px; }
.empty p { color: var(--stone); margin-top: 6px; }

/* Stats strip */
.stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1px; background: var(--linen); border: 1px solid var(--linen); border-radius: 6px; overflow: hidden; }
.stat { background: var(--white); padding: 20px; }
.stat p { font-size: 13px; color: var(--stone); }
.stat strong { display: block; margin-top: 8px; font-family: var(--display); font-size: 40px; font-weight: 600; line-height: 1; }
.stat strong.alert { color: var(--rust); }
.stat small { display: block; margin-top: 6px; font-size: 12px; color: var(--stone); }

.flash { margin-bottom: 20px; padding: 10px 14px; border-radius: var(--r); border: 1px solid; font-size: 14px; }
.flash-success { background: rgba(94,112,88,.1); border-color: rgba(94,112,88,.3); color: var(--sage); }
.flash-error { background: rgba(154,66,52,.06); border-color: rgba(154,66,52,.3); color: var(--rust); }
.note { margin: -12px 0 20px; padding: 10px 16px; border: 1px solid var(--linen); background: rgba(238,230,216,.5); border-radius: var(--r); color: var(--stone); }

.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--linen); margin-bottom: 32px; }
.tabs a { margin-bottom: -1px; padding: 10px 16px; border-bottom: 2px solid transparent; color: var(--stone); text-decoration: none; white-space: nowrap; }
.tabs a:hover { color: var(--charcoal); }
.tabs a.active { border-color: var(--walnut); color: var(--walnut); font-weight: 600; }

.logo-box { height: 128px; border: 1px dashed var(--linen); border-radius: var(--r); background: var(--paper); display: grid; place-items: center; margin-bottom: 16px; }
.logo-box img { max-height: 96px; max-width: 85%; object-fit: contain; }
.logo-box span { font-family: var(--display); font-size: 24px; color: rgba(122,115,106,.6); }
.terms-list { margin: 8px 0 0; padding-left: 20px; color: var(--stone); font-size: 14px; }
.perm-table td, .perm-table th { text-align: center; }
.perm-table td:first-child, .perm-table th:first-child { text-align: left; }
details.inline-edit > summary { list-style: none; cursor: pointer; }
details.inline-edit > summary::-webkit-details-marker { display: none; }
details.inline-edit[open] { background: var(--paper); }
.editor { padding: 20px; border-top: 1px solid var(--linen); }

/* Login */
.login { display: grid; grid-template-columns: 1.1fr 1fr; min-height: 100vh; }
.login-art { position: relative; overflow: hidden; background: var(--walnut-dark); color: var(--paper); padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.login-art::before { content: ""; position: absolute; inset: 0; opacity: .07; background-image: repeating-linear-gradient(172deg, var(--brass-light) 0 1px, transparent 1px 9px), repeating-linear-gradient(176deg, var(--brass-light) 0 1px, transparent 1px 23px); }
.login-art > * { position: relative; }
.login-art .big { font-family: var(--display); font-size: 44px; font-weight: 500; line-height: 1.08; max-width: 460px; }
.login-art .lead { margin-top: 20px; max-width: 420px; color: rgba(252,251,248,.65); font-size: 15px; line-height: 1.7; }
.login-form { display: flex; align-items: center; justify-content: center; padding: 64px 24px; }
.login-form > div { width: 100%; max-width: 360px; }
.login-form h1 { font-size: 32px; }
.login-form form { display: flex; flex-direction: column; gap: 16px; margin-top: 32px; }

/* Responsive */
@media (max-width: 1280px) { .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } .layout-2, .layout-split { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); }
  body.menu-open .sidebar { transform: none; }
  body.menu-open .scrim { display: block; position: fixed; inset: 0; background: rgba(42,41,39,.4); z-index: 45; }
  .menu-btn { display: inline-flex; }
  .main { padding-left: 0; }
  .topbar { padding-left: 64px; padding-right: 16px; }
  .content { padding: 24px 16px; }
  .login { grid-template-columns: 1fr; } .login-art { display: none; }
}
@media (max-width: 640px) { .g2 { grid-template-columns: 1fr; } .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } .me-text { display: none; } .search { display: none; } h1 { font-size: 28px; } }

/* ── Phase 2: catalogue & stock ── */
.crumbs { font-size: 13px; color: var(--stone); margin-bottom: 8px; }
.crumbs a { color: var(--stone); text-decoration: none; } .crumbs a:hover { color: var(--walnut); text-decoration: underline; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; padding: 12px; margin-bottom: 16px; align-items: center; }
.filters .input { width: auto; flex: 1 1 160px; min-width: 140px; }
.filters input[type=search] { flex: 2 1 240px; }
.list-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.row-link { cursor: pointer; }
.row-title { color: var(--charcoal); font-weight: 600; text-decoration: none; }
.row-title:hover { color: var(--walnut); text-decoration: underline; }
.thumb { width: 56px; height: 56px; border-radius: 4px; background: var(--paper); border: 1px solid var(--linen); display: grid; place-items: center; overflow: hidden; color: var(--linen); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .icon { width: 22px; height: 22px; }
.pos { color: var(--sage); font-weight: 600; } .neg { color: var(--rust); font-weight: 600; }
.stat strong.warn { color: var(--amber); }
.stat strong.money { font-size: 30px; }
.stats-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0; }
.kv dt { color: var(--stone); } .kv dd { margin: 0; text-align: right; }
.sticky-card { position: sticky; top: 88px; }

.spec-rows { display: flex; flex-direction: column; gap: 8px; }
.spec-row { display: grid; grid-template-columns: 20px minmax(120px, 0.7fr) minmax(0, 1.6fr) 32px; gap: 8px; align-items: center; }
.spec-row .drag { cursor: grab; color: var(--stone); letter-spacing: -2px; user-select: none; text-align: center; }
.spec-row.dragging { opacity: .4; }
.dims { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.file-list { list-style: none; margin: 10px 0 0; padding: 0; font-size: 13px; color: var(--stone); }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.gallery-item { margin: 0; border: 1px solid var(--linen); border-radius: 6px; overflow: hidden; background: var(--white); }
.gallery-item.primary { border-color: var(--brass); box-shadow: 0 0 0 1px var(--brass); }
.gallery-item img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--paper); }
.gallery-item figcaption { padding: 8px; display: flex; flex-direction: column; gap: 6px; min-height: 40px; }
.img-actions { display: flex; flex-wrap: wrap; gap: 2px; }
.img-actions form { display: inline; }
.upload-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

.quote-preview { display: grid; grid-template-columns: 110px minmax(0, 1fr) 190px; gap: 20px; align-items: start; }
.qp-img { width: 110px; height: 90px; border: 1px solid var(--linen); border-radius: 4px; display: grid; place-items: center; overflow: hidden; background: var(--paper); color: var(--linen); }
.qp-img img { width: 100%; height: 100%; object-fit: cover; }
.qp-name { font-weight: 700; letter-spacing: .02em; margin-bottom: 4px; }
.qp-specs { margin: 6px 0 0; padding-left: 16px; font-size: 13px; line-height: 1.6; }
.qp-meta { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 13px; }
.qp-meta dt { color: var(--stone); } .qp-meta dd { margin: 0; text-align: right; }

.cat-list { list-style: none; margin: 0; padding: 0; }
.cat-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 20px; border-bottom: 1px solid var(--linen); flex-wrap: wrap; }
.cat-row:last-child { border-bottom: 0; }
.cat-row.sub { padding-left: 36px; background: rgba(252,251,248,.6); }
.cat-row.dim .cat-name { opacity: .55; }
.cat-actions { display: flex; gap: 2px; flex-wrap: wrap; }
.cat-actions form { display: inline; }
.cat-form { display: grid; grid-template-columns: 1.2fr 1fr 1fr auto; gap: 12px; width: 100%; padding: 8px 0; }

@media (max-width: 1280px) { .sticky-card { position: static; } }
@media (max-width: 900px) { .quote-preview { grid-template-columns: 90px 1fr; } .qp-meta { grid-column: 1 / -1; } .cat-form { grid-template-columns: 1fr; } .stats-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .dims { grid-template-columns: repeat(2, minmax(0, 1fr)); } .spec-row { grid-template-columns: 1fr 32px; } .spec-row .drag { display: none; } .spec-row input:nth-of-type(2) { grid-column: 1; } }
.badge { white-space: nowrap; }
.gallery-item .badge { align-self: flex-start; }
.uppercase::placeholder { text-transform: none; }
