/* RifeyGit — адаптивный интерфейс (ПК и телефон) */
:root {
  --bg: #eef2f7;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --dark: #0f172a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 10px 30px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0; }
h3 { font-size: 16px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small, .sub { font-size: 12px; }
.sub { color: var(--muted); margin-top: 2px; }
.nowrap { white-space: nowrap; }
.mono { font-family: Consolas, "SF Mono", monospace; font-size: 12.5px; }
.link { font-size: 13px; }
code.sha {
  background: #f1f5f9; border: 1px solid var(--line); border-radius: 6px;
  padding: 1px 6px; font-size: 12px; color: #334155;
}
.empty { padding: 14px 4px; }
.empty-state { text-align: center; padding: 40px 20px; }
.err-code { font-size: 52px; font-weight: 800; color: var(--line); line-height: 1; }

/* ---------- Верхняя панель ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 12px;
  background: var(--dark); color: #fff;
  padding: 10px 16px; box-shadow: 0 2px 14px rgba(15, 23, 42, .25);
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; background: var(--brand);
  display: grid; place-items: center; font-weight: 800; font-size: 13px;
}
.brand-text { font-weight: 700; font-size: 16px; display: flex; flex-direction: column; line-height: 1.1; }
.brand-text small { font-weight: 400; font-size: 11px; color: #94a3b8; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.userbox { display: flex; align-items: center; gap: 8px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: #1e293b;
  display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #e2e8f0;
}
.userbox-text { display: flex; flex-direction: column; line-height: 1.15; }
.userbox-text b { font-size: 13px; }
.userbox-text small { font-size: 11px; color: #94a3b8; }
.burger {
  display: none; background: none; border: 0; padding: 6px; cursor: pointer;
  flex-direction: column; gap: 4px;
}
.burger span { width: 22px; height: 2px; background: #fff; border-radius: 2px; }

/* ---------- Каркас ---------- */
.shell { display: flex; min-height: calc(100vh - 55px); }
.sidebar {
  width: 230px; flex: 0 0 230px; background: #111c33; color: #cbd5e1;
  padding: 16px 12px; display: flex; flex-direction: column; gap: 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 10px; color: #cbd5e1; font-weight: 500;
}
.nav-item:hover { background: #1c2b4a; text-decoration: none; }
.nav-item.active { background: var(--brand); color: #fff; }
.nav-ico { width: 18px; text-align: center; }
.sidebar-note {
  margin-top: auto; background: #0b1428; border: 1px solid #1e293b;
  border-radius: 10px; padding: 10px; font-size: 12px; color: #94a3b8;
}
.sidebar-note b { color: #e2e8f0; display: block; margin-bottom: 3px; }
.backdrop { display: none; }
.main { flex: 1; min-width: 0; padding: 22px; max-width: 1320px; }

/* ---------- Заголовок страницы ---------- */
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 14px; margin-bottom: 18px; flex-wrap: wrap;
}
/* удаление/восстановление программы — кнопка живёт внутри формы в шапке */
.page-actions form { display: contents; }

.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }

/* ---------- Элементы ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: #fff; color: var(--ink); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 14px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: .15s;
}
.btn:hover { background: #f8fafc; text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: #e8edf5; color: var(--ink); }
.btn-danger { background: #fff5f5; border-color: #fecaca; color: var(--red); }
.btn-sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.inline { display: inline; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 18px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 14px;
}
.chip {
  display: inline-block; background: #eef2ff; color: #3730a3;
  border: 1px solid #e0e7ff; border-radius: 999px;
  padding: 2px 10px; font-size: 12px; font-weight: 700;
}
.badge {
  display: inline-block; border-radius: 999px; padding: 2px 9px;
  font-size: 11.5px; font-weight: 700; border: 1px solid transparent;
}
.badge-blue { background: #eff6ff; color: #1d4ed8; border-color: #dbeafe; }
.badge-green { background: #ecfdf5; color: #047857; border-color: #d1fae5; }
.badge-amber { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.badge-red { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.badge-gray { background: #f1f5f9; color: #475569; border-color: var(--line); }
.tag {
  display: inline-block; background: #f1f5f9; border: 1px solid var(--line);
  border-radius: 6px; padding: 1px 7px; font-size: 12px; font-weight: 700; color: #334155;
}
.tag-green { background: #ecfdf5; border-color: #a7f3d0; color: #047857; }
.hint-pill {
  background: #fffbeb; border: 1px solid #fde68a; color: #92400e;
  border-radius: 999px; padding: 7px 13px; font-size: 13px; font-weight: 600;
}
.hint-soft { background: #f8fafc; border-color: var(--line); color: var(--muted); padding: 4px 10px; }
.notice {
  background: #f8fafc; border: 1px dashed var(--line); border-radius: 10px;
  padding: 10px 12px; font-size: 12.5px; color: var(--muted); margin: 6px 0 2px;
}

/* ---------- Статистика ---------- */
.stats {
  display: grid; gap: 12px; margin-bottom: 18px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat b { display: block; font-size: 28px; line-height: 1.15; }
.stat span:not(.stat-ico) { color: var(--muted); font-size: 12.5px; }
.stat-ico {
  position: absolute; right: 12px; top: 10px; font-size: 18px; opacity: .35;
}

.grid-2 { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid-2 > *, .cards > *, .stats > * { min-width: 0; }
.cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

/* ---------- График ---------- */
.bars { display: flex; align-items: flex-end; gap: 5px; height: 150px; }
.bar-wrap { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.bar {
  background: linear-gradient(180deg, #60a5fa, var(--brand));
  border-radius: 6px 6px 0 0; min-height: 4px; transition: .2s;
}
.bar-wrap:hover .bar { background: linear-gradient(180deg, #93c5fd, var(--brand-dark)); }
.bar-label { text-align: center; font-size: 10.5px; color: var(--muted); margin-top: 4px; }
.chart-foot { margin-top: 8px; font-size: 12.5px; }

.toplist { list-style: none; margin: 0; padding: 0; counter-reset: t; }
.toplist li {
  display: flex; align-items: center; gap: 8px; padding: 9px 0;
  border-bottom: 1px dashed var(--line); font-size: 14px;
}
.toplist li:last-child { border-bottom: 0; }
.toplist a { flex: 1; color: var(--ink); }
.toplist-count {
  background: var(--brand); color: #fff; border-radius: 999px;
  min-width: 26px; text-align: center; padding: 1px 8px; font-weight: 700; font-size: 12.5px;
}

/* ---------- Лента событий ---------- */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li {
  display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px dashed var(--line);
}
.feed li:last-child { border-bottom: 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; flex: 0 0 10px; background: #cbd5e1; }
.dot-blue { background: var(--brand); }
.dot-green { background: var(--green); }
.dot-amber { background: var(--amber); }
.dot-red { background: var(--red); }
.dot-gray { background: #94a3b8; }
.feed-msg { font-size: 13px; color: #334155; margin-top: 3px; white-space: pre-wrap; }

.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip-card {
  border: 1px solid var(--line); background: #f8fafc; border-radius: 10px;
  padding: 8px 12px; font-size: 13.5px; color: var(--ink);
}
.chip-card:hover { border-color: var(--brand); text-decoration: none; }
.chip-card small { display: block; color: var(--muted); font-size: 12px; }

/* ---------- Таблицы ---------- */
.table-wrap { overflow-x: auto; max-width: 100%; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); padding: 8px 10px; border-bottom: 2px solid var(--line);
  white-space: nowrap; background: #f8fafc;
}
.tbl td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: #f8fafc; }
.ua { font-size: 11.5px; color: var(--muted); max-width: 260px; overflow: hidden;
      text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* ---------- Формы ---------- */
.form-narrow { max-width: 720px; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form-title { font-size: 15px; margin: 0 0 4px; color: var(--muted); text-transform: uppercase;
              letter-spacing: .05em; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.field > span, .field-label { font-weight: 600; font-size: 13.5px; }
.field small { color: var(--muted); font-size: 12px; }
.field input, .field select, .field textarea,
.filters input, .filters select, .row-form input, .row-form select {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-size: 16px; font-family: inherit; background: #fff; color: var(--ink);
}
.field textarea { font-size: 14px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus,
.filters input:focus, .filters select:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37, 99, 235, .14);
}
.field-row { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.radios { display: flex; gap: 10px; flex-wrap: wrap; }
.radio {
  display: flex; align-items: center; gap: 8px; border: 1px solid var(--line);
  background: #f8fafc; border-radius: 10px; padding: 10px 14px; cursor: pointer; font-weight: 600;
}
.radio:has(input:checked) { border-color: var(--brand); background: #eff6ff; color: var(--brand-dark); }
.radio input { width: 16px; height: 16px; }

.filters {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px;
}
.filters input, .filters select { width: auto; min-width: 150px; flex: 1; font-size: 14px; }
.row-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.row-form input, .row-form select { width: auto; min-width: 130px; padding: 6px 8px; font-size: 13px; }

/* ---------- Карточки программ ---------- */
.prog-card {
  display: block; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); color: var(--ink);
  transition: .15s;
}
.prog-card:hover { transform: translateY(-2px); border-color: #c7d2fe; text-decoration: none; }
.prog-top { display: flex; gap: 8px; justify-content: space-between; margin-bottom: 8px; }
.prog-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.prog-foot {
  display: flex; gap: 12px; font-size: 12.5px; color: var(--muted);
  border-top: 1px dashed var(--line); padding-top: 8px;
}
.prog-foot span:last-child { margin-left: auto; }

/* ---------- Git-история версий ---------- */
.commit-hint { border-left: 4px solid var(--brand); }
.git { position: relative; padding-left: 30px; }
.git::before {
  content: ""; position:absolute; left: 8px; top: 10px; bottom: 10px;
  width: 2px; background: var(--line);
}
.commit { position: relative; margin-bottom: 14px; }
.commit::before {
  content: ""; position: absolute; left: -28px; top: 16px; width: 12px; height: 12px;
  border-radius: 50%; background: #fff; border: 3px solid var(--brand); z-index: 1;
}
.commit.head::before { background: var(--green); border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(22, 163, 74, .16); }
.commit-card {
  border: 1px solid var(--line); background: #f8fafc; border-radius: 12px; padding: 12px 14px;
}
.commit.head .commit-card { background: #f0fdf4; border-color: #bbf7d0; }
.commit-line { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; }
.commit-msg { margin: 8px 0; font-size: 14px; white-space: pre-wrap; }
.commit-file {
  font-size: 13px; color: #334155; background: #fff; border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 10px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
}
.parent-link { color: var(--muted); font-size: 12.5px; }
.commit-actions {
  display: flex; gap: 10px; align-items: center; justify-content: flex-end;
  margin-top: 10px; flex-wrap: wrap;
}

.dl-summary { border-left: 4px solid var(--green); }

/* ---------- Вкладки и пагинация ---------- */
.tabs { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.tab {
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 16px; font-weight: 600; font-size: 14px; color: var(--muted);
}
.tab.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.tab:hover { text-decoration: none; }
.pager { display: flex; gap: 6px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.page-link {
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 11px;
  font-size: 13.5px; font-weight: 600; color: var(--ink); background: #fff;
}
.page-link.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- Уведомления ---------- */
.toast {
  background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--brand);
  border-radius: 10px; padding: 11px 14px; margin-bottom: 12px;
  box-shadow: var(--shadow); font-size: 14px;
  animation: slidein .25s ease;
}
.toast-ok { border-left-color: var(--green); }
.toast-err { border-left-color: var(--red); background: #fef2f2; }
.toast-info { border-left-color: var(--brand); }
.toast-static { margin-top: 12px; animation: none; }
.toast.gone { opacity: 0; transform: translateY(-8px); transition: .5s; pointer-events: none; }
@keyframes slidein { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; } }

/* ---------- Экран входа ---------- */
.auth-body {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background:
    radial-gradient(1000px 500px at 15% -10%, rgba(37, 99, 235, .18), transparent),
    radial-gradient(800px 400px at 100% 0%, rgba(245, 158, 11, .14), transparent), var(--bg);
}
.auth-wrap { width: 100%; max-width: 420px; }
.auth-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 30px 26px; box-shadow: 0 24px 60px rgba(15, 23, 42, .14);
}
.auth-logo {
  width: 54px; height: 54px; border-radius: 15px; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 20px; margin-bottom: 14px;
}
.auth-card h1 { margin-bottom: 2px; }
.auth-hint {
  margin-top: 18px; font-size: 12.5px; color: var(--muted);
  background: #f8fafc; border: 1px dashed var(--line); border-radius: 10px; padding: 10px 12px;
}

/* ---------- Планшет / телефон ---------- */
@media (max-width: 900px) {
  .burger { display: flex; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 60;
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: 0 0 40px rgba(0, 0, 0, .35); overflow-y: auto;
  }
  .sidebar.open { transform: none; }
  .backdrop {
    display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .5);
    opacity: 0; pointer-events: none; transition: .2s; z-index: 50;
  }
  .backdrop.show { opacity: 1; pointer-events: auto; }
  .main { padding: 14px; }
  .userbox-text { display: none; }
  h1 { font-size: 20px; }
  .stats { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
  .stat b { font-size: 24px; }
  .grid-2 { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .filters input, .filters select { min-width: 120px; }
  .tbl th, .tbl td { padding: 8px; }
  .brand-text small { display: none; }
  .git { padding-left: 24px; }
  .commit::before { left: -22px; }
  .ua { max-width: 140px; }
}

@media (max-width: 480px) {
  .page-head { flex-direction: column; align-items: stretch; }
  .page-actions .btn { width: 100%; }
  .cards { grid-template-columns: 1fr; }
  .topbar { padding: 8px 12px; }
}
