:root {
  --bg: #0f172a;
  --bg-soft: #1e293b;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --border: #e2e8f0;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
  --radius: 12px;
  --shadow: 0 4px 16px rgba(15, 23, 42, .08);
}

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

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

/* ---------- Логин ---------- */
.login-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #1e3a8a 0%, var(--bg) 55%);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border-radius: 16px;
  padding: 40px 32px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-logo { display: flex; justify-content: center; margin-bottom: 4px; }
.login-card h1 { font-size: 24px; text-align: center; }
.login-sub { text-align: center; color: var(--muted); font-size: 14px; }
.login-card input {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  outline: none;
  transition: border-color .15s;
}
.login-card input:focus { border-color: var(--primary); }
.login-card button {
  padding: 14px;
  border: none;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.login-card button:hover { background: var(--primary-dark); }
.login-card button:disabled { opacity: .6; cursor: default; }
.login-error { color: var(--danger); font-size: 14px; text-align: center; min-height: 20px; }

/* ---------- Шапка ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg);
  color: #fff;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.brand-name { font-size: 18px; font-weight: 700; }
.nav { display: flex; gap: 6px; margin-left: 8px; flex: 1; }
.nav-btn {
  background: transparent;
  border: none;
  color: #cbd5e1;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
}
.nav-btn.active { background: rgba(37,99,235,.25); color: #fff; font-weight: 600; }
.logout-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,.2);
  color: #cbd5e1;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}

/* ---------- Виды ---------- */
.view { max-width: 1200px; margin: 0 auto; padding: 20px 16px 60px; }
.projects-header, .board-header, .prop-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.projects-header h2, .board-header h2, .prop-header h2 { color: #fff; font-size: 22px; flex: 1; }
.btn {
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.ghost { background: transparent; border-color: rgba(255,255,255,.25); color: #e2e8f0; }
.btn:hover { opacity: .9; }

/* ---------- Проекты ---------- */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.project-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  cursor: pointer;
  border-top: 4px solid var(--primary);
  transition: transform .1s;
}
.project-card:active { transform: scale(.98); }
.project-card h3 { font-size: 17px; margin-bottom: 6px; }
.project-card p { color: var(--muted); font-size: 13px; min-height: 18px; }
.project-meta { margin-top: 12px; font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; }
.project-del { color: var(--danger); cursor: pointer; font-size: 12px; }

/* ---------- Доска ---------- */
.board {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 16px;
  align-items: flex-start;
  min-height: 60vh;
}
.board-col {
  flex: 0 0 280px;
  max-width: 85vw;
  background: var(--bg-soft);
  border-radius: var(--radius);
  padding: 10px;
  display: flex;
  flex-direction: column;
  max-height: 75vh;
}
.board-col.dragover { outline: 2px dashed var(--primary); }
.col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px 10px;
  color: #fff;
}
.col-head .col-name { font-weight: 700; font-size: 14px; }
.col-count { color: #94a3b8; font-size: 12px; }
.col-del { color: #94a3b8; cursor: pointer; background: none; border: none; font-size: 14px; padding: 2px 6px; }
.col-tasks { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; flex: 1; }
.task-card {
  background: var(--card);
  border-radius: 10px;
  padding: 12px;
  box-shadow: var(--shadow);
  cursor: grab;
  border-left: 4px solid var(--primary);
}
.task-card.dragging { opacity: .5; }
.task-card h4 { font-size: 14px; margin-bottom: 6px; }
.task-card .task-desc { font-size: 12px; color: var(--muted); white-space: pre-wrap; margin-bottom: 6px; }
.task-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 20px; background: #eef2ff; color: #3730a3; }
.tag.p-high { background: #fee2e2; color: #991b1b; }
.tag.p-low { background: #dcfce7; color: #166534; }
.task-assignee { font-size: 12px; color: var(--muted); margin-top: 6px; }
.task-del { float: right; color: var(--danger); cursor: pointer; font-size: 13px; background: none; border: none; }

/* ---------- Проп ---------- */
.prop-depts { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-bottom: 24px; }
.dept-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.dept-card h3 { font-size: 15px; margin-bottom: 8px; }
.dept-card .stat { display: flex; justify-content: space-between; font-size: 13px; padding: 3px 0; }
.dept-card .stat .val { font-weight: 600; }
.prop-section-title { color: #cbd5e1; font-size: 15px; font-weight: 700; margin: 20px 0 10px; }
.prop-accounts, .prop-lb { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.acct-card, .lb-row {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.acct-card .acct-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.acct-card .acct-name { font-weight: 700; font-size: 14px; }
.acct-card .acct-status { font-size: 11px; padding: 3px 8px; border-radius: 20px; background: #eef2ff; color: #3730a3; }
.acct-card .acct-status.funded { background: #dcfce7; color: #166534; }
.acct-card .acct-status.probed { background: #fee2e2; color: #991b1b; }
.acct-card .acct-row { display: flex; justify-content: space-between; font-size: 13px; padding: 3px 0; color: var(--muted); }
.acct-card .acct-row .val { color: var(--text); font-weight: 600; }
.lb-row { display: flex; justify-content: space-between; align-items: center; }
.lb-row .rank { font-weight: 800; color: var(--primary); width: 28px; }
.lb-row .lb-name { font-weight: 600; flex: 1; }
.lb-row .lb-score { font-weight: 800; font-size: 16px; }
.lb-row .lb-sub { font-size: 12px; color: var(--muted); }

/* ---------- Модалки ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal {
  background: var(--card);
  border-radius: 14px;
  padding: 22px;
  width: 100%;
  max-width: 420px;
  max-height: 85vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal h3 { font-size: 18px; }
.modal label { font-size: 13px; color: var(--muted); }
.modal input, .modal textarea, .modal select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  outline: none;
  font-family: inherit;
}
.modal textarea { min-height: 70px; resize: vertical; }
.modal .modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }
.modal .modal-actions .btn { flex: 1; }
.modal-error { color: var(--danger); font-size: 13px; }

/* ---------- Адаптив: планшет и телефон ---------- */
@media (max-width: 768px) {
  .topbar { padding: 8px 12px; }
  .nav-btn { padding: 8px 10px; font-size: 14px; }
  .board-col { flex: 0 0 78vw; }
  .projects-grid { grid-template-columns: 1fr 1fr; }
  .login-card { padding: 30px 22px; }
}
@media (max-width: 480px) {
  .projects-grid { grid-template-columns: 1fr; }
  .brand-name { font-size: 16px; }
  .logout-btn { font-size: 12px; padding: 5px 10px; }
}
