/* ============================================================
   AIWine CRM — standalone stylesheet
   Carries the AIWine design tokens (warm bone, claret, aged brass)
   so the crm/ folder can be deployed by itself.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,500;0,600;1,300;1,400;1,500;1,600&family=Manrope:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bone: #F4EFE5; --bone-alt: #EDE6D8; --card: #FAF6EE; --card-2: #FFFCF6;
  --ink: #1B1410; --ink-soft: #4A3D34; --muted: #8B7E6E; --faint: #B6A992;
  --line: #D8CFBE; --line-soft: #E6DECF;
  --claret: #5C1B27; --claret-deep: #3A0E18;
  --brass: #A98654; --brass-soft: #C9A878; --gold: #C9A45A;
  --green: #3F6B4B; --green-bright: #1F8A5B;
  --t-pinot:#6B1F2A; --t-syrah:#2A0E18; --t-chard:#C9A45A; --t-sauv:#93A35E;
  --t-pinotg:#D9B58C; --t-ries:#D7BE54; --t-rose:#D9889A; --t-merlot:#5C1B27;
  --t-cab:#3E1119; --t-sparkling:#C9B98C; --t-gewurz:#E0C277; --t-shiraz:#46101C;
  --t-grenache:#8A2F3C; --t-semillon:#D6C27A;
  --font-serif: 'Cormorant Garamond', Georgia, serif;
  --font-sans: 'Manrope', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bone); color: var(--ink); font-family: var(--font-sans); font-size: 14px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
::selection { background: var(--claret); color: var(--bone); }
a { color: var(--claret); text-decoration: none; }
button { font-family: var(--font-sans); cursor: pointer; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- typography helpers ---------- */
.label { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
.mono { font-family: var(--font-mono); }
.serif { font-family: var(--font-serif); }

/* ---------- app frame ---------- */
.crm { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.sidebar { background: var(--ink); color: var(--bone); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar::-webkit-scrollbar-thumb { background: #3a2f26; }
.side-brand { padding: 22px 20px 18px; border-bottom: 1px solid rgba(244,239,229,0.12); }
.side-wordmark { font-family: var(--font-sans); font-weight: 800; font-size: 19px; letter-spacing: -0.02em; color: var(--bone); display: flex; align-items: center; gap: 1px; }
.side-wordmark .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--brass-soft); margin: 0 3px; display: inline-block; }
.side-wordmark .suffix { color: var(--brass-soft); font-weight: 400; font-family: var(--font-mono); font-size: 11px; margin-left: 7px; letter-spacing: 0.14em; }
.side-section { padding: 16px 20px 6px; font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.2em; text-transform: uppercase; color: rgba(201,168,120,0.75); }
.side-nav { display: flex; flex-direction: column; padding: 0 10px; }
.side-link { display: flex; align-items: center; gap: 11px; padding: 8px 12px; border-radius: 3px; color: rgba(244,239,229,0.72); font-size: 13.5px; font-weight: 500; border: none; background: none; text-align: left; width: 100%; transition: background 0.15s, color 0.15s; position: relative; }
.side-link:hover { background: rgba(244,239,229,0.07); color: var(--bone); }
.side-link.active { background: rgba(92,27,39,0.55); color: var(--bone); }
.side-link.active::before { content: ''; position: absolute; left: -10px; top: 6px; bottom: 6px; width: 3px; background: var(--brass-soft); }
.side-link .ic { display: flex; opacity: 0.85; }
.side-link .count { margin-left: auto; font-family: var(--font-mono); font-size: 10.5px; color: rgba(201,168,120,0.9); }
.side-foot { margin-top: auto; padding: 14px 20px 18px; border-top: 1px solid rgba(244,239,229,0.12); display: flex; flex-direction: column; gap: 10px; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 0 28px; height: 60px; border-bottom: 1px solid var(--line); background: rgba(244,239,229,0.85); backdrop-filter: blur(14px); position: sticky; top: 0; z-index: 40; }
.content { padding: 26px 28px 60px; max-width: 1280px; width: 100%; margin: 0 auto; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 22px; flex-wrap: wrap; }
.page-title { font-family: var(--font-serif); font-size: 34px; font-weight: 500; line-height: 1.05; margin: 0; letter-spacing: -0.015em; }
.page-title em { font-style: italic; color: var(--claret); }
.page-sub { color: var(--muted); font-size: 13.5px; margin: 6px 0 0; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 9px 18px; border-radius: 3px; font-size: 13px; font-weight: 600; border: 1px solid transparent; transition: all 0.18s var(--ease); white-space: nowrap; }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--claret); color: var(--bone); }
.btn-primary:hover { background: var(--claret-deep); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--ink); color: var(--bone); border-color: var(--ink); }
.btn-quiet { background: transparent; color: var(--ink-soft); border: none; padding: 7px 10px; }
.btn-quiet:hover { background: var(--bone-alt); color: var(--ink); border-radius: 3px; }
.btn-danger { background: transparent; color: var(--claret); border-color: var(--claret); }
.btn-danger:hover { background: var(--claret); color: var(--bone); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn[disabled] { opacity: 0.45; pointer-events: none; }

/* ---------- inputs ---------- */
.input, .select, textarea.input { font-family: var(--font-sans); font-size: 13.5px; color: var(--ink); background: var(--card-2); border: 1px solid var(--line); border-radius: 3px; padding: 9px 12px; outline: none; transition: border-color 0.15s; width: 100%; }
.input:focus, .select:focus, textarea.input:focus { border-color: var(--brass); }
.input::placeholder { color: var(--faint); }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238B7E6E' fill='none' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; cursor: pointer; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > .label { font-size: 10px; }
.searchbox { position: relative; flex: 1; max-width: 360px; }
.searchbox .input { padding-left: 36px; }
.searchbox .ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); display: flex; pointer-events: none; }

/* segmented control */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 3px; background: var(--card); padding: 2px; gap: 2px; }
.seg button { border: none; background: none; padding: 6px 14px; font-size: 12px; font-weight: 600; color: var(--muted); border-radius: 2px; transition: all 0.15s; font-family: var(--font-sans); }
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--ink); color: var(--bone); }
.seg.seg-mono button { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.1em; }

/* ---------- cards & tiles ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 3px; }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line-soft); }
.card-title { font-size: 13px; font-weight: 700; margin: 0; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.stat-tile { background: var(--card); border: 1px solid var(--line); border-radius: 3px; padding: 16px 18px 14px; transition: box-shadow 0.22s var(--ease); }
.stat-tile.clickable { cursor: pointer; }
.stat-tile.clickable:hover { box-shadow: 0 10px 26px rgba(27,20,16,0.08); }
.stat-tile .num { font-family: var(--font-serif); font-size: 34px; font-weight: 500; line-height: 1; margin: 8px 0 4px; }
.stat-tile .delta { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.06em; }
.stat-tile .delta.up { color: var(--green); }
.stat-tile .delta.warn { color: var(--brass); }
.stat-tile .delta.bad { color: var(--claret); }

/* ---------- tables ---------- */
.tbl-wrap { background: var(--card); border: 1px solid var(--line); border-radius: 3px; overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); font-weight: 500; text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody tr.rowlink { cursor: pointer; transition: background 0.12s; }
.tbl tbody tr.rowlink:hover { background: var(--card-2); }
.tbl .num, .tbl .mono { font-family: var(--font-mono); font-size: 12px; }
.tbl .main-cell { font-weight: 600; }
.tbl .sub { color: var(--muted); font-size: 12px; font-weight: 400; }

/* ---------- badges & status ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.12em; text-transform: uppercase; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-soft); background: var(--card-2); white-space: nowrap; }
.badge .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge-green { color: var(--green); border-color: rgba(63,107,75,0.35); background: rgba(63,107,75,0.07); }
.badge-brass { color: var(--brass); border-color: rgba(169,134,84,0.4); background: rgba(169,134,84,0.08); }
.badge-claret { color: var(--claret); border-color: rgba(92,27,39,0.3); background: rgba(92,27,39,0.06); }
.badge-muted { color: var(--muted); }
.badge-ink { color: var(--bone); background: var(--ink); border-color: var(--ink); }
.pulse { animation: aw-pulse 2s infinite; }
@keyframes aw-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

/* country tag */
.ctag { font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.1em; padding: 2px 7px; border-radius: 2px; border: 1px solid var(--line); color: var(--muted); }
.ctag.nz { color: var(--ink-soft); }
.ctag.au { color: var(--brass); border-color: rgba(169,134,84,0.45); }

/* score bar */
.score { display: flex; align-items: center; gap: 8px; min-width: 110px; }
.score .bar { flex: 1; height: 4px; background: var(--line-soft); border-radius: 2px; overflow: hidden; }
.score .bar i { display: block; height: 100%; border-radius: 2px; }
.score .val { font-family: var(--font-mono); font-size: 11px; color: var(--ink-soft); width: 26px; text-align: right; }

/* ---------- avatar ---------- */
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--claret); color: var(--bone); display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; letter-spacing: 0.02em; flex: none; }
.avatar.brass { background: var(--brass); }
.avatar.lg { width: 44px; height: 44px; font-size: 15px; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tabs button { border: none; background: none; padding: 9px 16px; font-size: 13px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color 0.15s; font-family: var(--font-sans); }
.tabs button:hover { color: var(--ink); }
.tabs button.on { color: var(--ink); border-bottom-color: var(--claret); }
.tabs button .count { font-family: var(--font-mono); font-size: 10px; color: var(--brass); margin-left: 6px; }

/* ---------- drawer & modal ---------- */
.scrim { position: fixed; inset: 0; background: rgba(27,20,16,0.45); backdrop-filter: blur(3px); z-index: 90; animation: aw-fade 0.2s var(--ease); }
@keyframes aw-fade { from { opacity: 0; } }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 94vw); background: var(--bone); border-left: 1px solid var(--line); z-index: 95; box-shadow: -26px 0 70px rgba(27,20,16,0.25); display: flex; flex-direction: column; animation: aw-slide 0.32s var(--ease); }
@keyframes aw-slide { from { transform: translateX(40px); opacity: 0; } }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 22px 26px 16px; border-bottom: 1px solid var(--line); }
.drawer-body { flex: 1; overflow-y: auto; padding: 22px 26px; }
.drawer-foot { padding: 14px 26px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; background: var(--card); }
.modal-wrap { position: fixed; inset: 0; z-index: 95; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal { background: var(--bone); border: 1px solid var(--line); border-radius: 4px; width: min(620px, 100%); max-height: 88vh; display: flex; flex-direction: column; box-shadow: 0 30px 80px rgba(27,20,16,0.35); animation: aw-rise 0.28s var(--ease); }
@keyframes aw-rise { from { transform: translateY(14px); opacity: 0; } }

/* ---------- misc ---------- */
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 7px 14px; font-size: 13px; }
.kv .k { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); padding-top: 2px; }
.kv .v { color: var(--ink); }

.empty { text-align: center; padding: 46px 20px; color: var(--muted); }
.empty .glyph { font-family: var(--font-serif); font-style: italic; font-size: 26px; color: var(--faint); margin-bottom: 8px; }

.toast-host { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--ink); color: var(--bone); padding: 11px 22px; border-radius: 999px; font-size: 13px; font-weight: 500; display: flex; gap: 10px; align-items: center; animation: aw-toast 0.3s var(--ease); box-shadow: 0 10px 30px rgba(27,20,16,0.3); }
@keyframes aw-toast { from { transform: translateY(16px); opacity: 0; } }
.toast::before { content: '✓'; color: var(--brass-soft); font-weight: 700; }

.feed { display: flex; flex-direction: column; }
.feed-item { display: flex; gap: 13px; padding: 11px 0; border-bottom: 1px solid var(--line-soft); align-items: flex-start; }
.feed-item:last-child { border-bottom: none; }
.feed-ic { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); background: var(--card-2); display: flex; align-items: center; justify-content: center; flex: none; color: var(--ink-soft); }
.feed-body { flex: 1; min-width: 0; font-size: 13px; }
.feed-body b { font-weight: 700; }
.feed-when { font-family: var(--font-mono); font-size: 10px; color: var(--faint); letter-spacing: 0.06em; white-space: nowrap; padding-top: 3px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.split { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 1080px) { .grid-3 { grid-template-columns: 1fr 1fr; } .split, .grid-2 { grid-template-columns: 1fr; } }

.filters { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }

/* bar chart rows */
.hbar-row { display: grid; grid-template-columns: 150px 1fr 52px; gap: 12px; align-items: center; padding: 6px 0; font-size: 12.5px; }
.hbar-row .bar { height: 14px; background: var(--line-soft); border-radius: 2px; overflow: hidden; }
.hbar-row .bar i { display: block; height: 100%; background: var(--claret); }
.hbar-row .n { font-family: var(--font-mono); font-size: 11px; color: var(--ink-soft); text-align: right; }

/* sparkline columns */
.spark { display: flex; align-items: flex-end; gap: 3px; height: 44px; }
.spark i { flex: 1; background: var(--brass-soft); border-radius: 1px 1px 0 0; min-height: 2px; }
.spark i.hot { background: var(--claret); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.login-hero { background: linear-gradient(160deg, var(--claret) 0%, var(--claret-deep) 100%); color: var(--bone); padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.login-form { display: flex; align-items: center; justify-content: center; padding: 48px; }
@media (max-width: 860px) { .login { grid-template-columns: 1fr; } .login-hero { display: none; } }

/* print */
@media print { .sidebar, .topbar { display: none; } .crm { grid-template-columns: 1fr; } }
