:root {
  color-scheme: dark;
  --bg: #0a0a0a;
  --surface: #141414;
  --line: #303030;
  --text: #f3f1ea;
  --muted: #a4a39d;
  --yellow: #f7cf26;
  --yellow-bright: #ffdd4d;
  --danger: #ff7777;
  --success: #8adf91;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { min-width: 320px; margin: 0; color: var(--text); background: var(--bg); font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
a { color: var(--yellow); text-underline-offset: 3px; }
a:hover { color: var(--yellow-bright); }

.page { width: min(1440px, calc(100% - 48px)); min-height: 100vh; margin: 0 auto; }
.masthead { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 28px 0 21px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 13px; color: var(--text); text-decoration: none; }
.brand-mark { display: grid; width: 34px; height: 34px; place-items: center; color: #0a0a0a; background: var(--yellow); font-weight: 900; }
.logo { display: block; font-size: 17px; font-weight: 800; letter-spacing: .11em; }
.tagline { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.nav { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.nav a { padding: 7px 10px; color: var(--muted); font-size: 13px; font-weight: 600; text-decoration: none; }
.nav a:hover { color: var(--yellow); background: #1c1c1c; }
.logout { margin: 0 0 0 auto; }
.logout-button { min-height: 34px; padding: 7px 11px; color: var(--yellow) !important; border-color: #5a4b14; background: transparent; }
.logout-button:hover { color: #111 !important; border-color: var(--yellow); background: var(--yellow); }

.content { min-height: 560px; padding: 38px 0 56px; }
.footer { padding: 18px 0 28px; color: #757575; border-top: 1px solid var(--line); font-size: 12px; }
h1 { margin: 0 0 25px; font-size: clamp(25px, 4vw, 34px); line-height: 1.15; letter-spacing: -.04em; }
h2 { margin: 40px 0 14px; color: var(--text); font-size: 17px; }
p { margin: 0 0 18px; }

button, .button { display: inline-flex; align-items: center; justify-content: center; min-height: 37px; padding: 8px 13px; border: 1px solid var(--yellow); border-radius: 2px; color: #111 !important; background: var(--yellow); font: 700 13px/1 Inter, ui-sans-serif, system-ui, sans-serif; text-decoration: none; cursor: pointer; transition: background .15s, border-color .15s, transform .15s; }
button:hover, .button:hover { background: var(--yellow-bright); border-color: var(--yellow-bright); }
button:active, .button:active { transform: translateY(1px); }
button.danger { color: var(--danger) !important; border-color: #6d3333; background: transparent; }
button.danger:hover { color: #171010 !important; background: var(--danger); border-color: var(--danger); }

input, textarea, select { max-width: 100%; padding: 9px 10px; border: 1px solid #3a3a3a; border-radius: 2px; outline: none; color: var(--text); background: #101010; font: inherit; transition: border-color .15s, box-shadow .15s; }
input:focus, textarea:focus, select:focus { border-color: var(--yellow); box-shadow: 0 0 0 3px rgb(247 207 38 / 12%); }
textarea { min-height: 86px; resize: vertical; }
small { color: var(--muted); }
code { padding: 2px 5px; color: #f9dd62; background: #202020; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.grid, .form-table, .info, .message { width: 100%; border-collapse: collapse; border: 1px solid var(--line); background: var(--surface); }
.grid th, .form-table th, .info th, .message th { padding: 10px 12px; color: var(--muted); border-bottom: 1px solid var(--line); background: #191919; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-align: left; text-transform: uppercase; }
.grid td, .form-table td, .info td, .message td { padding: 12px; border-bottom: 1px solid #282828; vertical-align: top; }
.grid tr:last-child td, .form-table tr:last-child td, .info tr:last-child td, .message tr:last-child td { border-bottom: 0; }
.grid tbody tr:hover td { background: #1a1a1a; }
.form-table { width: min(880px, 100%); }
.form-table th, .info th { width: 210px; }
.compact { width: min(460px, 100%); }
.description { min-width: 230px; max-width: 440px; white-space: pre-wrap; }
.filter { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 20px; padding: 13px; border: 1px solid var(--line); background: var(--surface); }
.filter label { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); }
.filter-grid { align-items: end; }
.filter-grid label { display: grid; gap: 5px; }
.title-row, .group-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.title-row h1, .group-heading h2 { margin-bottom: 0; }
.toolbar, .bulk-bar, .group-actions, .inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
.toolbar { justify-content: space-between; margin: 22px 0; }
.bulk-bar { margin: 0 0 18px; padding: 13px; border: 1px solid #5a4b14; background: #1c1a10; }
.bulk-bar label { display: inline-flex; align-items: center; gap: 7px; }
.bulk-bar input[type="checkbox"], .grid input[type="checkbox"], .message input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--yellow); }
.project-group { margin: 0 0 32px; }
.group-heading { margin: 0 0 12px; }
.group-heading h2 { margin-top: 0; }
.muted { color: var(--muted); font-weight: 500; }
.actions { width: 1%; white-space: nowrap; text-align: right; }
.table-scroll { overflow: visible; }
@media (max-width: 900px) { .table-scroll { overflow-x: auto; padding-bottom: 150px; margin-bottom: -150px; } }
.message { margin-bottom: 16px; }
.message > tbody > tr > th { color: var(--text); background: #1c1c1c; font-size: 13px; letter-spacing: 0; text-transform: none; }
.preview { margin: 0; color: #e3e1dc; white-space: pre-wrap; font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; }
.inline { display: inline; }
.account-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.account-actions form { margin: 0; }
.search-progress { width: min(620px, 100%); margin: 0 0 20px; padding: 14px; border: 1px solid var(--line); background: var(--surface); }
.search-progress > div { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.search-progress span { color: var(--muted); font-size: 12px; }
progress { width: 100%; height: 10px; border: 0; border-radius: 0; accent-color: var(--yellow); background: #252525; }
progress::-webkit-progress-bar { background: #252525; }
progress::-webkit-progress-value { background: var(--yellow); }
progress::-moz-progress-bar { background: var(--yellow); }
.progress-compact { display: grid; grid-template-columns: minmax(75px, 1fr) auto; align-items: center; gap: 8px; min-width: 125px; }
.progress-compact progress { height: 7px; }
.secret-saved { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin: 8px 0 4px; }
.checkbox-line { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; }
.checkbox-line input { width: 16px; height: 16px; margin: 0; accent-color: var(--yellow); }
.settings-action { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; width: min(880px, 100%); margin: 14px 0 20px; padding: 13px; border: 1px solid var(--line); background: var(--surface); }
.settings-action small { flex-basis: 100%; }
.notice, .warning, .error, .empty { margin: 0 0 20px; padding: 13px 15px; border: 1px solid var(--line); background: var(--surface); }
.notice, .warning { border-left: 3px solid var(--yellow); }
.error { color: #ffd1d1; border-left: 3px solid var(--danger); }
.empty { padding: 45px 25px; color: var(--muted); text-align: center; }
.status { display: inline-flex; padding: 3px 7px; border: 1px solid #474747; border-radius: 999px; color: #cac9c3; background: #202020; font: 700 10px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .02em; }
.status-running, .status-ready_to_message, .status-approved { color: #a5edac; border-color: #33653a; background: #142b17; }
.status-failed, .status-not_relevant { color: #ffabab; border-color: #713434; background: #331717; }
.status-needs_review, .status-pending_approval { color: #ffe57b; border-color: #675823; background: #302a12; }
.status-messaged, .status-sent, .status-completed { color: #111; border-color: var(--yellow); background: var(--yellow); }
.status-cancelled, .status-warning { color: #c7c5bd; border-color: #555; background: #242424; }
.good { color: var(--success); font-weight: 700; }
.bad { color: var(--danger); }
.wait { color: var(--yellow); }

.status-summary { margin-bottom: 14px; }
.status-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.status-card { display: grid; align-content: start; gap: 5px; min-height: 118px; padding: 17px; border: 1px solid var(--line); border-left-width: 3px; background: var(--surface); }
.status-card > span, .status-card > small { color: var(--muted); }
.status-card > strong { font-size: 18px; }
.status-level-good { border-left-color: var(--success); }
.status-level-warning { border-left-color: var(--yellow); }
.status-level-bad { border-left-color: var(--danger); }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.metric { display: grid; gap: 3px; padding: 15px; border: 1px solid var(--line); background: var(--surface); }
.metric span { color: var(--muted); font-size: 12px; }
.metric b { color: var(--yellow); font-size: 24px; }

.login-shell { display: grid; min-height: 100vh; place-items: center; padding: 24px; }
.login-page { width: min(100%, 440px); }
.login-header { margin-bottom: 28px; }
.login-page h1 { margin: 26px 0 7px; }
.login-card { padding: 24px; border: 1px solid var(--line); background: var(--surface); }
.login-card p { color: var(--muted); }
.login-form { display: grid; gap: 16px; }
.login-form label { display: grid; gap: 7px; color: #d4d2c9; font-size: 13px; font-weight: 650; }
.login-form input { width: 100%; }
.login-form button { width: 100%; margin-top: 4px; }
.login-footer { margin-top: 14px; color: #777; font-size: 12px; text-align: center; }

@media (max-width: 760px) {
  .page { width: min(100% - 28px, 1440px); }
  .masthead { padding-top: 18px; }
  .nav { gap: 1px; }
  .nav a { padding: 7px 6px; font-size: 12px; }
  .logout { margin-left: 0; }
  .content { padding-top: 27px; overflow-x: auto; }
  .grid { min-width: 720px; }
  .form-table { min-width: 650px; }
  .message { min-width: 620px; }
  .status-grid, .metric-grid { grid-template-columns: 1fr 1fr; }
  .title-row, .group-heading { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 460px) {
  .status-grid, .metric-grid { grid-template-columns: 1fr; }
}
.grid tr.current-project td { background: #1c1a10; }

/* Окошко «Добавить аккаунт» поверх страницы */
.add-account-bar { margin: 14px 0 20px; }
.modal { width: min(640px, 94vw); max-height: 90vh; padding: 0; overflow: auto; color: var(--text); border: 1px solid var(--line); background: var(--surface); }
.modal::backdrop { background: rgba(0, 0, 0, 0.65); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal-close { padding: 2px 10px; font-size: 20px; line-height: 1; }
.modal-body { display: grid; gap: 12px; padding: 16px; }
.modal-body p { margin: 0; }
.modal-form { display: grid; gap: 10px; margin: 0; }
.modal-form label { display: grid; gap: 5px; color: var(--muted); }
.modal-form input, .modal-form select { width: 100%; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.modal-actions form { margin: 0; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.tab-button.active { color: #111; background: var(--yellow); border-color: var(--yellow); }
.tab-button[disabled] { opacity: 0.5; cursor: not-allowed; }
.tab-panel { display: grid; gap: 10px; }
.tab-panel[hidden] { display: none; }

/* Огоньки состояния и сворачиваемые строки */
.dot { display: inline-block; flex: none; width: 11px; height: 11px; border-radius: 50%; background: #666; vertical-align: middle; }
.dot-ok { background: #3fd45b; box-shadow: 0 0 6px rgb(63 212 91 / 55%); }
.dot-warn { background: var(--yellow); box-shadow: 0 0 6px rgb(247 207 38 / 55%); }
.dot-bad { background: #ff4d4d; box-shadow: 0 0 6px rgb(255 77 77 / 55%); }
.dot-none { background: #666; }
h2 .dot { margin-right: 6px; }
.muted { color: var(--muted); }
.acc-list { display: grid; gap: 6px; width: min(880px, 100%); }
.acc { border: 1px solid var(--line); background: var(--surface); }
.acc > summary { display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer; list-style: none; }
.acc > summary::-webkit-details-marker { display: none; }
.acc > summary::after { content: ""; width: 8px; height: 8px; margin: 0 4px 3px auto; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .15s; }
.acc[open] > summary::after { margin-bottom: -3px; transform: rotate(-135deg); }
.acc > summary:hover { background: #1a1a1a; }
.acc-name { font-weight: 700; }
.acc-body { display: grid; gap: 10px; padding: 4px 14px 14px; border-top: 1px solid #282828; }
.acc-body .acc-list { width: 100%; }
.acc-line { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.acc-body form { margin: 0; }
.add-account-bar { margin: 22px 0 8px; }
button.big { min-height: 52px; padding: 14px 30px; font-size: 16px; }
.qr-view { display: grid; justify-items: center; gap: 12px; }
.qr-image svg { display: block; width: 260px; height: 260px; max-width: 100%; }

/* Таблица «статус - количество»: число рядом с подписью, а не у правого края */
.counts { width: min(360px, 100%); }
.counts th.count, .counts td.count { width: 120px; text-align: left; font-weight: 700; }

/* Плашка «Задания»: узкая плашка (как плашки аккаунтов), таблица внутри растянута на всю её ширину */
.jobs-box { width: min(880px, 100%); }
.jobs-summary { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.jobs-stat b { color: inherit; }
.jobs-box > #project-jobs { padding: 0; border-top: 1px solid #282828; }
.jobs-box > #project-jobs .table-scroll { width: 100%; }
.jobs-box > #project-jobs > p { margin: 0; padding: 10px 14px; }

.jobs-table { width: 100%; min-width: 0; border: 0; table-layout: auto; }
.jobs-table th, .jobs-table td { padding: 8px 12px; }
.jobs-table td:nth-child(-n+4), .jobs-table th:nth-child(-n+4) { white-space: nowrap; width: 1%; }
.jobs-table td:last-child { width: auto; min-width: 220px; overflow-wrap: anywhere; }
.jobs-table .wait { color: inherit; }
.sel-wrap { position: relative; padding-left: 44px; }
.sel-wrap .sel-all { position: absolute; left: 6px; top: 22px; width: 25px; height: 25px; margin: 0; accent-color: var(--yellow); }
.sel-wrap .grid { overflow: visible; }
.grid th.sel, .grid td.sel { position: relative; width: 0; padding: 0; border: 0; background: transparent; }
.grid tbody tr:hover td.sel { background: transparent; }
.grid td.sel input { position: absolute; left: -32px; top: 14px; width: 17px; height: 17px; margin: 0; accent-color: var(--yellow); }
.notice-error { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 50; width: max-content; max-width: min(720px, 92vw); margin: 0; color: var(--danger); border-left: 3px solid var(--danger); cursor: pointer; box-shadow: 0 6px 24px rgba(0,0,0,.5); }

/* Меню «•••» и «+ Группа» */
.title-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
.menu { position: relative; display: inline-block; text-align: left; }
.menu > .menu-toggle { display: inline-flex; align-items: center; justify-content: center; min-height: 37px; padding: 8px 13px; border: 1px solid var(--line); border-radius: 2px; color: var(--text) !important; background: transparent; font: 700 13px/1 Inter, ui-sans-serif, system-ui, sans-serif; letter-spacing: 2px; cursor: pointer; user-select: none; }
.menu > .menu-toggle:hover, .menu.open > .menu-toggle { color: var(--yellow) !important; background: transparent; border-color: var(--yellow); }
.menu-list[hidden] { display: none; }
.menu-list { position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; display: grid; gap: 7px; min-width: 210px; padding: 10px; border: 1px solid var(--line); background: var(--surface); box-shadow: 0 10px 26px rgba(0, 0, 0, .55); }
.menu-left .menu-list { right: auto; left: 0; }
.menu-list form { margin: 0; }
.menu-list button, .menu-list .button { width: 100%; }
.menu-form { display: grid; gap: 7px; }
.menu-form input { width: 100%; box-sizing: border-box; }
.bulk-bar[hidden] { display: none; }
#projects-group-form { position: fixed; left: 50%; bottom: 20px; z-index: 40; margin: 0; transform: translateX(-50%); box-shadow: 0 10px 30px rgba(0, 0, 0, .6); }

.projects-table th { padding: 6px 10px; }
.projects-table td { padding: 5px 10px; line-height: 1.25; vertical-align: middle; }
.projects-table .menu > .menu-toggle { min-height: 28px; padding: 4px 10px; }
.projects-table small { font-size: 11px; }
.bulk-bar > span:not(:first-child) { color: var(--muted); }
