/* Маршрутка — стили. Перенесены из прежнего templates/base.html без изменения
   палитры и форм: продукт должен остаться узнаваемым. Вырезано то, что вместе
   со своими страницами: AI-панель, карточки publish-профилей, модалка превью,
   блоки гайдов. */

:root {
  --indigo: #4f46e5;
  --indigo-dark: #4338ca;
  --indigo-light: #eef2ff;
  --amber: #f59e0b;
  --amber-light: #fef3c7;
  --bg: #eef0f5;
  --surface: #ffffff;
  --border: #e2e5ec;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --text-light: #9ca3af;
  --success-bg: #d1fae5;
  --success-text: #065f46;
  --running-bg: #dbeafe;
  --running-text: #1e40af;
  --failed-bg: #fee2e2;
  --failed-text: #991b1b;
  --pending-bg: #f3f4f6;
  --pending-text: #6b7280;
  --cancelled-bg: #fef3c7;
  --cancelled-text: #92400e;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  display: flex;
  height: 100vh;
  overflow: hidden;
}
a { color: var(--indigo-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Sidebar ── */
.sidebar {
  width: 220px; flex-shrink: 0;
  background: linear-gradient(180deg, var(--indigo) 0%, var(--indigo-dark) 100%);
  margin: 1rem 0 1rem 1rem; border-radius: 20px; padding: 1.5rem 0;
  display: flex; flex-direction: column; color: #fff;
  overflow: hidden; height: calc(100vh - 2rem);
}
.sidebar-brand { padding: 0 1.25rem 1.25rem; border-bottom: 1px solid rgba(255,255,255,.12); margin-bottom: 1rem; }
.sidebar-brand .subtitle { font-size: .7rem; color: rgba(255,255,255,.55); margin-top: .35rem; text-transform: uppercase; letter-spacing: .04em; }
.sidebar nav { display: flex; flex-direction: column; gap: .15rem; padding: 0 .6rem; flex: 1; overflow-y: auto; }
.sidebar nav a {
  display: flex; align-items: center; gap: .6rem; padding: .55rem .75rem; border-radius: 12px;
  color: rgba(255,255,255,.7); font-size: .88rem; font-weight: 500; text-decoration: none;
  transition: background .15s, color .15s;
}
.sidebar nav a:hover { background: rgba(255,255,255,.12); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: rgba(255,255,255,.18); color: #fff; font-weight: 600; }
.sidebar .nav-icon {
  width: 1.5rem; height: 1.5rem; border-radius: 8px; background: rgba(255,255,255,.1);
  display: flex; align-items: center; justify-content: center; font-size: .85rem; flex-shrink: 0;
}
.sidebar .nav-count {
  margin-left: auto; background: rgba(255,255,255,.2); border-radius: 100px;
  padding: 0 .45rem; font-size: .72rem; font-weight: 700;
}
.sidebar-footer { margin-top: auto; padding: 1rem 1.25rem 0; border-top: 1px solid rgba(255,255,255,.1); font-size: .7rem; color: rgba(255,255,255,.4); }

/* ── Layout ── */
.main-wrap { flex: 1; min-width: 0; display: flex; padding: 1rem 1.25rem; height: 100vh; overflow: hidden; }
.content-area { flex: 1; min-width: 0; overflow-y: auto; padding: .5rem .5rem 2rem 0; }
.content-area::-webkit-scrollbar { width: 4px; }
.content-area::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

.page-header { margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.02em; }
.page-header .description { color: var(--text-muted); font-size: .85rem; margin-top: .2rem; }

/* ── Cards ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 1.35rem 1.5rem; margin-bottom: 1rem; }
.card-title { font-size: .9rem; font-weight: 600; margin-bottom: .85rem; }

/* ── Notices ── */
.notice, .alert {
  border-radius: 12px; padding: .7rem 1rem; margin-bottom: 1rem;
  font-size: .85rem; border: 1px solid transparent;
}
.notice { background: var(--indigo-light); color: var(--indigo-dark); border-color: #c7d2fe; }
.alert { background: var(--failed-bg); color: var(--failed-text); border-color: #fecaca; }

/* ── Tags ── */
.tag { display: inline-flex; align-items: center; padding: .2rem .65rem; border-radius: 100px; font-size: .76rem; font-weight: 600; line-height: 1.4; }
.tag-success { background: var(--success-bg); color: var(--success-text); }
.tag-failed { background: var(--failed-bg); color: var(--failed-text); }
.tag-running { background: var(--running-bg); color: var(--running-text); }
.tag-pending { background: var(--pending-bg); color: var(--pending-text); }
.tag-cancelled { background: var(--cancelled-bg); color: var(--cancelled-text); }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; padding: .5rem 1.1rem; border-radius: 10px; font-weight: 500; font-size: .85rem; border: none; cursor: pointer; transition: background .12s; line-height: 1.4; text-decoration: none; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--indigo); color: #fff; }
.btn-primary:hover { background: var(--indigo-dark); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-muted); }
.btn-outline:hover { background: var(--bg); }
.btn-danger { background: transparent; border: 1px solid #fecaca; color: var(--failed-text); }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: .3rem .65rem; font-size: .78rem; border-radius: 8px; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; margin: 0 -.25rem; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--border); font-size: .85rem; vertical-align: top; }
th:first-child, td:first-child { padding-left: .25rem; }
th { font-weight: 600; color: var(--text-muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafbfd; }

/* ── Forms ── */
.form-group { margin-bottom: .9rem; }
.form-label { display: block; font-size: .82rem; font-weight: 500; margin-bottom: .3rem; }
.form-hint { font-size: .75rem; color: var(--text-light); margin-top: .15rem; }
input[type="text"], input[type="url"], textarea, select {
  width: 100%; padding: .5rem .75rem; border: 1px solid var(--border); border-radius: 10px;
  font-size: .88rem; font-family: inherit; background: var(--surface); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--indigo); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
textarea { min-height: 120px; resize: vertical; }

/* ── KPI ── */
.kpi-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1.25rem; }
.kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: .9rem 1.1rem; text-align: center; }
.kpi-card .kpi-value { font-size: 1.5rem; font-weight: 800; letter-spacing: -.03em; line-height: 1.2; }
.kpi-card .kpi-label { font-size: .72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin-top: .15rem; }
.kpi-card.kpi-success .kpi-value { color: var(--success-text); }
.kpi-card.kpi-running .kpi-value { color: var(--running-text); }
.kpi-card.kpi-failed .kpi-value { color: var(--failed-text); }

/* ── Pipeline cards ── */
.pipeline-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .85rem; margin-bottom: 1.25rem; }
.pipeline-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 1.15rem 1.25rem; }
.pipeline-card.down { border-color: #fecaca; }
.pipeline-card .p-top { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; margin-bottom: .5rem; }
.pipeline-card .p-name { font-size: .95rem; font-weight: 600; }
.pipeline-card .p-meta { font-size: .78rem; color: var(--text-muted); display: flex; flex-direction: column; gap: .1rem; }
.pipeline-card .p-actions { margin-top: .75rem; display: flex; gap: .35rem; }

/* ── Filters ── */
.filters { display: flex; gap: .35rem; margin-bottom: 1rem; flex-wrap: wrap; }
.filters a { padding: .3rem .75rem; border-radius: 100px; font-size: .8rem; color: var(--text-muted); background: transparent; border: 1px solid var(--border); transition: all .12s; }
.filters a:hover { background: var(--bg); text-decoration: none; }
.filters a.active { background: var(--indigo-light); border-color: var(--indigo); color: var(--indigo-dark); font-weight: 500; }

/* ── Misc ── */
.mono { font-family: "SF Mono", "Fira Code", "Cascadia Code", monospace; font-size: .83rem; }
.muted { color: var(--text-muted); }
.empty-state { color: var(--text-light); font-size: .85rem; padding: 1rem 0; }
.truncate { max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-box { background: #1a1d2e; color: #cdd6f4; padding: .9rem 1rem; border-radius: 10px; font-family: "SF Mono", monospace; font-size: .78rem; line-height: 1.5; white-space: pre-wrap; max-height: 380px; overflow-y: auto; }
.info-grid { display: grid; grid-template-columns: auto 1fr; gap: .35rem 1rem; font-size: .85rem; }
.info-grid .label { color: var(--text-muted); white-space: nowrap; }
.breadcrumb { font-size: .82rem; color: var(--text-muted); margin-bottom: .5rem; }
.flex { display: flex; gap: .5rem; align-items: center; }
.mb-2 { margin-bottom: 1rem; }
.mt-2 { margin-top: 1rem; }
.steps { display: flex; flex-direction: column; gap: .3rem; }
.step-row { display: grid; grid-template-columns: 1.2rem 1fr auto; gap: .6rem; align-items: baseline; font-size: .84rem; padding: .3rem 0; border-bottom: 1px solid var(--border); }
.step-row:last-child { border-bottom: none; }
.step-dot { width: .55rem; height: .55rem; border-radius: 50%; }
.step-ok { background: var(--success-text); }
.step-error { background: var(--failed-text); }
.step-skip { background: var(--text-light); }

@media (max-width: 860px) {
  .sidebar { width: 60px; }
  .sidebar .subtitle, .sidebar nav a span.nav-label, .sidebar-footer { display: none; }
  .main-wrap { padding: .75rem; }
  .content-area { padding-right: 0; }
  .truncate { max-width: 160px; }
}

/* ── Система: диск/RAM, cleanup ── */
.system-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.usage-row { margin-bottom: .7rem; }
.usage-row:last-child { margin-bottom: 0; }
.usage-label { display: flex; justify-content: space-between; font-size: .82rem; color: var(--text-muted); margin-bottom: .3rem; }
.usage-bar { height: .5rem; border-radius: 100px; background: var(--pending-bg); overflow: hidden; }
.usage-bar-fill { height: 100%; border-radius: 100px; background: var(--indigo); }
.usage-bar-fill.warn { background: var(--amber); }
.usage-bar-fill.crit { background: var(--failed-text); }
.cleanup-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.cleanup-project-title { font-weight: 600; font-size: .85rem; margin-bottom: .6rem; }
.cleanup-actions { display: flex; flex-direction: column; gap: .5rem; }
.cleanup-preset { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.cleanup-preset .form-hint { margin: 0; }
.cleanup-preset form { display: flex; gap: .35rem; }

/* ── Публичные страницы: лендинг и вход — тёмная премиальная тема ──
   Композиция и техника взяты из mais-seating/AuthScreen (радиальные
   свечения на тёмном фоне, стеклянная карточка, светящиеся пин-точки),
   перекрашено в тона маршрутки: indigo вместо gold, amber (тоже уже есть
   в палитре) вместо teal — второй, тёплый акцент для глубины фона. */
:root {
  --dark-bg: #12121f;
  --dark-surface-1: rgba(32, 32, 52, .92);
  --dark-surface-2: rgba(17, 17, 28, .97);
  --dark-border: rgba(129, 140, 248, .16);
  --dark-border-hover: rgba(129, 140, 248, .4);
  --indigo-glow: #818cf8;
  --text-on-dark: #f4f4f8;
  --text-on-dark-muted: #9295b3;
  --text-on-dark-faint: #5c5f78;
}

body.standalone { display: block; height: auto; min-height: 100vh; overflow: auto; }
.standalone-wrap {
  position: relative; min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 2.5rem 1.25rem;
}

/* Тёмная тема — лендинг и вход (эффектные страницы). */
body.standalone-dark { background: var(--dark-bg); color: var(--text-on-dark); }
body.standalone-dark .standalone-wrap {
  background:
    radial-gradient(1100px 650px at 82% -8%, rgba(129, 140, 248, .16), transparent 60%),
    radial-gradient(850px 550px at 6% 108%, rgba(245, 158, 11, .09), transparent 55%),
    var(--dark-bg);
  overflow: hidden;
}

/* Светлая тема — privacy/terms (длинный читаемый текст). */
body.standalone-light { background: var(--bg); color: var(--text); }

@keyframes rise-in {
  from { opacity: 0; transform: translateY(16px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Лендинг ── */
.landing-card {
  position: relative; max-width: 580px; width: 100%; text-align: center;
  animation: rise-in .55s cubic-bezier(.22, 1, .36, 1);
}
.landing-logo {
  width: 220px; max-width: 60%; height: auto; margin: 0 auto 2.5rem; display: block;
  filter: drop-shadow(0 8px 24px rgba(129, 140, 248, .25));
}
.landing-title {
  font-size: 2rem; font-weight: 700; margin-bottom: .85rem; letter-spacing: -.02em;
  background: linear-gradient(135deg, #fff, var(--indigo-glow) 140%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.landing-desc {
  color: var(--text-on-dark-muted); font-size: .98rem; margin: 0 auto 2.5rem;
  max-width: 460px; line-height: 1.8;
}
.landing-actions { display: flex; flex-direction: column; gap: .75rem; align-items: center; }
.landing-legal { margin-top: 2.75rem; font-size: .82rem; color: var(--text-on-dark-faint); }
.landing-legal a { color: var(--text-on-dark-muted); }
.landing-legal a:hover { color: var(--indigo-glow); }
.landing-legal span.sep { margin: 0 .6rem; }

.btn-lg {
  padding: .85rem 2.6rem; font-size: 1rem; border-radius: 100px;
  background: linear-gradient(135deg, var(--indigo), #6366f1);
  box-shadow: 0 12px 32px -8px rgba(99, 102, 241, .55);
  transition: box-shadow .18s, transform .12s;
}
.btn-lg:hover { box-shadow: 0 16px 40px -8px rgba(99, 102, 241, .7); transform: translateY(-1px); }
.btn-lg:active { transform: translateY(0); }

/* ── Экран входа: пин-код ── */
.auth-card {
  position: relative; max-width: 340px; width: 100%; text-align: center;
  background: linear-gradient(180deg, var(--dark-surface-1), var(--dark-surface-2));
  border: 1px solid var(--dark-border); border-radius: 24px;
  padding: 2.75rem 2rem 2.25rem;
  box-shadow: 0 24px 70px -20px rgba(0, 0, 0, .65), inset 0 1px 0 rgba(255, 255, 255, .04);
  animation: rise-in .5s cubic-bezier(.22, 1, .36, 1);
}
.auth-brand { margin-bottom: 1.5rem; display: flex; justify-content: center; }
.auth-brand img { width: 150px; max-width: 100%; height: auto; display: block; }
.auth-title { font-size: .95rem; font-weight: 500; margin-bottom: 2rem; color: var(--text-on-dark-muted); }

.pin-dots { display: flex; justify-content: center; gap: .85rem; margin-bottom: 2.25rem; }
.pin-dot {
  width: .7rem; height: .7rem; border-radius: 50%;
  border: 1.5px solid var(--dark-border-hover); background: transparent;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.pin-dot.on {
  background: var(--indigo-glow); border-color: var(--indigo-glow);
  box-shadow: 0 0 14px -1px var(--indigo-glow);
}
.pin-dot.err { border-color: #f87171; }
.pin-dot.err.on { background: #f87171; border-color: #f87171; box-shadow: 0 0 14px -1px #f87171; }
.pin-dots.shake { animation: pin-shake .45s; }
@keyframes pin-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-9px); }
  40% { transform: translateX(9px); }
  60% { transform: translateX(-7px); }
  80% { transform: translateX(7px); }
}

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .65rem; }
.key {
  aspect-ratio: 1; border-radius: 50%; border: 1px solid var(--dark-border);
  background: rgba(255, 255, 255, .02); font-size: 1.15rem; font-weight: 500;
  color: var(--text-on-dark); cursor: pointer;
  transition: background .12s, border-color .12s, transform .06s;
}
.key:hover { border-color: var(--indigo-glow); background: rgba(129, 140, 248, .1); }
.key:active { transform: scale(.93); background: rgba(129, 140, 248, .22); }
.key-spacer { visibility: hidden; }
.key-back { font-size: 1rem; color: var(--text-on-dark-muted); background: transparent; border-color: transparent; }
.key-back:hover { background: rgba(255, 255, 255, .04); border-color: transparent; }

.auth-hint { min-height: 1.2rem; margin-top: 1.4rem; font-size: .8rem; letter-spacing: .02em; color: #f87171; }
.auth-back {
  display: inline-block; margin-top: 1.75rem; font-size: .8rem;
  color: var(--text-on-dark-faint);
}
.auth-back:hover { color: var(--indigo-glow); }

/* ── Privacy / Terms ── */
.policy-page { max-width: 720px; width: 100%; }
.policy-page h1 { font-size: 1.5rem; margin-bottom: .3rem; }
.policy-page .updated { color: var(--text-light); font-size: .82rem; margin-bottom: 2rem; }
.policy-page h2 { font-size: 1.05rem; margin: 1.75rem 0 .6rem; }
.policy-page p, .policy-page li { color: var(--text-muted); font-size: .92rem; line-height: 1.75; }
.policy-page ul { padding-left: 1.3rem; margin-bottom: .5rem; }
.policy-page a { color: var(--indigo-dark); }
.policy-back { display: inline-block; margin-top: 2rem; }
