:root {
  --bg: #0d0f14;
  --panel: #151821;
  --panel-2: #1a1e29;
  --border: #2a2f3d;
  --text: #e4e6ee;
  --text-dim: #7d8298;
  --accent: #5b8cff;
  --accent-dim: #3a5cb8;
  --danger: #ff6b6b;
  --warn: #ffb454;
  --success: #6ee7b7;
  --radius: 4px;
  --mono: 'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--mono);
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
}

:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Шапка ---------- */
header {
  padding: 14px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

header h1 {
  font-size: 15px;
  margin: 0;
  font-weight: 600;
  letter-spacing: .02em;
}

header h1::before {
  content: '> ';
  color: var(--accent);
}

.overall-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-dim);
}

.overall-progress-track {
  width: 110px;
  height: 4px;
  background: var(--panel-2);
  border: 1px solid var(--border);
}

.overall-progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width .2s ease;
}

.toolbar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

/* ---------- Элементы управления ---------- */
button {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 7px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 12px;
  transition: background .1s, border-color .1s;
}

button:hover { background: #232838; border-color: #3a4054; }
button:disabled { opacity: .35; cursor: not-allowed; }

button.primary {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: #fff;
}
button.primary:hover { background: var(--accent); }

button.danger-outline { color: var(--danger); border-color: var(--border); }
button.danger-outline:hover { border-color: var(--danger); background: rgba(255,107,107,.08); }

button.danger-solid {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
button.danger-solid:hover { background: #ff8080; }

input[type="file"] { display: none; }

select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 8px;
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 12px;
}

main { padding: 20px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

/* ---------- Форма добавления ---------- */
.form-panel {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr auto;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
}

.form-panel label {
  font-size: 10px;
  color: var(--text-dim);
  display: block;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.form-panel input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 9px;
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 12px;
}

.form-panel input:focus { outline: none; border-color: var(--accent); }

.form-panel .add-btn-wrap {
  display: flex;
  align-items: flex-end;
}

/* ---------- Диаграмма ---------- */
.gantt-wrapper { display: flex; }

.task-list {
  min-width: 250px;
  max-width: 250px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--panel);
}

.task-list-header, .timeline-header-row {
  height: 40px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
  position: sticky;
  top: 0;
  z-index: 3;
}

.month-spacer {
  height: 20px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
}

.task-row {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}

.task-row:hover { background: #181c27; }

.task-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  line-height: 1.3;
}

.task-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  width: fit-content;
  max-width: 100%;
  border-bottom: 1px dashed transparent;
}
.task-name:hover { color: var(--accent); border-bottom-color: var(--accent); }

.task-meta {
  font-size: 10px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-row-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  padding: 3px 6px;
  font-size: 12px;
  cursor: pointer;
  border-radius: var(--radius);
  font-family: var(--mono);
}
.icon-btn:hover { color: var(--text); border-color: var(--border); background: var(--panel-2); }
.icon-btn.del:hover { color: var(--danger); border-color: var(--danger); }

.timeline { position: relative; flex: 1; overflow: hidden; min-width: 0; }
.timeline-scroll { overflow-x: auto; }
.timeline-header-row { display: flex; padding: 0; position: relative; }

.day-cell {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--text-dim);
  border-right: 1px solid var(--border);
}

.day-cell .dow { font-size: 8px; opacity: .7; }
.day-cell.weekend { background: rgba(255,255,255,0.02); }
.day-cell.today { background: rgba(91,140,255,0.14); color: var(--accent); font-weight: 600; }

.month-row { display: flex; height: 20px; border-bottom: 1px solid var(--border); }

.month-cell {
  flex-shrink: 0;
  font-size: 10px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  padding-left: 6px;
  border-right: 1px solid var(--border);
}

.timeline-body { position: relative; }

.grid-row {
  height: 44px;
  border-bottom: 1px solid var(--border);
  position: relative;
  display: flex;
}

.grid-cell { flex-shrink: 0; border-right: 1px solid var(--border); }
.grid-cell.weekend { background: rgba(255,255,255,0.02); }
.grid-cell.today { background: rgba(91,140,255,0.08); }

/* ---------- Полоса задачи ---------- */
.bar {
  position: absolute;
  top: 8px;
  height: 28px;
  border-radius: var(--radius);
  background: var(--accent);
  border: 1px solid rgba(0,0,0,.25);
  display: flex;
  align-items: center;
  padding: 0 9px;
  font-size: 11px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: grab;
  user-select: none;
}
.bar:active { cursor: grabbing; }
.bar.dragging { outline: 1px solid #fff; z-index: 5; }

.bar .progress-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: rgba(255,255,255,0.22);
}

.bar .label { position: relative; z-index: 1; }

.bar .resize-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 8px;
  cursor: ew-resize;
  z-index: 2;
}
.resize-handle.left { left: 0; }
.resize-handle.right { right: 0; }

.drag-tip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 10px;
  padding: 3px 7px;
  border-radius: var(--radius);
  white-space: nowrap;
  z-index: 6;
  pointer-events: none;
}

.empty-state {
  padding: 50px 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
}

footer {
  padding: 12px 20px;
  color: var(--text-dim);
  font-size: 11px;
}

.zoom-controls { display: flex; gap: 4px; align-items: center; }

::-webkit-scrollbar { height: 9px; width: 9px; }
::-webkit-scrollbar-track { background: var(--panel); }
::-webkit-scrollbar-thumb { background: #333a4d; border-radius: var(--radius); }
::-webkit-scrollbar-thumb:hover { background: #454e66; }

/* ---------- Тосты ---------- */
.toast-stack {
  position: fixed;
  bottom: 18px;
  right: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 1000;
  max-width: 300px;
}

.toast {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  color: var(--text);
  padding: 9px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .15s ease, transform .15s ease;
  cursor: pointer;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-info { border-left-color: var(--accent); }

/* ---------- Модальные окна ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
  padding: 16px;
}

.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 400px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 { font-size: 13px; margin: 0; font-weight: 600; }

.modal-body { padding: 14px; }

.modal-message { margin: 0 0 4px; font-size: 12px; color: var(--text); line-height: 1.5; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.field { margin-bottom: 10px; }
.field label {
  font-size: 10px;
  color: var(--text-dim);
  display: block;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.field input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 9px;
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 12px;
}
.field input:focus { outline: none; border-color: var(--accent); }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.field-error {
  color: var(--danger);
  font-size: 11px;
  margin: 4px 0 0;
}

/* ---------- Адаптив ---------- */
@media (max-width: 720px) {
  header { padding: 12px 14px; }
  main { padding: 12px; }
  .form-panel { grid-template-columns: 1fr 1fr; }
  .form-panel > div:first-child { grid-column: 1 / -1; }
  .add-btn-wrap { grid-column: 1 / -1; }
  .overall-progress-track { width: 70px; }
  .task-list { min-width: 160px; max-width: 160px; }
}
