:root {
  --bg: #f5f6f8; --card: #fff; --text: #1d2330; --muted: #6b7280; --line: #e3e6eb;
  --primary: #3b5bdb; --primary-d: #2f4ac0; --success: #2b8a3e; --danger: #c92a2a; --warn: #e67700;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111418; --card: #1a1e24; --text: #e6e8eb; --muted: #9aa3ae; --line: #2b313a; --primary: #5c7cfa; --primary-d: #4c6ef5; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small, small { font-size: .85rem; }
.pre { white-space: pre-wrap; margin-top: 0; }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .75rem 1.25rem; background: var(--card); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); }
.topbar nav { display: flex; gap: 1.1rem; align-items: center; flex-wrap: wrap; }
.container { max-width: 1150px; margin: 0 auto; padding: 1.25rem 16px 3rem; }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: 100%; max-width: 380px; }
.crumbs { margin: 0 0 .4rem; color: var(--muted); font-size: .9rem; }

.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head.sub { margin: 1.5rem 0 .75rem; }
.page-head.sub h2 { margin: 0; }
.tabs { display: flex; gap: .25rem; flex-wrap: wrap; }
.tabs a { padding: .3rem .75rem; border-radius: 999px; color: var(--muted); }
.tabs a.on { background: var(--primary); color: #fff; }
.tabs a:hover { text-decoration: none; background: var(--line); }
.tabs a.on:hover { background: var(--primary-d); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem; }
details.card > summary { cursor: pointer; font-weight: 600; }
details[open].card > summary { margin-bottom: .75rem; }
.new-item > summary { color: var(--primary); }

form label { display: block; margin-bottom: .75rem; font-weight: 500; font-size: .9rem; }
input, textarea, select { display: block; width: 100%; margin-top: .25rem; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 7px; font: inherit; background: var(--bg); color: var(--text); }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
input[type=file] { padding: .4rem; }
.row { display: flex; gap: 1rem; flex-wrap: wrap; }
.row > label { flex: 1; min-width: 160px; }
.file-pick { margin-bottom: .2rem; }
.file-pick + small { display: block; margin-bottom: .75rem; }
form.inline { display: flex; gap: .5rem; flex-wrap: wrap; }

.btn { display: inline-block; padding: .5rem 1rem; border-radius: 7px; border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-d); }
.btn.success { background: var(--success); border-color: var(--success); color: #fff; }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); margin-top: .5rem; }
.link { background: none; border: 0; padding: 0; font: inherit; font-size: .85rem; cursor: pointer; color: var(--primary); }
.link.danger { color: var(--danger); }

.flash { padding: .6rem .9rem; border-radius: 7px; margin-bottom: .75rem; background: #e6f4ea; color: #1e6b34; border: 1px solid #b7dfc3; }
.flash.err { background: #fdecec; color: #a61e1e; border-color: #f3c1c1; }

.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--line); color: var(--text); white-space: nowrap; vertical-align: middle; }
.b-active, .b-in_progress { background: #dbe4ff; color: #2f4ac0; }
.b-on_hold { background: #fff3bf; color: #8a5a00; }
.b-done { background: #d3f9d8; color: #2b8a3e; }
.b-closed { background: #e9ecef; color: #495057; }
.b-todo { background: #f1f3f5; color: #495057; }
.b-high { background: #ffe3e3; color: #c92a2a; }
.b-medium { background: #fff4e6; color: #d9480f; }
.b-low { background: #e7f5ff; color: #1971c2; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.project-card { color: var(--text); display: block; margin: 0; }
.project-card:hover { text-decoration: none; border-color: var(--primary); }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: .4rem 0; }
.progress { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin: .6rem 0 .4rem; }
.progress span { display: block; height: 100%; background: var(--success); }
.overdue { color: var(--danger); font-weight: 600; }
.empty { color: var(--muted); text-align: center; padding: 2rem 0; }

.cols { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.25rem; align-items: start; }
@media (max-width: 860px) { .cols { grid-template-columns: 1fr; } }
.meta { display: grid; grid-template-columns: auto 1fr; gap: .3rem 1rem; margin: 0; font-size: .9rem; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }

table.list { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list th, .list td { padding: .6rem .8rem; text-align: left; border-bottom: 1px solid var(--line); }
.list th { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.list tr:last-child td { border-bottom: 0; }
@media (max-width: 600px) {
  .list thead { display: none; }
  .list tr { display: block; border-bottom: 1px solid var(--line); padding: .5rem 0; }
  .list td { display: inline-block; border: 0; padding: .2rem .8rem; }
  .list td:first-child { display: block; font-weight: 600; }
}

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline .card p { margin: .4rem 0; }
.timeline form { margin: 0; }

.attachments { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .6rem; margin: .5rem 0 .75rem; }
aside .attachments { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.att { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--bg); }
.att img { display: block; width: 100%; height: 95px; object-fit: cover; }
.fileicon { display: grid; place-items: center; height: 95px; font-weight: 700; color: var(--muted); font-size: 1.1rem; letter-spacing: .05em; }
.fileicon:hover { text-decoration: none; color: var(--primary); }
.att-meta { padding: .35rem .5rem; font-size: .8rem; }
.att-meta a { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-meta small { color: var(--muted); }
.att-meta form { display: inline; margin-left: .4rem; }
.org-filter { margin: -.25rem 0 1rem; }
.org-filter select { width: auto; min-width: 220px; margin: 0; }
