:root {
  --paper: #edf0f4;
  --card: #fbfcfd;
  --ink: #1b2233;
  --muted: #6b7689;
  --line: #cbd2dc;
  --accent: #2f4bdb;
  --p1: #3e8e6b;
  --p2: #e0a100;
  --p3: #d6452f;
  --r: 6px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a { color: var(--accent); }
h1, h2 { line-height: 1.15; margin: 0 0 12px; }
h2 { font-size: 20px; }
.muted { color: var(--muted); font-weight: 400; }
.wrap { max-width: 1280px; margin: 0 auto; padding: 0 20px; }

/* шапка */
.topbar { background: var(--ink); color: #fff; }
.bar { display: flex; align-items: center; justify-content: space-between; height: 52px; }
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 18px; letter-spacing: .01em; }
.nav { display: flex; align-items: center; gap: 20px; }
.nav a, .linkbtn { color: #dfe4ee; text-decoration: none; font: inherit; }
.nav a:hover, .linkbtn:hover { color: #fff; text-decoration: underline; }
.linkbtn { background: none; border: 0; padding: 0; cursor: pointer; }
.nav form { margin: 0; }

/* сообщения */
.flash { margin: 16px 0 0; padding: 10px 14px; border-radius: var(--r); border: 1px solid var(--line); background: var(--card); }
.flash.success { border-color: var(--p1); }
.flash.warning { border-color: var(--p2); }
.flash.danger { border-color: var(--p3); }
.error { color: var(--p3); margin: 0; }

/* карточки и формы */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; margin: 20px 0; }
.auth { max-width: 400px; margin: 10vh auto; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 12px; }
.row > label { flex: 1; }
.wrapit { flex-wrap: wrap; align-items: flex-end; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; font-weight: 600; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
input, select {
  font: inherit; font-weight: 400; color: inherit;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r); background: #fff; min-width: 0;
}
input[type=checkbox] { padding: 0; width: 18px; height: 18px; }
.btn {
  display: inline-block; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  padding: 8px 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--card); color: var(--ink);
}
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #2339b0; }
.btn.small { padding: 4px 10px; font-size: 14px; }

/* месяц */
.monthbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 24px 0 14px; }
.monthbar h1 { font-size: 42px; letter-spacing: -.02em; margin: 0; }
.year { color: var(--muted); font-weight: 400; }
.monthnav { display: flex; gap: 8px; }

.planner { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.cal { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--line); }
.grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; }
.dow > div { background: var(--ink); color: #dfe4ee; padding: 8px; font-size: 14px; font-weight: 600; }
.cal .dow { margin-bottom: 1px; }

.day {
  display: flex; flex-direction: column; gap: 6px; align-items: stretch;
  min-height: 112px; padding: 8px; border: 0; text-align: left; cursor: pointer;
  background: var(--card); color: inherit; font: inherit;
}
.day:hover { background: #fff; }
.day.out { background: #f1f3f7; color: var(--muted); }
.day.sel { outline: 2px solid var(--accent); outline-offset: -2px; background: #fff; }
.num {
  width: 26px; height: 26px; display: grid; place-items: center;
  border-radius: 50%; font-weight: 600; font-variant-numeric: tabular-nums;
}
.day.today .num { background: var(--accent); color: #fff; }

.chips { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.chip {
  display: block; font-size: 12px; line-height: 1.35; padding: 2px 6px;
  border-left: 3px solid var(--pc); background: #eef1f7; border-radius: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chip.done { text-decoration: line-through; opacity: .6; }
.p1 { --pc: var(--p1); } .p2 { --pc: var(--p2); } .p3 { --pc: var(--p3); }
.more { font-size: 12px; color: var(--muted); }

/* панель дня */
.panel { position: sticky; top: 16px; margin: 0; }
.panel h2 { text-transform: none; }
.tasks { list-style: none; margin: 0 0 16px; padding: 0; }
.tasks li {
  display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center;
  padding: 8px 0 8px 10px; border-bottom: 1px solid var(--line); border-left: 3px solid var(--pc);
}
.tasks .title { overflow-wrap: anywhere; }
.tasks .time { display: block; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tasks li.done .title { text-decoration: line-through; color: var(--muted); }
.tasks input[type=checkbox] { margin: 0; cursor: pointer; }
.del { background: none; border: 0; cursor: pointer; color: var(--muted); font-size: 20px; line-height: 1; padding: 4px 8px; border-radius: var(--r); }
.del:hover { color: var(--p3); }

/* админка */
.pagetitle { margin-top: 24px; }
.tablecard { padding: 0; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 14px; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }
.actions .inline { display: flex; gap: 6px; }
.actions .inline input { padding: 4px 8px; font-size: 14px; width: 190px; }

@media (max-width: 960px) {
  .planner { grid-template-columns: 1fr; }
  .panel { position: static; }
}
@media (max-width: 720px) {
  .wrap { padding: 0 10px; }
  .monthbar h1 { font-size: 30px; }
  .day { min-height: 64px; padding: 4px; }
  .dow > div { padding: 6px 2px; text-align: center; font-size: 13px; }
  .chips { flex-direction: row; flex-wrap: wrap; }
  .chip { width: 8px; height: 8px; padding: 0; font-size: 0; border: 0; border-radius: 50%; background: var(--pc); }
  .more { font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* события и редактор */
textarea { font: inherit; font-weight: 400; color: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r); background: #fff; resize: vertical; min-width: 0; }
.chip.event { border-left-color: var(--accent); background: #dfe5ff; font-weight: 600; }
.tasks li.event { --pc: var(--accent); }
.mark { width: 18px; text-align: center; color: var(--accent); font-size: 14px; line-height: 1; }
.tasks .note { display: block; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.tasks .title { cursor: pointer; }
.tasks .title:hover { text-decoration: underline; }
.tasks .edit { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.tasks .edit:hover .title { text-decoration: underline; }
.btn.danger { color: var(--p3); }
.btn.danger:hover { border-color: var(--p3); }
.dlg { width: min(480px, calc(100vw - 24px)); border: 1px solid var(--line); border-radius: var(--r); background: var(--card); color: var(--ink); padding: 20px; }
.dlg::backdrop { background: rgba(27, 34, 51, .45); }
.dlgbtns { display: flex; gap: 8px; align-items: center; }
.spacer { flex: 1; }
@media (max-width: 720px) {
  .chip.event { background: var(--accent); }
}
