/* INAI CRM — navy & gold, matching inaievents.in */
:root {
  --navy: #001235;
  --navy-2: #0b1f4d;
  --navy-3: #16306b;
  --gold: #C9A227;
  --gold-d: #A9820D;
  --gold-l: #F6D368;
  --cream: #F4EFE4;
  --bg: #f6f4ef;
  --card: #ffffff;
  --ink: #1b2130;
  --muted: #6b7280;
  --line: #e7e3d9;
  --line-2: #efece5;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --info: #2563eb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 18, 53, .06), 0 4px 16px rgba(0, 18, 53, .06);
  --font: 'Jost', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --serif: 'Playfair Display', Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: 14.5px; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--navy-3); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
h1 { font-family: var(--serif); font-size: 26px; color: var(--navy); }
h3 { font-size: 16px; }
small, .muted { color: var(--muted); }
code, .code { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; }
pre.code { background: #f3f1ea; padding: 12px; border-radius: 8px; overflow: auto; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }
.hidden { display: none !important; }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--navy); color: #cfd6e6; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.side .logo { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
.side .logo img { width: 34px; height: 34px; }
.side .logo strong { font-family: var(--serif); color: #fff; font-size: 19px; letter-spacing: .02em; display: block; line-height: 1.1; }
.side .logo span { font-size: 10.5px; color: var(--gold); letter-spacing: .14em; text-transform: uppercase; }
.side nav { padding: 10px 10px 20px; flex: 1; }
.side .grp { font-size: 10.5px; text-transform: uppercase; letter-spacing: .14em; color: #7f8bab; padding: 14px 10px 6px; }
.side a.nav { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: #d8deec; font-size: 14px; }
.side a.nav:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.side a.nav.active { background: linear-gradient(90deg, rgba(201,162,39,.22), rgba(201,162,39,.06)); color: var(--gold-l); box-shadow: inset 3px 0 0 var(--gold); }
.side a.nav svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.side .me { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; display: flex; align-items: center; gap: 10px; }
.side .me .av { width: 32px; height: 32px; border-radius: 50%; background: var(--gold); color: var(--navy); display: grid; place-items: center; font-weight: 600; flex: none; }
.side .me .who { flex: 1; min-width: 0; }
.side .me .who b { display: block; color: #fff; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side .me .who small { color: #8f9aba; }
.side .me button { background: none; border: 0; color: #aab4cf; cursor: pointer; padding: 6px; border-radius: 6px; }
.side .me button:hover { background: rgba(255,255,255,.08); color: #fff; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; background: var(--navy); color: #fff; padding: 10px 16px; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 30; }
.topbar strong { font-family: var(--serif); font-size: 18px; }
.topbar button { background: none; border: 0; color: #fff; padding: 6px; cursor: pointer; }
.content { padding: 24px 28px 48px; max-width: 1400px; width: 100%; }
.content.wide { max-width: none; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { flex: 1; min-width: 200px; }
.page-head .sub { display: block; font-family: var(--font); font-size: 13px; color: var(--muted); font-weight: 400; margin-top: 2px; }
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 4px; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 500; font-size: 14px; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 8px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap; line-height: 1.2; text-decoration: none !important; }
.btn:hover { border-color: #cfc9b8; background: #fbfaf7; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-2); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--navy); }
.btn.gold:hover { background: var(--gold-l); }
.btn.danger { color: var(--err); }
.btn.danger:hover { background: #fef2f2; border-color: #fecaca; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: rgba(0,18,53,.05); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.icon { padding: 6px; }
.btn svg { width: 16px; height: 16px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Cards / KPIs ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line-2); }
.card-h h3 { flex: 1; }
.card-b { padding: 16px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; position: relative; overflow: hidden; box-shadow: var(--shadow); }
.kpi::after { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--gold); }
.kpi .l { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.kpi .v { font-size: 24px; font-weight: 600; color: var(--navy); margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.kpi.alert::after { background: var(--err); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fbfaf6; white-space: nowrap; }
table.t td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: #fbf8ee; }
table.t .r, .r { text-align: right; }
table.t .num, .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
table.t tfoot td { font-weight: 600; background: #fbfaf6; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }

/* ---------- Toolbar / filters ---------- */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line-2); }
.toolbar .search { flex: 1; min-width: 180px; max-width: 360px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs button { font: inherit; font-size: 13px; border: 1px solid transparent; background: none; padding: 6px 12px; border-radius: 999px; cursor: pointer; color: var(--muted); }
.tabs button.on { background: var(--navy); color: #fff; }
.tabs button:not(.on):hover { background: rgba(0,18,53,.05); }

/* ---------- Forms ---------- */
input, select, textarea { font: inherit; font-size: 14px; color: var(--ink); background: #fff; border: 1px solid #d9d4c7; border-radius: 8px; padding: 8px 10px; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201,162,39,.18); }
textarea { resize: vertical; min-height: 70px; }
input[type=checkbox] { width: auto; accent-color: var(--navy); }
input[type=color] { padding: 2px; height: 36px; width: 48px; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: #4b5263; font-weight: 500; }
label.chk { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; color: var(--ink); cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-grid h3, .form-grid .span2 { grid-column: 1 / -1; }
.form-grid h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .1em; color: var(--gold-d); margin-top: 6px; }
.span2 { grid-column: span 2; }
.req::after { content: ' *'; color: var(--err); }
.hint { font-size: 12px; color: var(--muted); font-weight: 400; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; background: #eef0f4; color: #475069; white-space: nowrap; }
.badge.ok { background: #dcfce7; color: #166534; }
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.err { background: #fee2e2; color: #991b1b; }
.badge.info { background: #dbeafe; color: #1e40af; }
.badge.gold { background: #fbf1cf; color: #7a5d06; }
.badge.navy { background: var(--navy); color: #fff; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }

/* ---------- Kanban ---------- */
.kanban { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 16px; align-items: flex-start; min-height: calc(100vh - 210px); }
.col { flex: 0 0 290px; background: #efece4; border-radius: 12px; display: flex; flex-direction: column; max-height: calc(100vh - 190px); }
.col-h { padding: 12px 12px 8px; display: flex; align-items: center; gap: 8px; border-top: 3px solid var(--c, var(--gold)); border-radius: 12px 12px 0 0; }
.col-h b { flex: 1; font-weight: 600; font-size: 14px; }
.col-h .cnt { font-size: 12px; background: #fff; border-radius: 999px; padding: 1px 8px; color: var(--muted); }
.col-sum { padding: 0 12px 8px; font-size: 12px; color: var(--muted); }
.col-body { padding: 4px 8px 10px; overflow-y: auto; flex: 1; min-height: 60px; }
.col.over { background: #e6e1d2; outline: 2px dashed var(--gold); outline-offset: -4px; }
.lcard { background: #fff; border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; box-shadow: 0 1px 2px rgba(0,18,53,.08); border: 1px solid transparent; cursor: grab; }
.lcard:hover { border-color: var(--gold); }
.lcard.dragging { opacity: .45; }
.lcard .t { font-weight: 600; font-size: 14px; color: var(--navy); margin-bottom: 4px; line-height: 1.3; }
.lcard .m { font-size: 12.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.lcard .m span { display: inline-flex; align-items: center; gap: 4px; }
.lcard .m svg { width: 13px; height: 13px; }
.lcard .f { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12px; }
.lcard .f .own { margin-left: auto; width: 22px; height: 22px; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center; font-size: 10.5px; }
.lcard .amt { font-weight: 600; color: var(--gold-d); }
.drop-ph { height: 4px; background: var(--gold); border-radius: 2px; margin: 2px 0 8px; }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.timeline .ic { width: 28px; height: 28px; border-radius: 50%; background: #f3efe3; display: grid; place-items: center; flex: none; color: var(--gold-d); }
.timeline .ic svg { width: 14px; height: 14px; }
.timeline .body { flex: 1; min-width: 0; }
.timeline .body p { margin: 0; white-space: pre-wrap; word-break: break-word; }
.timeline .body small { display: block; margin-top: 2px; }

/* ---------- Detail views ---------- */
.dl { display: grid; grid-template-columns: 140px 1fr; gap: 8px 14px; font-size: 14px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; word-break: break-word; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 18px; align-items: start; }
.contact-links { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Vendor cards ---------- */
.vgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; padding: 16px; }
.vcard { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: #fff; display: flex; flex-direction: column; gap: 8px; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.vcard:hover { border-color: var(--gold); box-shadow: var(--shadow); }
.vcard .top { display: flex; gap: 10px; align-items: flex-start; }
.vcard .ini { width: 40px; height: 40px; border-radius: 10px; background: var(--cream); color: var(--gold-d); display: grid; place-items: center; font-weight: 700; font-family: var(--serif); font-size: 17px; flex: none; }
.vcard h4 { font-size: 15px; color: var(--navy); }
.vcard .meta { font-size: 13px; color: var(--muted); }
.stars { color: var(--gold); letter-spacing: 1px; font-size: 13px; }
.stars .off { color: #d8d2c1; }

/* ---------- Document editor ---------- */
.lines { width: 100%; border-collapse: collapse; }
.lines th { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 500; text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.lines td { padding: 6px; vertical-align: top; border-bottom: 1px solid var(--line-2); }
.lines td input, .lines td select, .lines td textarea { padding: 6px 8px; }
.lines td textarea { min-height: 34px; margin-top: 4px; font-size: 13px; }
.lines .amt { text-align: right; padding-top: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 500; }
.lines .w-qty { width: 80px; } .lines .w-rate { width: 120px; } .lines .w-pct { width: 78px; } .lines .w-tax { width: 90px; } .lines .w-amt { width: 120px; } .lines .w-x { width: 36px; }
.sum-box { margin-left: auto; width: 340px; max-width: 100%; }
.sum-box .row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; gap: 10px; }
.sum-box .row.total { border-top: 2px solid var(--navy); margin-top: 6px; padding-top: 10px; font-size: 18px; font-weight: 600; color: var(--navy); }
.sum-box input { width: 120px; text-align: right; }
.combo { position: relative; }
.combo-list { position: absolute; left: 0; right: 0; top: 100%; z-index: 40; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); max-height: 260px; overflow-y: auto; margin-top: 2px; min-width: 260px; }
.combo-list div { padding: 8px 10px; cursor: pointer; font-size: 13.5px; }
.combo-list div small { display: block; }
.combo-list div:hover, .combo-list div.hl { background: #fbf6e6; }
.sticky-actions { position: sticky; bottom: 0; background: rgba(246,244,239,.95); backdrop-filter: blur(4px); padding: 12px 0; border-top: 1px solid var(--line); margin-top: 18px; display: flex; gap: 8px; flex-wrap: wrap; z-index: 5; }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0, 18, 53, .45); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; z-index: 100; overflow-y: auto; animation: fade .15s; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 640px; box-shadow: 0 20px 60px rgba(0,0,0,.3); animation: pop .18s; }
.modal.lg { max-width: 880px; }
.modal.sm { max-width: 440px; }
.modal-h { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line-2); gap: 10px; }
.modal-h h2 { flex: 1; font-family: var(--serif); font-size: 20px; color: var(--navy); }
.modal-b { padding: 18px 20px; max-height: 70vh; overflow-y: auto; }
.modal-f { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line-2); background: #fcfbf8; border-radius: 0 0 14px 14px; }
.modal-f .left { margin-right: auto; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(10px) scale(.98); opacity: 0; } }

/* ---------- Toast ---------- */
#toast-root { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); font-size: 14px; max-width: 380px; animation: pop .2s; border-left: 4px solid var(--gold); }
.toast.err { border-left-color: var(--err); }

/* ---------- Alerts ---------- */
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; font-size: 14px; }
.alert.ok { background: #dcfce7; color: #166534; }
.alert.err { background: #fee2e2; color: #991b1b; }
.alert.info { background: #fbf1cf; color: #7a5d06; }

/* ---------- Auth ---------- */
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(ellipse at top, #0b1f4d, var(--navy) 60%); }
.auth-card { background: #fff; border-radius: 16px; padding: 28px; width: 100%; max-width: 400px; box-shadow: 0 30px 80px rgba(0,0,0,.35); position: relative; overflow: hidden; }
.auth-card::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 5px; background: linear-gradient(90deg, #A9820D, #F6D368, #C9A227, #8C6A08); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-brand img { width: 46px; height: 46px; }
.auth-brand strong { font-family: var(--serif); font-size: 24px; color: var(--navy); display: block; }
.auth-brand span { color: var(--gold-d); font-size: 11px; letter-spacing: .16em; text-transform: uppercase; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-card .btn { justify-content: center; padding: 10px; }

/* ---------- Charts ---------- */
.bars { display: flex; align-items: flex-end; gap: 14px; height: 180px; padding: 10px 4px 0; }
.bars .grp { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; }
.bars .pair { flex: 1; display: flex; gap: 4px; align-items: flex-end; width: 100%; justify-content: center; }
.bars .bar { width: 40%; max-width: 28px; border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.bars .bar.s { background: var(--navy); }
.bars .bar.p { background: var(--gold); }
.bars .lbl { font-size: 11.5px; color: var(--muted); }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.funnel .row { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: 13.5px; }
.funnel .row .name { width: 150px; flex: none; display: flex; align-items: center; gap: 6px; }
.funnel .row .trk { flex: 1; background: #f1eee6; border-radius: 6px; height: 12px; overflow: hidden; }
.funnel .row .fill { height: 100%; border-radius: 6px; }
.funnel .row .n { width: 36px; text-align: right; font-weight: 600; }

/* ---------- Permissions matrix ---------- */
.perm-table td, .perm-table th { text-align: center; }
.perm-table td:first-child, .perm-table th:first-child { text-align: left; }
.perm-table .grp-row td { background: #fbf8ee; font-size: 11.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--gold-d); font-weight: 600; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .split { grid-template-columns: 1fr; }
  .g3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 60; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,18,53,.4); }
  .topbar { display: flex; }
  .content { padding: 16px 16px 40px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .form-grid, .form-grid.c3, .form-grid.c4 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .dl { grid-template-columns: 110px 1fr; }
  .col { flex-basis: 260px; }
  .lines thead { display: none; }
  .lines, .lines tbody, .lines tr, .lines td { display: block; width: 100% !important; }
  .lines tr { border: 1px solid var(--line); border-radius: 10px; padding: 8px; margin-bottom: 10px; position: relative; }
  .lines td { border: 0; padding: 4px 0; }
  .lines td[data-l]::before { content: attr(data-l); display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 2px; }
  .lines .amt { text-align: left; padding-top: 4px; }
  .lines td.w-x { position: absolute; right: 6px; top: 6px; width: auto !important; }
  .sum-box { width: 100%; }
  h1 { font-size: 22px; }
}

@media print {
  .side, .topbar, .no-print, .sticky-actions { display: none !important; }
  .shell { display: block; }
  .content { padding: 0; }
  .card { box-shadow: none; }
}
