/* Purinexa VC Scanner — theme matched to Purinexa Group Pvt Ltd CRM (dark navy + teal/blue), mobile-first */
:root {
  --bg: #070d1a; --bg2: #0a1424; --panel: #0e1b30; --panel2: #13233d; --panel3: #182b49;
  --line: rgba(120,165,255,.13); --line2: rgba(120,165,255,.22);
  --teal: #2dd4ea; --teal2: #1fa6c9; --blue: #3b82f6; --silver: #e9eff8;
  --text: #dbe5f2; --muted: #8ea6c8; --muted2: #5f7699;
  --green: #34d399; --red: #f87171; --amber: #fbbf24; --violet: #a78bfa;
  --field: #0a1526; --scrim: rgba(3,8,18,.72);
  --grad: linear-gradient(135deg,#2dd4ea,#3b82f6);
  --grad-soft: linear-gradient(135deg,rgba(45,212,234,.14),rgba(59,130,246,.12));
  --shadow: 0 10px 30px rgba(2,8,20,.5);
  --radius: 14px;
  --font: 'Inter','Segoe UI',system-ui,sans-serif;
  --font-head: 'Montserrat','Segoe UI',system-ui,sans-serif;
  --on-grad: #03121f;
  --tap: 44px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
body.light {
  --bg: #eef3f9; --bg2: #f6f9fc; --panel: #ffffff; --panel2: #f2f6fb; --panel3: #e9eff7;
  --line: rgba(20,50,90,.11); --line2: rgba(20,50,90,.2);
  --silver: #13233c; --text: #2a3b52; --muted: #5a7089; --muted2: #8296ad;
  --field: #ffffff; --scrim: rgba(30,50,80,.45);
  --teal: #0e7490; --teal2: #0b8aa8; --blue: #2563eb; --violet: #7c3aed;
  --green: #059669; --red: #dc2626; --amber: #b45309;
  --grad: linear-gradient(135deg,#1fa6c9,#2563eb);
  --grad-soft: linear-gradient(135deg,rgba(31,166,201,.12),rgba(59,130,246,.1));
  --shadow: 0 10px 30px rgba(40,70,110,.14);
  --on-grad: #ffffff;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14.5px; line-height: 1.45; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased;
  background-image: radial-gradient(900px 500px at 85% -10%, rgba(45,212,234,.07), transparent), radial-gradient(700px 500px at -10% 110%, rgba(59,130,246,.06), transparent); }
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--font-head); color: var(--silver); }
h1 { font-size: 1.35rem; font-weight: 800; margin: 0 0 .4rem; letter-spacing: .2px; }
h2 { font-size: 1.02rem; font-weight: 700; margin: 0 0 .5rem; }
h3 { font-size: .9rem; font-weight: 700; margin: 0 0 .4rem; letter-spacing: .3px; }
p { margin: 0 0 .75rem; }
code { background: var(--panel2); border: 1px solid var(--line); padding: 0 .3em; border-radius: 4px; font-size: .9em; color: var(--silver); }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; }
.flex { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; }
.grow { flex: 1 1 auto; }
::-webkit-scrollbar { width: 9px; height: 9px; } ::-webkit-scrollbar-thumb { background: #20375c; border-radius: 6px; }

/* ---------- Brand ---------- */
.brand { display: flex; align-items: center; gap: .6rem; color: var(--silver); }
.brand:hover { text-decoration: none; }
.brand img { width: 36px; height: 36px; object-fit: contain; }
.brand .nm { font-family: var(--font-head); font-weight: 800; font-size: 15px; letter-spacing: 2px; color: var(--silver); line-height: 1.05; }
.brand .nm .x { color: var(--teal); }
.brand .tg { font-size: 8.5px; letter-spacing: 1.6px; color: var(--teal2); font-weight: 600; margin-top: 2px; white-space: nowrap; }
.brand-lockup { display: inline-flex; flex-direction: column; align-items: center; font-size: 10px; width: 25em; max-width: 100%; margin: 0 auto 8px; font-family: var(--font-head); line-height: 1; user-select: none; }
.brand-lockup .bl-p { width: 8.6em; height: 8.6em; object-fit: contain; display: block; margin: 0 0 .5em; }
.brand-lockup .bl-name { font-weight: 800; font-size: 2.6em; letter-spacing: .075em; margin-right: -.075em; background: linear-gradient(135deg,#f5f8fc 0%,#c8d3e0 45%,#eef3f9 60%,#9fb0c4 100%); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent; white-space: nowrap; }
body.light .brand-lockup .bl-name { background: linear-gradient(135deg,#13233c,#3a5278); -webkit-background-clip: text; background-clip: text; }
.brand-lockup .bl-name span { background: linear-gradient(135deg,#4fd8e8,#1fa6c9); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent; }
.brand-lockup .bl-group { display: flex; align-items: center; justify-content: center; gap: 1em; margin-top: .9em; color: #2fb9d6; }
.brand-lockup .bl-group i { display: block; flex: 0 0 3.8em; height: .13em; min-height: 1px; background: #2fb9d6; border-radius: 1px; }
.brand-lockup .bl-group b { font-weight: 600; font-size: 1.16em; letter-spacing: .58em; margin-right: -.58em; white-space: nowrap; }
.brand-lockup .bl-tag { margin-top: 1.5em; font-weight: 600; font-size: .72em; letter-spacing: .17em; margin-right: -.17em; color: #dbe5f0; white-space: nowrap; }
body.light .brand-lockup .bl-tag { color: #3a5278; }
.brand-lockup .bl-app { margin-top: 1.3em; font-weight: 700; font-size: 1.05em; letter-spacing: .32em; margin-right: -.32em; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent; white-space: nowrap; }

/* ---------- Top bar + bottom nav ---------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1rem; padding: .5rem 1rem; background: rgba(10,20,36,.8); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
body.light .topbar { background: rgba(255,255,255,.85); }
.topnav { display: flex; gap: .25rem; margin-left: .5rem; }
.topnav a { padding: .45rem .75rem; border-radius: 10px; color: var(--muted); font-weight: 600; font-size: .9rem; }
.topnav a.active, .topnav a:hover { background: var(--grad-soft); color: var(--silver); text-decoration: none; border: 1px solid rgba(45,212,234,.25); }
.topnav a:not(.active) { border: 1px solid transparent; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.user-chip { display: inline-flex; align-items: center; gap: .5rem; background: var(--panel2); border: 1px solid var(--line); padding: .3rem .7rem .3rem .3rem; border-radius: 30px; font-size: .82rem; max-width: 190px; }
.user-chip .av { width: 26px; height: 26px; border-radius: 50%; background: var(--grad); display: grid; place-items: center; font-weight: 700; font-size: 12px; color: var(--on-grad); flex-shrink: 0; }
.user-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bottomnav { display: none; }
.app-main { max-width: 1180px; margin: 0 auto; padding: 1rem; }
@media (max-width: 760px) {
  .topnav, .user-chip span { display: none; }
  .topbar { padding: .45rem .75rem; gap: .5rem; }
  .brand .tg { display: none; }
  .app-main { padding: .75rem .75rem calc(74px + var(--safe-b)); }
  .bottomnav { display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: rgba(10,20,36,.95); backdrop-filter: blur(12px); border-top: 1px solid var(--line2); padding: .3rem .25rem calc(.3rem + var(--safe-b)); }
  body.light .bottomnav { background: rgba(255,255,255,.95); }
  .bottomnav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px; border-radius: 12px; color: var(--muted); font-size: .68rem; font-weight: 600; letter-spacing: .3px; text-decoration: none; }
  .bottomnav a svg { width: 22px; height: 22px; }
  .bottomnav a.active { color: var(--teal); background: var(--grad-soft); }
  .bottomnav a.scan { color: var(--silver); }
  .bottomnav a.scan svg { width: 40px; height: 40px; padding: 8px; border-radius: 50%; background: var(--grad); color: var(--on-grad); box-shadow: 0 4px 16px rgba(45,212,234,.35); margin-top: -18px; }
}

/* ---------- Cards / panels ---------- */
.card { background: linear-gradient(180deg, var(--panel), rgba(14,27,48,.6)); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
body.light .card { background: var(--panel); box-shadow: var(--shadow); }
.card + .card { margin-top: 1rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .75rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.breadcrumb { font-size: .82rem; color: var(--muted2); margin-bottom: .35rem; }
.breadcrumb a { color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .7rem; margin-bottom: 1rem; }
@media (max-width: 480px) { .stats { grid-template-columns: 1fr 1fr; gap: .5rem; } }
.stat { position: relative; overflow: hidden; background: linear-gradient(180deg, var(--panel), rgba(14,27,48,.6)); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem .9rem; }
body.light .stat { background: var(--panel); }
.stat::after { content: ''; position: absolute; top: -30px; right: -30px; width: 90px; height: 90px; border-radius: 50%; background: radial-gradient(circle, rgba(45,212,234,.12), transparent 70%); }
.stat .label { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; font-weight: 600; }
.stat .value { font-family: var(--font-head); font-size: 1.55rem; font-weight: 800; line-height: 1.2; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

.dataset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .75rem; }
@media (max-width: 480px) { .dataset-grid { grid-template-columns: 1fr; } }
.dataset-card { background: linear-gradient(180deg, var(--panel), rgba(14,27,48,.6)); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem; display: flex; flex-direction: column; gap: .4rem; transition: border-color .15s; }
body.light .dataset-card { background: var(--panel); }
.dataset-card:hover { border-color: rgba(45,212,234,.45); }
.dataset-card h3 { margin: 0; font-size: 1rem; }
.dataset-card .meta { color: var(--muted); font-size: .84rem; }
.dataset-card .counts { display: flex; gap: .85rem; font-size: .82rem; margin-top: .25rem; color: var(--muted); }
.dataset-card .counts b { font-size: 1rem; color: var(--silver); }
.dataset-card .actions { margin-top: auto; display: flex; gap: .4rem; flex-wrap: wrap; padding-top: .5rem; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: var(--tap); padding: .55rem 1rem; border-radius: 10px; border: 1px solid var(--line2); background: var(--panel2); color: var(--text); font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; line-height: 1.2; white-space: nowrap; transition: all .15s; -webkit-tap-highlight-color: transparent; }
.btn:hover { border-color: var(--teal); color: var(--silver); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--grad); border: none; color: var(--on-grad); box-shadow: 0 4px 16px rgba(45,212,234,.25); }
.btn-primary:hover { filter: brightness(1.08); color: var(--on-grad); }
.btn-success { background: linear-gradient(135deg,#34d399,#0ea5a3); border: none; color: #03201a; box-shadow: 0 4px 16px rgba(52,211,153,.25); }
.btn-success:hover { filter: brightness(1.08); color: #03201a; }
.btn-danger { background: transparent; border-color: rgba(248,113,113,.4); color: #fca5a5; }
.btn-danger:hover { background: rgba(248,113,113,.12); border-color: var(--red); color: #fca5a5; }
body.light .btn-danger { color: var(--red); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--teal); border-color: transparent; }
.btn-sm { min-height: 36px; padding: .35rem .7rem; font-size: .82rem; border-radius: 8px; }
.btn-lg { min-height: 50px; padding: .8rem 1.2rem; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-icon { padding: .35rem .5rem; }
.chip { display: inline-flex; align-items: center; min-height: 34px; padding: .25rem .7rem; border-radius: 999px; border: 1px solid var(--line2); background: var(--panel2); color: var(--muted); font-size: .8rem; font-weight: 600; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.chip.active { background: var(--grad); color: var(--on-grad); border-color: transparent; }
.chip.active.role-company { background: linear-gradient(135deg,#a78bfa,#6366f1); color: #fff; }
.chip.active.role-designation { background: linear-gradient(135deg,#fbbf24,#f59e0b); color: #1a1200; }

/* ---------- Forms ---------- */
label { display: block; font-size: .72rem; font-weight: 600; color: var(--muted); letter-spacing: .6px; text-transform: uppercase; margin: .95rem 0 .4rem; }
form > label:first-child, .form-grid > div:first-child > label, .modal form label:first-of-type { margin-top: .4rem; }
label small { font-weight: 400; text-transform: none; letter-spacing: 0; }
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=hidden]):not([type=submit]):not([type=button]), select, textarea {
  width: 100%; min-height: var(--tap); padding: .6rem .85rem; border: 1px solid var(--line2); border-radius: 10px; font: inherit; font-size: 16px; line-height: 1.35; background: var(--field); color: var(--silver); outline: none; transition: border .15s, box-shadow .15s; -webkit-appearance: none; appearance: none;
}
input::placeholder, textarea::placeholder { color: var(--muted2); opacity: 1; }
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 2.2rem; }
input[type=date] { min-height: var(--tap); }
input[type=search]::-webkit-search-cancel-button { -webkit-appearance: none; }
input:-webkit-autofill, input:-webkit-autofill:focus { -webkit-text-fill-color: var(--silver); -webkit-box-shadow: 0 0 0 1000px var(--field) inset; transition: background-color 9999s; }
select option { background: var(--panel); }
input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(45,212,234,.12); }
input[type=date]::-webkit-calendar-picker-indicator { filter: invert(.75); cursor: pointer; }
body.light input[type=date]::-webkit-calendar-picker-indicator { filter: none; }
textarea { min-height: 76px; resize: vertical; line-height: 1.5; }
input.is-missing, textarea.is-missing { border-color: rgba(251,191,36,.6); }
input.is-uncertain, textarea.is-uncertain { border-color: var(--amber); background: rgba(251,191,36,.08); }
.field-hint { font-size: .76rem; color: var(--muted2); margin-top: .2rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 .9rem; }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 480px) { .form-grid { grid-template-columns: 1fr; } }
.check { display: inline-flex; align-items: center; gap: .45rem; font-weight: 500; margin: 0; color: var(--text); text-transform: none; letter-spacing: 0; font-size: .88rem; min-height: 36px; }
.check input { width: 20px; height: 20px; accent-color: var(--teal2); }
.search-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: .75rem; }
.search-row input[type=search] { flex: 1 1 220px; }
.search-row select { width: auto; flex: 1 1 140px; }
@media (max-width: 480px) { .search-row .btn { flex: 1 1 calc(50% - .5rem); } }

.rep-list { display: flex; flex-direction: column; gap: .45rem; }
.rep-row { display: grid; gap: .4rem; align-items: center; grid-template-columns: 1fr; padding: .55rem; border: 1px solid var(--line); border-radius: 10px; background: rgba(10,21,38,.5); }
body.light .rep-row { background: var(--panel2); }
.rep-row input, .rep-row select { margin: 0; }
.rep-row .rep-main { grid-column: 1 / -1; }
.rep-row .rep-remove { justify-self: end; }
.rep-row .rep-sub { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; grid-column: 1 / -1; }
.rep-row .rep-foot { display: flex; justify-content: space-between; align-items: center; grid-column: 1 / -1; }
@media (min-width: 640px) {
  .rep-row.phone { grid-template-columns: 2fr 1fr .7fr .7fr auto auto; }
  .rep-row.phone .rep-main, .rep-row.phone .rep-sub, .rep-row.phone .rep-foot { grid-column: auto; display: contents; }
  .rep-row.email { grid-template-columns: 2fr 1fr auto auto; }
  .rep-row.email .rep-main, .rep-row.email .rep-foot { grid-column: auto; display: contents; }
}
.rep-row.address { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.rep-row.address .rep-main { grid-column: 1 / -1; }
.rep-row.address .rep-remove { grid-column: 1 / -1; }

/* ---------- Alerts / badges ---------- */
.alert { padding: .65rem .8rem; border-radius: 10px; border: 1px solid transparent; margin: .5rem 0; font-size: .88rem; }
.alert-error { background: rgba(248,113,113,.12); color: #fca5a5; border-color: rgba(248,113,113,.35); }
.alert-warn { background: rgba(251,191,36,.12); color: #fcd34d; border-color: rgba(251,191,36,.35); }
.alert-info { background: var(--grad-soft); color: var(--text); border-color: rgba(45,212,234,.25); }
.alert-success { background: rgba(52,211,153,.12); color: #6ee7b7; border-color: rgba(52,211,153,.35); }
body.light .alert-error { color: #991b1b; } body.light .alert-warn { color: #92400e; } body.light .alert-success { color: #065f46; }
.alert ul { margin: .25rem 0 0 1.1rem; padding: 0; }
.alert a { color: inherit; text-decoration: underline; }
.badge { display: inline-block; padding: .12rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 700; letter-spacing: .3px; background: var(--panel2); border: 1px solid var(--line2); color: var(--muted); }
.badge-green { background: rgba(52,211,153,.14); color: #6ee7b7; border-color: rgba(52,211,153,.35); }
.badge-amber { background: rgba(251,191,36,.14); color: #fcd34d; border-color: rgba(251,191,36,.35); }
.badge-blue { background: var(--grad-soft); color: var(--teal); border-color: rgba(45,212,234,.3); }
.badge-red { background: rgba(248,113,113,.14); color: #fca5a5; border-color: rgba(248,113,113,.35); }
body.light .badge-green { color: #065f46; } body.light .badge-amber { color: #92400e; } body.light .badge-red { color: #991b1b; }

/* ---------- Tables (desktop) + card rows (mobile) ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(180deg, var(--panel), rgba(14,27,48,.5)); }
body.light .table-wrap { background: var(--panel); }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: .6rem .7rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: rgba(10,21,38,.6); font-size: .68rem; text-transform: uppercase; letter-spacing: 1.1px; color: var(--muted2); white-space: nowrap; font-weight: 700; }
body.light th { background: var(--panel2); }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--teal); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(45,212,234,.045); }
td.actions { white-space: nowrap; }
td a { color: var(--silver); }
.contact-cards { display: none; }
@media (max-width: 760px) {
  .table-wrap.responsive { display: none; }
  .contact-cards { display: flex; flex-direction: column; gap: .5rem; }
  .ccard { display: grid; grid-template-columns: auto 1fr auto; gap: .6rem; align-items: center; padding: .7rem .75rem; border: 1px solid var(--line); border-radius: 12px; background: linear-gradient(180deg, var(--panel), rgba(14,27,48,.6)); }
  body.light .ccard { background: var(--panel); }
  .ccard input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--teal2); }
  .ccard .cc-main { min-width: 0; }
  .ccard .cc-name { font-weight: 700; color: var(--silver); font-size: .95rem; }
  .ccard .cc-sub { font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ccard .cc-meta { font-size: .76rem; color: var(--muted2); margin-top: .15rem; display: flex; gap: .5rem; flex-wrap: wrap; }
  .ccard .cc-act { display: flex; flex-direction: column; gap: .3rem; }
}
.pager { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-top: .75rem; flex-wrap: wrap; font-size: .86rem; color: var(--muted); }
.dl { display: grid; grid-template-columns: 150px 1fr; gap: .35rem .75rem; font-size: .9rem; }
.dl dt { color: var(--muted2); font-size: .78rem; text-transform: uppercase; letter-spacing: .5px; font-weight: 600; padding-top: .1rem; }
.dl dd { margin: 0; white-space: pre-wrap; word-break: break-word; color: var(--text); }
@media (max-width: 520px) { .dl { grid-template-columns: 1fr; } .dl dt { margin-top: .4rem; } }

/* ---------- Empty / loading ---------- */
.empty { text-align: center; padding: 2rem 1rem; color: var(--muted2); }
.empty h3 { color: var(--silver); }
.loading-block { display: flex; align-items: center; gap: .6rem; color: var(--muted); padding: 1.5rem; justify-content: center; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line2); border-top-color: var(--teal); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { height: 8px; background: var(--panel3); border-radius: 999px; overflow: hidden; margin: .4rem 0; }
.progress > div { height: 100%; background: var(--grad); width: 0; transition: width .25s; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; right: 1rem; bottom: calc(1rem + var(--safe-b)); display: flex; flex-direction: column; gap: .5rem; z-index: 100; max-width: min(92vw, 380px); }
@media (max-width: 760px) { .toasts { left: .75rem; right: .75rem; bottom: calc(80px + var(--safe-b)); max-width: none; } }
.toast { background: var(--panel3); color: var(--silver); border: 1px solid var(--line2); padding: .65rem .9rem; border-radius: 10px; box-shadow: var(--shadow); font-size: .9rem; animation: fadein .2s; }
.toast-success { border-color: rgba(52,211,153,.5); }
.toast-error { border-color: rgba(248,113,113,.6); background: rgba(127,29,29,.85); color: #fee2e2; }
.toast-warn { border-color: rgba(251,191,36,.6); }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Modal (bottom sheet on mobile) ---------- */
.modal-backdrop { position: fixed; inset: 0; background: var(--scrim); display: flex; align-items: center; justify-content: center; z-index: 90; padding: 1rem; }
.modal { background: var(--panel); border: 1px solid var(--line2); border-radius: 16px; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; padding: 1.1rem; box-shadow: var(--shadow); }
.modal h2 { margin-top: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; flex-wrap: wrap; }
.modal-lg { max-width: 820px; }
@media (max-width: 640px) {
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal { max-width: none; border-radius: 18px 18px 0 0; max-height: 94vh; padding: 1rem 1rem calc(1rem + var(--safe-b)); animation: sheet .22s ease-out; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; }
  .modal-actions .btn[style*="margin-right:auto"] { width: 100%; margin: 0 !important; }
}
@keyframes sheet { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }

/* ---------- Scanner ---------- */
.scan-sides { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
@media (max-width: 640px) { .scan-sides { grid-template-columns: 1fr; } }
.side-box { border: 1.5px dashed var(--line2); border-radius: var(--radius); padding: .75rem; background: rgba(10,21,38,.4); display: flex; flex-direction: column; gap: .5rem; }
body.light .side-box { background: var(--panel2); }
.side-box.has-image { border-style: solid; }
.side-box.side-front { border-color: rgba(45,212,234,.5); }
.side-box.side-back { border-color: rgba(167,139,250,.5); }
.side-box h3 { display: flex; justify-content: space-between; align-items: center; margin: 0; }
.side-preview { position: relative; background: #04101e; border-radius: 10px; min-height: 150px; display: grid; place-items: center; overflow: hidden; }
.side-preview img, .side-preview canvas { max-width: 100%; max-height: 300px; display: block; }
.side-preview .placeholder { color: #7f95b3; font-size: .88rem; text-align: center; padding: 1rem; }
.side-controls { display: flex; gap: .4rem; flex-wrap: wrap; }
.side-controls .btn { flex: 1 1 auto; }
.capture-btn { font-size: 1rem; min-height: 50px; }
.scan-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .75rem; }
.scan-actions .btn-primary, .scan-actions .btn-success { flex: 1 1 220px; }
@media (max-width: 640px) { .scan-actions .btn { flex: 1 1 100%; } }
.ocr-status { display: flex; align-items: center; gap: .6rem; padding: .6rem .8rem; border-radius: 10px; background: var(--panel2); border: 1px solid var(--line2); margin-top: .75rem; }
.ocr-status.is-error { background: rgba(248,113,113,.12); border-color: rgba(248,113,113,.4); }
.ocr-status.is-warn { background: rgba(251,191,36,.12); border-color: rgba(251,191,36,.4); }
.ocr-status.is-ok { background: rgba(52,211,153,.12); border-color: rgba(52,211,153,.4); }
.raw-text { white-space: pre-wrap; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .78rem; background: var(--field); border: 1px solid var(--line); border-radius: 10px; padding: .6rem; max-height: 220px; overflow: auto; color: var(--text); }
.review-layout { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 980px) { .review-layout { grid-template-columns: 320px 1fr; align-items: start; } .review-side { position: sticky; top: 64px; } }
.review-side .side-preview { min-height: 100px; }
.review-side .side-preview img { max-height: 200px; }
@media (max-width: 760px) { .review-side .scan-sides { grid-template-columns: 1fr 1fr; } .review-side .side-preview img { max-height: 120px; } .review-side .side-box { padding: .4rem; } }

/* Line picker: assign recognised lines to name / company / designation */
.line-picker { border: 1px solid rgba(45,212,234,.3); border-radius: var(--radius); background: var(--grad-soft); padding: .8rem; margin-bottom: 1rem; }
.line-picker h3 { margin: 0 0 .25rem; }
.line-picker .lp-help { font-size: .82rem; color: var(--muted); margin-bottom: .6rem; }
.lp-list { display: flex; flex-direction: column; gap: .4rem; }
.lp-row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; padding: .45rem .55rem; border-radius: 10px; background: rgba(10,21,38,.55); border: 1px solid var(--line); }
body.light .lp-row { background: var(--panel); }
.lp-row .lp-text { flex: 1 1 160px; font-size: .9rem; color: var(--silver); word-break: break-word; }
.lp-row .lp-side { font-size: .65rem; color: var(--muted2); text-transform: uppercase; letter-spacing: .5px; }
.lp-row .lp-chips { display: flex; gap: .3rem; flex-wrap: wrap; }
.lp-row.assigned-name { border-color: rgba(45,212,234,.6); }
.lp-row.assigned-company { border-color: rgba(167,139,250,.6); }
.lp-row.assigned-designation { border-color: rgba(251,191,36,.6); }
.lp-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .4rem; margin-top: .6rem; font-size: .82rem; }
.lp-summary div { background: rgba(10,21,38,.55); border: 1px solid var(--line); border-radius: 8px; padding: .4rem .55rem; }
body.light .lp-summary div { background: var(--panel); }
.lp-summary b { display: block; font-size: .66rem; text-transform: uppercase; letter-spacing: .5px; color: var(--muted2); }
.lp-summary span { color: var(--silver); }
.lp-summary .lp-empty span { color: var(--amber); }

/* sticky save bar on mobile */
.save-bar { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .75rem; }
@media (max-width: 760px) {
  .save-bar { position: sticky; bottom: calc(66px + var(--safe-b)); z-index: 25; background: rgba(10,20,36,.95); backdrop-filter: blur(10px); border: 1px solid var(--line2); border-radius: 14px; padding: .55rem; margin: .75rem -.25rem 0; }
  body.light .save-bar { background: rgba(255,255,255,.95); }
  .save-bar .btn-success { flex: 1 1 100%; }
  .save-bar .btn:not(.btn-success) { flex: 1 1 40%; }
}

.crop-stage { position: relative; background: #04101e; border-radius: 10px; overflow: hidden; touch-action: none; user-select: none; }
.crop-stage canvas { display: block; max-width: 100%; }
.crop-box { position: absolute; border: 2px solid #ffd54f; box-shadow: 0 0 0 9999px rgba(0,0,0,.5); cursor: move; }
.crop-handle { position: absolute; width: 26px; height: 26px; background: #ffd54f; border-radius: 50%; border: 2px solid #1d2b3a; }
.crop-handle.nw { left: -13px; top: -13px; cursor: nwse-resize; }
.crop-handle.ne { right: -13px; top: -13px; cursor: nesw-resize; }
.crop-handle.sw { left: -13px; bottom: -13px; cursor: nesw-resize; }
.crop-handle.se { right: -13px; bottom: -13px; cursor: nwse-resize; }
.range-row { display: grid; grid-template-columns: 90px 1fr 44px; gap: .5rem; align-items: center; font-size: .86rem; }
.range-row input[type=range] { width: 100%; accent-color: var(--teal2); }
video.camera { width: 100%; max-height: 70vh; background: #000; border-radius: 10px; display: block; }
.camera-overlay { position: absolute; inset: 10%; border: 2px solid rgba(255,255,255,.7); border-radius: 8px; pointer-events: none; }
.dup-item { border: 1px solid var(--line); border-radius: 10px; padding: .6rem; margin-top: .5rem; background: rgba(10,21,38,.5); }
body.light .dup-item { background: var(--panel2); }
.dup-item .reasons { color: var(--amber); font-size: .82rem; }

/* ---------- Auth pages ---------- */
.auth-body { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.auth-card { width: 100%; max-width: 420px; background: linear-gradient(180deg, var(--panel), var(--bg2)); border: 1px solid var(--line2); border-radius: 20px; padding: 1.6rem 1.4rem; box-shadow: var(--shadow); }
body.light .auth-card { background: var(--panel); }
.auth-card-wide { max-width: 540px; }
.auth-card h1 { text-align: center; font-size: 1.05rem; font-weight: 600; color: var(--muted); letter-spacing: .5px; margin: .2rem 0 1rem; }
.auth-card .btn-block { margin-top: 1rem; }
.auth-card table td { font-size: .86rem; }
@media (max-width: 480px) { .auth-body { padding: .6rem; align-items: start; } .auth-card { padding: 1.3rem 1rem; } }

/* theme toggle */
.theme-toggle { display: inline-flex; align-items: center; gap: .4rem; }
@media print { .topbar, .bottomnav, .toasts, .btn, .save-bar { display: none !important; } }
