:root {
  --bg: #0f1113;
  --bg2: #15181b;
  --bg3: #1c2024;
  --line: #2a2e33;
  --text: #e6e6e6;
  --muted: #8b9199;
  --dim: #5c636b;
  --accent: #e6e6e6;
  --ok: #9fd3a8;
  --warn: #e3c37a;
  --radius: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 -apple-system, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }

#app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { border-right: 1px solid var(--line); padding: 22px 18px; display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; gap: 12px; align-items: flex-start; }
.brand img { opacity: .9; flex: none; margin-top: 2px; }
.brand-name { font-weight: 600; font-size: 14px; line-height: 1.25; }
.brand-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.brand-ver { color: var(--dim); font-size: 11px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { padding: 8px 10px; border-radius: 8px; color: var(--muted); }
.nav a:hover { background: var(--bg2); color: var(--text); }
.nav a.active { background: var(--bg3); color: var(--text); }
.user { margin-top: auto; font-size: 13px; color: var(--muted); display: flex; gap: 10px; align-items: center; }
.user img { width: 28px; height: 28px; border-radius: 50%; filter: grayscale(1); }
.user .nm { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user a { color: var(--dim); }
.user a:hover { color: var(--text); }

.main { padding: 32px 40px 64px; max-width: 1100px; width: 100%; }
.loading, .empty { color: var(--muted); padding: 40px 0; }
h1 { font-size: 22px; font-weight: 600; margin: 0 0 6px; }
h2 { font-size: 15px; font-weight: 600; margin: 28px 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.lead { color: var(--muted); margin: 0 0 22px; }
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.head .actions { display: flex; gap: 8px; flex: none; }

.btn { background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; cursor: pointer; font-size: 13px; color: var(--text); }
.btn:hover { background: var(--bg3); }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn.primary:hover { opacity: .9; }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--bg2); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.card { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: block; }
a.card:hover { border-color: var(--muted); }
.card .ttl { font-weight: 600; margin-bottom: 4px; }
.card .prog { color: var(--muted); font-size: 13px; min-height: 2.6em; }
.card .meta { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; font-size: 12px; color: var(--muted); }
.bar { height: 3px; background: var(--bg3); border-radius: 3px; margin-top: 10px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--text); }

.tag { display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.tag.confirmed { border-color: var(--ok); color: var(--ok); }
.tag.expected { border-color: var(--warn); color: var(--warn); }
.tag.unknown { border-style: dashed; }
.tag.postponed, .tag.rejected { opacity: .6; }
.tag.done, .tag.approved, .tag.submitted { border-color: var(--ok); color: var(--ok); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 8px; }
.stat { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat .v { font-size: 26px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 12px; color: var(--muted); margin-top: 4px; }

.month { margin-bottom: 18px; }
.month-h { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1px solid var(--line); padding-bottom: 6px; margin-bottom: 6px; }
.month-h b { font-weight: 600; }
.month-h span { color: var(--dim); font-size: 12px; font-variant-numeric: tabular-nums; }
.month.current .month-h b::before { content: "● "; color: var(--ok); font-size: 9px; vertical-align: 2px; }

.act { display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; align-items: start; padding: 7px 6px; border-radius: 8px; }
.act:hover { background: var(--bg2); }
.act input { margin: 4px 0 0; accent-color: var(--text); width: 15px; height: 15px; cursor: pointer; }
.act .t { line-height: 1.4; }
.act.done .t { color: var(--dim); text-decoration: line-through; }
.act .sub { font-size: 12px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; margin-top: 2px; }
.act .sub a:hover { color: var(--text); text-decoration: underline; }
.act .r { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.act .r .edit { opacity: 0; }
.act:hover .r .edit { opacity: 1; }
.overdue { color: var(--warn); }

.kv { display: grid; grid-template-columns: 170px 1fr; gap: 6px 16px; font-size: 14px; margin: 14px 0 6px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.note { background: var(--bg2); border-left: 2px solid var(--line); padding: 10px 14px; color: var(--muted); font-size: 13px; border-radius: 0 8px 8px 0; margin: 12px 0; }

.files { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.file { display: grid; grid-template-columns: 1fr auto auto; gap: 14px; padding: 9px 14px; border-top: 1px solid var(--line); font-size: 14px; align-items: center; }
.file:first-child { border-top: 0; }
.file:hover { background: var(--bg2); }
.file .n { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file .n::before { content: "▫ "; color: var(--dim); }
.file.folder .n::before { content: "▪ "; }
.file .d, .file .s { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.files-empty { padding: 14px; color: var(--muted); font-size: 13px; }

.comments { display: flex; flex-direction: column; gap: 10px; }
.comment { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
.comment .by { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; margin-bottom: 4px; }
.comment .by a { color: var(--dim); } .comment .by a:hover { color: var(--text); }
.comment p { margin: 0; white-space: pre-wrap; }
.cform { display: flex; gap: 8px; margin-top: 10px; }
.cform textarea { flex: 1; background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; resize: vertical; min-height: 44px; }

.logrow { display: grid; grid-template-columns: 150px 1fr; gap: 14px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.logrow .w { color: var(--dim); font-size: 12px; font-variant-numeric: tabular-nums; }
.logrow .who { color: var(--muted); }

table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:hover td { background: var(--bg2); }

.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.form input, .form select, .form textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
.form textarea { min-height: 70px; resize: vertical; }
.form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form .btns { display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal .box { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 22px; width: min(620px, 100%); max-height: 90vh; overflow: auto; }
.modal h3 { margin: 0 0 14px; font-size: 16px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 8px; font-size: 13px; z-index: 60; }

.login { display: grid; place-items: center; min-height: 70vh; text-align: center; }
.login .box { max-width: 380px; }
.login img { width: 48px; margin-bottom: 14px; opacity: .9; }
.login p { color: var(--muted); }

.cal { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.cal .m { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.cal .m b { display: block; margin-bottom: 8px; }
.cal .m.cur { border-color: var(--muted); }
.cal .dl { display: flex; gap: 8px; font-size: 13px; padding: 3px 0; align-items: baseline; }
.cal .dl .d { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; width: 46px; }
.cal .dl.done { color: var(--dim); text-decoration: line-through; }
.cal .dl a:hover { text-decoration: underline; }

@media (max-width: 760px) {
  #app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 14px 16px; gap: 12px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .user { margin-top: 0; }
  .main { padding: 20px 16px 48px; }
  .kv { grid-template-columns: 1fr; }
  .logrow { grid-template-columns: 1fr; gap: 2px; }
  .form .row { grid-template-columns: 1fr; }
}
