:root {
  color-scheme: light;
  --ink: #1f2933;
  --muted: #7b8794;
  --line: #e4e9f0;
  --bg: #f6f8fb;
  --card: #ffffff;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --ok-bg: #dcfce7; --ok-ink: #166534;
  --warn-bg: #fef3c7; --warn-ink: #92400e;
  --err-bg: #fee2e2; --err-ink: #991b1b;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.04);
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.wrap { width: 100%; margin: 0 auto; padding: 0 32px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 24px 0 4px; }
h2 { font-size: 18px; margin: 22px 0 10px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Topbar */
.topbar { background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; gap: 20px; height: 58px; }
.brand { font-weight: 700; font-size: 17px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 6px; }
.nav a { padding: 6px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--bg); text-decoration: none; }
.nav a.active { background: #eef2ff; color: var(--accent); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user-name { font-weight: 600; font-size: 14px; }
.badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; letter-spacing: .02em; }
.badge.ok { background: var(--ok-bg); color: var(--ok-ink); }
.badge.off { background: #eceff3; color: var(--muted); }

/* Cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }

/* Forms */
label { display: block; font-size: 13px; font-weight: 600; margin: 10px 0 4px; color: #52606d; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
textarea { resize: vertical; min-height: 70px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 160px; }
.inline { display: inline; }
.form-actions { margin-top: 14px; display: flex; gap: 10px; align-items: center; }

/* Buttons */
.btn { -webkit-appearance: none; appearance: none; display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 8px; border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; background: var(--accent); color: #fff; }
.btn:hover { background: var(--accent-dark); color: #fff; text-decoration: none; }
.btn-sm { padding: 5px 11px; font-size: 13px; }
.btn-ghost { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--bg); color: var(--ink); }
.btn-danger { background: var(--card); color: var(--err-ink); border-color: #f3c2c2; }
.btn-danger:hover { background: var(--err-bg); color: var(--err-ink); }
.btn-success { background: #16a34a; color: #fff; }
.btn-success:hover { background: #15803d; color: #fff; }

/* Flash */
.flash { padding: 11px 16px; border-radius: 8px; margin: 18px 0 0; font-weight: 500; }
.flash-success { background: var(--ok-bg); color: var(--ok-ink); }
.flash-error { background: var(--err-bg); color: var(--err-ink); }
.flash-info { background: #dbeafe; color: #1e40af; }

/* Tables / lists */
.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: none; }
.list-item .grow { flex: 1; min-width: 0; }
.report-row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; background: #fff; }
.report-row:hover { border-color: #c7d2fe; }

/* Chips / tags */
.chip { display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; padding: 2px 8px; border-radius: 6px; background: #eef2ff; color: #3730a3; }
.chip.commit { background: #ecfdf5; color: #065f46; }
.chip.merge_request { background: #eff6ff; color: #1e40af; }
.chip.issue { background: #fef3c7; color: #92400e; }
.chip.comment { background: #f3f4f6; color: #4b5563; }
.chip.gitlab { background: #fce7d6; color: #9a3412; }
.status { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; text-transform: capitalize; }
.status.draft { background: #eceff3; color: var(--muted); }
.status.compiled { background: #dbeafe; color: #1e40af; }
.status.final { background: var(--ok-bg); color: var(--ok-ink); }
.status.open { background: #eceff3; color: var(--muted); }
.status.in_progress { background: #fef3c7; color: #92400e; }
.status.done { background: var(--ok-bg); color: var(--ok-ink); }

/* Auth screens */
.auth-wrap { max-width: 400px; margin: 60px auto; }
.auth-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 28px; }
.auth-card h1 { margin-top: 0; text-align: center; }
.auth-alt { text-align: center; margin-top: 16px; font-size: 14px; }

/* Misc */
.footer { color: var(--muted); font-size: 13px; text-align: center; padding: 30px 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.spacer { flex: 1; }
.empty { text-align: center; color: var(--muted); padding: 30px; }
.kv { display: flex; gap: 8px; font-size: 13px; color: var(--muted); margin-top: 2px; flex-wrap: wrap; }
.activity-title {
  font-weight: 700; margin: 4px 0 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%;
}
.activity-details { margin-top: 6px; }
.activity-details > summary { cursor: pointer; color: var(--muted); font-size: 12px; font-weight: 600; list-style: none; }
.activity-details > summary::-webkit-details-marker { display: none; }
.wp-list-details > summary { cursor: pointer; list-style: none; }
.wp-list-details > summary::-webkit-details-marker { display: none; }
.wp-list-details > summary::before { content: "▸ "; color: var(--muted); font-size: 13px; }
.wp-list-details[open] > summary::before { content: "▾ "; }
.richtext-preview { margin-top: 8px; font-size: 14px; }
.richtext-preview img { max-width: 100%; border-radius: 6px; margin: 4px 0; }
.richtext-preview table { border-collapse: collapse; max-width: 100%; margin: 4px 0; }
.richtext-preview td, .richtext-preview th { border: 1px solid var(--line); padding: 6px 9px; }
.richtext-preview p { margin: 0 0 8px; }
.richtext-preview p:last-child { margin-bottom: 0; }
.richtext-preview h1, .richtext-preview h2, .richtext-preview h3, .richtext-preview h4 { margin: 10px 0 6px; }
.richtext-preview ul, .richtext-preview ol { margin: 4px 0 8px; padding-left: 22px; }
.richtext-preview blockquote { margin: 6px 0; padding: 2px 12px; border-left: 3px solid var(--line); color: var(--muted); }
.richtext-preview code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: .9em; }
.richtext-preview pre { background: var(--bg); padding: 10px 12px; border-radius: 8px; overflow-x: auto; }
.richtext-preview pre code { background: none; padding: 0; }
.richtext-preview hr { border: none; border-top: 1px solid var(--line); margin: 10px 0; }

/* Markdown editor (activity "additional details") */
.mdedit { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.mdedit-toolbar { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 6px; border-bottom: 1px solid var(--line); background: var(--bg); }
.mdedit-sep { width: 1px; align-self: stretch; background: var(--line); margin: 2px 2px; }
.md-btn {
  -webkit-appearance: none; appearance: none; border: 1px solid transparent; background: transparent;
  color: var(--ink); font: inherit; font-size: 12px; font-weight: 600; padding: 5px 8px; border-radius: 6px; cursor: pointer;
}
.md-btn:hover { background: var(--card); border-color: var(--line); }
.md-btn.active { background: #eef2ff; border-color: #c7d2fe; color: var(--accent); }
.mdedit-input {
  border: none; border-radius: 0; min-height: 120px; max-height: 460px;
  font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.mdedit-input:focus { box-shadow: none; }
.mdedit-images {
  display: grid; gap: 10px; padding: 10px 11px; border-top: 1px solid var(--line); background: #fcfcfd;
}
.mdedit-images[hidden] { display: none; }
.mdedit-image-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.mdedit-image-item {
  display: grid; gap: 6px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
}
.mdedit-image-item img {
  display: block; width: 100%; max-height: 180px; object-fit: contain; border-radius: 6px; background: var(--bg);
}
.mdedit-image-label { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mdedit-preview { padding: 10px 11px; min-height: 120px; margin-top: 0; }

/* Compact activity edit / add form: fields flow into a responsive grid */
.list-item { flex-wrap: wrap; }
.list-item .grow { flex: 1 1 300px; }
.act-form { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: flex-start; }
.act-form .field { flex: 1 1 180px; min-width: 0; }
.act-form .field label { margin-top: 0; }
.act-form .field-wide { flex-basis: 100%; }
.act-form .field-proj { flex: 1 1 220px; }
.act-form .field-sm { flex: 0 1 130px; }
.pill-stat { display: inline-flex; flex-direction: column; align-items: center; background: var(--bg); border-radius: 10px; padding: 10px 18px; min-width: 90px; }
.pill-stat b { font-size: 20px; color: var(--accent); }
.pill-stat span { font-size: 11px; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; }
.stat-row { display: flex; gap: 12px; flex-wrap: wrap; margin: 6px 0 4px; }

/* Report detail page: denser layout so more fits above the fold */
.report-page .card { padding: 14px 18px; margin-bottom: 12px; }
.report-page .card-head { margin-bottom: 8px; }
.report-page h2 { margin: 0 0 4px; }
.report-page .list-item { padding: 8px 0; }
.stat-strip { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 6px; font-size: 13px; color: var(--muted); }
.stat-strip b { color: var(--ink); font-weight: 700; }
.activity-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.activity-row .activity-title { flex: 1 1 220px; margin: 0; min-width: 0; }
.activity-row .kv { margin-top: 0; flex: 0 1 auto; }

/* Projects page: same denser layout as the report page */
.projects-page .card { padding: 14px 18px; margin-bottom: 12px; }
.projects-page .card-head { margin-bottom: 8px; }
.projects-page h2 { margin: 0 0 4px; }
.projects-page h3 { margin: 10px 0 6px; }
.projects-page .list-item { padding: 8px 0; }

/* Yearly report calendar */
.cal-head { display: flex; align-items: center; justify-content: center; gap: 16px; margin-bottom: 10px; }
.cal-head h2 { min-width: 64px; text-align: center; }
.cal-legend { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; margin-bottom: 20px; font-size: 12px; color: var(--muted); }
.legend-item { display: flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.dot.current { background: var(--accent); }
.dot.done { background: #16a34a; }
.dot.missing { background: #dc2626; }
.dot.future { background: #cbd5e1; }

.year-calendar { display: flex; flex-direction: column; gap: 6px; }
.cal-month-row { display: flex; align-items: center; gap: 12px; padding: 4px 0; border-bottom: 1px solid var(--line); }
.cal-month-row:last-child { border-bottom: none; }
.cal-month-label { flex: 0 0 88px; font-size: 13px; font-weight: 600; color: var(--muted); }
.cal-weeks { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.week-box {
  -webkit-appearance: none; appearance: none; cursor: pointer; text-align: center;
  display: flex; align-items: center; justify-content: center;
  width: 52px; height: 36px; border-radius: 7px; border: 1px solid transparent;
  font: inherit; font-size: 12px; font-weight: 700; color: #fff;
}
.week-box:hover { text-decoration: none; filter: brightness(1.08); transform: translateY(-1px); }
.week-box.status-current { background: var(--accent); }
.week-box.status-done { background: #16a34a; }
.week-box.status-missing { background: #dc2626; }
.week-box.status-future { background: #e2e8f0; color: #64748b; }
@media (max-width: 700px) {
  .cal-month-label { flex-basis: 66px; font-size: 12px; }
  .week-box { width: 40px; height: 32px; font-size: 11px; }
}

/* Edit-activity modal */
dialog.modal {
  position: relative; border: none; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px; width: min(1080px, 96vw); max-height: 86vh; overflow: auto; margin: auto;
}
dialog.modal::backdrop { background: rgba(15, 23, 42, .45); }
dialog.modal h3 { margin: 0 0 14px; padding-right: 26px; }
.modal-close {
  position: absolute; top: 14px; right: 16px; border: none; background: transparent;
  font-size: 20px; line-height: 1; cursor: pointer; color: var(--muted); padding: 4px;
}
.modal-close:hover { color: var(--ink); }
