:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #1b1d21;
  --muted: #6b7280;
  --line: #e3e6ea;
  --accent: #2f6df6;
  --accent-soft: #e8f0ff;
  --ok: #17864b;
  --warn: #b45309;
  --danger: #c02626;
  --rowh: 54px;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 10px; line-height: 1.25; }
h2 { font-size: 17px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

/* --- шапка --- */
.topbar {
  display: flex; align-items: center; gap: 22px;
  padding: 0 22px; height: 56px;
  background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; font-size: 16px; color: var(--ink); letter-spacing: -0.2px; }
.brand:hover { text-decoration: none; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a {
  padding: 6px 11px; border-radius: 7px; color: var(--muted); font-size: 14px;
}
.topbar nav a:hover { background: var(--bg); text-decoration: none; color: var(--ink); }
.topbar nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.who { color: var(--ink); font-size: 14px; }
.new-btn {
  background: var(--accent); color: #fff; padding: 7px 13px;
  border-radius: 7px; font-size: 14px; font-weight: 600;
}
.new-btn:hover { text-decoration: none; background: #2559d6; }
.linkbtn { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 14px; padding: 0; }
.linkbtn:hover { color: var(--ink); }

/* --- каркас --- */
.wrap { max-width: 1400px; margin: 0 auto; padding: 22px; }
.centered { max-width: 420px; margin: 8vh auto; padding: 22px; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; margin-top: 12px; }
.page-title { font-size: 22px; margin-bottom: 16px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; margin-bottom: 18px;
}

.flashes { margin-bottom: 14px; }
.flash {
  padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; font-size: 14px;
  background: #e9f7ef; color: var(--ok); border: 1px solid #c7ead6;
}
.flash.error { background: #fdecec; color: var(--danger); border-color: #f5cfcf; }

/* --- формы --- */
.form label, .login label { display: block; margin-bottom: 14px; font-size: 13px; color: var(--muted); }
input[type=text], input[type=password], input[type=email], input[type=number],
input[type=date], input[type=datetime-local], input:not([type]), select, textarea {
  display: block; width: 100%; margin-top: 5px;
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  font: inherit; color: var(--ink); background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { resize: vertical; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > label { flex: 1 1 180px; }
.check-inline { display: flex; align-items: center; gap: 7px; align-self: center; margin-top: 6px; }
.check-inline input { width: auto; margin: 0; }

button, .btn {
  display: inline-block; padding: 9px 16px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  font: inherit; cursor: pointer;
}
button:hover, .btn:hover { background: var(--bg); text-decoration: none; }
button.primary, .primary.btn { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { background: #2559d6; }
button.primary.warn { background: var(--warn); border-color: var(--warn); }
button.danger { color: var(--danger); border-color: #f0cccc; }
button:disabled { opacity: .45; cursor: default; }
.actions { display: flex; gap: 10px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.inline { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.mini { padding: 4px 9px; font-size: 13px; border-radius: 6px; }
.mini.ok { background: var(--ok); border-color: var(--ok); color: #fff; }

.login h1 { margin-bottom: 2px; }
.login p { margin-top: 0; margin-bottom: 18px; }
.login button { width: 100%; }

.people {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px;
  max-height: 190px; overflow-y: auto; padding: 4px;
}
.person {
  display: flex !important; align-items: center; gap: 7px; margin: 0 !important;
  padding: 6px 11px; border: 1px solid var(--line); border-radius: 20px;
  background: #fff; cursor: pointer; font-size: 14px; color: var(--ink);
}
.person input { width: auto; margin: 0; }
.person:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.person i { color: var(--muted); font-style: normal; font-size: 12px; }

/* --- панель навигации по датам --- */
.toolbar { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.nav-dates { display: flex; gap: 6px; }
.chip {
  padding: 6px 12px; border: 1px solid var(--line); border-radius: 7px;
  background: #fff; color: var(--ink); font-size: 14px;
}
.chip:hover { background: var(--accent-soft); text-decoration: none; }
.period { font-size: 18px; margin: 0; }
.dept-filter { margin-left: auto; }
.dept-filter select { width: auto; margin: 0; }

/* --- сетка календаря --- */
.grid {
  --cols: 7;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
.grid.team { overflow-x: auto; }
.grid-head, .grid-body {
  display: grid;
  grid-template-columns: 56px repeat(var(--cols), minmax(110px, 1fr));
  min-width: min-content;
}
.grid-head {
  background: var(--card); border-bottom: 1px solid var(--line);
}
.corner { border-right: 1px solid var(--line); }
.dayhead {
  padding: 9px 8px; text-align: center; border-right: 1px solid var(--line);
  font-size: 13px; display: flex; flex-direction: column; gap: 2px;
}
.dayhead .dow { font-weight: 600; }
.dayhead .sub { color: var(--muted); font-size: 11px; }
.dayhead.weekend { background: #fafbfc; color: var(--muted); }
.dayhead.is-today { color: var(--accent); }
.dayhead.is-today .dow::after { content: " ·"; }
.dayhead.is-me { background: var(--accent-soft); }

.hours { border-right: 1px solid var(--line); }
.hour {
  height: var(--rowh); position: relative;
  border-bottom: 1px solid var(--line);
}
.hour span {
  position: absolute; top: 3px; right: 7px;
  font-size: 11px; color: var(--muted); background: var(--card); padding: 0 2px;
}

.col { position: relative; border-right: 1px solid var(--line); height: calc(var(--rows) * var(--rowh)); }
.slots { display: flex; flex-direction: column; height: 100%; }
.slot { flex: 1 1 0; border-bottom: 1px dashed #eef0f3; }
.slot:nth-child(even) { border-bottom-style: solid; border-bottom-color: var(--line); }
.slot:hover { background: var(--accent-soft); }

.events { position: absolute; inset: 0; pointer-events: none; }
.ev {
  position: absolute; pointer-events: auto; overflow: hidden;
  background: var(--accent); color: #fff; border-radius: 6px;
  padding: 3px 6px; font-size: 12px; line-height: 1.3;
  display: flex; flex-direction: column; box-shadow: 0 1px 2px rgba(0,0,0,.12);
}
.ev:hover { text-decoration: none; filter: brightness(1.07); }
.ev-time { font-size: 11px; opacity: .85; flex: none; }
.ev-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev.short { flex-direction: row; align-items: baseline; gap: 5px; padding: 2px 6px; }
.ev.short .ev-time { line-height: 1.1; }
.ev.tentative { background: #fff; color: var(--ink); border: 1px dashed var(--accent); }
.ev.tentative .ev-time { opacity: .7; }
.ev.free { background: #8b93a1; }
.ev.muted { background: #7d8896; }
.ev.muted.tentative { background: #fff; border-color: #7d8896; }

/* --- приглашения --- */
.pending {
  background: #fff8e8; border: 1px solid #f0dfb8;
  border-radius: var(--radius); padding: 14px 18px; margin-bottom: 16px;
}
.pending-title { font-weight: 600; margin-bottom: 8px; font-size: 14px; }
.pending-row {
  display: flex; justify-content: space-between; align-items: center;
  gap: 14px; padding: 6px 0; flex-wrap: wrap;
}
.pending-row .muted { font-size: 13px; display: block; }
.pending-actions { display: flex; gap: 7px; align-items: center; }

/* --- карточка события --- */
.event-card { max-width: 660px; }
.event-meta div { padding: 6px 0; border-bottom: 1px solid var(--line); }
.k { display: inline-block; min-width: 110px; color: var(--muted); font-size: 13px; }
.participants { margin: 16px 0; }
.participants ul { list-style: none; padding: 0; margin: 8px 0 0; }
.participants li { padding: 4px 0; }
.tag {
  font-style: normal; font-size: 11px; padding: 2px 7px; border-radius: 10px;
  background: var(--bg); color: var(--muted); margin-left: 6px;
}
.tag.ok { background: #e9f7ef; color: var(--ok); }
.tag.no { background: #fdecec; color: var(--danger); }
.tag.wait { background: #fff6e5; color: var(--warn); }

.conflict {
  background: #fff6e5; border: 1px solid #f0dfb8; border-radius: var(--radius);
  padding: 14px 18px; margin-bottom: 16px;
}
.conflict ul { margin: 8px 0; padding-left: 20px; }

/* --- подбор слотов --- */
.slots-result { display: flex; flex-direction: column; gap: 12px; }
.slot-day {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 18px;
}
.slot-day h3 { font-size: 14px; color: var(--muted); margin-bottom: 10px; }
.slot-list { display: flex; flex-wrap: wrap; gap: 8px; }
.slot-chip {
  padding: 7px 13px; border: 1px solid var(--accent); border-radius: 20px;
  background: var(--accent-soft); color: var(--accent); font-size: 14px; font-weight: 500;
}
.slot-chip:hover { background: var(--accent); color: #fff; text-decoration: none; }

/* --- настройки, админка --- */
.feed-url {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 11px 14px; margin: 10px 0; word-break: break-all;
}
.steps { padding-left: 22px; color: var(--ink); }
.steps li { margin-bottom: 6px; }

.people-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.people-table th {
  text-align: left; font-size: 12px; color: var(--muted);
  font-weight: 600; padding: 8px; border-bottom: 1px solid var(--line);
}
.people-table td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.people-table tr.off { opacity: .55; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.row-actions input { width: 130px; margin: 0; padding: 4px 8px; font-size: 13px; }

@media (max-width: 760px) {
  .topbar { gap: 10px; padding: 0 12px; overflow-x: auto; }
  .topbar nav a { padding: 6px 8px; }
  .wrap { padding: 12px; }
  .grid { overflow-x: auto; }
  .grid-head { position: static; }
  .row > label { flex: 1 1 100%; }
}
