/* Digital Catalog — shared design system (charcoal + brass, HeroUI-inspired components) */
:root {
  --ink: #16181D; --ink-2: #2A2D34; --muted: #5B5F68; --subtle: #8C877E;
  --bg: #F4F2EE; --surface: #FFFFFF; --field: #F4F2EE; --line: #E3DFD7; --line-2: #CFCAC0;
  --brass: #C9954A; --brass-ink: #7A4E14; --brass-soft: #F1E6D4;
  --ok: #1B6E40; --ok-soft: #E2F1E8; --warn: #936316; --warn-soft: #FEF6E0; --danger: #B42318; --danger-soft: #FDECEA;
  --wa: #177245;
  --radius: 12px; --radius-lg: 16px;
  --shadow: 0 0 5px rgba(0,0,0,.02), 0 2px 10px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 40px rgba(22,24,29,.18);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
img { max-width: 100%; display: block; }
a { color: var(--brass-ink); }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--ink); }
h1, h2, h3 { font-family: var(--display); font-weight: 600; margin: 0; letter-spacing: -.01em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 18px; border-radius: var(--radius);
  border: 0; font-weight: 600; font-size: 14px; text-decoration: none; transition: transform .12s ease, background .15s ease, opacity .15s; white-space: nowrap; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: var(--ink-2); }
.btn-brass { background: var(--brass); color: var(--ink); }
.btn-soft { background: var(--brass-soft); color: var(--brass-ink); }
.btn-light { background: var(--field); color: var(--ink); }
.btn-outline { background: transparent; border: 2px solid var(--line); color: var(--ink); }
.btn-wa { background: var(--wa); color: #fff; }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-sm { height: 36px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn-block { width: 100%; }
.icon-btn { width: 44px; height: 44px; border-radius: var(--radius); border: 0; background: var(--field); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.icon-btn.sm { width: 34px; height: 34px; border-radius: 9px; background: transparent; color: var(--muted); }
.icon-btn.sm:hover { background: var(--field); color: var(--ink); }
.icon { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* Fields (HeroUI "flat" variant) */
.field { display: flex; flex-direction: column; gap: 2px; background: var(--field); border-radius: var(--radius); padding: 8px 12px; border: 2px solid transparent; transition: border-color .15s, background .15s; }
.field:focus-within { border-color: var(--brass); background: #fff; }
.field label, .field .lbl { font-size: 12px; color: var(--muted); font-weight: 500; }
.field label .req, .req { color: var(--danger); }
.field input, .field select, .field textarea { border: 0; outline: 0; background: transparent; padding: 0; font-size: 15px; min-height: 24px; width: 100%; }
.field textarea { resize: vertical; min-height: 64px; }
.field.invalid { border-color: var(--danger); background: var(--danger-soft); }
.field-error { color: var(--danger); font-size: 12px; margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

/* Chips & badges */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 17px; border: 1px solid var(--line); background: #fff; font-size: 13px; font-weight: 500; white-space: nowrap; transition: all .15s; }
.chip.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 3px; background: currentColor; opacity: .8; }
.badge.new { background: var(--warn-soft); color: var(--warn); }
.badge.contacted { background: #E7EEF9; color: #1F4E8C; }
.badge.closed, .badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.muted { background: var(--field); color: var(--muted); }
.badge.brass { background: var(--brass-soft); color: var(--brass-ink); }

/* Cards */
.card { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow); }

/* Data table with sticky header + scroll */
.table-wrap { overflow: auto; max-height: calc(100vh - 260px); max-height: calc(100dvh - 260px); border-radius: var(--radius); background: #fff; border: 1px solid var(--line); -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; min-width: 680px; }
.table thead th { position: sticky; top: 0; z-index: 2; background: #EFECE6; color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; text-align: left; padding: 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table tbody td { padding: 11px 12px; border-bottom: 1px solid #F0EDE7; vertical-align: middle; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: #FBFAF7; }
.table .sr { width: 56px; color: var(--muted); font-variant-numeric: tabular-nums; }
.table .thumb { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; background: var(--field); }
.table .actions { display: flex; gap: 2px; justify-content: flex-end; }
.empty { padding: 48px 16px; text-align: center; color: var(--muted); }

/* Modal / drawer */
.modal-backdrop { position: fixed; inset: 0; background: rgba(22,24,29,.45); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .18s ease; }
.modal { background: #fff; border-radius: 18px; width: min(680px, 100%); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: pop .22s cubic-bezier(.2,.9,.3,1.2); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 10px; }
.modal-body { padding: 8px 20px 16px; overflow: auto; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 20px 18px; border-top: 1px solid var(--line); }
@media (max-width: 640px) {
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal { border-radius: 20px 20px 0 0; max-height: 92dvh; animation: slideup .25s ease; padding-bottom: var(--safe-bottom); }
}

/* Toast */
.toast-host { position: fixed; left: 50%; bottom: calc(90px + var(--safe-bottom)); transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; box-shadow: var(--shadow-lg); animation: toastin .25s ease; max-width: 90vw; }
.toast.error { background: var(--danger); }

/* Skeleton */
.skel { background: linear-gradient(90deg, #ece8e1 25%, #f6f4f0 50%, #ece8e1 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 12px; }

@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes pop { from { opacity: 0; transform: scale(.94) translateY(8px) } to { opacity: 1; transform: none } }
@keyframes slideup { from { transform: translateY(100%) } to { transform: none } }
@keyframes toastin { from { opacity: 0; transform: translateY(10px) } to { opacity: 1; transform: none } }
@keyframes shimmer { to { background-position: -200% 0 } }
@keyframes rise { from { opacity: 0; transform: translateY(14px) } to { opacity: 1; transform: none } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
.nowrap { white-space: nowrap; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 2px 0; font-size: 13px; color: var(--muted); }
.badge.quoted, .badge.sent { background: #E7EEF9; color: #1F4E8C; }
.badge.converted, .badge.confirmed { background: var(--brass-soft); color: var(--brass-ink); }
