:root {
  --bg: #f6f7f9; --card: #fff; --text: #1f2328; --muted: #656d76; --line: #d8dee4;
  --accent: #0969da; --ok: #1a7f37; --bad: #cf222e; --warn: #9a6700; --info: #8250df;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.topbar { display: flex; align-items: center; gap: 20px; padding: 8px 20px; background: #24292f; color: #fff; flex-wrap: wrap; }
.topbar a { color: #f0f6fc; }
.topbar .brand { font-weight: 700; font-size: 16px; }
.topbar nav { display: flex; gap: 16px; flex-wrap: wrap; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.topbar .muted { color: #c9d1d9; }
.topbar form { margin: 0; }
.bell { position: relative; color: #f0f6fc; }
.bell .count { background: var(--bad); color: #fff; border-radius: 9px; padding: 0 6px; font-size: 11px; margin-left: 2px; }

.page { max-width: 1200px; margin: 20px auto; padding: 0 16px; }
.page.wide { max-width: none; }
.page.narrow { max-width: 420px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin-bottom: 16px; }
.grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 16px; }
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }

.btn { display: inline-block; border: 1px solid var(--line); background: #f6f8fa; color: var(--text); border-radius: 6px; padding: 5px 12px; cursor: pointer; font: inherit; }
.btn:hover { text-decoration: none; background: #eef1f4; }
.btn.primary { background: #1f883d; border-color: #1a7f37; color: #fff; }
.btn.small { padding: 2px 8px; font-size: 12px; }
button.link { background: none; border: 0; color: inherit; cursor: pointer; font: inherit; padding: 0; }

.flash { padding: 8px 12px; border-radius: 6px; margin-bottom: 12px; background: #ddf4ff; border: 1px solid #b6e3ff; }
.flash.error { background: #ffebe9; border-color: #ffcecb; }
.flash.success { background: #dafbe1; border-color: #aceebb; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; flex-wrap: wrap; }
.tabs a { padding: 6px 12px; border-bottom: 2px solid transparent; color: var(--text); }
.tabs a.active { border-color: #fd8c73; font-weight: 600; }

table.list { width: 100%; border-collapse: collapse; background: var(--card); }
table.list th, table.list td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list th { font-size: 12px; color: var(--muted); font-weight: 600; }
table.list tr.overdue td:first-child { box-shadow: inset 3px 0 var(--bad); }

.badge { display: inline-block; border-radius: 10px; padding: 1px 8px; font-size: 12px; background: #eaeef2; white-space: nowrap; }
.st-new { background: #ddf4ff; } .st-in_progress { background: #fff8c5; } .st-waiting_client { background: #fbefff; }
.st-review { background: #ffe2cc; } .st-done { background: #dafbe1; } .st-postponed, .st-cancelled { background: #eaeef2; color: var(--muted); }
.pr-high { color: var(--bad); font-weight: 600; } .pr-low { color: var(--muted); }
.unread { background: var(--accent); color: #fff; border-radius: 9px; padding: 0 6px; font-size: 11px; }
.late { color: var(--bad); font-weight: 600; }

.form label { display: block; margin-bottom: 10px; font-weight: 600; }
.form label .helptext, .form .helptext { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
input[type=text], input[type=date], input[type=time], input[type=number], input[type=password], select, textarea {
  width: 100%; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; font: inherit; background: #fff;
}
select[multiple] { min-height: 90px; }
.form .errorlist { color: var(--bad); margin: 2px 0; padding: 0; list-style: none; font-weight: 400; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 16px; }
.inline-radio ul, .inline-radio div { display: flex; gap: 16px; list-style: none; padding: 0; margin: 4px 0; }
.inline-radio label { font-weight: 400; }

.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-bottom: 12px; align-items: end; }

.chat { max-height: 560px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.msg { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; }
.msg.system { background: #f6f8fa; border-style: dashed; color: var(--muted); font-size: 13px; }
.msg .meta { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.msg .quote { border-left: 3px solid var(--line); padding-left: 8px; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.msg .text { white-space: pre-wrap; }
.msg details summary { font-size: 12px; color: var(--accent); cursor: pointer; }

dl.props { display: grid; grid-template-columns: 140px 1fr; gap: 6px 10px; margin: 0; }
dl.props dt { color: var(--muted); }
dl.props dd { margin: 0; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 3px 0; }
.checklist .done { text-decoration: line-through; color: var(--muted); }

.kanban { display: grid; grid-template-columns: repeat(7, minmax(190px, 1fr)); gap: 10px; overflow-x: auto; }
.kanban-col { background: #eef1f4; border-radius: 8px; padding: 8px; min-height: 200px; }
.kanban-list { min-height: 150px; display: flex; flex-direction: column; gap: 6px; }
.kanban-card { display: block; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 8px; color: var(--text); cursor: grab; }
.kanban-card:hover { text-decoration: none; border-color: var(--accent); }
.kanban-card.late-card { box-shadow: inset 3px 0 var(--bad); }

#gantt .vis-item { border-radius: 4px; border-color: #8c959f; background: #ddf4ff; font-size: 12px; }
#gantt .vis-item.st-in_progress { background: #fff8c5; } #gantt .vis-item.st-waiting_client { background: #fbefff; }
#gantt .vis-item.st-review { background: #ffe2cc; } #gantt .vis-item.st-done { background: #dafbe1; }
#gantt .vis-item.st-postponed { background: #eaeef2; }
#gantt .vis-item.late { border: 2px solid var(--bad); }
#gantt .vis-item.vis-background.baseline { background: rgba(9, 105, 218, .12); border: 0; }
.fc .fc-event { border-color: #8c959f; background: #ddf4ff; }
.fc .fc-event, .fc .fc-event .fc-event-main, .fc .fc-event-title { color: var(--text); }
.fc .fc-event.st-in_progress { background: #fff8c5; } .fc .fc-event.st-waiting_client { background: #fbefff; }
.fc .fc-event.st-review { background: #ffe2cc; } .fc .fc-event.st-done { background: #dafbe1; opacity: .7; }
.fc .fc-event.st-postponed { background: #eaeef2; }

@media print {
  .topbar, .no-print, .flash { display: none !important; }
  body { background: #fff; }
  .page { margin: 0; max-width: none; }
  .card { border: 0; padding: 0; }
  table.list th, table.list td { padding: 4px 6px; }
}
