:root {
  --bg: #eef1f4;
  --panel: #ffffff;
  --panel-2: #f6f8fa;
  --line: #dde2e8;
  --ink: #1a2230;
  --ink-2: #5a6575;
  --blue: #3179df;
  --blue-ink: #ffffff;
  --blue-soft: #e6effc;
  --green: #1fa35b;
  --amber: #d99a00;
  --red: #d6453d;
  --grey: #9aa3ae;
  --log-bg: #141922;
  --log-ink: #d3dae3;
  --radius: 12px;
  --radius-s: 8px;
  --font: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151a22; --panel: #1d242e; --panel-2: #232b37; --line: #2e3744; --ink: #e7ebf0; --ink-2: #98a3b2;
    --blue: #4a8cf0; --blue-soft: #1f2d45; --log-bg: #0f131a; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--blue); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 26px; line-height: 1.2; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }

/* ---- верхняя панель ---- */
.top { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; align-items: center; gap: 16px; height: 58px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: var(--ink); text-decoration: none; }
.brand img { width: 26px; height: 26px; }
.brand span { color: var(--ink-2); font-weight: 500; font-size: 14px; }
.top .sp { flex: 1; }
.menu { position: relative; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); min-width: 210px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-s); box-shadow: 0 10px 30px rgb(10 20 40 / 0.14); padding: 6px; display: none; }
.menu.open .menu-pop { display: block; }
.menu-pop button, .menu-pop a { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; background: none; border-radius: 6px; cursor: pointer; color: var(--ink); text-decoration: none; }
.menu-pop button:hover, .menu-pop a:hover { background: var(--panel-2); }

/* ---- кнопки и поля ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 15px; border-radius: var(--radius-s); border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; font-weight: 550; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: color-mix(in srgb, var(--ink) 25%, var(--line)); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: var(--blue-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--red); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { height: 32px; padding: 0 11px; font-size: 14px; }
.btn:disabled { opacity: 0.55; cursor: default; }
label.f { display: block; margin-bottom: 14px; }
label.f > span { display: block; font-weight: 550; margin-bottom: 5px; }
label.f > small { display: block; color: var(--ink-2); font-size: 13px; margin-top: 4px; }
input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--panel);
}
textarea { height: auto; padding: 10px 12px; resize: vertical; }
textarea.code { font: 13px/1.55 var(--mono); min-height: 340px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.check { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 14px; cursor: pointer; }
.check input { margin-top: 4px; width: 17px; height: 17px; accent-color: var(--blue); }

/* ---- индикатор состояния: главная деталь пульта ---- */
.led { width: 10px; height: 10px; border-radius: 50%; background: var(--grey); flex: none; }
.led.running { background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 22%, transparent), 0 0 10px color-mix(in srgb, var(--green) 70%, transparent); }
.led.building, .led.queued, .led.starting { background: var(--amber); animation: blink 1.1s ease-in-out infinite; }
.led.warn { background: var(--amber); }
.led.error { background: var(--red); box-shadow: 0 0 0 3px color-mix(in srgb, var(--red) 22%, transparent); }
.led.download { background: var(--blue); }
@keyframes blink { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .led { animation: none !important; } }
.state { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); }

/* ---- главная: плитки ---- */
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; padding: 30px 0 18px; flex-wrap: wrap; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; padding-bottom: 40px; }
.tile { position: relative; display: flex; flex-direction: column; gap: 12px; padding: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); min-height: 168px; }
.tile .ic { font-size: 30px; line-height: 1; width: 48px; height: 48px; display: grid; place-items: center; background: var(--panel-2); border-radius: 10px; }
.tile .t { display: flex; gap: 12px; align-items: flex-start; }
.tile .nm { font-weight: 650; font-size: 16px; line-height: 1.3; }
.tile .ds { font-size: 13px; color: var(--ink-2); margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile .act { margin-top: auto; display: flex; gap: 8px; align-items: center; }
.tile .act .btn.primary { flex: 1; }
.tile .addr { font-size: 12.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.section-t { margin: 8px 0 12px; color: var(--ink-2); font-size: 14px; font-weight: 600; }
.empty { padding: 48px 24px; text-align: center; background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty p { max-width: 460px; margin: 8px auto 18px; color: var(--ink-2); }

/* ---- страница программы ---- */
.apphead { display: flex; gap: 16px; align-items: center; padding: 26px 0 16px; flex-wrap: wrap; }
.apphead .ic { font-size: 38px; width: 64px; height: 64px; display: grid; place-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.apphead .info { flex: 1; min-width: 220px; }
.apphead .info .row { margin-top: 4px; gap: 14px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 14px; cursor: pointer; color: var(--ink-2); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--blue); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.card > h3 { margin-bottom: 12px; }
.alert { padding: 12px 14px; border-radius: var(--radius-s); background: color-mix(in srgb, var(--red) 10%, var(--panel)); border: 1px solid color-mix(in srgb, var(--red) 35%, var(--line)); margin-bottom: 16px; font-size: 14px; }
.note { padding: 12px 14px; border-radius: var(--radius-s); background: var(--blue-soft); margin-bottom: 16px; font-size: 14px; }

.log { background: var(--log-bg); color: var(--log-ink); font: 12.5px/1.55 var(--mono); padding: 14px 16px; border-radius: var(--radius-s); height: 460px; overflow: auto; white-space: pre-wrap; word-break: break-word; margin: 0; }
.log.short { height: 320px; }

table.rel { width: 100%; border-collapse: collapse; font-size: 14px; }
table.rel td, table.rel th { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.rel th { font-weight: 600; color: var(--ink-2); font-size: 13px; }
table.rel tr:last-child td { border-bottom: 0; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 20px; font-size: 12.5px; background: var(--panel-2); border: 1px solid var(--line); white-space: nowrap; }
.tag.ok { color: var(--green); border-color: color-mix(in srgb, var(--green) 40%, var(--line)); }
.tag.failed { color: var(--red); border-color: color-mix(in srgb, var(--red) 40%, var(--line)); }
.tag.cur { background: var(--blue); color: #fff; border-color: var(--blue); }
.scroll-x { overflow-x: auto; }

/* ---- загрузка файла ---- */
.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 26px 18px; text-align: center; cursor: pointer; background: var(--panel-2); }
.drop.over { border-color: var(--blue); background: var(--blue-soft); }
.drop b { display: block; margin-bottom: 4px; }
.progress { height: 6px; background: var(--panel-2); border-radius: 4px; overflow: hidden; margin-top: 12px; }
.progress > i { display: block; height: 100%; width: 0; background: var(--blue); transition: width 0.2s; }

/* ---- окно ---- */
.modal-bg { position: fixed; inset: 0; background: rgb(10 16 28 / 0.45); display: grid; place-items: center; z-index: 20; padding: 16px; }
.modal { background: var(--panel); border-radius: 14px; width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow: auto; padding: 22px; box-shadow: 0 24px 60px rgb(0 0 0 / 0.25); }
.modal h2 { margin-bottom: 16px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ---- вход ---- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; }
.login .brand { margin-bottom: 22px; font-size: 20px; }
.login .btn { width: 100%; height: 42px; }
.err { color: var(--red); font-size: 14px; min-height: 20px; margin: -4px 0 10px; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: 0.2s; z-index: 30; max-width: calc(100vw - 32px); }
#toast.on { opacity: 1; transform: translateX(-50%); }
#toast.bad { background: var(--red); color: #fff; }

.users td .apps { display: flex; flex-wrap: wrap; gap: 4px; }
.foot-note { padding: 0 0 30px; font-size: 13px; color: var(--ink-2); }

@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
  .brand span { display: none; }
  h1 { font-size: 22px; }
  .apphead .row.btns { width: 100%; }
  .apphead .row.btns .btn { flex: 1; }
  .log { height: 360px; }
  .hide-m { display: none; }
}
