/* Program Cloud admin panel. No build step: this file is loaded directly by dashboard.html. */

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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2d3148;
  --accent: #4f6ef7;
  --accent2: #7c3aed;
  --text: #e4e6f0;
  --text-muted: #7b82a8;
  --green: #10b981;
  --yellow: #f59e0b;
  --red: #ef4444;
  --radius: 12px;
  --header-h: 56px;
  --sidebar-w: 216px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  min-height: 100vh;
}

/* ── Header ─────────────────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 30;
}
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; letter-spacing: -0.3px; }
.logo-icon {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.header-right { display: flex; align-items: center; gap: 10px; }
#user-badge {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
}
.role-chip { color: var(--accent); margin-left: 6px; }

/* ── Login ──────────────────────────────────────────────── */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--header-h));
  padding: 24px;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
}
.login-card h2 { font-size: 20px; margin-bottom: 6px; }
.login-card p { color: var(--text-muted); font-size: 13px; margin-bottom: 28px; }
#login-error { color: var(--red); font-size: 12px; margin-top: 12px; min-height: 18px; text-align: center; }

/* ── Form controls ──────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; letter-spacing: 0.4px; }
.field input, .field select, .field textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
}
.field textarea { resize: vertical; min-height: 110px; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field .hint { font-size: 11px; color: var(--text-muted); margin-top: 6px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 16px; }

button { font-family: inherit; }
.btn-primary, .btn-secondary, .btn-danger {
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: opacity .15s, border-color .15s, background .15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--surface2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--accent); }
.btn-danger { background: transparent; color: var(--red); border-color: var(--border); }
.btn-danger:hover { border-color: var(--red); }
.btn-primary:hover { opacity: .88; }
.btn-primary:disabled, .btn-secondary:disabled, .btn-danger:disabled { opacity: .5; cursor: default; }
.btn-block { width: 100%; padding: 11px; margin-top: 8px; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ── Shell: sidebar + content ───────────────────────────── */
#shell { display: none; min-height: calc(100vh - var(--header-h)); }
#shell.active { display: flex; }

#sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  position: sticky;
  top: var(--header-h);
  align-self: flex-start;
  max-height: calc(100vh - var(--header-h));
  overflow-y: auto;
}
.nav-group-title {
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 14px 10px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  cursor: pointer;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--surface2); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.nav-icon { width: 18px; text-align: center; font-size: 14px; }

#content { flex: 1; min-width: 0; padding: 24px 28px 60px; max-width: 1400px; }

.view-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.view-head h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.4px; }
.view-head p { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.view-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.section-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin: 28px 0 14px;
}
.section-title:first-child { margin-top: 0; }

/* ── Cards ──────────────────────────────────────────────── */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.card-label { font-size: 11px; color: var(--text-muted); letter-spacing: 0.5px; margin-bottom: 8px; }
.card-value { font-size: 32px; font-weight: 700; line-height: 1; letter-spacing: -1px; }
.card-value.sm { font-size: 22px; }
.card-value.blue { color: #60a5fa; }
.card-value.green { color: var(--green); }
.card-value.purple { color: #a78bfa; }
.card-value.yellow { color: var(--yellow); }
.card-value.orange { color: #fb923c; }
.card-value.teal { color: #2dd4bf; }
.card-value.red { color: var(--red); }

/* ── Charts ─────────────────────────────────────────────── */
.charts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.chart-card h3 { font-size: 13px; font-weight: 600; margin-bottom: 16px; }
.chart-wrap { position: relative; height: 220px; }
.chart-wrap.tall { height: 300px; }

/* ── Tables ─────────────────────────────────────────────── */
.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table-card h3 { font-size: 13px; font-weight: 600; padding: 16px 20px 14px; border-bottom: 1px solid var(--border); }
/* Wide tables scroll inside the card instead of stretching the page. */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 10px 20px;
  text-align: left;
  background: var(--surface2);
  white-space: nowrap;
}
tbody tr { border-top: 1px solid var(--border); }
tbody tr:hover { background: var(--surface2); }
tbody td { padding: 11px 20px; font-size: 13px; vertical-align: top; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.actions { white-space: nowrap; text-align: right; }
td.actions button { margin-left: 6px; }
.empty { color: var(--text-muted); text-align: center; padding: 28px 20px; font-size: 13px; }
.muted { color: var(--text-muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.truncate { max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 500;
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.badge.blue { color: #60a5fa; border-color: #24406b; }
.badge.green { color: var(--green); border-color: #14503c; }
.badge.yellow { color: var(--yellow); border-color: #5c4310; }
.badge.red { color: var(--red); border-color: #5e2020; }
.badge.purple { color: #a78bfa; border-color: #3d2f63; }

/* ── Filter bar ─────────────────────────────────────────── */
.filters {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 18px;
}
.filters .field { margin-bottom: 0; min-width: 150px; }
.filters .field.grow { flex: 1; }

/* ── Pagination ─────────────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: 12px; justify-content: flex-end; margin-top: 14px; font-size: 12px; color: var(--text-muted); }

/* ── Modal ──────────────────────────────────────────────── */
#modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(6, 8, 14, .7);
  z-index: 50;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 20px 20px;
  overflow-y: auto;
}
#modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
}
.modal.wide { max-width: 760px; }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); font-size: 15px; font-weight: 600; }
.modal-body { padding: 20px 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.modal-error { color: var(--red); font-size: 12px; margin-top: 10px; min-height: 16px; }

/* ── Toasts ─────────────────────────────────────────────── */
#toasts { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 13px;
  max-width: 380px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
}
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }
.toast.info { border-left-color: var(--accent); }

/* ── Misc ───────────────────────────────────────────────── */
#loading { display: none; align-items: center; justify-content: center; min-height: calc(100vh - var(--header-h)); }
.spinner { width: 36px; height: 36px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
.spinner.sm { width: 18px; height: 18px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

.notice {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--yellow);
  border-radius: 8px;
  padding: 14px 18px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.notice strong { color: var(--text); }
.notice code, pre.code {
  display: block;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  margin-top: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--text);
  overflow-x: auto;
  white-space: pre;
}
.detail-list { display: grid; grid-template-columns: 150px 1fr; gap: 10px 16px; font-size: 13px; }
.detail-list dt { color: var(--text-muted); }
.detail-list dd { word-break: break-word; white-space: pre-wrap; }

@media (max-width: 800px) {
  #sidebar { display: none; }
  #content { padding: 20px 16px 48px; }
}

/* ── Tenant (SaaS) ───────────────────────────────────── */
#tenant-name {
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#tenant-banner {
  background: rgba(245, 158, 11, .14);
  border-bottom: 1px solid var(--yellow);
  color: var(--yellow);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 24px;
  text-align: center;
}
.sub-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 20px; }

/* ── Обзор: компания и первые шаги ───────────────────── */
.ov-company { margin-bottom: 14px; }
.ov-company-main { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-bottom: 16px; }
.ov-company-name { font-size: 18px; font-weight: 700; word-break: break-word; }
.ov-code { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; }
.ov-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 14px; }
.ov-fact-value { font-size: 14px; font-weight: 600; word-break: break-word; }
.ov-note { margin-top: 14px; font-size: 12px; color: var(--yellow); }
.ov-note a { color: var(--accent); }
.ov-steps { padding: 6px 20px; margin-bottom: 14px; }
.ov-step { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-top: 1px solid var(--border); }
.ov-step:first-child { border-top: 0; }
.ov-check {
  flex: 0 0 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center; font-size: 12px; color: #fff;
}
.ov-step.done .ov-check { background: var(--green); border-color: var(--green); }
.ov-step.done .ov-step-title { text-decoration: line-through; color: var(--text-muted); }
.ov-step-text { flex: 1; min-width: 0; }
.ov-step-title { font-size: 13px; font-weight: 600; }
.ov-step-hint { font-size: 12px; margin-top: 2px; }
.ov-step-link { text-decoration: none; white-space: nowrap; }
.ov-login-hint { margin-top: 14px; margin-bottom: 20px; border-left-color: var(--accent); }
.pw-gen { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.pw-gen code { display: inline-block; margin: 0; padding: 6px 10px; }
@media (max-width: 800px) {
  .ov-step { flex-wrap: wrap; }
  .ov-step-text { flex-basis: calc(100% - 50px); }
  .ov-step-link { margin-left: 36px; }
}
