/* The scrape dashboard. One column of sections, as the Streamlit page had,
   in Persian, right to left, light or dark with the reader's system. */
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --text: #17212b;
  --muted: #5f6b76;
  --border: #e3e8ec;
  --accent: #0f766e;
  --accent-soft: #e3f3f1;
  --ok: #15803d;
  --ok-soft: #e7f6ec;
  --info: #1d4ed8;
  --info-soft: #e8efff;
  --warn: #b45309;
  --warn-soft: #fdf3e2;
  --danger: #c2410c;
  --danger-soft: #fdece4;
  --bar: #e9eef2;
  --shadow: 0 1px 2px rgba(16, 24, 32, .05), 0 4px 14px rgba(16, 24, 32, .04);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1418;
    --surface: #161d23;
    --surface-2: #1b232a;
    --text: #e7edf2;
    --muted: #93a1ad;
    --border: #26313a;
    --accent: #2dd4bf;
    --accent-soft: #10302d;
    --ok: #4ade80;
    --ok-soft: #12291b;
    --info: #7aa2ff;
    --info-soft: #18233d;
    --warn: #fbbf24;
    --warn-soft: #2d2412;
    --danger: #fb923c;
    --danger-soft: #2f1c12;
    --bar: #24303a;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: Vazirmatn, Tahoma, sans-serif;
  font-size: 14px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }

/* ── top bar ── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { max-width: 1240px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 14px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; }
@media (prefers-color-scheme: dark) { .brand-mark { color: #08201d; } }
.brand h1 { margin: 0; font-size: 16px; font-weight: 800; line-height: 1.3; }
.brand small { display: block; color: var(--muted); font-size: 11.5px; font-weight: 500; letter-spacing: .02em; direction: ltr; text-align: right; }
.topbar .spacer { flex: 1; }
.live { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); animation: pulse 2s infinite; }
.live.is-off i { background: var(--danger); animation: none; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.dry { background: var(--warn-soft); color: var(--warn); border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 700; }

/* ── page ── */
.page { max-width: 1240px; margin: 0 auto; padding: 22px 20px 60px; display: flex; flex-direction: column; gap: 18px; }
.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px 20px;
}
.section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.section-head h2 { margin: 0; font-size: 16px; font-weight: 800; }
.section-head .num { width: 26px; height: 26px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 13px; font-weight: 800; }
.section-head .refresh { margin-inline-start: auto; color: var(--muted); font-size: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* ── alerts, as st.success / st.info / st.error ── */
.alert { border-radius: 10px; padding: 10px 14px; margin: 0 0 12px; font-size: 13.5px; border: 1px solid transparent; }
.alert-ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.alert-info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 22%, transparent); }
.alert-warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }

/* ── progress bar, as st.progress ── */
.progress { margin: 4px 0 16px; }
.progress-label { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.progress-label b { color: var(--text); font-size: 15px; }
.progress-track { height: 12px; border-radius: 999px; background: var(--bar); overflow: hidden; }
.progress-track span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #fff)); transition: width .6s ease; }

/* ── metrics, as st.metric ── */
.metrics { display: grid; gap: 10px; margin-bottom: 10px; }
.metrics-5 { grid-template-columns: repeat(5, 1fr); }
.metrics-6 { grid-template-columns: repeat(6, 1fr); }
.metrics-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 1050px) { .metrics-5, .metrics-6 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 600px) { .metrics-5, .metrics-6, .metrics-3 { grid-template-columns: repeat(2, 1fr); } }
.metric { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.metric .label { color: var(--muted); font-size: 12px; line-height: 1.5; min-height: 2.6em; }
.metric .value { font-size: 21px; font-weight: 800; line-height: 1.35; margin-top: 2px; overflow-wrap: anywhere; }
.metric .value.small { font-size: 15.5px; }
.metric .hint { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.metric.is-bad .value { color: var(--danger); }
.metric.is-good .value { color: var(--ok); }

.caption { color: var(--muted); font-size: 12.5px; margin: 8px 0 0; line-height: 1.9; }

/* ── tables, as st.dataframe ── */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; margin-top: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { background: var(--surface-2); color: var(--muted); font-weight: 700; text-align: right; padding: 9px 12px; white-space: nowrap; border-bottom: 1px solid var(--border); }
td { padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: left; font-variant-numeric: tabular-nums; }
.chip { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--bar); color: var(--muted); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.run { background: var(--info-soft); color: var(--info); }
.cell-bar { display: flex; align-items: center; gap: 8px; min-width: 150px; }
.cell-bar .track { flex: 1; height: 7px; border-radius: 999px; background: var(--bar); overflow: hidden; }
.cell-bar .track i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.cell-bar b { font-size: 12px; min-width: 46px; text-align: left; }

/* ── expanders, as st.expander ── */
details.expander { border: 1px solid var(--border); border-radius: 12px; margin-top: 12px; background: var(--surface); }
details.expander > summary { cursor: pointer; padding: 10px 14px; font-weight: 700; font-size: 13.5px; list-style: none; display: flex; align-items: center; gap: 8px; }
details.expander > summary::-webkit-details-marker { display: none; }
details.expander > summary::before { content: '‹'; display: inline-block; transition: transform .2s; color: var(--muted); font-size: 18px; line-height: 1; }
details.expander[open] > summary::before { transform: rotate(-90deg); }
details.expander > .body { padding: 2px 16px 14px; }
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { padding: 4px 0; }

/* ── forms and buttons ── */
.controls { display: grid; grid-template-columns: auto auto 1fr; gap: 12px; align-items: start; }
@media (max-width: 760px) { .controls { grid-template-columns: 1fr; } }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 8px 16px; font-weight: 700; font-size: 13.5px; cursor: pointer; transition: background .15s, border-color .15s, opacity .15s; text-decoration: none; color: var(--text); white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .btn-primary { color: #08201d; } }
.btn-primary:hover { filter: brightness(1.06); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); background: var(--danger-soft); }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.input, select.input { height: 38px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); padding: 0 12px; min-width: 0; width: 100%; }
.input:focus, .btn:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; }
.form-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; align-items: end; }
@media (max-width: 900px) { .form-grid { grid-template-columns: 1fr 1fr; } }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; margin: 12px 0; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { position: relative; }
.pill input { position: absolute; opacity: 0; pointer-events: none; }
.pill span { display: inline-block; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--border); font-size: 12.5px; cursor: pointer; user-select: none; }
.pill input:checked + span { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 700; }
.pill input:focus-visible + span { outline: 2px solid var(--accent); }
.depth-row { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; flex-wrap: wrap; }
.depth-row .input { width: 90px; }
.depth-row span { font-size: 12.5px; color: var(--muted); }

pre.log { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: 12px; line-height: 1.6; max-height: 300px; overflow: auto; direction: ltr; text-align: left; white-space: pre-wrap; margin: 0; }
.downloads { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.downloads .btn { justify-content: flex-start; }

/* ── charts ── */
.chart-box { position: relative; height: 320px; }
.empty { color: var(--muted); padding: 30px 0; text-align: center; }

/* ── loading shimmer for the first paint of a panel ── */
.skeleton { height: 120px; border-radius: 12px; background: linear-gradient(90deg, var(--surface-2), var(--bar), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── toast for button results ── */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px); opacity: 0; background: var(--text); color: var(--surface); padding: 10px 18px; border-radius: 12px; font-size: 13.5px; transition: all .25s; z-index: 50; max-width: 90vw; box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.is-error { background: var(--danger); color: #fff; }

/* ── login ── */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 28px 26px; box-shadow: var(--shadow); }
.login-card .brand { margin-bottom: 20px; }
.login-card .btn { width: 100%; margin-top: 14px; height: 40px; }

/* ── category colours: one colour per category on every chart.
   Validated set (fixed order, adjacent pairs CVD-safe in both modes);
   in light mode three of them are under 3:1 on the surface, so every
   chart that uses them also carries text labels or a table. ── */
:root {
  --cat-1: #2a78d6; /* آپارتمان */
  --cat-2: #eb6834; /* خانه و ویلا */
  --cat-3: #1baf7a; /* زمین و کلنگی */
  --cat-4: #eda100; /* دفتر کار */
  --cat-5: #e87ba4; /* مغازه */
  --cat-6: #008300; /* صنعتی، کشاورزی و تجاری */
  --cat-7: #8a949c;
}
@media (prefers-color-scheme: dark) {
  :root {
    --cat-1: #3987e5; --cat-2: #d95926; --cat-3: #199e70;
    --cat-4: #c98500; --cat-5: #d55181; --cat-6: #008300; --cat-7: #6b7680;
  }
}
.cat-1 { --c: var(--cat-1); } .cat-2 { --c: var(--cat-2); } .cat-3 { --c: var(--cat-3); }
.cat-4 { --c: var(--cat-4); } .cat-5 { --c: var(--cat-5); } .cat-6 { --c: var(--cat-6); } .cat-7 { --c: var(--cat-7); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; background: var(--c); margin-inline-end: 6px; vertical-align: 0; flex: none; }

.charts .section { display: flex; flex-direction: column; }

/* headline numbers above the daily chart */
.stat-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.stat-strip > div { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 7px 10px; min-width: 0; }
.stat-strip span { display: block; color: var(--muted); font-size: 11.5px; }
.stat-strip b { display: block; font-size: 17px; font-weight: 800; line-height: 1.4; }
.stat-strip small { display: block; color: var(--muted); font-size: 11px; }
@media (max-width: 600px) { .stat-strip { grid-template-columns: repeat(2, 1fr); } }

/* ranked distribution, as a list of bars */
.dist-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.dist-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.dist-name { display: inline-flex; align-items: center; font-size: 13.5px; font-weight: 600; min-width: 0; }
.dist-val { display: inline-flex; align-items: baseline; gap: 8px; white-space: nowrap; }
.dist-val b { font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums; }
.dist-val em { font-style: normal; color: var(--muted); font-size: 12px; min-width: 44px; text-align: left; }
.dist-track { height: 10px; border-radius: 999px; background: var(--bar); overflow: hidden; }
.dist-track span { display: block; height: 100%; min-width: 4px; border-radius: 999px; background: var(--c); transition: width .5s ease; }
.dist-list li:hover .dist-name { color: var(--accent); }
.charts .chart-box { height: 300px; }

/* ── phones ── */
@media (max-width: 640px) {
  .topbar-inner { flex-wrap: wrap; gap: 8px 10px; padding: 8px 12px; }
  .brand h1 { font-size: 14.5px; white-space: nowrap; }
  .brand small, .live #liveText { display: none; }
  .dry { order: 5; flex-basis: 100%; text-align: center; padding: 3px 10px; }
  .page { padding: 14px 10px 40px; gap: 14px; }
  .section { padding: 14px 12px 16px; }
  .section-head h2 { font-size: 15px; }
  .section-head .refresh { display: none; }
  .metric .value { font-size: 18px; }
  .controls .btn { width: 100%; }
}

/* A grid or flex child defaults to its content's width, so one wide table
   (the daily chart's «جدول») stretched its column and then the whole page.
   Let every column shrink; a wide table scrolls inside its own box instead. */
.grid-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 900px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }
.grid-2 > *, .page > *, .charts .section > *, details.expander, details.expander > .body { min-width: 0; }
.chart-box { width: 100%; min-width: 0; }
.chart-box canvas { max-width: 100%; }

/* the daily table: short headers that may wrap, tighter cells, so it fits its card */
.table-compact { font-size: 12px; }
.table-compact th { white-space: normal; line-height: 1.45; padding: 7px 8px; vertical-align: bottom; font-size: 11.5px; }
.table-compact td { padding: 7px 8px; }
.table-compact th .dot { margin-inline-end: 4px; }
details.expander > .body.table-wrap { padding: 0; border: 0; border-top: 1px solid var(--border); border-radius: 0 0 12px 12px; }

/* ── «ارسال به ملکاوید» progress ── */
.push-state { margin-top: 16px; border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; background: var(--surface-2); }
.push-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 14px; margin-bottom: 10px; }
.push-head span { color: var(--muted); font-size: 12.5px; }
.steps { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.steps li { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13.5px; }
.steps li i { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border); flex: none; }
.steps li.is-now { color: var(--text); font-weight: 700; }
.steps li.is-now i { border-color: var(--accent); border-top-color: transparent; animation: spin .9s linear infinite; }
.steps li.is-done { color: var(--text); }
.steps li.is-done i { background: var(--accent); border-color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }
.push-parts { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.push-part { display: grid; grid-template-columns: 52px minmax(0, 1fr) minmax(0, 1.4fr); align-items: center; gap: 10px; font-size: 12.5px; }
.push-part .track { height: 8px; border-radius: 999px; background: var(--bar); overflow: hidden; }
.push-part .track i { display: block; height: 100%; background: var(--info); border-radius: 999px; transition: width .5s; }
.push-part .track i.ok { background: var(--ok); }
.push-part .track i.bad { background: var(--danger); }
.push-part .lbl { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.push-log li { font-size: 12.5px; padding: 2px 0; }

[hidden] { display: none !important; }

/* ── crawl areas ── */
table.areas td { vertical-align: middle; }
table.areas td:nth-child(2) { white-space: normal; min-width: 280px; }
.area-name { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.area-form .pill span { padding: 3px 9px; font-size: 12px; }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.muted { color: var(--muted); font-size: 12px; }
td small.muted { margin-inline-start: 6px; }
.btn-sm { padding: 5px 12px; font-size: 12.5px; border-radius: 8px; }
.area-save:not(:disabled) { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ═══ layout v2: tabs, guidance, live views ═══ */

/* tabs under the top bar */
.tabs { max-width: 1240px; margin: 0 auto; padding: 0 20px; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { display: flex; align-items: center; gap: 9px; border: 0; background: none; padding: 10px 14px 11px; border-bottom: 3px solid transparent; cursor: pointer; color: var(--muted); text-align: right; white-space: nowrap; border-radius: 10px 10px 0 0; }
.tabs button svg { width: 20px; height: 20px; fill: currentColor; flex: none; }
.tabs button span { display: flex; flex-direction: column; line-height: 1.35; }
.tabs button b { font-size: 14px; font-weight: 800; }
.tabs button small { font-size: 11px; }
.tabs button:hover { color: var(--text); background: var(--surface-2); }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tabs button[aria-selected="true"] small { color: var(--muted); }
.tab-panel { display: flex; flex-direction: column; gap: 18px; }
.tab-panel[hidden] { display: none !important; }
@media (max-width: 760px) { .tabs button small { display: none; } .tabs { padding: 0 8px; } .tabs button { padding: 8px 10px 9px; } }

/* what a part of the page is: information or a command */
.banner { border-radius: 12px; padding: 10px 14px; font-size: 13px; border: 1px solid var(--border); }
.banner-info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 20%, transparent); }
.banner-act { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.tag { font-size: 11px; font-weight: 800; padding: 1px 8px; border-radius: 6px; }
.tag-info { background: var(--info-soft); color: var(--info); }
.tag-act { background: var(--warn-soft); color: var(--warn); }
.section.action { border-inline-start: 4px solid var(--warn); }
.section.flash { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent); transition: box-shadow .4s; }
details.section.advanced > summary { cursor: pointer; list-style: none; margin-bottom: 0; }
details.section.advanced > summary::-webkit-details-marker { display: none; }
details.section.advanced[open] > summary { margin-bottom: 8px; }
details.section.advanced:not([open]) { padding-bottom: 14px; }

/* the cycle */
.cycle { list-style: none; margin: 0 0 16px; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; counter-reset: c; }
.cycle li { position: relative; display: flex; flex-direction: column; gap: 2px; padding: 12px 14px 12px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); color: var(--muted); min-width: 0; }
.cycle li b { color: var(--text); font-size: 14px; }
.cycle li small { font-size: 12px; }
.cycle .dot-n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 13px; background: var(--bar); color: var(--muted); margin-bottom: 4px; }
.cycle li.is-done .dot-n { background: var(--ok); color: #fff; }
.cycle li.is-now { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent) inset; }
.cycle li.is-now .dot-n { background: var(--accent); color: #fff; }
.cycle li:not(:last-child)::after { content: '‹'; position: absolute; left: -11px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 18px; z-index: 1; }
@media (max-width: 760px) { .cycle { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cycle li::after { display: none; } }

/* the one thing to do next */
.next { display: flex; align-items: center; gap: 16px; padding: 16px 18px; border-radius: 14px; margin-bottom: 16px; border: 1px solid var(--border); }
.next-body { flex: 1; min-width: 0; }
.next-tag { font-size: 11.5px; font-weight: 800; }
.next h3 { margin: 2px 0 2px; font-size: 17px; font-weight: 800; }
.next p { margin: 0; font-size: 13.5px; color: var(--muted); }
.next .btn { flex: none; }
.next-act { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.next-act .next-tag { color: var(--warn); }
.next-watch { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 25%, transparent); }
.next-watch .next-tag { color: var(--info); }
.next-done { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.next-done .next-tag { color: var(--ok); }
@media (max-width: 640px) { .next { flex-direction: column; align-items: stretch; } }

.metrics-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1050px) { .metrics-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.metric .value .chip { font-size: 11.5px; vertical-align: 3px; }
.pulse-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); margin-inline-end: 6px; vertical-align: 1px; animation: pulse 2s infinite; box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); }

.panel-box { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; background: var(--surface); min-width: 0; }
.panel-box h4 { margin: 0 0 10px; font-size: 14px; font-weight: 800; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
button.link { border: 0; background: none; color: var(--accent); font-weight: 700; font-size: 12.5px; cursor: pointer; padding: 0; }
.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.feed li { display: flex; gap: 10px; align-items: flex-start; }
.feed li > div { min-width: 0; }
.feed li b { font-size: 13px; }
.feed li small { display: block; color: var(--muted); font-size: 12px; }
.feed-icon { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--bar); }
.feed-icon.ok { background: var(--ok); } .feed-icon.run { background: var(--info); } .feed-icon.bad { background: var(--danger); }
.chip.bad { background: var(--danger-soft); color: var(--danger); }
.bad-text { color: var(--danger); }

/* bees */
.bee-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.bee-summary div { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; }
.bee-summary b { display: block; font-size: 20px; font-weight: 800; line-height: 1.3; }
.bee-summary span { color: var(--muted); font-size: 11.5px; }
.bees { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; max-height: 420px; overflow: auto; }
.bee { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; background: var(--surface); }
.bee-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.bee-head b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.bee-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--bar); flex: none; }
.bee-online .bee-dot { background: var(--ok); animation: pulse 2s infinite; }
.bee-lagging .bee-dot { background: var(--warn); }
.bee-offline { opacity: .7; }
.bee dl { margin: 0; display: grid; gap: 3px; font-size: 12.5px; }
.bee dl div { display: flex; justify-content: space-between; gap: 8px; }
.bee dt { color: var(--muted); }
.bee dd { margin: 0; font-weight: 600; text-align: left; }
.chip.warn { background: var(--warn-soft); color: var(--warn); }

/* live log */
.log-filters { display: flex; gap: 6px; flex-wrap: wrap; margin: -4px 0 10px; }
.log-filters button { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 3px 11px; font-size: 12px; cursor: pointer; color: var(--muted); }
.log-filters button.is-on { background: var(--accent); border-color: var(--accent); color: #fff; }
.now-line { display: flex; align-items: center; padding: 8px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; font-weight: 700; margin-bottom: 10px; color: var(--muted); }
.now-line .pulse-dot { background: var(--muted); animation: none; }
.now-line.is-busy { color: var(--ok); background: var(--ok-soft); }
.now-line.is-busy .pulse-dot { background: var(--ok); animation: pulse 2s infinite; }
.log-list { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow: auto; border: 1px solid var(--border); border-radius: 12px; }
.log-list li { display: grid; grid-template-columns: 112px 58px minmax(0, 1fr); gap: 8px; align-items: center; padding: 6px 10px; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.log-list li:last-child { border-bottom: 0; }
.log-list li[hidden] { display: none; }
.log-list time { color: var(--muted); font-variant-numeric: tabular-nums; direction: ltr; text-align: right; font-size: 11.5px; }
.log-badge { font-size: 11px; font-weight: 800; text-align: center; border-radius: 6px; padding: 1px 0; background: var(--bar); color: var(--muted); }
.ev-detail .log-badge { background: var(--ok-soft); color: var(--ok); }
.ev-list .log-badge { background: var(--info-soft); color: var(--info); }
.ev-round .log-badge { background: var(--accent-soft); color: var(--accent); }
.ev-warn .log-badge { background: var(--warn-soft); color: var(--warn); }
.ev-error .log-badge { background: var(--danger-soft); color: var(--danger); }
.ev-error .log-text { color: var(--danger); }
.log-text { overflow-wrap: anywhere; }

/* tables grouped by city */
tbody.city-group .city-head td { background: var(--surface-2); cursor: pointer; border-bottom: 1px solid var(--border); }
tbody.city-group .city-head:hover td { background: var(--accent-soft); }
.city-head .caret { display: inline-block; width: 0; height: 0; border-inline-start: 5px solid transparent; border-inline-end: 5px solid transparent; border-top: 6px solid var(--muted); margin-inline-end: 8px; vertical-align: 2px; transition: transform .15s; }
tbody.city-group.is-collapsed .caret { transform: rotate(90deg); }
tbody.city-group.is-collapsed .city-row { display: none; }
td.indent { padding-inline-start: 30px; color: var(--muted); }
td.wrap { white-space: normal; min-width: 220px; }
.city-pill { display: inline-block; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 1px 8px; margin: 2px 0 2px 4px; font-size: 12px; }
.city-pill small { color: var(--muted); }
tr.is-current td { background: color-mix(in srgb, var(--accent-soft) 60%, transparent); }

/* crawl areas, compact: a row per city, its categories edited in place */
.area-divider td { background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 800; padding: 6px 12px; }
.area-row td { vertical-align: middle; }
.area-row .chip { margin: 1px 0; }
.area-edit td { background: var(--accent-soft); }
.area-edit-box { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; white-space: normal; }
.area-edit-box .spacer { flex: 1; }
.section { scroll-margin-top: 130px; }

/* district assignment, as a bar under the send's steps */
.district-progress { margin: 4px 0 12px; }
.district-progress .progress-track { height: 10px; }
