/* Доска Solomon. Раскладка: верхняя панель, под ней доска на всю ширину с горизонтальной прокруткой колонок. */
:root {
  --bg: #eef1f4;
  --surface: #ffffff;
  --list: #f1f2f4;
  --ink: #172b4d;
  --muted: #5e6c84;
  --line: #dcdfe4;
  --accent: #0f6e78;
  --accent-ink: #ffffff;
  --danger: #b42318;
  --ok: #1f845a;
  --overlay: rgba(9, 30, 66, .54);
  --tint-1: rgba(9,30,66,.05); --tint-2: rgba(9,30,66,.08); --tint-3: rgba(9,30,66,.13);
  --shadow: 0 1px 1px rgba(9,30,66,.25), 0 0 1px rgba(9,30,66,.31);
  --shadow-lg: 0 8px 24px rgba(9,30,66,.25);
  --lbl-green: #4bce97; --lbl-yellow: #f5cd47; --lbl-orange: #fea362; --lbl-red: #f87168;
  --lbl-purple: #9f8fef; --lbl-blue: #579dff; --lbl-sky: #6cc3e0; --lbl-pink: #e774bb; --lbl-black: #8590a2;
  --f-display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161a1d; --surface: #22272b; --list: #101204; --ink: #dee4ea; --muted: #9fadbc; --line: #38414a;
    --accent: #4fb9c3; --accent-ink: #0b1f22; --danger: #f87168; --ok: #4bce97; --overlay: rgba(0,0,0,.6);
    --shadow: 0 1px 1px rgba(0,0,0,.5); --shadow-lg: 0 8px 24px rgba(0,0,0,.6);
    --list: #101214;
    --tint-1: rgba(255,255,255,.04); --tint-2: rgba(255,255,255,.08); --tint-3: rgba(255,255,255,.15);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.43 var(--f-display); }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; text-wrap: balance; }
.mono { font-family: var(--f-mono); }
.muted { color: var(--muted); }

.btn { border: 0; border-radius: 4px; padding: 6px 12px; background: var(--tint-2); color: var(--ink); font-weight: 500; }
.btn:hover { background: var(--tint-3); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent); filter: brightness(1.12); }
.btn.danger { background: transparent; color: var(--danger); }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: default; }

.input { width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 4px; padding: 7px 10px; background: var(--surface); }
textarea.input { resize: vertical; min-height: 64px; }
.field { display: grid; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.err { color: var(--danger); font-size: 13px; }

/* Верхняя панель */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; height: 48px;
  padding: env(safe-area-inset-top, 0px) max(12px, env(safe-area-inset-right, 0px)) 0 max(12px, env(safe-area-inset-left, 0px));
  background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar .logo { display: flex; align-items: center; gap: 8px; font-weight: 800; text-decoration: none; color: var(--ink); }
.topbar .logo i { width: 22px; height: 22px; border-radius: 5px; background: var(--accent); display: inline-block; position: relative; }
.topbar .logo i::before, .topbar .logo i::after { content: ""; position: absolute; top: 4px; width: 5px; background: var(--accent-ink); border-radius: 1px; }
.topbar .logo i::before { left: 5px; height: 13px; } .topbar .logo i::after { left: 12px; height: 8px; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a { text-decoration: none; color: var(--ink); padding: 6px 10px; border-radius: 4px; font-weight: 500; }
.topbar nav a:hover, .topbar nav a.on { background: var(--tint-2); }
.topbar .spacer { flex: 1; }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 11px; font-weight: 700;
  background: var(--accent); color: var(--accent-ink); flex: none; text-transform: uppercase; }
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }

/* Страницы */
.page { max-width: 1100px; margin: 0 auto; padding: 28px max(16px, env(safe-area-inset-right, 0px)) 48px max(16px, env(safe-area-inset-left, 0px)); display: grid; gap: 20px; }
.page h1 { font-size: 22px; font-weight: 800; }
.section-title { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }

/* Вход */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.auth form { width: min(380px, 100%); background: var(--surface); border-radius: 8px; box-shadow: var(--shadow-lg); padding: 32px 28px; display: grid; gap: 14px; }
.auth h1 { font-size: 20px; text-align: center; }
.auth .sub { text-align: center; color: var(--muted); margin-top: -6px; }
.auth a { color: var(--accent); }
.pw { position: relative; display: block; }
.pw .input { padding-right: 38px; }
.pw-eye { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); width: 32px; height: 30px; border: 0; background: transparent;
  color: var(--muted); display: grid; place-items: center; border-radius: 4px; cursor: pointer; }
.pw-eye:hover { color: var(--ink); }
.pw-rules { list-style: none; margin: -6px 0 0; padding: 0; display: grid; gap: 2px; font-size: 12px; color: var(--muted); }
.pw-rules li::before { content: "○"; display: inline-block; width: 16px; }
.pw-rules li.ok { color: var(--ok); }
.pw-rules li.ok::before { content: "✓"; }
.pw-meter { display: flex; align-items: center; gap: 10px; margin-top: -6px; font-size: 12px; color: var(--muted); }
.pw-meter[hidden] { display: none; }
.pw-meter-bars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; flex: 1; }
.pw-meter-bars i { height: 4px; border-radius: 2px; background: var(--line); }
.pw-meter[data-level="0"] i.on { background: var(--danger); }
.pw-meter[data-level="1"] i.on { background: #e2a03f; }
.pw-meter[data-level="2"], .pw-meter[data-level="3"] { color: var(--ok); }
.pw-meter[data-level="2"] i.on, .pw-meter[data-level="3"] i.on { background: var(--ok); }
.pw-meter[data-level="0"] .pw-meter-text { color: var(--danger); }

/* Список досок */
.board-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.board-tile { height: 96px; border-radius: 6px; padding: 10px 12px; color: #fff; text-decoration: none; font-weight: 700; font-size: 16px;
  display: flex; flex-direction: column; justify-content: space-between; box-shadow: var(--shadow); position: relative; overflow: hidden; border: 0; text-align: left; }
.board-tile::after { content: ""; position: absolute; inset: 0; background: rgba(0,0,0,0); transition: background .1s; }
.board-tile:hover::after { background: rgba(0,0,0,.12); }
.board-tile small { font-weight: 500; font-size: 12px; opacity: .9; }
.board-tile.new { background: var(--tint-2); color: var(--ink); font-weight: 500; font-size: 14px; justify-content: center; align-items: center; }
@media (prefers-color-scheme: dark) { .board-tile.new { background: rgba(255,255,255,.08); } }

/* Доска */
#app { height: 100%; display: flex; flex-direction: column; }
.board-page { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.board-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px max(12px, env(safe-area-inset-right, 0px)) 10px max(12px, env(safe-area-inset-left, 0px));
  background: rgba(0,0,0,.18); color: #fff; }
.board-head .title { font-size: 18px; font-weight: 800; padding: 4px 8px; border-radius: 4px; background: transparent; border: 0; color: #fff; max-width: 100%; }
.board-head .title:hover { background: rgba(255,255,255,.2); }
.board-head input.title { background: #fff; color: #172b4d; }
.board-head .btn { background: rgba(255,255,255,.2); color: #fff; }
.board-head .btn:hover { background: rgba(255,255,255,.32); }
.board-head .btn.on { background: #fff; color: #172b4d; }
.board-head .seg { display: inline-flex; gap: 2px; background: rgba(0,0,0,.15); padding: 2px; border-radius: 6px; }
.board-head select { background: rgba(255,255,255,.2); color: #fff; border: 0; border-radius: 4px; padding: 6px 8px; }
.board-head select option { color: #172b4d; }
.board-head .spacer { flex: 1; }
.board-body { flex: 1; min-height: 0; overflow: auto; }

.lists { display: flex; align-items: flex-start; gap: 12px; padding: 12px max(12px, env(safe-area-inset-right, 0px)) 24px max(12px, env(safe-area-inset-left, 0px)); height: 100%; }
.list { flex: 0 0 272px; max-height: 100%; display: flex; flex-direction: column; background: var(--list); border-radius: 12px; box-shadow: var(--shadow); }
.list-head { display: flex; align-items: center; gap: 4px; padding: 8px 8px 4px 12px; cursor: grab; touch-action: none; }
.list-head h3 { flex: 1; font-size: 14px; font-weight: 700; padding: 4px 0; overflow-wrap: anywhere; cursor: pointer; }
.list-head input { flex: 1; }
.list-head .count { font-size: 12px; color: var(--muted); font-family: var(--f-mono); }
.icon-btn { border: 0; background: transparent; border-radius: 4px; width: 28px; height: 28px; display: grid; place-items: center; color: var(--muted); }
.icon-btn:hover { background: var(--tint-3); color: var(--ink); }
.cards { display: flex; flex-direction: column; gap: 8px; padding: 4px 8px; overflow-y: auto; min-height: 8px; }
.list-foot { padding: 4px 8px 8px; }
.add-card { width: 100%; text-align: left; border: 0; background: transparent; color: var(--muted); padding: 6px 8px; border-radius: 6px; }
.add-card:hover { background: var(--tint-3); color: var(--ink); }
.composer { display: grid; gap: 8px; }
.composer .row { display: flex; gap: 6px; align-items: center; }
.add-list { flex: 0 0 272px; background: rgba(255,255,255,.24); color: #fff; border: 0; border-radius: 12px; padding: 12px; text-align: left; font-weight: 500; }
.add-list:hover { background: rgba(255,255,255,.34); }
.add-list-form { flex: 0 0 272px; background: var(--list); border-radius: 12px; padding: 8px; }

.card { background: var(--surface); border-radius: 8px; box-shadow: var(--shadow); padding: 8px 10px; display: grid; gap: 6px; cursor: pointer; touch-action: none; user-select: none; position: relative; }
.card:hover { outline: 2px solid var(--accent); outline-offset: -2px; }
.card .labels { display: flex; flex-wrap: wrap; gap: 4px; }
.lbl { height: 8px; min-width: 40px; border-radius: 4px; }
.lbl.wide { height: auto; min-width: 0; padding: 1px 8px; font-size: 12px; font-weight: 600; color: #172b4d; }
.card .ctitle { overflow-wrap: anywhere; }
.card.done .ctitle { text-decoration: line-through; color: var(--muted); }
.badges { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 12px; color: var(--muted); }
.badges .spacer { flex: 1; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 4px; border-radius: 3px; }
.badge.due-soon { background: #f5cd47; color: #533f04; }
.badge.overdue { background: #c9372c; color: #fff; }
.badge.done { background: #1f845a; color: #fff; }
.placeholder { border-radius: 8px; background: var(--tint-3); }
.list.placeholder { flex: 0 0 272px; border-radius: 12px; background: rgba(0,0,0,.18); box-shadow: none; }
.drag-ghost { position: fixed; z-index: 100; pointer-events: none; transform: rotate(3deg); box-shadow: var(--shadow-lg); opacity: .95; }

/* Карточка: окно */
.modal-bg { position: fixed; inset: 0; z-index: 50; background: var(--overlay); overflow-y: auto; display: flex; justify-content: center; align-items: flex-start;
  padding: max(24px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) 48px max(12px, env(safe-area-inset-left, 0px)); }
.modal { width: min(760px, 100%); background: var(--list); border-radius: 12px; padding: 20px; display: grid; gap: 18px; position: relative; }
.modal .close { position: absolute; top: 10px; right: 10px; }
.modal-title { font-size: 20px; font-weight: 700; border: 0; background: transparent; width: calc(100% - 40px); padding: 4px 6px; border-radius: 4px; resize: none; overflow: hidden; }
.modal-title:focus { background: var(--surface); }
.modal .in-list { font-size: 13px; color: var(--muted); padding-left: 6px; }
.modal-grid { display: grid; grid-template-columns: minmax(0, 1fr) 200px; gap: 20px; }
.modal-main, .modal-side { display: grid; gap: 18px; align-content: start; min-width: 0; }
.modal-side .field select, .modal-side .field input { width: 100%; }
.modal-side .field input[type=checkbox] { width: auto; }
.block h4 { margin: 0 0 8px; font-size: 14px; font-weight: 700; }
.label-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.label-chip { border: 2px solid transparent; border-radius: 4px; height: 28px; min-width: 44px; padding: 0 8px; font-size: 12px; font-weight: 600; color: #172b4d; }
.label-chip.on { border-color: var(--ink); }
.check-item { display: flex; align-items: flex-start; gap: 8px; padding: 4px 0; }
.check-item span { flex: 1; overflow-wrap: anywhere; }
.check-item.done span { text-decoration: line-through; color: var(--muted); }
.progress { height: 8px; background: var(--tint-3); border-radius: 4px; overflow: hidden; margin-bottom: 6px; }
.progress i { display: block; height: 100%; background: var(--accent); }
.comment { display: grid; grid-template-columns: auto 1fr; gap: 8px; }
.comment .body { background: var(--surface); border-radius: 8px; padding: 8px 10px; box-shadow: var(--shadow); white-space: pre-wrap; overflow-wrap: anywhere; }
.comment .meta { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.desc-view { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface); border-radius: 6px; padding: 8px 10px; min-height: 48px; cursor: text; }
.desc-view.empty { color: var(--muted); }
@media (max-width: 640px) { .modal-grid { grid-template-columns: 1fr; } }

/* Гант */
.gantt { --day: 32px; position: relative; min-width: max-content; min-height: 100%; }
.gantt.zoom-week { --day: 12px; }
.gantt-row { display: flex; min-height: 36px; border-bottom: 1px solid var(--line); }
.gantt-name { position: sticky; left: 0; z-index: 3; flex: 0 0 260px; background: var(--surface); border-right: 1px solid var(--line); padding: 6px 10px; display: flex; align-items: center; gap: 8px; overflow: hidden; }
.gantt-name button { border: 0; background: transparent; text-align: left; padding: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.gantt-name button:hover { color: var(--accent); text-decoration: underline; }
.gantt-group .gantt-name { background: var(--list); font-weight: 700; }
.gantt-group { background: var(--list); }
.gantt-track { position: relative; flex: none; display: flex; align-items: center; }
.gantt-head { position: sticky; top: 0; z-index: 4; background: var(--surface); border-bottom: 1px solid var(--line); }
.gantt-head .gantt-name { z-index: 5; font-size: 12px; font-weight: 700; color: var(--muted); }
.gantt-months, .gantt-days { display: flex; }
.gantt-months div { border-left: 1px solid var(--line); font-size: 12px; font-weight: 700; white-space: nowrap; }
.gantt-months span { position: sticky; left: 266px; display: inline-block; padding: 2px 6px; }
@media (max-width: 560px) { .gantt-months span { left: 156px; } }
.gantt-days div { width: var(--day); flex: none; text-align: center; font-size: 11px; color: var(--muted); border-left: 1px solid var(--line); font-family: var(--f-mono); }
.gantt-days div.we { background: var(--tint-1); }
.gantt.zoom-week .gantt-days div { font-size: 0; }
.gantt.zoom-week .gantt-days div.mon { font-size: 9px; overflow: visible; text-align: left; }
.gantt-grid { position: absolute; inset: 0; display: flex; pointer-events: none; }
.gantt-grid div { width: var(--day); flex: none; border-left: 1px solid transparent; }
.gantt-grid div.we { background: var(--tint-1); }
.gantt-today { position: absolute; top: 0; bottom: 0; width: 2px; background: #c9372c; z-index: 2; pointer-events: none; }
.gantt-bar { position: absolute; top: 6px; height: 24px; border-radius: 4px; color: #fff; font-size: 12px; font-weight: 600; padding: 0 8px; display: flex; align-items: center;
  white-space: nowrap; overflow: hidden; cursor: grab; touch-action: none; user-select: none; box-shadow: var(--shadow); z-index: 1; }
.gantt-bar.done { opacity: .5; }
.gantt-bar .h { position: absolute; top: 0; bottom: 0; width: 8px; cursor: ew-resize; }
.gantt-bar .h.l { left: 0; } .gantt-bar .h.r { right: 0; }
.gantt-empty { position: sticky; left: 266px; margin: 4px 0; padding: 4px 10px; font-size: 12px; color: var(--muted); align-self: center; }
@media (max-width: 560px) { .gantt-empty { left: 156px; } }
.gantt-hint { padding: 10px 14px; color: var(--muted); font-size: 13px; }

/* Админка */
.table-wrap { overflow-x: auto; background: var(--surface); border-radius: 8px; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.pill.ok { background: #dcfff1; color: #216e4e; } .pill.wait { background: #fff7d6; color: #7f5f01; } .pill.off { background: #ffeceb; color: #ae2e24; }
.pill.admin { background: #e9f2ff; color: #0c66e4; }
.panel { background: var(--surface); border-radius: 8px; box-shadow: var(--shadow); padding: 16px; display: grid; gap: 12px; }
.form-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.form-row .field { flex: 1 1 200px; }
.linkbox { font-family: var(--f-mono); font-size: 12px; background: var(--list); padding: 8px; border-radius: 4px; overflow-wrap: anywhere; }
.notice { background: #fff7d6; color: #533f04; border-radius: 6px; padding: 10px 12px; }

.toast { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 200; background: #172b4d; color: #fff;
  padding: 10px 16px; border-radius: 6px; box-shadow: var(--shadow-lg); max-width: calc(100% - 32px); }

.popover { position: fixed; z-index: 60; background: var(--surface); border-radius: 8px; box-shadow: var(--shadow-lg); padding: 12px; width: 280px; display: grid; gap: 8px; }
.popover h4 { margin: 0; text-align: center; font-size: 14px; color: var(--muted); }
.popover .item { border: 0; background: transparent; text-align: left; padding: 6px 8px; border-radius: 4px; }
.popover .item:hover { background: var(--tint-2); }
.swatches { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.swatches button { height: 32px; border-radius: 4px; border: 2px solid transparent; }
.swatches button.on { border-color: var(--ink); }

@media (max-width: 560px) {
  .topbar nav a span { display: none; }
  .list, .add-list, .add-list-form { flex-basis: 85vw; }
  .gantt-name { flex-basis: 150px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 8px 14px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--accent); }
.table-wrap a { color: var(--accent); }
.gantt-head .gantt-track { display: block; }
