/* Технический стиль-заглушка. Визуальную систему сделаем отдельным заходом. */
:root { --ink: #16181d; --muted: #6b7280; --line: #e5e7eb; --bg: #fbfbfa;
        --plan: #94a3b8; --live: #d97706; --done: #16a34a; --today: #2563eb; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink);
       font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
.topbar { display: flex; justify-content: space-between; align-items: center;
          padding: 12px 20px; border-bottom: 1px solid var(--line); }
.brand { font-weight: 600; text-decoration: none; color: inherit; letter-spacing: .02em; }
nav { display: flex; gap: 16px; align-items: center; }
.inline { display: inline; }
main { max-width: 880px; margin: 0 auto; padding: 32px 20px; }
h1 { font-size: 1.5rem; margin: 0 0 12px; }
p { color: var(--muted); }
button { font: inherit; padding: 6px 14px; border: 1px solid var(--line);
         border-radius: 6px; background: #fff; cursor: pointer; }
button:hover { border-color: var(--ink); }
.stack p { color: var(--ink); }

/* --- Календарь ---------------------------------------------------------- */

main.main--wide { max-width: 1600px; padding: 20px; }

.cal-head { display: flex; justify-content: space-between; align-items: center;
            gap: 16px; margin-bottom: 14px; }
.cal-nav { display: flex; align-items: center; gap: 10px; }
.cal-nav h1 { margin: 0; min-width: 8.5em; text-transform: capitalize; }
a.btn { display: inline-flex; align-items: center; justify-content: center;
        padding: 6px 14px; border: 1px solid var(--line); border-radius: 6px;
        background: #fff; color: inherit; text-decoration: none; }
a.btn:hover { border-color: var(--ink); }
.btn--icon { width: 34px; padding: 6px 0; font-size: 1.1rem; line-height: 1; }

.cal-weekdays, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-weekdays { gap: 8px; margin-bottom: 6px; }
.cal-weekdays div { font-size: .78rem; color: var(--muted); text-transform: uppercase;
                    letter-spacing: .06em; padding-left: 4px; }
.cal-grid { gap: 8px; }

.day { min-height: 128px; background: #fff; border: 1px solid var(--line);
       border-radius: 8px; padding: 6px; display: flex; flex-direction: column; gap: 5px; }
.day--weekend { background: #fcfcfb; }
/* Соседние месяцы приглушены: видно, что неделя целая, но глаз за них не цепляется. */
.day--other { background: transparent; border-color: transparent; opacity: .45; }
.day--today { border-color: var(--today); box-shadow: 0 0 0 1px var(--today); }

.day-head { display: flex; align-items: baseline; gap: 6px; }
.day-num { font-size: .82rem; color: var(--muted); min-width: 1.4em; text-align: right; }
.day--today .day-num { color: var(--today); font-weight: 700; }
.day-label { display: none; font-size: .82rem; color: var(--muted); }
.day-tasks { display: flex; flex-direction: column; gap: 5px; }

/* Статус читается краем карточки: план — пунктир, работа — янтарь, факт — зелёный. */
.task { border: 1px solid var(--line); border-left: 3px solid var(--line);
        border-radius: 6px; padding: 5px 7px; background: #fff; font-size: .82rem; }
.task--planned { border-style: dashed; border-left-color: var(--plan); color: var(--muted); }
.task--in_progress { border-left-color: var(--live); background: #fffbeb;
                     box-shadow: 0 0 0 1px rgba(217, 119, 6, .25); }
.task--done { border-left-color: var(--done); }

.task-client { display: flex; align-items: center; gap: 5px;
               font-size: .74rem; color: var(--muted); }
.task-client-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.live { width: 7px; height: 7px; border-radius: 50%; background: var(--live);
        margin-left: auto; flex: 0 0 auto; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .live { animation: none; } }

.task-title { line-height: 1.3; margin: 2px 0; overflow-wrap: anywhere; }
.task--done .task-title { text-decoration-color: var(--muted); }
.task-foot { display: flex; justify-content: space-between; gap: 6px;
             font-size: .76rem; color: var(--muted); }
.task-amount { font-weight: 600; color: var(--ink); white-space: nowrap; }

.task[role="button"] { cursor: pointer; }
.task[role="button"]:hover { border-color: var(--ink); }
.task[role="button"]:focus-visible { outline: 2px solid var(--today); outline-offset: 1px; }

/* Кнопки дня не мозолят глаза: появляются на наведении, но всегда доступны
   с клавиатуры и на тач-экране, где наведения не бывает. */
.day-actions { margin-left: auto; display: flex; gap: 2px; opacity: 0; transition: opacity .12s; }
.day:hover .day-actions, .day:focus-within .day-actions { opacity: 1; }
@media (hover: none) { .day-actions { opacity: 1; } }
.icon { font: inherit; line-height: 1; padding: 1px 6px; border: 1px solid transparent;
        border-radius: 5px; background: none; color: var(--muted); cursor: pointer; }
.icon:hover { border-color: var(--line); background: #fff; color: var(--ink); }

/* --- Плашка таймера ----------------------------------------------------- */

.timer-bar { position: sticky; top: 0; z-index: 20; display: flex; flex-wrap: wrap;
             align-items: center; gap: 10px; padding: 8px 20px;
             background: #fffbeb; border-bottom: 1px solid #fcd34d; font-size: .88rem; }
.timer-bar--idle { display: none; }
.timer-task { font-weight: 600; }
.timer-client { color: var(--muted); }
.timer-clock { margin-left: auto; font-variant-numeric: tabular-nums;
               font-size: 1.05rem; font-weight: 600; }
.timer-stop { font: inherit; padding: 4px 12px; border: 1px solid var(--live);
              border-radius: 6px; background: #fff; color: var(--live); cursor: pointer; }
.timer-stop:hover { background: var(--live); color: #fff; }
.timer-warning { flex-basis: 100%; color: #b45309; font-size: .8rem; }
.timer-warning a { color: inherit; }

/* Идущая задача должна быть видна в сетке с одного взгляда. */
.task--running { border-left-color: var(--live); background: #fffbeb;
                 box-shadow: 0 0 0 2px rgba(217, 119, 6, .35); }
.icon--timer { margin-left: 4px; }
.icon--danger:hover { border-color: #dc2626; color: #dc2626; }

/* --- Интервалы ---------------------------------------------------------- */

.entries { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 6px;
           display: flex; flex-direction: column; gap: 6px; font-size: .78rem; }
.entries-head { display: flex; justify-content: space-between; color: var(--muted);
                text-transform: lowercase; }
.entries-total { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 600; }
.entries-empty { color: var(--muted); margin: 0; }
.entry { display: flex; flex-direction: column; gap: 3px; padding: 4px 5px;
         border: 1px solid var(--line); border-radius: 5px; background: #fff; }
.entry--running { border-color: var(--live); background: #fffbeb; }
.entry--new { border-style: dashed; }
.entry-times { display: flex; gap: 4px; }
.entry-times input { font: inherit; font-size: .74rem; width: 100%; padding: 2px 4px;
                     border: 1px solid var(--line); border-radius: 4px; }
.entry-meta { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.entry-billable { display: flex; align-items: center; gap: 3px; cursor: pointer; }
.entry-duration { margin-left: auto; font-variant-numeric: tabular-nums; }
.entry-manual { border: 1px solid var(--line); border-radius: 3px; padding: 0 3px;
                font-size: .68rem; }

/* --- Форма задачи в ячейке --------------------------------------------- */

.task-form { display: flex; flex-direction: column; gap: 6px; font-size: .82rem;
             border-top: 1px solid var(--line); padding-top: 6px; margin-top: 2px; }
.field { display: flex; flex-direction: column; gap: 2px; }
.field-name { font-size: .72rem; color: var(--muted); text-transform: lowercase; }
.task-form input, .task-form select {
  font: inherit; width: 100%; padding: 4px 6px;
  border: 1px solid var(--line); border-radius: 5px; background: #fff; color: inherit; }
.task-form input:focus, .task-form select:focus { outline: none; border-color: var(--today); }
.field--error input, .field--error select { border-color: #dc2626; }
.field-error { color: #dc2626; font-size: .72rem; }
.field-help { color: var(--muted); font-size: .7rem; line-height: 1.25; }
.form-error { color: #dc2626; font-size: .76rem; }
.form-error ul { margin: 0; padding-left: 1.1em; }
.form-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.form-actions button { font: inherit; font-size: .8rem; padding: 4px 9px;
                       border: 1px solid var(--line); border-radius: 5px;
                       background: #fff; cursor: pointer; }
.form-actions button:hover { border-color: var(--ink); }
.form-actions .primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.form-actions .primary:hover { opacity: .9; }
.form-actions .danger { color: #dc2626; }
.form-actions .danger:hover { border-color: #dc2626; }
.form-actions .quiet { color: var(--muted); border-color: transparent; }

/* --- Завершение задачи -------------------------------------------------- */

.preview { margin: 0; display: flex; flex-direction: column; gap: 2px; font-size: .78rem; }
.preview > div { display: flex; justify-content: space-between; gap: 8px; }
.preview dt { color: var(--muted); }
.preview dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.preview-note { color: var(--muted); font-size: .72rem; }

.result { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px;
          display: flex; flex-direction: column; gap: 6px; }
.result-head { font-size: .8rem; font-weight: 600; color: var(--done); }
.result-amount, .result-rate { font-weight: 600; }
.result-gap--down { color: #dc2626; }
.result-gap--up { color: var(--done); }
.icon--done:hover { border-color: var(--done); color: var(--done); }

/* Ячейка с открытой формой не должна ужиматься до размера соседей. */
.day:has(.task-form) { grid-row: span 2; z-index: 1; }
.day-standalone { max-width: 420px; }

/* --- Дашборд ------------------------------------------------------------ */

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden;
                   clip: rect(0 0 0 0); white-space: nowrap; }

.dash-head { display: flex; justify-content: space-between; align-items: center;
             flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.dash-filter { display: flex; align-items: center; gap: 8px; }
.dash-filter select { font: inherit; padding: 6px 10px; border: 1px solid var(--line);
                      border-radius: 6px; background: #fff; color: inherit; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.tile { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.tile-label { font-size: .76rem; color: var(--muted); text-transform: uppercase;
              letter-spacing: .06em; }
.tile-value { font-size: 2rem; font-weight: 650; line-height: 1.15; margin: 4px 0 6px;
              font-variant-numeric: tabular-nums; }
.tile-foot { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; font-size: .78rem; }
.tile-was { color: var(--muted); }
.tile-split { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px;
              padding-top: 8px; border-top: 1px solid var(--line);
              font-size: .76rem; color: var(--muted); }
.split-base { color: var(--muted); margin-left: 4px; }
.split-item { white-space: nowrap; }

.delta { font-weight: 600; white-space: nowrap; }
.delta--up { color: var(--done); }
.delta--down { color: #dc2626; }
.delta--flat, .delta--none { color: var(--muted); font-weight: 400; }

.notice { background: #fffbeb; border: 1px solid #fcd34d; border-radius: 8px;
          padding: 8px 12px; font-size: .82rem; color: var(--ink); margin: 0 0 16px; }
.empty { text-align: center; padding: 40px 0; }

.panel { background: #fff; border: 1px solid var(--line); border-radius: 10px;
         padding: 14px 16px; margin-bottom: 16px; }
.panel h2 { font-size: .95rem; margin: 0 0 4px; }
.panel-second { margin-top: 18px !important; padding-top: 14px;
                border-top: 1px solid var(--line); }
.panel-note { font-size: .78rem; margin: 0 0 10px; }
.panel-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
.panel-row .panel { margin-bottom: 16px; }

.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: .84rem; }
table.grid th { text-align: left; font-size: .72rem; font-weight: 500; color: var(--muted);
                text-transform: uppercase; letter-spacing: .05em;
                padding: 0 8px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.grid td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.grid tr:last-child td { border-bottom: none; }
table.grid .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.grid .strong { font-weight: 600; }
table.grid .quiet { color: var(--muted); }
table.grid .low { color: #dc2626; }
table.grid .row--empty td { color: var(--muted); opacity: .55; }
.cell-sub { font-size: .72rem; color: var(--muted); font-weight: 400; }
table.grid .dot { display: inline-block; vertical-align: middle; margin-right: 5px; }

.facts { margin: 0; display: flex; flex-direction: column; gap: 4px; font-size: .84rem; }
.facts > div { display: flex; justify-content: space-between; gap: 12px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.fact--bad dd { color: #dc2626; }
.fact--good dd { color: var(--done); }

/* График: столбики тянутся от общей базовой линии, высота — доля от лучшего дня. */
.chart { display: flex; align-items: flex-end; gap: 2px; height: 140px; margin-top: 4px; }
.chart-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end;
             height: 100%; min-width: 0; }
.chart-bar { background: var(--today); border-radius: 3px 3px 0 0; min-height: 2px; }
.chart-col--empty .chart-bar { background: var(--line); min-height: 1px; }
.chart-day { font-size: .64rem; color: var(--muted); text-align: center;
             height: 14px; line-height: 14px; }

@media (max-width: 900px) {
  .tiles, .panel-row { grid-template-columns: 1fr; }
  .dash-head { align-items: stretch; }
  .chart { height: 110px; }
  .chart-day { display: none; }
}

/* --- Отчёт -------------------------------------------------------------- */

.report-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px;
               background: #fff; border: 1px solid var(--line); border-radius: 10px;
               padding: 12px 14px; margin-bottom: 16px; }
.report-form .field { gap: 3px; }
.report-form select, .report-form input {
  font: inherit; padding: 6px 10px; border: 1px solid var(--line);
  border-radius: 6px; background: #fff; color: inherit; }
.report-form button { padding: 6px 16px; }
.report-form .primary { background: var(--ink); color: #fff; border-color: var(--ink); }

.report-actions { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.copy-status { font-size: .8rem; color: var(--muted); }

.report { background: #fff; border: 1px solid var(--line); border-radius: 10px;
          padding: 24px 28px; max-width: 720px; }
.report-client { font-size: 1.4rem; margin: 0; }
.report-period { margin: 2px 0 18px; }
.report-list { list-style: none; margin: 0; padding: 0; }
/* Название тянется, цена и время держат правый край: список читается
   сверху вниз одной колонкой цифр, а не рваным краем. */
.report-list li { display: flex; align-items: baseline; gap: 10px;
                  padding: 7px 0; border-bottom: 1px solid var(--line); }
.line-title { flex: 1; overflow-wrap: anywhere; }
.line-amount { font-weight: 600; white-space: nowrap;
               font-variant-numeric: tabular-nums; min-width: 6em; text-align: right; }
.line-time { color: var(--muted); white-space: nowrap;
             font-variant-numeric: tabular-nums; min-width: 4.5em; text-align: right; }
.report-total { display: flex; align-items: baseline; gap: 10px; margin: 14px 0 0;
                color: var(--ink); font-size: 1rem; }
.report-total strong { margin-left: auto; font-variant-numeric: tabular-nums; }
.total-time { min-width: 4.5em; text-align: right; font-variant-numeric: tabular-nums; }
.total-tasks { color: var(--muted); font-size: .8rem; }
.report-empty { margin: 0; }

/* Печать: на лист уходит только сам отчёт. */
@media print {
  .topbar, .timer-bar, .no-print { display: none !important; }
  body { background: #fff; }
  main, main.main--wide { max-width: none; padding: 0; }
  .report { border: none; border-radius: 0; padding: 0; max-width: none; }
  .report-list li { break-inside: avoid; }
}

/* На узком экране сетка не читается — разворачиваем месяц вертикальным списком. */
@media (max-width: 900px) {
  main.main--wide { padding: 14px; }
  .cal-weekdays { display: none; }
  .cal-grid { grid-template-columns: 1fr; gap: 6px; }
  .day { min-height: 0; }
  .day--other { display: none; }
  .day--empty { opacity: .6; padding: 4px 6px; }
  .day-num { display: none; }
  .day-label { display: block; text-transform: capitalize; }
  .day--today .day-label { color: var(--today); font-weight: 700; }
  .task { font-size: .9rem; }
}
