/* IndiaMART Supplier Intelligence — dashboard styles */
:root {
  --bg: #0f1418;
  --bg-soft: #151c22;
  --panel: #1a232a;
  --panel-2: #202b34;
  --line: #2a3843;
  --text: #e6eef4;
  --muted: #8fa6b5;
  --accent: #35c4a6;
  --accent-dim: #1f7f6c;
  --warn: #f0b429;
  --bad: #ef6461;
  --ok: #4fc38a;
  --info: #59a5e5;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.35);
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif; }
h1, h2, h3 { font-weight: 650; margin: 0 0 8px; letter-spacing: .2px; }
h1 { font-size: 15px; } h2 { font-size: 15px; } h3 { font-size: 13px; color: var(--muted); }
a { color: var(--accent); }
code { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.hidden { display: none !important; }

.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

/* ── sidebar ── */
.sidebar { background: var(--bg-soft); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 18px; padding: 18px 14px; position: sticky;
  top: 0; height: 100vh; }
.brand { display: flex; gap: 10px; align-items: center; }
.brand p { margin: 0; font-size: 11px; color: var(--muted); letter-spacing: .6px;
  text-transform: uppercase; }
.brand h1 { color: var(--text); }
.brand-mark { width: 26px; height: 26px; border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim)); box-shadow: var(--shadow); }
nav { display: flex; flex-direction: column; gap: 2px; }
nav a { color: var(--muted); text-decoration: none; padding: 9px 11px; border-radius: 8px;
  font-size: 13.5px; }
nav a:hover { background: var(--panel); color: var(--text); }
nav a.active { background: var(--panel-2); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
.backend-state { font-size: 12px; padding: 6px 8px; border-radius: 8px; background: var(--panel); }
.backend-state.ok { color: var(--ok); } .backend-state.bad { color: var(--bad); }
.local-note { font-size: 11px; color: var(--muted); }

/* ── main ── */
.main { padding: 0 20px 32px; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 14px 0;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 5; }
.run-select { display: flex; align-items: center; gap: 8px; }
.run-select label { color: var(--muted); font-size: 12px; }
select, input { background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 9px; font: inherit; min-width: 0; }
select:focus, input:focus { outline: 2px solid var(--accent-dim); border-color: var(--accent); }
#run-picker { max-width: 340px; }
.topbar-spacer { flex: 1; }
.elapsed { color: var(--muted); font-family: var(--mono); font-size: 12.5px; }
.status-pill { padding: 5px 12px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
  letter-spacing: .8px; text-transform: uppercase; background: var(--panel); color: var(--muted);
  border: 1px solid var(--line); white-space: nowrap; }
.status-pill.running, .status-pill.discovering, .status-pill.enriching { color: var(--info); border-color: var(--info); }
.status-pill.complete { color: var(--ok); border-color: var(--ok); }
.status-pill.partial, .status-pill.stopping { color: var(--warn); border-color: var(--warn); }
.status-pill.error, .status-pill.failed { color: var(--bad); border-color: var(--bad); }

.banner { margin-top: 14px; padding: 10px 14px; border-radius: var(--radius);
  background: #2a1f14; border: 1px solid var(--warn); color: #f6d98b; }
.banner.bad { background: #2a1515; border-color: var(--bad); color: #f7b7b5; }
.banner.ok { background: #12271e; border-color: var(--ok); color: #a6e3c4; }
.page { padding-top: 18px; display: flex; flex-direction: column; gap: 16px; }

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.hint { color: var(--muted); font-size: 12px; margin: 0 0 10px; }

/* ── controls ── */
.field-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 12px; }
.field-grid label, .toggles label { display: flex; flex-direction: column; gap: 4px;
  font-size: 12px; color: var(--muted); }
.field-grid .span2 { grid-column: span 2; }
.toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.toggles label { flex-direction: row; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text); }
.toggles input { width: 15px; height: 15px; accent-color: var(--accent); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
button, .btn { font: inherit; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); padding: 8px 13px; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
button:hover:not(:disabled), .btn:hover { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent-dim); border-color: var(--accent); color: #eafaf5; font-weight: 650; }
button.danger { background: #3a1d1d; border-color: var(--bad); color: #f6c0be; }
button.ghost { background: transparent; }
.command { margin-top: 12px; font-family: var(--mono); font-size: 11.5px; color: var(--muted);
  background: var(--bg-soft); padding: 8px 10px; border-radius: 8px; word-break: break-all; }

/* ── progress ── */
.progress-wrap { margin-bottom: 12px; }
.progress { height: 8px; background: var(--bg-soft); border-radius: 999px; overflow: hidden;
  border: 1px solid var(--line); }
#progress-bar { height: 100%; background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  transition: width .4s ease; }
.progress.indeterminate #progress-bar { width: 35% !important; animation: slide 1.6s infinite; }
@keyframes slide { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }
.stages { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.stage { font-size: 11.5px; padding: 5px 9px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--bg-soft); color: var(--muted); }
.stage.DONE { color: var(--ok); border-color: var(--ok); }
.stage.RUNNING { color: var(--info); border-color: var(--info); }
.stage.FAILED { color: var(--bad); border-color: var(--bad); }
.stage.DISABLED { opacity: .5; text-decoration: line-through; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(126px, 1fr)); gap: 10px; }
.kpi { background: var(--bg-soft); border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; }
.kpi b { display: block; font-size: 19px; font-weight: 700; letter-spacing: -.3px; }
.kpi span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.kpi.zero b { color: var(--muted); }
/* A caption is not a metric: a paragraph placed in a KPI-card strip spans the
   strip's full width instead of being squeezed into one ~126px KPI cell. */
.cards > p { grid-column: 1 / -1; margin: 0; }
.log { background: var(--bg-soft); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px; font-family: var(--mono); font-size: 11.5px; color: #c8d7e2;
  max-height: 260px; overflow: auto; white-space: pre-wrap; margin: 0; }
.artifacts { font-family: var(--mono); font-size: 11.5px; color: var(--muted);
  word-break: break-all; display: flex; flex-direction: column; gap: 4px; }

/* ── tables ── */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filters button { padding: 5px 10px; font-size: 12px; border-radius: 999px; }
.filters button.active { background: var(--accent-dim); border-color: var(--accent); color: #eafaf5; }
.search { flex: 1; min-width: 200px; }
.pager { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.table-scroll { overflow: auto; max-height: 74vh; border-radius: 8px; border: 1px solid var(--line); }
.data-table { width: 100%; border-collapse: collapse; font-size: 12.8px; }
.data-table th, .data-table td { padding: 7px 9px; border-bottom: 1px solid var(--line);
  text-align: left; vertical-align: top; }
.data-table thead th { position: sticky; top: 0; background: var(--panel-2); z-index: 2;
  white-space: nowrap; font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted); cursor: pointer; }
.data-table thead th.sorted::after { content: " ▾"; color: var(--accent); }
.data-table thead th.sorted.asc::after { content: " ▴"; color: var(--accent); }
.data-table tbody tr { cursor: pointer; }
.data-table tbody tr:hover { background: var(--panel-2); }
.data-table td.nowrap { white-space: nowrap; }
.data-table td .sub { display: block; color: var(--muted); font-size: 11px; }
.badge { display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: .4px;
  padding: 2px 7px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg-soft);
  color: var(--muted); margin: 1px 3px 1px 0; white-space: nowrap; }
.badge.ok { color: var(--ok); border-color: var(--ok); }
.badge.warn { color: var(--warn); border-color: var(--warn); }
.badge.bad { color: var(--bad); border-color: var(--bad); }
.badge.info { color: var(--info); border-color: var(--info); }
.badge.muted { color: var(--muted); }
.empty { padding: 22px; text-align: center; color: var(--muted); font-size: 13px; }

.basis { padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 600;
  border: 1px solid var(--line); white-space: nowrap; }
.basis.OBSERVED { background: #dff1e2; color: #1b5e20; }
.basis.DERIVED { background: #dcebfb; color: #0d3c61; }
.basis.NOT_AVAILABLE { background: #f0f0f0; color: #666; }
.bars { display: flex; flex-direction: column; gap: 7px; }
.bar { display: grid; grid-template-columns: 168px 1fr 52px; gap: 9px; align-items: center; font-size: 12.5px; }
.bar .track { height: 8px; border-radius: 999px; background: var(--bg-soft); border: 1px solid var(--line); overflow: hidden; }
.bar .fill { height: 100%; background: var(--accent-dim); }
.bar b { text-align: right; font-weight: 650; }
.kv, .defs { display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; font-size: 12.5px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-family: var(--mono); word-break: break-all; }
.defs div { grid-column: 1 / -1; font-size: 12px; color: var(--muted); border-bottom: 1px dashed var(--line); padding: 5px 0; }
.defs b { color: var(--text); }

/* ── drawer ── */
.drawer { position: fixed; inset: 0; z-index: 20; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(6,10,13,.65); }
.drawer-panel { position: absolute; right: 0; top: 0; bottom: 0; width: min(760px, 92vw);
  background: var(--bg-soft); border-left: 1px solid var(--line); display: flex;
  flex-direction: column; box-shadow: -12px 0 30px rgba(0,0,0,.45); }
.drawer[aria-hidden="true"] { display: none; }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px;
  border-bottom: 1px solid var(--line); }
.drawer-head h2 { flex: 1; margin: 0; }
.drawer-body { overflow: auto; padding: 16px 18px 40px; }
.drawer-body section { margin-bottom: 20px; }
.drawer-body h3 { text-transform: uppercase; letter-spacing: .8px; font-size: 11.5px;
  color: var(--accent); border-bottom: 1px solid var(--line); padding-bottom: 5px; }

/* ── password overlay (shown by app.js on any HTTP 401) ── */
.auth-overlay { position: fixed; inset: 0; z-index: 40; display: flex;
  align-items: center; justify-content: center; background: rgba(6,10,13,.8); }
.auth-card { display: flex; flex-direction: column; gap: 10px; width: min(340px, 90vw);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; box-shadow: 0 12px 40px rgba(0,0,0,.55); }
.auth-card h2 { margin: 0; }
.auth-card input { width: 100%; }
.rows { display: grid; grid-template-columns: max-content 1fr; gap: 5px 14px; font-size: 13px; }
.rows dt { color: var(--muted); font-size: 12px; }
.rows dd { margin: 0; word-break: break-word; }
.rows dd a { text-decoration: none; }
.cand { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 9px;
  background: var(--panel); }
.cand .cand-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 7px; }
.cand .cand-head b { font-family: var(--mono); font-size: 14px; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 40; }
.toast { background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 8px; padding: 10px 13px; font-size: 12.5px; max-width: 420px; box-shadow: var(--shadow); }
.toast.bad { border-left-color: var(--bad); }
.toast.warn { border-left-color: var(--warn); }

/* ── advanced options ── */
.advanced { margin: 10px 0; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--bg-soft); }
.advanced summary { cursor: pointer; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.advanced summary:hover { color: var(--text); }
.advanced[open] summary { margin-bottom: 10px; color: var(--accent); }

/* ── resource status ── */
.resource-status { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.resource-chip { font-size: 11px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg-soft); color: var(--muted); font-weight: 600; }
.resource-chip.NORMAL { color: var(--ok); border-color: var(--ok); }
.resource-chip.PRESSURE { color: var(--warn); border-color: var(--warn); }
.resource-chip.START_REFUSED { color: var(--bad); border-color: var(--bad); }
.resource-chip.STOPPING_FOR_PRESSURE { color: var(--bad); border-color: var(--bad); }
.resource-chip.RECOVERED { color: var(--info); border-color: var(--info); }

/* ── scrapers page ── */
.scraper-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.scraper-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.scraper-card h3 { margin: 0 0 4px; font-size: 14px; color: var(--text); }
.scraper-card .platform { font-size: 11px; color: var(--accent); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px; }
.scraper-card .desc { font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
.scraper-card .caps { display: flex; flex-wrap: wrap; gap: 5px; }
.scraper-card .cap { font-size: 10.5px; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg-soft); color: var(--muted); }

/* ── run detail tabs ── */
.run-tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 1px solid var(--line); padding-bottom: 0; }
.run-tabs button { border-radius: 8px 8px 0 0; border: 1px solid transparent; border-bottom: 0; background: transparent; color: var(--muted); padding: 8px 14px; font-size: 12.5px; }
.run-tabs button.active { background: var(--panel); border-color: var(--line); color: var(--text); font-weight: 600; }
.run-tabs button:hover { color: var(--text); }

/* ── charts ── */
.chart-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; font-size: 12px; }
.chart-bar .label { width: 140px; text-align: right; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chart-bar .track { flex: 1; height: 18px; background: var(--bg-soft); border-radius: 4px; overflow: hidden; }
.chart-bar .fill { height: 100%; background: var(--accent-dim); border-radius: 4px; }
.chart-bar .value { width: 50px; text-align: right; font-weight: 600; font-size: 11.5px; }

/* ── responsive: tablet drops the columns marked hideAt, mobile becomes cards ── */
@media (max-width: 1180px) {
  .grid.two { grid-template-columns: 1fr; }
  .field-grid { grid-template-columns: repeat(2, 1fr); }
  .app { grid-template-columns: 196px 1fr; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap;
    align-items: center; gap: 10px; }
  nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-foot { margin: 0; }
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table tr { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px;
    padding: 6px 8px; background: var(--panel); }
  .data-table td { border: 0; padding: 3px 0; display: grid;
    grid-template-columns: 128px 1fr; gap: 10px; }
  .data-table td::before { content: attr(data-col); color: var(--muted); font-size: 11px;
    text-transform: uppercase; letter-spacing: .4px; }
  .table-scroll { max-height: none; border: 0; overflow: visible; }
  .drawer-panel { width: 100%; border-left: 0; }
}

/* P2.14 verified people — read-only person records inside the existing
   business detail; no new navigation, no new visual language. */
.people { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.people-title { margin: 0 0 6px; font-size: 13px; color: var(--text); }
.people-group { color: var(--muted); font-size: 11px; text-transform: uppercase;
  letter-spacing: .5px; margin: 8px 0 4px; }
.person-card { background: var(--panel-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 8px 10px; margin-bottom: 6px; }
.person-card > div { margin: 0 0 2px; }
.person-name { font-weight: 650; }
.person-evidence { word-break: break-all; }
.people-index { margin-top: 16px; }
.people-index .empty { padding: 12px; text-align: left; }
