/* DealMaker — visual parity со старым Railway UI */
:root {
  --bg:        #fafafa;
  --side-bg:   #f6f6f7;
  --card:      #ffffff;
  --line:      #e5e5ea;
  --text:      #0f0f10;
  --muted:     #6e6e73;
  --placeholder:#a1a1a6;
  --primary:   #1d4ed8;
  --primary-hover: #1e40af;
  --ok-bg:     #d1f5d8;
  --ok-fg:     #1f7a3a;
  --warn-bg:   #fff1c2;
  --warn-fg:   #8a6300;
  --err-bg:    #fee2e2;
  --err-fg:    #a01818;
  --idle-bg:   #e5e5ea;
  --idle-fg:   #6e6e73;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.error { color: var(--err-fg); }
.danger { color: var(--err-fg); }

/* ── Sidebar layout ──────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  flex: 0 0 215px;
  width: 215px;
  background: var(--side-bg);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 14px 12px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 15px;
  color: var(--text); padding: 4px 6px; margin-bottom: 14px;
}
.sidebar .brand .logo {
  display: inline-block; width: 22px; height: 22px;
  background: linear-gradient(135deg, #1d4ed8 0%, #4338ca 100%);
  border-radius: 6px; color: white;
  font-size: 12px; line-height: 22px; text-align: center; font-weight: 700;
}
.btn-new {
  display: block; width: 100%;
  background: var(--primary); color: white;
  border: none; border-radius: 8px; padding: 10px 14px;
  font-size: 14px; font-weight: 500;
  text-align: center; cursor: pointer;
  margin-bottom: 18px;
}
.btn-new:hover { background: var(--primary-hover); text-decoration: none; }
.sidebar .label {
  font-size: 11px; letter-spacing: 0.6pt;
  text-transform: uppercase; color: var(--muted);
  padding: 0 6px; margin: 6px 0 8px;
}
.sidebar .nav { flex: 1; overflow-y: auto; margin: 0; padding: 0; list-style: none; }
.sidebar .nav li a {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 6px;
  color: var(--text); font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar .nav li a:hover { background: rgba(0,0,0,0.04); text-decoration: none; }
.sidebar .nav li a.active { background: rgba(0,0,0,0.06); font-weight: 600; }
.sidebar .nav li a::before { content: "📁"; font-size: 13px; opacity: 0.7; }
.sidebar .footer {
  border-top: 1px solid var(--line); padding-top: 12px; margin-top: 6px;
  font-size: 12px; color: var(--muted);
}
.sidebar .footer .ver { padding: 4px 6px; opacity: 0.6; }

/* ── Main area ───────────────────────────────────────── */
.main { flex: 1; min-width: 0; padding: 32px 40px; max-width: 1200px; }
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.crumb a { color: var(--muted); }
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
h1 { font-size: 22px; font-weight: 700; margin: 4px 0 18px; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 10px; }

/* ── Tabs (на детальной проекта) ─────────────────────── */
.tabs {
  display: flex; align-items: center; gap: 14px;
  font-size: 13px; letter-spacing: 0.6pt; text-transform: uppercase;
  color: var(--muted); margin: 8px 0 22px;
}
.tabs a { color: var(--muted); }
.tabs a.active { color: var(--text); font-weight: 700; }
.tabs .sep { color: var(--placeholder); }
.tabs-spacer { flex: 1; }

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-block; padding: 8px 16px; border-radius: 8px;
  font-size: 13px; font-weight: 500; cursor: pointer;
  border: 1px solid transparent;
}
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); text-decoration: none; }
.btn-primary:disabled { background: #9bb6ec; border-color: #9bb6ec; cursor: not-allowed; }
.btn-outline { background: white; color: var(--primary); border-color: var(--line); }
.btn-outline:hover { border-color: var(--primary); text-decoration: none; }
.btn-link { background: none; border: none; color: var(--muted); font-size: 13px; cursor: pointer; padding: 4px 6px; }
.btn-link:hover { color: var(--text); text-decoration: underline; }
.btn-link.danger { color: var(--err-fg); }
form.inline { display: inline; }

/* ── Project cards (list) ────────────────────────────── */
.project-card {
  display: block; background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 16px 20px; margin-bottom: 10px;
  position: relative; color: var(--text);
}
.project-card:hover { border-color: #c5c5c8; box-shadow: 0 2px 4px rgba(0,0,0,0.04); text-decoration: none; }
.project-card .title { font-weight: 600; font-size: 15px; margin-bottom: 4px; padding-right: 130px; }
.project-card .meta { color: var(--muted); font-size: 13px; }
.project-card .meta .sep { margin: 0 6px; opacity: 0.5; }
.project-card .badge { position: absolute; top: 16px; right: 20px; }

.empty { color: var(--muted); padding: 40px 0; text-align: center; }

/* ── Status badges ───────────────────────────────────── */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 12px;
  font-size: 11px; font-weight: 500;
  background: var(--idle-bg); color: var(--idle-fg);
}
.badge-ok      { background: var(--ok-bg);   color: var(--ok-fg); }
.badge-warn    { background: var(--warn-bg); color: var(--warn-fg); }
.badge-err     { background: var(--err-bg);  color: var(--err-fg); }
.badge-idle    { background: var(--idle-bg); color: var(--idle-fg); }

/* ── Drag-drop area (docs tab) ───────────────────────── */
.dropzone {
  display: block;
  border: 1px dashed #c0c0c5; border-radius: 10px;
  padding: 48px 24px; text-align: center; background: white;
  margin-bottom: 14px; cursor: pointer;
  position: relative;
}
.dropzone:hover, .dropzone.over { border-color: var(--primary); background: #f8faff; }
.dropzone .hint { color: var(--muted); font-size: 13px; margin-top: 6px; }
.dropzone > input[type=file] {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  opacity: 0; cursor: pointer;
}

.summary-line {
  font-size: 13px; color: var(--muted); margin-bottom: 14px;
}
.summary-line .b { color: var(--text); font-weight: 600; }

/* docs list (rows) */
.doc-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 4px; border-bottom: 1px solid var(--line);
}
.doc-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-row .stage-dots { display: inline-flex; gap: 4px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--idle-bg); }
.dot.ok { background: #34c759; }
.dot.warn { background: #ffb800; }
.dot.err { background: #ff3b30; }
.dot.run { background: #0a4a9c; animation: pulse 1.5s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* sections */
.section-card {
  background: white; border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 18px; margin-bottom: 12px;
}
.section-card .head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 8px;
}
.section-card .head .dot { margin: 0; }
.section-card .head .name { font-weight: 500; flex: 1; }
.section-card .head .hint { color: var(--muted); font-size: 12px; }
.section-card input[type=text], .section-card input[type=number] {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 6px; font-size: 14px; background: white;
}
.section-card input:focus { outline: none; border-color: var(--primary); }
.section-card .remove { color: var(--err-fg); margin-top: 8px; display: inline-block; }

.add-section {
  display: inline-block; background: var(--primary); color: white;
  border-radius: 8px; padding: 10px 16px; cursor: pointer; border: none;
  font-size: 13px; font-weight: 500;
}
.add-section:hover { background: var(--primary-hover); text-decoration: none; }
.add-competitor {
  display: inline-block; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 16px; background: white; color: var(--text); cursor: pointer;
  font-size: 13px; margin-left: 8px;
}
.add-competitor:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }

/* report tab actions */
.report-actions { display: flex; gap: 8px; align-items: center; margin-bottom: 22px; }
.report-actions .spacer { flex: 1; }

/* form (new project) */
.form-narrow { max-width: 460px; }
.form-narrow label { display: block; font-size: 13px; margin-bottom: 4px; color: var(--text); }
.form-narrow label .req { color: var(--err-fg); }
.form-narrow input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 14px; margin-bottom: 12px; background: white;
}
.form-narrow input:focus { outline: none; border-color: var(--primary); }
.form-narrow .help { color: var(--muted); font-size: 12px; margin: 0 0 14px; }

/* login */
.login {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px; background: var(--bg);
}
.login .card { width: 100%; max-width: 360px; background: var(--card);
               border: 1px solid var(--line); border-radius: 12px; padding: 28px; }
.login h1 { font-size: 18px; margin-bottom: 18px; text-align: center; }
.login label { display: block; font-size: 13px; margin-bottom: 4px; }
.login input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 14px; margin-bottom: 14px; background: white;
}
.login button { width: 100%; padding: 11px; font-weight: 500; }
.login .error {
  background: var(--err-bg); color: var(--err-fg);
  padding: 8px 12px; border-radius: 6px; margin-bottom: 12px; font-size: 13px;
}

/* report content */
.report {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 28px 36px;
}
.report h1 { font-size: 22px; margin: 0 0 14px; }
.report h2 { font-size: 17px; font-weight: 600; margin: 28px 0 8px; }
.report table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.report table th, .report table td {
  padding: 7px 10px; border-bottom: 1px solid var(--line); font-size: 13px;
}
.report .dd-card, .report .dd-conclusion { margin: 24px 0; }

/* sections — collapsible company groups (own + competitors) */
.company-group {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  margin-bottom: 12px; overflow: hidden;
}
.company-group > summary {
  list-style: none;
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; cursor: pointer;
  user-select: none;
}
.company-group > summary::-webkit-details-marker { display: none; }
.company-group .caret {
  width: 0; height: 0; flex-shrink: 0;
  border-left: 5px solid transparent; border-right: 5px solid transparent;
  border-top: 6px solid var(--muted);
  transition: transform 0.15s ease;
  transform: rotate(-90deg);
}
.company-group[open] > summary .caret { transform: rotate(0); }
.company-group .company-name { font-weight: 600; font-size: 15px; }
.company-group .company-meta { color: var(--muted); font-size: 12px; }
.company-group .company-tag {
  font-size: 10px; font-weight: 600; letter-spacing: 0.4px; text-transform: uppercase;
  padding: 2px 8px; border-radius: 4px;
  background: #eef2ff; color: #1d4ed8;
}
.company-group .company-tag.tag-rival { background: #fff1c2; color: #8a6300; }
.company-group .company-count { color: var(--muted); font-size: 12px; margin-left: auto; }
.company-group .summary-action { margin-left: 12px; }
.company-group .company-body {
  padding: 0 18px 14px; border-top: 1px solid var(--line);
}
.company-group .section-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.company-group .section-row:last-of-type { border-bottom: none; }
.company-group .section-row .name { flex: 1; min-width: 0; font-weight: 500; }
.company-group .section-row .hint { color: var(--muted); font-size: 12px; }
.company-group .section-row .hint code {
  background: #f5f5f7; padding: 1px 5px; border-radius: 3px; font-size: 11px;
}
.add-section-form {
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
  padding: 12px 0 4px; border-top: 1px dashed var(--line); margin-top: 6px;
}
.add-section-form select, .add-section-form input {
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px;
  font-size: 13px; background: white;
}
.add-section-form select { min-width: 200px; }
.add-section-form input { width: 140px; }
.add-section-form input:focus, .add-section-form select:focus {
  outline: none; border-color: var(--primary);
}
.add-competitor-form {
  display: flex; gap: 6px; align-items: center; margin-top: 16px;
  padding: 14px 18px; background: #fafafb;
  border: 1px dashed var(--line); border-radius: 10px;
}
.add-competitor-form input {
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 6px;
  font-size: 13px; background: white;
}
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* mobile */
@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar {
    position: sticky; top: 0; z-index: 10;
    width: 100%; height: auto; flex: 0 0 auto;
    padding: 10px 12px;
    border-right: none; border-bottom: 1px solid var(--line);
    background: var(--bg);
  }
  .sidebar .brand, .sidebar .btn-new, .sidebar .label, .sidebar .footer { display: none; }
  .sidebar .nav {
    flex: 0 0 auto; display: flex; flex-direction: row; gap: 6px;
    max-height: none; overflow-x: auto; padding: 4px 0;
    scroll-snap-type: x proximity;
  }
  .sidebar .nav li { flex: 0 0 auto; scroll-snap-align: start; }
  .sidebar .nav li a {
    padding: 6px 12px; border-radius: 6px;
    font-size: 13px; white-space: nowrap;
    background: white; border: 1px solid var(--line);
  }
  .sidebar .nav li a::before { display: none; }
  .main { padding: 14px 16px; max-width: 100%; }
  h1 { font-size: 19px; }

  .tabs { font-size: 11px; flex-wrap: wrap; }
  .tabs .delete-link, .tabs form { margin-left: auto; }
  .tabs-spacer { flex-basis: 100%; height: 0; }

  .report-actions { flex-wrap: wrap; }
  .report-actions .spacer { display: none; }
  .report { padding: 16px 18px; }

  .company-group > summary { flex-wrap: wrap; gap: 6px 10px; padding: 12px 14px; }
  .company-group .company-count { margin-left: 0; }
  .company-group .company-body { padding: 0 14px 12px; }
  .company-group .section-row { flex-wrap: wrap; gap: 6px 10px; }
  .company-group .section-row .hint { flex-basis: 100%; }
  .add-section-form { flex-direction: column; align-items: stretch; }
  .add-section-form select, .add-section-form input { width: 100%; }
  .add-competitor-form { flex-wrap: wrap; padding: 12px; }
  .add-competitor-form input { flex: 1 1 calc(50% - 4px); }
}

