:root {
  --bg: #f3f1ec;
  --paper: #fff;
  --ink: #181816;
  --muted: #77736c;
  --line: #dedbd4;
  --accent: #ef5b35;
  --ok: #267b59;
  --shadow: 0 18px 50px rgba(25, 24, 21, .08);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
h1, h2, p { margin-top: 0; }
h1 { margin: 0; font-size: 24px; letter-spacing: -.03em; }
h2 { margin: 4px 0 10px; font-size: 30px; line-height: 1.1; letter-spacing: -.04em; }
button, select, input, textarea { font: inherit; }

.topbar { height: 96px; padding: 0 max(28px, calc((100vw - 1200px) / 2)); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.eyebrow { text-transform: uppercase; letter-spacing: .13em; font-size: 11px; color: var(--muted); font-weight: 700; }
.profile { padding: 10px 14px; background: var(--paper); border: 1px solid var(--line); border-radius: 999px; color: inherit; font-size: 13px; text-decoration: none; }
main { max-width: 1200px; margin: auto; padding: 42px 28px 80px; }
.hero { display: flex; justify-content: space-between; gap: 40px; align-items: end; padding: 35px 0 42px; }
.hero h2 { max-width: 680px; font-size: 48px; }
.hero p { max-width: 690px; color: var(--muted); }

.primary, .secondary, .icon { border: 0; border-radius: 12px; padding: 13px 18px; cursor: pointer; }
.primary { background: var(--accent); color: #fff; font-weight: 700; box-shadow: 0 8px 22px rgba(239, 91, 53, .2); }
.secondary { background: #eeeae3; }
.icon { flex: 0 0 40px; width: 40px; height: 40px; padding: 0; display: grid; place-items: center; background: transparent; font-size: 26px; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); }
.hidden { display: none !important; }
.login { max-width: 620px; margin: 70px auto; padding: 38px; }
.telegram-login { display: inline-block; margin-top: 8px; text-decoration: none; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.stat { padding: 20px; }
.stat strong { display: block; font-size: 28px; }
.stat span, .muted { color: var(--muted); }
.board { overflow: hidden; }
.section-head { display: flex; justify-content: space-between; align-items: end; padding: 24px 26px; border-bottom: 1px solid var(--line); }
.section-head h2 { margin-bottom: 0; font-size: 26px; }
select { border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; background: #fff; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 16px 20px; text-align: left; border-bottom: 1px solid #ebe8e2; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #faf8f4; }
.task-title { font-weight: 700; }
.task-code { display: block; color: var(--muted); font-size: 12px; }
.pill { display: inline-block; padding: 4px 8px; border-radius: 999px; background: #eeeae3; font-size: 12px; }
.priority-urgent, .priority-critical { background: #ffe1d9; color: #a72e12; }
.status-in_progress { background: #dff0e8; color: var(--ok); }

dialog { width: min(620px, calc(100% - 28px)); padding: 0; overflow-x: hidden; border: 0; border-radius: 22px; box-shadow: 0 30px 90px rgba(0, 0, 0, .25); }
dialog::backdrop { background: rgba(20, 20, 18, .55); backdrop-filter: blur(4px); }
dialog form, #taskDetail { padding: 28px; }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.dialog-head > div { min-width: 0; }
.dialog-head h2 { overflow-wrap: anywhere; }
label { display: block; margin: 18px 0 8px; font-weight: 700; }
textarea, input[type=file] { width: 100%; margin-top: 7px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #faf9f6; }
textarea { min-height: 150px; resize: vertical; }
.urgent { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border-radius: 12px; background: #fff5f1; font-weight: 500; }
.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.form-status { margin: 12px 0 0; color: var(--muted); }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.detail-block { min-width: 0; padding: 15px; border-radius: 12px; background: #f5f3ef; }
.detail-wide { grid-column: 1 / -1; }
.detail-block span { display: block; color: var(--muted); font-size: 12px; }
.detail-block p { margin: 5px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.detail-block a { color: var(--accent); }
.warning { background: #fff3dc; }
.admin-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 100px auto; gap: 8px; margin-top: 10px; }
.admin-row > * { min-width: 0; }
.admin-row input { width: 100%; margin: 0; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; }

.comments { display: grid; gap: 9px; margin-top: 10px; }
.comment { padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); }
.comment strong { font-size: 13px; }
.comment time { margin-left: 8px; color: var(--muted); font-size: 11px; }
.comment p { margin: 5px 0 0; }
.comment-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-top: 12px; }
.comment-form textarea { min-height: 72px; margin: 0; }
.comment-form .primary { align-self: end; }

@media (max-width: 760px) {
  .topbar { height: 78px; padding: 0 18px; }
  .profile { max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
  main { padding: 24px 14px 60px; }
  .hero { display: block; padding-top: 18px; }
  .hero h2 { font-size: 34px; }
  .hero .primary { width: 100%; margin-top: 14px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .section-head { align-items: start; gap: 12px; }
  th:nth-child(2), td:nth-child(2), th:nth-child(3), td:nth-child(3), th:nth-child(5), td:nth-child(5) { display: none; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-wide { grid-column: auto; }
  .admin-row, .comment-form { grid-template-columns: 1fr; }
  .admin-row .primary, .comment-form .primary { width: 100%; }
}
