/* Соловьи · IT-бюро — токены бренда + компоненты админки FileSync.
   Палитра и темы из solovyi-brand. Акцент — оранжевый #EF6A2D (только акцент). */

:root,
[data-theme="light"] {
  --bg: #FAF3EB;
  --surface: #FFFFFF;
  --surface-2: #F4ECE1;
  --text: #14110D;
  --muted: #7a6e5e;
  --border: #E7DAC9;
  --border-2: #DBCDB8;
  --accent: #EF6A2D;
  --accent-press: #D9531B;
  --accent-soft: #FBE3D5;
  --success: #4f9e5d;
  --success-bg: #e7f3e9;
  --error: #C0392B;
  --error-bg: #f7e4e1;
  --shadow: 0 1px 2px rgba(20,17,13,.06), 0 8px 24px rgba(20,17,13,.06);
}

[data-theme="dark"] {
  --bg: #14110E;
  --surface: #1E1915;
  --surface-2: #251F1A;
  --text: #F3ECE3;
  --muted: #A99B8B;
  --border: #322A22;
  --border-2: #41372D;
  --accent: #EF6A2D;
  --accent-press: #D9531B;
  --accent-soft: rgba(239,106,45,.16);
  --success: #5BB96A;
  --success-bg: rgba(91,185,106,.14);
  --error: #ff7b72;
  --error-bg: rgba(255,123,114,.14);
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }

/* hidden must win over component display rules (e.g. .login-screen{display:flex}) */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

.display {
  font-family: "Sora", "Segoe UI", system-ui, sans-serif;
  font-weight: 700;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- brand lockup ---------- */
.logo { display: inline-flex; align-items: center; gap: 10px; }
.logo__mark { width: 30px; height: 30px; color: var(--text); flex: none; }
.logo__text { display: flex; flex-direction: column; line-height: 1.1; }
.logo__name {
  font-family: "Sora", "Segoe UI", system-ui, sans-serif;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 2px;
}
.logo__sub { font-size: 11px; color: var(--muted); letter-spacing: .3px; margin-top: 1px; }
.logo__sep { color: var(--accent); font-weight: 700; }

/* ---------- buttons ---------- */
.btn {
  appearance: none;
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  border-radius: 9px;
  padding: 8px 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: background .12s, border-color .12s, color .12s, opacity .12s;
  white-space: nowrap;
}
.btn:hover { background: var(--accent-press); }
.btn:active { transform: translateY(.5px); }
.btn:disabled { opacity: .55; cursor: default; }

.btn--ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border-2);
}
.btn--ghost:hover { background: var(--surface-2); border-color: var(--accent); color: var(--text); }

.btn--sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn--icon { padding: 6px; border-radius: 8px; background: transparent; color: var(--muted); border: 1px solid transparent; }
.btn--icon:hover { background: var(--surface-2); color: var(--text); }

/* ---------- inputs ---------- */
.input, select.input {
  font: inherit;
  width: 100%;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-2);
  border-radius: 9px;
  padding: 9px 11px;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder { color: var(--muted); }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }

/* ---------- card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

/* ---------- header ---------- */
.appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.appbar__right { display: flex; align-items: center; gap: 10px; }
.who { color: var(--muted); font-size: 13px; }
.who b { color: var(--text); font-weight: 600; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 22px 20px 60px; }

/* ---------- section heading ---------- */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin: 4px 0 14px;
}
.section-head h2 {
  font-family: "Sora", "Segoe UI", system-ui, sans-serif;
  font-weight: 700; font-size: 17px; margin: 0;
}
.muted { color: var(--muted); }
.dim { color: var(--muted); font-size: 12.5px; }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; border-radius: 14px; }
table.agents { width: 100%; border-collapse: collapse; }
table.agents th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.agents td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.agents tr:last-child td { border-bottom: none; }
table.agents tr:hover td { background: var(--surface-2); }

.agent-name { font-weight: 600; display: inline-flex; align-items: center; gap: 8px; }
.mono { font-family: ui-monospace, "Cascadia Code", "Consolas", monospace; font-size: 12.5px; }

/* status dot */
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }
.dot--on { background: var(--success); box-shadow: 0 0 0 3px var(--success-bg); }
.dot--off { background: #b9ac9a; }
.dot--never { background: transparent; border: 1.5px solid var(--border-2); }
.status-txt { font-size: 12.5px; }
.status-txt.on { color: var(--success); }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ---------- modal ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(20,17,13,.45);
  display: flex; align-items: center; justify-content: center;
  padding: 18px;
}
.modal {
  width: 100%; max-width: 560px; max-height: 86vh; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow); overflow: hidden;
}
.modal--wide { max-width: 760px; }
.modal__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); flex: none; }
.modal__head h3 { margin: 0; font-family: "Sora", "Segoe UI", system-ui; font-weight: 700; font-size: 16px; }
.modal__body { padding: 16px 18px; overflow: auto; flex: 1 1 auto; min-height: 0; }
.modal__foot { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; flex: none; }

/* file browser: pin crumbs + toolbar, scroll only the list */
.modal__body--files { display: flex; flex-direction: column; overflow: hidden; }
.modal__body--files #fb-list { flex: 1 1 auto; min-height: 0; overflow: auto; }

/* ---------- file browser ---------- */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 13px; margin-bottom: 10px; }
.crumbs button { appearance: none; border: none; background: none; color: var(--accent); cursor: pointer; font: inherit; padding: 2px 4px; border-radius: 6px; }
.crumbs button:hover { background: var(--surface-2); }
.crumbs span.sep { color: var(--muted); }
.flist { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.frow { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--border); }
.frow:last-child { border-bottom: none; }
.frow.dir { cursor: pointer; }
.frow.dir:hover { background: var(--surface-2); }
.frow .ico { width: 18px; height: 18px; color: var(--muted); flex: none; }
.frow.dir .ico { color: var(--accent); }
.frow .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.frow .sz { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

/* ---------- login ---------- */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 22px; }
.login-card { width: 100%; max-width: 380px; padding: 26px 24px; text-align: center; }
.login-logo { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 18px; }
.login-logo .bird { width: 46px; height: 46px; color: var(--text); }
.login-logo .nm { font-family: "Sora","Segoe UI",system-ui; font-weight: 800; font-size: 22px; letter-spacing: 3px; }
.login-logo .sub { font-size: 12px; color: var(--muted); letter-spacing: .3px; }
.login-card h1 { font-family:"Sora","Segoe UI",system-ui; font-weight:700; font-size: 16px; margin: 2px 0 16px; }
.login-card .field { text-align: left; }

/* ---------- misc ---------- */
.banner { padding: 9px 12px; border-radius: 9px; font-size: 13px; margin-bottom: 12px; display: none; }
.banner.err { display: block; background: var(--error-bg); color: var(--error); border: 1px solid color-mix(in srgb, var(--error) 30%, transparent); }
.banner.ok { display: block; background: var(--success-bg); color: var(--success); border: 1px solid color-mix(in srgb, var(--success) 30%, transparent); }

.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--border-2); border-top-color: var(--accent); border-radius: 50%; animation: sp .7s linear infinite; vertical-align: -3px; }
@keyframes sp { to { transform: rotate(360deg); } }

.toast {
  position: fixed; right: 18px; bottom: 18px; z-index: 80;
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: 10px; padding: 11px 14px; box-shadow: var(--shadow); max-width: 340px;
  opacity: 0; transform: translateY(8px); transition: opacity .15s, transform .15s; pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }
.toast.err { border-left-color: var(--error); }

.creds { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-top: 6px; }
.creds .kv { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; }
.creds .kv span { color: var(--muted); }
.creds .kv b { font-family: ui-monospace, "Cascadia Code", monospace; font-weight: 600; }

.audit-list { display: flex; flex-direction: column; }

/* ---------- grouped agents ---------- */
.grp-list { display: flex; flex-direction: column; gap: 14px; }
.grp-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.grp-head__title b { font-family: "Sora", "Segoe UI", system-ui, sans-serif; font-size: 14.5px; }
.grp-head__actions { display: flex; gap: 6px; }
.grp-block .table-wrap { border-radius: 0 0 14px 14px; }
.grp-empty { padding: 16px; color: var(--muted); font-size: 13px; }

.grp-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 4px; border-bottom: 1px solid var(--border); }
.grp-row:last-child { border-bottom: none; }
.audit-row { display: grid; grid-template-columns: 130px 1fr auto; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--border); font-size: 13px; align-items: baseline; }
.audit-row:last-child { border-bottom: none; }
.audit-row .t { color: var(--muted); font-size: 12px; }
.audit-row .res-ok { color: var(--success); }
.audit-row .res-bad { color: var(--error); }

@media (max-width: 620px) {
  .logo__sub { display: none; }
  .audit-row { grid-template-columns: 1fr; gap: 2px; }
  .who { display: none; }
}

/* --- client search --- */
.agents-search { margin: 2px 0 12px; }
.input--search { width: 100%; }

/* --- group collapse + title --- */
.grp-head__title { display: flex; align-items: center; gap: 6px; min-width: 0; }
.grp-toggle { color: var(--muted); font-size: 12px; line-height: 1; width: 24px; }
.grp-toggle:hover { color: var(--accent); }
.grp-body { }

/* --- divider inside modals --- */
.sep-line { height: 1px; background: var(--border); margin: 14px 0; }

/* --- layered confirm dialog (above the base modal) --- */
.overlay--top { z-index: 90; }
.modal--sm { max-width: 420px; }

/* --- client self-update --- */
.badge { display: inline-block; font-size: 11px; line-height: 1; padding: 3px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
.badge--ok  { background: rgba(38,160,90,.12);  color: #1f9254; border-color: rgba(38,160,90,.30); }
.badge--out { background: rgba(217,131,27,.14); color: #b5760f; border-color: rgba(217,131,27,.32); }
.badge--upd { background: rgba(45,121,239,.12); color: #2766d9; border-color: rgba(45,121,239,.30); }
.badge--err { background: rgba(214,69,69,.12);  color: #c23b3b; border-color: rgba(214,69,69,.30); }
[data-theme="dark"] .badge--ok  { color: #57d08a; }
[data-theme="dark"] .badge--out { color: #e9a13d; }
[data-theme="dark"] .badge--upd { color: #6ea3ff; }
[data-theme="dark"] .badge--err { color: #ef7b7b; }
.build-tag { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 11px; color: var(--muted); opacity: .8; }
.mono { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; }

.upd-build { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 12px; }
.upd-build__name { font-family: "Sora", "Segoe UI", system-ui, sans-serif; font-size: 16px; font-weight: 600; margin: 2px 0; }
.upd-upload { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.upd-summary { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
.upd-chip { display: inline-flex; align-items: baseline; gap: 5px; font-size: 12px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px; }
.upd-chip b { font-size: 13px; color: var(--text); font-variant-numeric: tabular-nums; }
.upd-chip--ok b  { color: #1f9254; } [data-theme="dark"] .upd-chip--ok b  { color: #57d08a; }
.upd-chip--out b { color: #b5760f; } [data-theme="dark"] .upd-chip--out b { color: #e9a13d; }
.upd-chip--upd b { color: #2766d9; } [data-theme="dark"] .upd-chip--upd b { color: #6ea3ff; }
.upd-chip--err b { color: #c23b3b; } [data-theme="dark"] .upd-chip--err b { color: #ef7b7b; }
.upd-actions { display: flex; align-items: center; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.upd-table th, .upd-table td { padding: 7px 10px; }
.upd-table .dot { margin-right: 4px; }

/* --- server version tag in appbar --- */
.ver-tag { font-size: 11.5px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px 9px; white-space: nowrap; }

/* --- duplicate PC-name disambiguator --- */
.dupe-tag { margin-left: 8px; font-size: 10.5px; line-height: 1; padding: 2px 7px; border-radius: 999px; background: rgba(217,131,27,.14); color: #b5760f; border: 1px solid rgba(217,131,27,.30); white-space: nowrap; vertical-align: middle; }
[data-theme="dark"] .dupe-tag { color: #e9a13d; }

/* --- new-client approval --- */
.badge--pending { background: rgba(217,131,27,.16); color: #b5760f; border-color: rgba(217,131,27,.34); }
[data-theme="dark"] .badge--pending { color: #e9a13d; }
.pending-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; background: rgba(217,131,27,.10); border: 1px solid rgba(217,131,27,.30); border-radius: 12px; }
.pending-banner b { font-variant-numeric: tabular-nums; }
.chk { font-size: 13px; }
.chk input { margin-top: 2px; }
