:root {
  --text: #1f2933;
  --muted: #5f6c7b;
  --background: #f5f7f8;
  --surface: #ffffff;
  --border: #d5dbe1;
  --accent: #0f766e;
  --error: #b42318;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--background);
  line-height: 1.5;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

a { color: var(--accent); }
.topbar nav { display: flex; flex-wrap: wrap; gap: 4px 16px; flex: 1 1 100%; }
.topbar form { margin: 0 0 0 auto; }
.user-name { color: var(--muted); font-size: 14px; }

main { max-width: 720px; margin: 0 auto; padding: 24px 16px; }
main.narrow { max-width: 420px; }

.card {
  padding: 24px;
  background: var(--surface);
  border-radius: 8px;
}

h1 { margin: 0 0 12px; font-size: 24px; line-height: 1.25; }
p { margin: 0 0 12px; }
ul { margin: 0; padding-left: 20px; }

label { display: block; margin: 16px 0 4px; font-weight: 600; }

input[type="text"],
input[type="password"],
input[type="date"],
input[type="time"],
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  /* 16px не даёт телефону увеличивать страницу при вводе. */
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

button {
  min-height: 44px;
  padding: 8px 16px;
  font-size: 16px;
  color: #ffffff;
  background: var(--accent);
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

button.quiet {
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--border);
}

.card form button[type="submit"] { width: 100%; margin-top: 20px; }
.error { color: var(--error); }
.muted { color: var(--muted); }

h2 { margin: 24px 0 8px; font-size: 18px; }

.button {
  display: block;
  min-height: 44px;
  padding: 10px 16px;
  color: #ffffff;
  text-align: center;
  text-decoration: none;
  background: var(--accent);
  border-radius: 6px;
}

button.danger { color: var(--error); background: transparent; border: 1px solid var(--error); }
.inline-form button[type="submit"] { margin-top: 0; }
.form-back { margin: 16px 0 0; text-align: center; }

.notice { margin: 0 0 16px; padding: 10px 12px; border-radius: 6px; background: #e6f4f1; }
.notice.error { color: var(--error); background: #fdecea; }
.notice.info { background: #eef1f4; }

/* Статусы смен. Цвет дублируется подписью в легенде и в списке смен. */
.status-entered { --status: #b7791f; --status-bg: #fdf3d8; }
.status-approved { --status: #1f7a4d; --status-bg: #dcf3e6; }
.status-closed { --status: #52606d; --status-bg: #e4e8ec; }
.status-rejected { --status: #b42318; --status-bg: #fde3e0; }

.month-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.month-head h1 { margin: 0; font-size: 20px; text-align: center; }
.month-nav {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; font-size: 24px; color: var(--accent);
  text-decoration: none; border: 1px solid var(--border); border-radius: 6px;
}

.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; margin: 16px 0 12px; }
.cal-weekday { padding: 4px 0; font-size: 12px; color: var(--muted); text-align: center; }
.cal-cell {
  display: flex; flex-direction: column; gap: 2px;
  min-height: 52px; padding: 2px; color: var(--text);
  text-decoration: none; background: var(--background); border-radius: 4px;
}
.cal-outside { background: transparent; }
.cal-free:hover { outline: 1px solid var(--accent); }
.cal-today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-number { font-size: 13px; text-align: center; }
.cal-shift {
  display: block; padding: 3px 0; font-size: 11px; line-height: 1.2; text-align: center;
  color: var(--status); text-decoration: none; background: var(--status-bg);
  border-left: 3px solid var(--status); border-radius: 3px;
}
.cal-shift.status-rejected { text-decoration: line-through; }

.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: 0 0 12px; padding: 0; font-size: 13px; list-style: none; }
.swatch { display: inline-block; width: 12px; height: 12px; margin-right: 6px; background: var(--status); border-radius: 3px; }
.totals { margin: 0; }

.shift-list, .history, .changes { padding: 0; list-style: none; }
.shift-list li { border-top: 1px solid var(--border); }
.shift-list a { display: block; padding: 10px 0; color: var(--text); text-decoration: none; }
.shift-list .muted { display: block; margin-left: 18px; font-size: 14px; }

fieldset.choice { margin: 16px 0 0; padding: 0; border: 0; }
fieldset.choice legend { margin-bottom: 4px; padding: 0; font-weight: 600; }
.choice-item {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; margin: 0 8px 0 0;
  padding: 0 16px; font-weight: 400; border: 1px solid var(--border); border-radius: 6px;
}
.choice-item[hidden] { display: none; }

#shift-hours { margin: 12px 0 0; }
.custom-hours { margin-top: 16px; }
.custom-hours summary { min-height: 32px; color: var(--accent); cursor: pointer; }
.custom-hours > .muted { margin: 8px 0 0; font-size: 14px; }
.time-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.details { display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; margin: 0 0 16px; }
.details dt { color: var(--muted); }
.details dd { margin: 0; overflow-wrap: anywhere; }

.history > li { padding: 12px 0; border-top: 1px solid var(--border); }
.history p { margin: 0 0 4px; overflow-wrap: anywhere; }
.history .muted { font-size: 14px; }
.changes li { font-size: 14px; overflow-wrap: anywhere; }
.pager { display: flex; justify-content: space-between; gap: 12px; margin: 12px 0 0; }

/* Экраны управляющего */
.actions-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.actions-row > * { flex: 1 1 140px; }
.actions-row form button[type="submit"] { width: 100%; margin-top: 0; }
.quiet-button { color: var(--accent); background: transparent; border: 1px solid var(--border); }

.pharmacy-list { padding: 0; list-style: none; }
.pharmacy-list li { padding: 12px 0; border-top: 1px solid var(--border); }
.pharmacy-name { font-weight: 600; }

.day-list { margin: 0; padding: 0; list-style: none; }
.day-row { display: flex; gap: 8px; padding: 6px 0; border-top: 1px solid var(--border); }
.day-row.weekend .day-label { color: var(--error); }
.day-row.today { background: #eef7f5; }
.day-label { flex: 0 0 52px; font-size: 14px; }
.slots { display: flex; flex: 1 1 auto; flex-direction: column; gap: 4px; min-width: 0; }
.slot { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.slot-kind { flex: 0 0 40px; font-size: 12px; color: var(--muted); }
.chip {
  display: inline-block; max-width: 100%; padding: 4px 8px; font-size: 14px;
  color: var(--status); text-decoration: none; overflow-wrap: anywhere;
  background: var(--status-bg); border-left: 3px solid var(--status); border-radius: 4px;
}
.chip.status-rejected { text-decoration: line-through; }
.slot-add {
  display: inline-flex; align-items: center; min-height: 32px; padding: 0 8px;
  font-size: 13px; border: 1px dashed var(--border); border-radius: 4px;
}
.slot-open .slot-add:only-of-type { color: var(--error); border-color: var(--error); }

table.summary { width: 100%; border-collapse: collapse; font-size: 14px; }
table.summary th, table.summary td { padding: 6px 4px; text-align: left; border-top: 1px solid var(--border); }
table.summary th:not(:first-child), table.summary td:not(:first-child) { text-align: right; }

.queue { margin: 0 0 8px; padding: 0; list-style: none; }
.queue > li { padding: 10px 0; border-top: 1px solid var(--border); }
.queue > li.has-conflict { background: #fff7f5; }
.queue-item { display: flex; gap: 12px; margin: 0; font-weight: 400; }
.queue-item input { flex: 0 0 auto; width: 24px; height: 24px; margin-top: 2px; }
.queue-links { display: flex; gap: 16px; margin: 4px 0 0 36px; font-size: 14px; }
.tag { padding: 1px 6px; font-size: 12px; background: #eef1f4; border-radius: 4px; }

/* Расхождения */
.issue-list { margin: 0 0 8px; padding: 0; list-style: none; }
.issue-list > li { padding: 10px 0; overflow-wrap: anywhere; border-top: 1px solid var(--border); }
.issue-list .error { margin: 4px 0 0; }
.issue-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.slot-empty { color: var(--error); border-color: var(--error); }
.month-head h1 { overflow-wrap: anywhere; }

/* Сводка директора */
.network-totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin: 0 0 8px; }
.network-totals div { padding: 8px; background: #f6f8fa; border-radius: 6px; }
.network-totals dt { font-size: 13px; color: var(--muted); }
.network-totals dd { margin: 0; font-size: 20px; font-weight: 600; }
.pharmacy-list.network .actions-row > * { flex-basis: 110px; }
.pharmacy-list li.is-overdue { background: #fff7f5; }
.tag-closed { background: #e6f4ea; }
.tag-ready { background: #e8f0fe; }
.tag-late { color: #fff; background: var(--error); }
/* Сотрудники и журнал */
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0 12px; align-items: end; margin: 0 0 12px; }
.filters button { margin-top: 12px; }
.filter-box { margin: 0 0 12px; }
.filter-box summary { min-height: 32px; color: var(--accent); cursor: pointer; }
.checks .choice-item { margin-bottom: 6px; }
.credentials code { font-size: 20px; letter-spacing: 1px; overflow-wrap: anywhere; }
a.user-name { text-decoration: none; }