/* Detailing Scheduler — дизайн-система v1.1 (чистый минимал, offline, без CDN). */
:root {
  --bg: #f7f8fa;
  --card: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --border: #e3e6ea;
  --accent: #2563eb;
  --accent-weak: #eef2ff;
  --danger: #dc2626;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  /* Полосы услуг — пастель «как Excel» (фон заголовка, цвета проставляются inline из вью). */
  /* Статусы броней (тонкая полоска слева блока + фон чипа в списке дня). */
  --st-planned: #94a3b8;
  --st-accepted: #3b82f6;
  --st-in_progress: #f59e0b;
  --st-done: #22c55e;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, "Inter", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 20px 0 10px; }
h3 { font-size: 15px; margin: 0 0 12px; }

/* ---- Header / nav ---- */
.app-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.app-header-inner {
  max-width: 1400px; margin: 0 auto; padding: 10px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { font-weight: 700; color: var(--text); font-size: 15px; }
.brand:hover { text-decoration: none; }
.app-nav { display: flex; align-items: center; gap: 16px; }
.app-nav a { color: var(--muted); font-weight: 500; }
.app-nav a:hover { color: var(--text); text-decoration: none; }
.app-nav .who { color: var(--muted); font-size: 13px; }
.app-nav form { margin: 0; }

/* ---- Layout ---- */
.container { max-width: 1400px; margin: 0 auto; padding: 20px; }
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px;
}

/* ---- Buttons (пастель) ---- */
.btn, button, input[type=submit] {
  font: inherit; cursor: pointer; border: 1px solid transparent;
  background: #e5e7eb; color: var(--text);
  border-radius: 8px; padding: 6px 12px; transition: background .12s, border-color .12s;
}
.btn:hover, button:hover { background: #d5d9df; }
.btn-primary, button[type=submit].btn-primary {
  background: #bfdbfe; color: #1e3a8a;
}
.btn-primary:hover { background: #a8cbf7; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: #eceef2; color: var(--text); }
button.danger, .btn-danger { background: #fecaca; color: #991b1b; }
button.danger:hover { background: #fbb4b4; }

/* ---- Forms ---- */
form p { margin: 0 0 10px; }
label { font-size: 13px; color: var(--muted); }
input[type=text], input[type=password], input[type=number], input[type=date],
select, textarea {
  font: inherit; color: var(--text); background: var(--card);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; width: 100%;
  max-width: 340px;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak);
}
.err { color: var(--danger); font-weight: 600; }
.notice { border-left: 4px solid var(--accent); background: var(--accent-weak); margin-bottom: 16px; }
.notice code { background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 2px 8px; font-size: 15px; }

/* ---- Generic tables (admin/day list) ---- */
table { border-collapse: collapse; width: 100%; }
table th, table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
table th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .02em; }

/* ---- Board (полосы × слоты) ---- */
.board-scroll {
  overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--card);
}
/* table-layout:fixed — запись не растягивает столбец (текст обрезается многоточием).
   width:100% — доска тянется на всю свою колонку: нет зазора до календаря, правый край
   вровень с карточкой «Записи на день». min-width — ниже уходим в горизонт-скролл (мобилка).
   Часовым колонкам ширину НЕ задаём: при fixed+100% они поровну делят остаток и растягиваются. */
table.board { border-collapse: collapse; table-layout: fixed; width: 100%; min-width: 850px; }
table.board th.lane-col { width: 150px; }
/* 46px, а не 28: метка «21:00» (~28px текста + 16px padding) не влезала в узкую ячейку,
   nowrap-текст вылезал наружу и раздувал scrollWidth → возвращался горизонт-скроллбар. */
table.board th.slot-end { width: 46px; }
table.board th, table.board td {
  border: 1px solid var(--border); padding: 6px 8px; font-size: 12px;
  white-space: nowrap; height: 38px; text-align: center;
}
table.board thead th { background: #f3f4f6; color: var(--muted); font-size: 12px; text-transform: none; letter-spacing: 0; }
.lane-col {
  position: sticky; left: 0; z-index: 2; text-align: left; color: var(--text); font-weight: 600;
  min-width: 150px; background: #e2e8f0;
  overflow: hidden; text-overflow: ellipsis;  /* длинные имена («Плёнка Володин П.») — многоточием, полное в title */
}
td.free { min-width: 56px; }
td.free:hover { background: var(--accent-weak); cursor: pointer; }
/* Закрывающая граница дня (21:00): узкая нейтральная колонка, не бронируется. */
th.slot-end, td.slot-end { width: 46px; min-width: 46px; background: #f3f4f6; color: var(--muted); cursor: default; }
td.slot-end:hover { background: #f3f4f6; }
/* Блок брони — бледно-красный «как розовая ячейка Excel»; статус — тонкая полоска слева. */
td.booking {
  background: #fee2e2; color: var(--text); text-align: left; cursor: pointer;
  font-weight: 500; border-radius: 4px;
  border-left: 4px solid var(--st-planned);  /* статус-полоса слева */
  /* Мягкий пыльно-розовый контур КАЖДОГО блока inset-тенью: не зависит от border-collapse,
     поэтому соседние брони в забитой вплотную полосе разделены, но контур не «кричит». */
  box-shadow: inset 0 0 0 2px #c08a8a;
  overflow: hidden; text-overflow: ellipsis;  /* длинный текст обрезается, не растягивает столбец */
}
td.booking.status-accepted { border-left-color: var(--st-accepted); }
td.booking.status-in_progress { border-left-color: var(--st-in_progress); }
td.booking.status-done { border-left-color: var(--st-done); }
td.booking.conflict { background: #fecaca; border-left-color: var(--danger); }
/* Чипы статуса в списке дня сохраняют цветной фон. */
.chip.status-planned { background: var(--st-planned); }
.chip.status-accepted { background: var(--st-accepted); }
.chip.status-in_progress { background: var(--st-in_progress); }
.chip.status-done { background: var(--st-done); }

/* ---- Calendar ---- */
table.calendar { table-layout: fixed; }
table.calendar th { text-align: center; }
.wd-sat, .wd-sun { color: #dc2626; font-weight: 700; }
table.calendar td {
  border: 1px solid var(--border); height: 56px; vertical-align: top; padding: 4px 6px; text-align: left;
}
.cal-day { text-align: center; cursor: pointer; }
.cal-day.day-off { color: #dc2626; }                    /* красное число: выходной/праздник */
.cal-day.other-month { color: #c4c9d0; }                /* соседний месяц приглушён (важнее day-off) */
.cal-day.today { background: #dcfce7; }                 /* сегодня — светло-зелёный */
.cal-day.selected { border: 2px solid #2563eb; }        /* выбранный — рамка */
.cal-day.selected:not(.today) { background: #bfdbfe; }  /* выбранный не-сегодня — светло-голубой */
.badge {
  display: inline-block; background: var(--accent); color: #fff;
  border-radius: 999px; padding: 0 7px; font-size: 11px; font-weight: 600;
}

/* ---- Modal ---- */
.modal-card {
  position: fixed; top: 8%; left: 50%; transform: translateX(-50%);
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(16, 24, 40, .22); padding: 20px; z-index: 1000;
  width: min(420px, calc(100vw - 32px));
  max-height: 85vh; overflow-y: auto;  /* кнопки Сохранить/Удалить всегда видны */
}
.modal-card textarea { max-height: 110px; }

/* ---- Status chips (day list) ---- */
.chip { display: inline-block; color: #fff; font-size: 12px; font-weight: 600; padding: 1px 9px; border-radius: 999px; }

/* ---- Dashboard (Task 5): доска слева, календарь справа, история снизу ---- */
.dash { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 20px; align-items: start; }
.dash-side { position: sticky; top: 72px; }
.mine-toggle { margin: 0 0 12px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-head button { padding: 2px 10px; }
.day-list { margin-top: 20px; }
.day-list h2 { margin-top: 0; }
.day-list table td { font-size: 13px; }
/* ---- Мобильный адаптив (узкий экран) ---- */
@media (max-width: 900px) {
  /* Дашборд в столбец: доска+список, затем календарь (#day-region — атомарный HTMX-свап). */
  /* minmax(0,1fr), НЕ 1fr: иначе широкая доска (fixed-layout ~1084px) не даёт колонке
     сжаться и распирает страницу; с min 0 доска скроллится внутри .board-scroll. */
  .dash { grid-template-columns: minmax(0, 1fr); }
  .dash-main, .dash-side { min-width: 0; }
  .dash-side { position: static; width: 100%; margin-top: 16px; }
  /* Шапка переносится по строкам. */
  .app-header-inner { flex-wrap: wrap; gap: 8px; }
  .app-nav { flex-wrap: wrap; gap: 8px; font-size: 14px; }
  /* Модалка помещается на узкий экран (max-height/overflow уже заданы). */
  .modal-card { max-width: 95vw; }
  /* Тач-таргеты ≥ 40px. */
  button, .btn, .app-nav a { min-height: 40px; display: inline-flex; align-items: center; }
  /* Доска остаётся таблицей с горизонтальным скроллом (.board-scroll), полоса залипает слева. */
  table.board .lane-col { position: sticky; left: 0; z-index: 2; }
}
