:root {
  --bg: #0d1117;
  --bg-soft: #131a24;
  --surface: #171f2b;
  --surface-2: #1d2735;
  --border: #263243;
  --text: #e6edf3;
  --text-dim: #8b98a9;
  --accent: #4f8cff;
  --accent-2: #7c5cff;
  --accent-grad: linear-gradient(135deg, #4f8cff 0%, #7c5cff 100%);
  --danger: #f85149;
  --success: #3fb950;
  --radius: 12px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

code {
  font-family: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 13px;
}

/* ---------- layout ---------- */

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--bg-soft);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 20px; }

.brand-logo {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--accent-grad);
  color: #fff;
  font-weight: 800;
  font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(79, 140, 255, 0.35);
}

.brand-logo-lg { width: 52px; height: 52px; font-size: 28px; border-radius: 14px; margin: 0 auto; }

.brand-text { display: flex; flex-direction: column; }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: 0.3px; }
.brand-sub { font-size: 12px; color: var(--text-dim); }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }

.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px;
  border-radius: 9px;
  color: var(--text-dim);
  text-decoration: none;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.nav-item svg { width: 18px; height: 18px; }
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active {
  background: rgba(79, 140, 255, 0.12);
  color: var(--accent);
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.user-chip { display: flex; align-items: center; gap: 9px; font-size: 14px; min-width: 0; }
.user-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.user-avatar {
  width: 30px; height: 30px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  color: var(--accent);
}

.content {
  flex: 1;
  padding: 34px 42px;
  max-width: 1100px;
}

/* ---------- page head ---------- */

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 26px;
}
.page-head h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.3px; }
.page-sub { color: var(--text-dim); font-size: 14px; margin-top: 3px; }

/* ---------- cards ---------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 18px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 22px;
  box-shadow: var(--shadow);
}

.card-narrow { max-width: 520px; }
.card-title { font-size: 17px; font-weight: 650; margin-bottom: 18px; }

.stat-card { display: flex; flex-direction: column; gap: 6px; margin-bottom: 0; }
.stat-label { color: var(--text-dim); font-size: 13px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.6px; }
.stat-value { font-size: 34px; font-weight: 750; }
.stat-muted { color: var(--text-dim); }
.stat-hint { font-size: 12.5px; color: var(--text-dim); }
.stat-link { font-size: 13.5px; color: var(--accent); text-decoration: none; margin-top: 4px; }
.stat-link:hover { text-decoration: underline; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 9px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: filter 0.15s, background 0.15s, transform 0.05s;
  font-family: inherit;
}
.btn:active { transform: translateY(1px); }
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}
.btn:disabled:hover { filter: none; }

.head-actions { display: flex; gap: 10px; align-items: center; }

.btn-primary {
  background: var(--accent-grad);
  color: #fff;
  box-shadow: 0 4px 14px rgba(79, 140, 255, 0.3);
}
.btn-primary:hover { filter: brightness(1.1); }

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

.btn-danger {
  background: rgba(248, 81, 73, 0.12);
  color: var(--danger);
  border-color: rgba(248, 81, 73, 0.35);
}
.btn-danger:hover { background: rgba(248, 81, 73, 0.22); }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }

/* ---------- forms ---------- */

.form-grid { display: flex; flex-direction: column; gap: 16px; max-width: 460px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13.5px; font-weight: 600; color: var(--text-dim); }
.field-hint { font-size: 12.5px; color: var(--text-dim); font-weight: 400 !important; }

.field input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 13px;
  color: var(--text);
  font-size: 14.5px;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.18);
}

.form-actions { display: flex; gap: 10px; margin-top: 6px; }

/* ---------- table ---------- */

.table-wrap { overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
  font-weight: 600;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-2); }

.table-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.table-actions form { display: inline; }

.badge {
  display: inline-block;
  background: rgba(79, 140, 255, 0.12);
  color: var(--accent);
  border: 1px solid rgba(79, 140, 255, 0.3);
  border-radius: 7px;
  padding: 3px 10px;
  font-size: 13px;
  font-weight: 650;
  font-family: ui-monospace, Consolas, monospace;
}

/* ---------- reimage log ---------- */

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid;
}

.status-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.st-run {
  background: rgba(79, 140, 255, 0.1);
  border-color: rgba(79, 140, 255, 0.35);
  color: #79a8ff;
}
.st-run .status-dot { animation: pulse 1.3s ease-in-out infinite; }

.st-ok {
  background: rgba(63, 185, 80, 0.1);
  border-color: rgba(63, 185, 80, 0.4);
  color: #7ee29a;
}

.st-err {
  background: rgba(248, 81, 73, 0.1);
  border-color: rgba(248, 81, 73, 0.4);
  color: #ffb3ae;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

.time-cell { color: var(--text-dim); font-size: 13.5px; white-space: nowrap; }
.mac-cell { color: var(--text-dim); white-space: nowrap; }
.num-unknown { color: var(--text-dim); }

.row-link { cursor: pointer; }

/* карточка ПК */

.pc-info { display: flex; flex-direction: column; }

.pc-info-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.pc-info-row:last-child { border-bottom: none; }

.pc-info-label {
  flex-shrink: 0;
  width: 190px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* таймлайн статусов */

.timeline { list-style: none; margin: 4px 0 0; padding: 0; }

.timeline-item {
  position: relative;
  padding: 0 0 22px 30px;
}
.timeline-item::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 16px;
  bottom: -2px;
  width: 2px;
  background: var(--border);
}
.timeline-item:last-child { padding-bottom: 4px; }
.timeline-item:last-child::before { display: none; }

.timeline-dot {
  position: absolute;
  left: 0;
  top: 4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 3px solid var(--surface);
  box-sizing: border-box;
}
.timeline-dot.st-run { background: var(--accent); }
.timeline-dot.st-ok { background: var(--success); }
.timeline-dot.st-err { background: var(--danger); }

.timeline-current .timeline-dot.st-run { animation: pulse 1.3s ease-in-out infinite; }
.timeline-current .timeline-status { color: var(--text); }

.timeline-status { font-weight: 600; font-size: 14.5px; }

.timeline-meta {
  color: var(--text-dim);
  font-size: 13px;
  margin-top: 2px;
  display: flex;
  gap: 10px;
  align-items: baseline;
}

.timeline-delta {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 8px;
  font-size: 12px;
}
.empty-inline { color: var(--text-dim); padding: 12px 0; }
.empty-hint { font-size: 13px; }

/* ---------- files ---------- */

.files-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.crumbs { font-size: 15px; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.crumbs a { color: var(--accent); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.crumb-sep { color: var(--text-dim); }
.crumb-current { font-weight: 650; }

.files-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form input[type="text"] {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 11px;
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  width: 150px;
}
.inline-form input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
}

.file-pick { position: relative; overflow: hidden; }
.file-pick input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-progress { color: var(--accent); font-size: 14px; margin-bottom: 12px; }

.toggle-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

/* ---------- api section ---------- */

.api-desc { color: var(--text-dim); font-size: 14px; margin-bottom: 16px; }

.api-row {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 7px 0;
  flex-wrap: wrap;
}
.api-row code { word-break: break-all; }

.api-label {
  flex-shrink: 0;
  width: 90px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.api-key { color: var(--accent); }
.api-note { color: var(--text-dim); font-size: 13.5px; }

/* ---------- alerts ---------- */

.alert {
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 18px;
  font-size: 14px;
  border: 1px solid;
}
.alert-error {
  background: rgba(248, 81, 73, 0.1);
  border-color: rgba(248, 81, 73, 0.4);
  color: #ffb3ae;
}
.alert-success {
  background: rgba(63, 185, 80, 0.1);
  border-color: rgba(63, 185, 80, 0.4);
  color: #7ee29a;
}

/* ---------- empty state ---------- */

.empty {
  text-align: center;
  padding: 38px 20px;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}

/* ---------- login ---------- */

.login-body {
  background:
    radial-gradient(800px 500px at 20% -10%, rgba(79, 140, 255, 0.14), transparent),
    radial-gradient(700px 500px at 90% 110%, rgba(124, 92, 255, 0.12), transparent),
    var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-wrap { width: 100%; max-width: 400px; }

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 32px;
  box-shadow: var(--shadow);
}

.login-brand { text-align: center; margin-bottom: 26px; }
.login-brand h1 { font-size: 24px; margin-top: 14px; letter-spacing: -0.3px; }
.login-brand p { color: var(--text-dim); font-size: 14px; margin-top: 3px; }

.login-form { display: flex; flex-direction: column; gap: 16px; }

.login-foot {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  margin-top: 18px;
}

/* ---------- responsive ---------- */

@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; padding: 12px 16px; }
  .brand { padding: 0; }
  .nav { flex-direction: row; flex: 1; justify-content: center; }
  .sidebar-footer { border: none; padding: 0; }
  .content { padding: 22px 18px; }
}
