:root {
  --bg: #f5f6fa; --surface: #ffffff; --surface-2: #f0f2f8; --border: #e3e6ef;
  --text: #171a2b; --muted: #6a7089; --accent: #5b5ff0; --accent-ink: #ffffff; --accent-soft: #eceeff;
  --ok: #17a05d; --ok-soft: #e3f6ec; --warn: #d98a0b; --warn-soft: #fdf1da; --bad: #d8434b; --bad-soft: #fde8e9;
  --shadow: 0 1px 2px rgba(20,24,50,.06), 0 8px 24px rgba(20,24,50,.06);
  --radius: 12px; --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1020; --surface: #161931; --surface-2: #1d2140; --border: #2a2f52;
    --text: #e8eaf8; --muted: #8d93b5; --accent: #7a7dff; --accent-ink: #0e1020; --accent-soft: #23274d;
    --ok: #3ccf86; --ok-soft: #12382a; --warn: #f0b04a; --warn-soft: #3b2e12; --bad: #ff6b73; --bad-soft: #3d1a1f;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 14px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
a { color: var(--accent); text-decoration: none; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.hidden { display: none !important; }

/* login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(900px 500px at 20% -10%, var(--accent-soft), transparent), var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; padding: 32px; box-shadow: var(--shadow); }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.logo-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--accent); display: grid; place-items: center; }
.logo-mark svg { width: 18px; height: 18px; }
.login-card h1 { font-size: 22px; margin: 22px 0 4px; }
.login-card form { display: grid; gap: 14px; margin-top: 20px; }

/* controls */
label.field { display: grid; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
input[type=text], input[type=password], input[type=number], select {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); background: var(--surface);
  border-radius: 9px; outline: none; font-weight: 400; color: var(--text); }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 600; white-space: nowrap; transition: .12s; }
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
.btn.danger { color: var(--bad); }
.btn.danger:hover:not(:disabled) { background: var(--bad-soft); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); }
.error-text { color: var(--bad); font-size: 13px; min-height: 18px; }

/* shell */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 22px; padding: 0 24px; height: 58px;
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { padding: 7px 12px; border-radius: 8px; color: var(--muted); font-weight: 600; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-weight: 700; text-transform: uppercase; }
.page { max-width: 1320px; margin: 0 auto; padding: 28px 24px 60px; }
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; }
.spacer { flex: 1; }
.crumb { color: var(--muted); font-weight: 600; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.server-card { padding: 20px; cursor: pointer; transition: .15s; display: grid; gap: 14px; }
.server-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.server-card h3 { font-size: 16px; }
.server-card .stats { display: flex; gap: 22px; }
.stat b { display: block; font-size: 22px; line-height: 1.1; }
.stat span { color: var(--muted); font-size: 12px; }
.empty { padding: 56px 20px; text-align: center; color: var(--muted); }
.empty h3 { color: var(--text); margin-bottom: 6px; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--surface-2); color: var(--muted); }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.pulse::before { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .25; } }

/* server page */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 18px; }
.tile { padding: 14px 16px; }
.tile span { color: var(--muted); font-size: 12px; font-weight: 600; }
.tile b { display: block; font-size: 22px; margin-top: 2px; }
.tile.clickable { cursor: pointer; }
.tile.clickable:hover { border-color: var(--accent, #6d5efc); }
.toolbar { display: flex; gap: 10px; align-items: center; padding: 12px; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.toolbar input[type=text] { width: 220px; }
.task-banner { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--accent-soft); color: var(--accent); font-weight: 600; border-bottom: 1px solid var(--border); }
.spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 10px 14px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td.name { font-weight: 600; white-space: nowrap; }
td .sub { color: var(--muted); font-size: 12px; font-weight: 400; }
td.actions { text-align: right; white-space: nowrap; }
/* checkboxes: drawn here, the same in every browser and theme */
input[type=checkbox] { appearance: none; -webkit-appearance: none; width: 18px; height: 18px; margin: 0; flex: none;
  border: 1.5px solid var(--muted); border-radius: 5px; background: var(--surface); display: inline-grid; place-content: center;
  vertical-align: middle; cursor: pointer; transition: background .12s, border-color .12s; }
input[type=checkbox]::before { content: ""; width: 10px; height: 10px; transform: scale(0); transition: transform .12s;
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%); background: var(--accent-ink); }
input[type=checkbox]:checked { background: var(--accent); border-color: var(--accent); }
input[type=checkbox]:checked::before { transform: scale(1); }
input[type=checkbox]:hover:not(:disabled) { border-color: var(--accent); }
input[type=checkbox]:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=checkbox]:disabled { opacity: .45; cursor: not-allowed; }
/* on/off settings are switches */
.ar-switch input[type=checkbox] { width: 34px; height: 20px; border-radius: 20px; padding: 0 2px; place-content: center start;
  background: var(--surface-2); border-color: var(--border); }
.ar-switch input[type=checkbox]::before { width: 14px; height: 14px; border-radius: 50%; clip-path: none; transform: none;
  background: var(--muted); transition: transform .15s, background .15s; }
.ar-switch input[type=checkbox]:checked { background: var(--accent); border-color: var(--accent); }
.ar-switch input[type=checkbox]:checked::before { transform: translateX(14px); background: var(--accent-ink); }
.proxy-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 7px; }
.proxy-dot.active { background: var(--ok); } .proxy-dot.failed { background: var(--bad); }

.console { margin-top: 18px; }
.console-head { display: flex; align-items: center; padding: 10px 16px; cursor: pointer; font-weight: 700; gap: 8px; }
.console-body { max-height: 260px; overflow: auto; padding: 4px 16px 14px; font-family: var(--mono); font-size: 12.5px; line-height: 1.7; }
.console-body .ok { color: var(--ok); } .console-body .error { color: var(--bad); }
.console-body time { color: var(--muted); margin-right: 10px; }

.connect-panel { padding: 56px 20px; text-align: center; display: grid; gap: 12px; justify-items: center; }
.connect-panel .big-spinner { width: 34px; height: 34px; border-width: 3px; color: var(--accent); }
.err-box { background: var(--bad-soft); color: var(--bad); padding: 12px 16px; border-radius: 10px; max-width: 640px; white-space: pre-wrap; text-align: left; font-size: 13px; }

/* menu, dialog, toast */
.menu-wrap { position: relative; display: inline-block; }
.menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; min-width: 190px; padding: 6px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); text-align: left; }
.menu button { display: block; width: 100%; text-align: left; padding: 8px 10px; background: none; border: 0; border-radius: 7px; cursor: pointer; }
.menu button:hover { background: var(--surface-2); }
.menu button.danger { color: var(--bad); }
dialog { border: 1px solid var(--border); border-radius: 16px; padding: 0; background: var(--surface); color: var(--text); box-shadow: var(--shadow); width: min(520px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(10,12,30,.5); backdrop-filter: blur(2px); }
.dlg { padding: 24px; display: grid; gap: 14px; }
.dlg h2 { font-size: 18px; }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.checks { display: grid; gap: 6px; max-height: 180px; overflow: auto; padding: 10px; border: 1px solid var(--border); border-radius: 9px; }
.checks label { display: flex; gap: 8px; align-items: center; font-weight: 400; color: var(--text); cursor: pointer; }
.kv { display: grid; grid-template-columns: 110px 1fr auto; gap: 8px 12px; align-items: center; }
.kv dt { color: var(--muted); }
pre.logbox { margin: 0; max-height: 320px; overflow: auto; background: var(--surface-2); padding: 12px; border-radius: 9px; font: 12px/1.6 var(--mono); white-space: pre-wrap; word-break: break-all; }
#toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 100; }
.toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); max-width: 380px; animation: pop .2s; }
.toast.error { background: var(--bad); color: #fff; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }
.tabs { display: flex; gap: 4px; margin-bottom: 16px; }
.tabs button { padding: 8px 14px; border: 0; background: none; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--muted); }
.tabs button.active { background: var(--accent-soft); color: var(--accent); }
.table-wrap.scroll-y { max-height: 65vh; overflow: auto; }
.table-wrap.scroll-y thead th { position: sticky; top: 0; z-index: 1; background: var(--surface); }
[hidden] { display: none !important; }
tr.grp td { background: var(--surface-2); }
@media (max-width: 720px) { .topbar { padding: 0 14px; gap: 10px; } .page { padding: 18px 14px 50px; } .toolbar input[type=text] { width: 100%; } .row2 { grid-template-columns: 1fr; } }
.add-server { display: flex; gap: 10px; padding: 12px; margin-bottom: 18px; }
.add-server input { flex: 1; }
.server-card .stats .btn { align-self: center; }

.connect-hero { min-height: calc(100vh - 160px); display: grid; place-items: center; }
.connect-card { width: 100%; max-width: 560px; padding: 36px; text-align: center; }
.connect-card h1 { font-size: 24px; margin-bottom: 8px; }
.connect-card p { margin: 0 0 22px; }
.connect-card form { display: flex; gap: 10px; }
.connect-card form input { flex: 1; padding: 12px 14px; font-size: 15px; }
.connect-card form .btn { padding: 12px 20px; }
.inline-field { display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 600; font-size: 12.5px; }
.inline-field select { width: auto; padding: 7px 10px; }
@media (max-width: 720px) { .connect-card form { flex-direction: column; } }

td { white-space: nowrap; }
td .sub { max-width: 230px; overflow: hidden; text-overflow: ellipsis; }

/* loading buttons */
.btn.loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.loading::after { content: ""; position: absolute; inset: 0; margin: auto; width: 14px; height: 14px; border: 2px solid var(--muted);
  border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.btn.primary.loading::after { border-color: var(--accent-ink); border-right-color: transparent; }
.sub.err { color: var(--bad); white-space: normal; max-width: 260px; }
td a { color: inherit; }
td.name a:hover { color: var(--accent); }
dialog.wide { width: min(1100px, calc(100vw - 32px)); }
/* tables in dialogs: the header stays while the list scrolls, nothing pushes the dialog sideways */
.dlg .table-wrap { max-width: 100%; }
.dlg table thead th { position: sticky; top: 0; z-index: 1; background: var(--surface); }
.kvtable { display: grid; grid-template-columns: minmax(150px, 34%) 1fr; gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.kvtable > div { background: var(--surface); padding: 7px 12px; word-break: break-word; }
.kvtable .k { color: var(--muted); font-weight: 600; font-size: 12.5px; }

/* autorestart */
.ar-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 16px; }
.ar-card { padding: 20px; display: grid; gap: 12px; align-content: start; }
.ar-switch { display: flex; gap: 10px; align-items: center; font-weight: 700; cursor: pointer; }
td.ar-msg { white-space: normal; max-width: 420px; font-size: 13px; }
#arstat { display: flex; gap: 6px; flex-wrap: wrap; }
@media (max-width: 720px) { .ar-grid { grid-template-columns: 1fr; } }

.ar-add { display: flex; gap: 10px; padding: 12px; border-bottom: 1px solid var(--border); align-items: stretch; }
.ar-add textarea { flex: 1; resize: vertical; padding: 9px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); font: 13px/1.5 var(--mono); }
.ar-add textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ar-bulk { gap: 8px; }
.ar-switch.sm { font-weight: 600; font-size: 13px; }
td select { width: auto; padding: 5px 8px; font-size: 13px; }
.err-inline { color: var(--bad); }

.connect-top { display: grid; place-items: center; padding-top: 24px; }
tr.clickable { cursor: pointer; }
.ok-inline { color: var(--ok); }

.warn-inline { color: var(--warn); font-weight: 700; }
a.mailcell { color: inherit; white-space: nowrap; }
a.mailcell:hover { text-decoration: underline; }

/* profile live view */
dialog.vnc { width: min(1500px, 96vw); }
dialog.vnc .dlg { gap: 10px; padding: 16px; }
.vnc-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.vnc-head h2 { font-size: 16px; }
.vnc-screen { position: relative; height: min(80vh, 900px); background: #000; border-radius: 10px; overflow: hidden; }
.vnc-msg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 10px; color: #c8cbe0; z-index: 2; padding: 20px; text-align: center; }
.btn.eye { padding: 5px 8px; color: var(--accent); }
.ar-ta { flex: 1; resize: vertical; padding: 9px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); font: 13px/1.5 var(--mono); }

a.persona { display: block; font-size: 12px; font-weight: 500; color: var(--accent); white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
a.persona:hover { text-decoration: underline; }

/* autorestart: summary tiles on top, dimmed switched-off servers, the folded "add by hand" form */
.ar-kpi { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.ar-kpi .tile b { font-size: 20px; }
tr.row-off td { opacity: .55; }
details.ar-adddet { position: relative; }
details.ar-adddet summary { list-style: none; cursor: pointer; }
details.ar-adddet summary::-webkit-details-marker { display: none; }
details.ar-adddet[open] .ar-add { position: absolute; right: 0; top: 36px; z-index: 5; width: min(560px, 90vw);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
/* the autorestart server table fits its card: compact selects, the switch and the mode side by side */
#arservers td select { width: auto; max-width: 130px; padding: 5px 8px; font-size: 13px; }
#arservers td .cell-row { display: flex; gap: 8px; align-items: center; }
#arservers td, #arservers th { padding-left: 10px; padding-right: 10px; }
#arservers td.ar-msg { max-width: 200px; }

.batch-banner { display: flex; align-items: center; gap: 14px; padding: 14px 18px; margin-bottom: 16px; border-color: var(--accent, #6d5efc); }
.badge.info { background: rgba(80, 140, 255, .14); color: #3a6fd8; }
.badge.muted { background: rgba(127, 127, 127, .14); color: var(--muted); }

.prov-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; margin-bottom: 12px; }
.prov-card { padding: 16px 18px; display: grid; gap: 12px; }
.pc-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.pc-name { font-size: 18px; font-weight: 700; text-transform: capitalize; }
.pc-nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pc-num { display: grid; gap: 2px; }
.pc-num b { font-size: 24px; line-height: 1.1; }
.pc-num b.bad { color: var(--bad); }
.pc-num b.warn { color: var(--warn); }
.pc-num span { font-size: 11.5px; color: var(--muted); line-height: 1.25; }

.badge-row { display: inline-flex; flex-wrap: wrap; gap: 4px; }
td.problems { white-space: normal; min-width: 180px; }
.prob-bar { padding: 10px 14px; margin-bottom: 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--warn-soft); }
.prob-bar .sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.batch-mail { white-space: normal; margin-top: 6px; display: grid; gap: 4px; max-width: 460px; }
.bm-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: 12px; }
.bm-line .mono { color: var(--muted); }
td.problems .sub, .prob-bar .sub { white-space: normal; overflow: visible; text-overflow: clip; }

.bm-prof { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: 12px; }
.bm-box { border-left: 2px solid var(--border); padding: 2px 0 2px 8px; display: grid; gap: 3px; font-size: 12px; }
.bm-box .mono { color: var(--muted); }

.batch-mail { display: flex !important; flex-wrap: wrap; gap: 6px; max-width: 520px; }
.batch-mail .bm-prof { flex-basis: 100%; }
.bm-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border: 1px solid var(--border); border-radius: 999px; font-size: 11.5px; }
.bm-chip .mono { color: var(--muted); }
.of-sum { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }

/* batch rows: the profile's tags, then one compact line per bad mailbox */
.batch-mail { display: grid !important; gap: 3px; margin-top: 6px; max-width: 520px; white-space: normal; }
.bm-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 2px; }
.batch-mail .badge, td.problems .badge { white-space: nowrap; font-size: 11px; padding: 1px 7px; }
.bm-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: 12px; line-height: 1.5; }
.bm-mail { color: var(--muted); }
.bm-line.gone .bm-mail { text-decoration: line-through; opacity: .6; }
.bm-ico { width: 14px; text-align: center; font-weight: 700; color: var(--muted); flex: none; }
.bm-ico.ok { color: var(--ok); }
.bm-ico.bad { color: var(--bad); font-size: 10px; }
/* compact batch line under a profile: counts, not every mailbox */
.bm-tags { margin-top: 6px; max-width: 360px; white-space: normal; }
.bm-tags .badge { white-space: nowrap; font-size: 11px; padding: 1px 7px; }
a.err-chip { cursor: pointer; text-decoration: none; }
a.err-chip:hover { filter: brightness(1.15); }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: normal; max-width: 220px; }
/* bad activity work page */
.wk-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; margin: 0 0 22px; }
.wk-steps > div { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; color: var(--muted); }
.wk-steps b { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--accent, #6366f1); color: #fff; font-size: 13px; }
.wk-h { margin: 22px 0 10px; font-size: 15px; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.wk-h .muted { font-weight: 400; font-size: 12.5px; }
.wk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.wk-list { display: grid; gap: 10px; }
.wk-batch { padding: 16px 18px; display: grid; gap: 12px; }
.wk-batch.slim { padding: 12px 16px; gap: 8px; }
.wk-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.wk-where { font-size: 13.5px; }
.wk-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); gap: 8px; }
.wk-stat { display: grid; gap: 2px; }
.wk-stat b { font-size: 22px; line-height: 1.1; }
.wk-stat b.bad { color: var(--bad); }
.wk-stat b.warn { color: var(--warn, #d97706); }
.wk-stat b.zero { color: var(--muted); font-weight: 500; }
.wk-stat span { font-size: 11.5px; color: var(--muted); }
.wk-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.wk-note { padding: 16px 18px; border: 1px dashed var(--border); border-radius: var(--radius); color: var(--muted); }
.wk-prog { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.wk-prog > div { height: 100%; background: var(--ok, #16a34a); }
.danger-text { color: var(--bad) !important; }
.wk-left { display: grid; gap: 8px; margin-top: 4px; }
.wk-left-prof { display: grid; gap: 3px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; }
.wk-left-prof .pc-name { text-decoration: none; }
.wk-left-item { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12.5px; }
.wk-left-item .badge { font-size: 10.5px; padding: 0 6px; }
.wk-more summary { cursor: pointer; font-size: 12.5px; color: var(--muted); }
/* mailbox lists in dialogs: everything fits the dialog - fixed columns, text wraps, no sideways scroll */
.mb-filters { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; padding: 0 0 10px; }
.mb-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-right: auto; }
.mb-filters input[type=text] { width: 220px; }
.mb-filters select { width: auto; max-width: 220px; }
.mb-filters .ar-switch { white-space: nowrap; }
.mb-wrap { max-height: 50vh; overflow: auto; border: 1px solid var(--border); border-radius: 10px; }
table.mb-table { table-layout: fixed; width: 100%; }
table.mb-table th, table.mb-table td { white-space: normal; padding: 9px 10px; vertical-align: top; }
table.mb-table td .sub { max-width: none; white-space: normal; overflow: visible; }
.mb-email { word-break: break-all; font-size: 12.5px; }
table.mb-table td.problems { min-width: 0; }
.mb-actions { padding: 10px 0 0; border-bottom: 0; }
.mb-actions .inline-field select { max-width: 260px; }
@media (max-width: 760px) { .mb-filters input[type=text], .mb-filters select { width: 100%; max-width: none; } }
/* people: pictures, the cabinet */
img.avatar { object-fit: cover; display: block; flex: none; }
span.avatar { flex: none; }
.user-link { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 600; }
.user-link:hover span:last-child { color: var(--accent); }
.person { display: flex; align-items: center; gap: 10px; }
.me-card { display: flex; align-items: center; gap: 22px; padding: 22px 24px; margin-bottom: 8px; flex-wrap: wrap; }
.me-avatar { position: relative; cursor: pointer; border-radius: 50%; }
.me-avatar .avatar { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--accent-soft); }
.me-avatar-edit { position: absolute; inset: auto 0 0 0; text-align: center; font-size: 11px; font-weight: 700; color: #fff;
  background: rgba(20,24,50,.55); border-radius: 0 0 48px 48px; padding: 3px 0 6px; opacity: 0; transition: .15s; }
.me-avatar:hover .me-avatar-edit { opacity: 1; }
.me-info { display: grid; gap: 6px; min-width: 220px; flex: 1; }
.me-info h1 { font-size: 22px; margin: 0; }
.me-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.me-today { display: grid; justify-items: center; padding: 12px 22px; border-radius: 12px; background: var(--ok-soft); min-width: 170px; }
.me-today b { font-size: 34px; color: var(--ok); line-height: 1.1; }
.me-today .muted { font-size: 12px; }
.hist-wrap { max-height: 460px; overflow: auto; }

/* one bad-activity picture on every page */
.ba-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 10px 14px; margin-bottom: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; }
.ba-bar b { font-size: 15px; }
.ba-bar .ba-sep { width: 1px; height: 18px; background: var(--border); }
.ba-bar .spacer { flex: 1; }

/* a "?" next to a field label: its explanation on hover (title) */
.tip { display: inline-grid; place-items: center; width: 15px; height: 15px; margin-left: 4px; border-radius: 50%;
  border: 1px solid var(--muted); color: var(--muted); font-size: 10px; font-weight: 700; line-height: 1; cursor: help;
  vertical-align: 1px; }
.tip:hover, .tip:focus { color: var(--text); border-color: currentColor; outline: none; }
.dlg-sec { margin: 14px 0 6px; padding-top: 10px; border-top: 1px solid var(--border); font-weight: 700; font-size: 13.5px; }
.dlg-sec:first-of-type { border-top: 0; padding-top: 0; margin-top: 4px; }
.tip-pop { position: fixed; z-index: 1000; max-width: min(320px, calc(100vw - 16px)); padding: 8px 10px; border-radius: 8px;
  background: var(--text); color: var(--surface); font-size: 12.5px; font-weight: 400; line-height: 1.4; box-shadow: var(--shadow);
  pointer-events: none; white-space: normal; }

/* the proxy automation's runs: each profile's steps */
.spinner.sm { width: 10px; height: 10px; border-width: 2px; display: inline-block; vertical-align: -1px; }
.pxrun-prof { border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; margin-top: 8px; }
.pxrun-head { display: flex; align-items: center; gap: 8px; }
.pxsteps { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 3px; }
.pxsteps li { display: grid; grid-template-columns: 18px minmax(150px, 220px) 1fr auto; gap: 8px; align-items: baseline; font-size: 12.5px; }
.pxsteps .ic { text-align: center; }
.pxsteps .lbl { font-weight: 600; }
.pxsteps .det { color: var(--muted); overflow-wrap: anywhere; }
.pxsteps .t { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.pxsteps li.st-run .lbl { color: var(--warn); }
.pxsteps li.st-fail .det { color: var(--bad); }
.pxrun-menu { right: 0; }
.menu button[disabled] { opacity: .5; cursor: default; }
@media (max-width: 700px) { .pxsteps li { grid-template-columns: 18px 1fr; } .pxsteps .det, .pxsteps .t { grid-column: 2; } }

/* tables that fit the screen (Проксі): fixed columns, text wraps, no scroll of their own, the header sticks */
.table-wrap.fit-wrap { overflow: visible; }
table.fit { table-layout: fixed; }
table.fit th { white-space: normal; position: sticky; top: 0; z-index: 2; background: var(--surface); padding: 10px 10px; }
table.fit td { white-space: normal; overflow-wrap: anywhere; padding: 10px 10px; vertical-align: top; }
table.fit td .sub { max-width: none; overflow: visible; white-space: normal; }
table.fit td.name { white-space: normal; }
table.fit td.actions { text-align: right; }
table.fit td.actions .btn { white-space: nowrap; }

/* the proxy automation's work journal: one list, a row opens */
.jr-list { display: grid; }
.jr { border-top: 1px solid var(--border); }
.jr.live { background: color-mix(in srgb, var(--warn) 6%, transparent); }
.jr-head { display: grid; grid-template-columns: 16px auto 132px minmax(160px, 1.2fr) minmax(0, 2fr) 70px; gap: 10px; align-items: center; padding: 9px 14px; cursor: pointer; }
.jr.act .jr-head { cursor: default; }
.jr-head:hover { background: var(--surface-2); }
.jr-chev { color: var(--muted); }
.jr-time { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.jr-what { min-width: 0; overflow-wrap: anywhere; font-size: 13px; }
.jr-items { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.jr-dur { text-align: right; font-size: 12px; white-space: nowrap; }
.jr-body { padding: 4px 14px 14px 40px; }
.chip { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 999px; padding: 2px 8px; font-size: 11.5px; cursor: pointer; }
.chip:hover { border-color: var(--accent); }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); display: inline-block; }
.chip.ok .dot { background: var(--ok); } .chip.bad .dot { background: var(--bad); } .chip.warn .dot { background: var(--warn); }
.pxrun-prof.hl { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
@media (max-width: 900px) {
  .jr-head { grid-template-columns: 16px auto 1fr; }
  .jr-what, .jr-items { grid-column: 2 / -1; }
  .jr-dur { display: none; }
  .jr-body { padding-left: 14px; }
}

/* proxy automation: runs in plain words, phases, panels */
.px-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 12px; font-size: 13.5px; }
.px-stage { margin: 0 0 10px; padding: 8px 12px; border-radius: 8px; background: var(--warn-soft); font-size: 13px; }
.px-sum { margin: 6px 0 4px; font-size: 13px; }
.px-sum.ok { color: var(--ok); } .px-sum.bad { color: var(--bad); } .px-sum.warn { color: var(--warn); }
.px-phase { margin-top: 10px; }
.px-phase-t { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin-bottom: 2px; }
.pxrun-head { flex-wrap: wrap; }
.pxrun-head .badge { margin-left: 4px; }
.px-sub { margin: 14px 0 6px; font-weight: 700; font-size: 13.5px; }
.px-rows { display: grid; gap: 4px; }
.px-row { display: grid; grid-template-columns: auto auto 1fr auto; gap: 10px; align-items: center; width: 100%; text-align: left; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); cursor: pointer; font: inherit; font-size: 13px; }
.px-row:hover { border-color: var(--accent); }
.px-row.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.px-row.static { cursor: default; grid-template-columns: auto 1fr auto; }
.px-row .muted { overflow-wrap: anywhere; }
.px-go { color: var(--muted); }
.px-tech { margin-top: 12px; } .px-tech summary { color: var(--muted); cursor: pointer; font-size: 12.5px; }
.px-cur { padding: 12px 14px; margin: 12px 0; }
.px-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; margin: 4px 0 12px; }
.px-tile { border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; display: grid; gap: 2px; min-width: 0; }
.px-tile span { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.px-tile b { font-size: 14px; overflow-wrap: anywhere; } .px-tile i { font-style: normal; font-size: 12px; color: var(--muted); }
.px-acts { padding: 12px 14px; display: grid; gap: 10px; }
.px-acts > div { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: 13px; }
.px-prev { display: grid !important; gap: 4px; font-size: 12.5px; border-top: 1px solid var(--border); padding-top: 8px; }
.btn.icon { padding: 4px 8px; margin-left: 4px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; background: none; color: var(--muted); padding: 6px 12px; cursor: pointer; font: inherit; font-size: 13px; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.active { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.jr-row { display: grid; grid-template-columns: auto 132px 1fr 80px; gap: 12px; align-items: center; width: 100%; text-align: left; padding: 10px 14px;
  border: 0; border-top: 1px solid var(--border); background: none; color: var(--text); font: inherit; font-size: 13px; cursor: pointer; }
.jr-row:hover { background: var(--surface-2); }
.jr-row.static { cursor: default; }
.jr-row.live { background: color-mix(in srgb, var(--warn) 7%, transparent); }
.jr-row .jr-what { overflow-wrap: anywhere; }
@media (max-width: 760px) { .jr-row { grid-template-columns: auto 1fr; } .jr-row .jr-what { grid-column: 1 / -1; } .jr-row .jr-dur { display: none; }
  .px-row { grid-template-columns: auto 1fr; } .px-row .muted { grid-column: 1 / -1; } .px-go { display: none; } }

/* actions of a fit table: the buttons in one row, inside their column */
table.fit td.actions { white-space: nowrap; vertical-align: middle; }
table.fit td.actions .btn + .btn { margin-left: 6px; }
@media (max-width: 900px) { table.fit td.actions { white-space: normal; } table.fit td.actions .btn { margin: 2px 0 2px 6px; } }
/* panels: buttons and inputs wrap inside the card, nothing sticks out */
.px-acts .btn, .pxrun-head .btn, .dlg-actions .btn { white-space: nowrap; }
.px-acts > div > .muted { flex: 1 1 260px; min-width: 0; }
.pxrun-head { gap: 8px; }
.pxrun-head b { overflow-wrap: anywhere; min-width: 0; }
.dlg-actions { flex-wrap: wrap; }
.toolbar input[type=text] { min-width: 0; max-width: 100%; }
/* toolbars: selects as wide as their text, not the whole row */
.toolbar select { width: auto; max-width: 100%; }
.toolbar input[type=text] { width: 240px; }
