:root {
  --paper: #ffffff;   /* фон страницы */
  --card: #faf6ef;    /* карточка: поля и текст на светлобежевом */
  --field: #ffffff;   /* сами поля ввода */
  --ink: #16211f;
  --muted: #5d6b68;
  --line: #ded5c6;
  --accent: #0f6e56;
  --accent-soft: #e3efeb;
  --alert: #a33a2d;
  --warn: #8a5a0b;
  --radius: 6px;

  /* нейтральная бежевая гамма мобильной версии */
  --sand: #efe9df;       /* шапка */
  --sand-deep: #e4dbcb;  /* подложка вкладок */
  --sand-line: #d9cfbd;
  --grey-btn: #e7e2d8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 500; margin: 0 0 4px; }
h2 { font-size: 17px; font-weight: 500; margin: 28px 0 10px; }

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 20px;
  background: var(--sand);
  border-bottom: 1px solid var(--sand-line);
}
.brand { font-weight: 500; color: var(--ink); flex: 1; }
.nav {
  display: flex; gap: 4px; margin: 0 auto;
  background: var(--sand-deep); border: 1px solid var(--sand-line);
  border-radius: 10px; padding: 4px;
}
.nav a {
  color: var(--muted); padding: 7px 16px; border-radius: 8px;
  white-space: nowrap;
}
.nav a:hover { color: var(--ink); text-decoration: none; }
.nav a.here {
  background: var(--field); color: var(--ink);
  box-shadow: 0 1px 2px rgba(30, 24, 12, .12);
}
.who {
  flex: 1; text-align: right; color: var(--muted); font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.who:hover { color: var(--ink); text-decoration: none; }
.who.here { color: var(--ink); font-weight: 500; }
.cabinet-links { display: none; gap: 16px; margin-bottom: 4px; }
/* Личный кабинет: всё по центру узкой колонкой. */
.profile { text-align: center; }
.profile .card-fields { justify-content: center; text-align: left; }
.profile .stack { max-width: 280px; margin: 0 auto; }
.profile .stack label { text-align: left; }
.profile .hint { margin-top: 10px; }
.actions-center { justify-content: center; }
.leave-form { margin-top: 28px; }
.leave-link {
  background: none; border: 0; padding: 0;
  color: var(--alert); font-size: 15px; text-decoration: underline;
  text-underline-offset: 2px; cursor: pointer;
}
.leave-link:hover { background: none; color: #7f2d23; }

.page { max-width: 880px; margin: 24px auto 64px; padding: 0 20px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
}
.card.narrow { max-width: 420px; margin: 0 auto; }
.lead { color: var(--muted); margin: 0; }
.hint { color: var(--muted); font-size: 14px; margin-top: 20px; }

.dayhead, .monthhead {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 20px;
}
.total-pair { display: flex; gap: 26px; }
.total { text-align: right; line-height: 1.1; }
.total-value { display: block; font-size: 34px; font-weight: 500; }
.total-label { font-size: 13px; color: var(--muted); }
.total.over .total-value { color: var(--warn); }
.daynav { display: flex; align-items: center; gap: 10px; }
.daynav-date { margin: 0; }
.daynav-date input {
  font: inherit; font-size: 22px; font-weight: 500; color: var(--ink);
  border: 1px solid transparent; background: none; padding: 2px 6px;
  border-radius: var(--radius); cursor: pointer;
}
.daynav-date input:hover { border-color: var(--line); }
/* Месяц — обычная надпись; настоящее поле прячем под ней и открываем showPicker. */
.monthbtn {
  font: inherit; font-size: 22px; font-weight: 500; color: var(--ink);
  background: none; border: 1px solid transparent; border-radius: var(--radius);
  padding: 2px 10px; cursor: pointer;
}
.monthbtn:hover { background: none; border-color: var(--line); }
.picker-hidden {
  position: absolute; left: 50%; bottom: 0;
  width: 1px; height: 1px; padding: 0; border: 0; opacity: 0; pointer-events: none;
}

.daynav a, .daynav-step {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 4px 16px; font-size: 22px; line-height: 1.3;
  color: var(--ink); text-decoration: none;
}
.daynav a:hover { border-color: var(--accent); text-decoration: none; }
.daynav-step.off { color: var(--line); cursor: default; }

.monthnav { display: flex; gap: 8px; }
.monthnav a {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 2px 10px; color: var(--ink);
}
.monthnav a:hover { border-color: var(--accent); text-decoration: none; }

.rows { display: flex; flex-direction: column; gap: 10px; }
.row { border-left: 2px solid var(--line); padding-left: 12px; }
.row:focus-within { border-left-color: var(--accent); }
.row-main { display: flex; gap: 8px; }
input, select {
  font: inherit; color: var(--ink); background: var(--field);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 7px 10px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input:disabled { background: #f0ece4; color: var(--muted); }
input.task { flex: 1; min-width: 0; }
input.hours { width: 72px; text-align: right; }
input.ue { width: 72px; text-align: right; }
.row-extra { display: flex; gap: 8px; margin-top: 6px; }
input.comment { flex: 1; min-width: 0; font-size: 14px; color: var(--muted); }
input.link { width: 240px; flex: none; font-size: 14px; color: var(--muted); }
a.link { color: var(--accent); }
a.task-name.link { text-decoration: underline; text-underline-offset: 2px; }
.drop {
  border: 1px solid transparent; background: none; color: var(--muted);
  font-size: 18px; line-height: 1; width: 32px; border-radius: var(--radius); cursor: pointer;
}
.drop:hover { color: var(--alert); border-color: var(--line); }

.actions { display: flex; align-items: center; gap: 12px; margin-top: 20px; }
.actions-stack { flex-direction: column; align-items: stretch; gap: 10px; }
.actions-stack button { width: 100%; padding: 12px 14px; }
button, .primary-link {
  font: inherit; padding: 8px 14px; border-radius: var(--radius);
  border: 1px solid transparent; background: var(--grey-btn); color: var(--ink); cursor: pointer;
}
button:hover { background: #ddd6c8; }
.primary, .primary-link {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.primary:hover, .primary-link:hover { background: #0c5a47; text-decoration: none; }

.stack { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.stack label { display: flex; flex-direction: column; gap: 5px; font-size: 14px; color: var(--muted); }
.stack input { font-size: 16px; }
.anon .page {
  min-height: 100vh; margin: 0 auto;
  display: flex; align-items: center; justify-content: center;
}
.signin {
  width: 100%; max-width: 360px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 28px;
}
.signin h1 { text-align: center; margin-bottom: 18px; }
.signin .hint { text-align: center; }
.signin .stack { margin-top: 0; }

.alert, .notice {
  border-radius: var(--radius); padding: 10px 14px; margin: 0 0 18px; font-size: 15px;
}
.alert { background: #fbeceb; color: var(--alert); border: 1px solid #f0cfcb; }
.notice { background: var(--accent-soft); color: var(--accent); border: 1px solid #c6ded6; }
.alert ul { margin: 0; padding-left: 18px; }

.stats { display: flex; gap: 36px; padding: 16px 0 22px; border-bottom: 1px solid var(--line); }
.stat-value { display: block; font-size: 26px; font-weight: 500; }
.stat-label { font-size: 13px; color: var(--muted); }

.days { list-style: none; margin: 0; padding: 0; }
.day {
  display: flex; align-items: baseline; gap: 14px;
  padding: 9px 0 9px 12px; border-bottom: 1px solid var(--line);
  border-left: 2px solid transparent;
}
.day.weekend .day-date { color: var(--muted); }
.day.missing { border-left-color: var(--alert); }
.day-date { width: 96px; flex: none; font-size: 14px; color: var(--muted); }
.day-body { flex: 1; display: flex; flex-wrap: wrap; gap: 6px; color: var(--ink); min-width: 0; }
.day-body:hover { text-decoration: none; }
.day-body.empty { color: var(--muted); }
.day.missing .day-body.empty { color: var(--alert); }
.day-hours { width: 56px; text-align: right; flex: none; font-weight: 500; }
.day-tasks { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.task-line { display: flex; align-items: center; gap: 10px; }
.task-name {
  flex: 1; min-width: 0; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.task-hours { color: var(--muted); font-size: 14px; width: 56px; text-align: right; flex: none; }
.task-ue { color: var(--muted); font-size: 14px; width: 72px; text-align: right; flex: none; }
.task-line input.ue { padding: 4px 8px; font-size: 14px; width: 68px; }
.who-name { font-weight: 500; margin-right: 4px; }

.export { margin-left: auto; }

.table-scroll { overflow-x: auto; margin-bottom: 24px; }
.table-scroll table { margin-bottom: 0; }
table { width: 100%; border-collapse: collapse; margin-bottom: 24px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { font-weight: 500; font-size: 14px; color: var(--muted); }
td.num, th.num { text-align: right; }
td.strong { font-weight: 500; }
tfoot td { font-weight: 500; border-bottom: 0; }
.items .comment { display: block; font-size: 14px; color: var(--muted); margin-top: 2px; }

.export-line { justify-content: center; margin-top: 0; margin-bottom: 22px; }

/* Мой месяц: выбор месяца по центру, недели-аккордеоны. */
.monthpick {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  gap: 14px; margin-bottom: 20px;
}
.total-pair-center { justify-content: center; gap: 40px; margin-bottom: 24px; }
.total-pair-center .total { text-align: center; }
.hint-center { text-align: center; }

.weeks { display: flex; flex-direction: column; }
.week { border-bottom: 1px solid var(--line); }
.week > summary {
  display: flex; align-items: baseline; gap: 12px;
  padding: 11px 0; cursor: pointer; list-style: none;
}
.week > summary::-webkit-details-marker { display: none; }
.week > summary::before { content: "▸"; color: var(--muted); width: 12px; flex: none; }
.week[open] > summary::before { content: "▾"; }
.week > summary:hover .week-name { color: var(--accent); }
.week-name { width: 110px; flex: none; font-weight: 500; }
.week-range { flex: 1; min-width: 0; color: var(--muted); font-size: 14px; }
.week-hours { width: 72px; text-align: right; flex: none; font-weight: 500; }
.week-ue { width: 84px; text-align: right; flex: none; color: var(--muted); }
.week .days { margin: 0 0 12px; }
.week .day { padding-left: 26px; border-bottom: 0; }

.people { display: flex; flex-direction: column; }
.person { border-bottom: 1px solid var(--line); }
.person > summary {
  display: flex; align-items: baseline; gap: 12px;
  padding: 11px 0; cursor: pointer; list-style: none;
}
.person > summary::-webkit-details-marker { display: none; }
.person > summary::before { content: "▸"; color: var(--muted); width: 12px; flex: none; }
.person[open] > summary::before { content: "▾"; }
.person > summary:hover .person-name { color: var(--accent); }
.person-name { width: 230px; flex: none; font-weight: 500; }
.person-meta {
  flex: 1; min-width: 0; color: var(--muted); font-size: 14px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.person-days { width: 62px; text-align: right; flex: none; color: var(--muted); font-size: 14px; }
.person-hours { width: 72px; text-align: right; flex: none; font-weight: 500; }
.person-ue { width: 84px; text-align: right; flex: none; color: var(--muted); }
.person .day-date:hover { color: var(--accent); }
.person .days { margin: 0 0 12px; }
.person .day { padding-left: 26px; border-bottom: 0; }
.person .empty-state { padding: 0 0 12px 26px; font-size: 14px; }

.card-fields {
  display: grid; grid-template-columns: max-content max-content;
  gap: 8px 16px; margin: 0 0 18px;
}
.card-fields dt { color: var(--muted); font-size: 14px; text-align: right; }
.card-fields dd { margin: 0; }
/* Список сотрудников: вся строка — ссылка на карточку, как в сводке. */
.person-row {
  display: flex; align-items: baseline; gap: 12px;
  padding: 11px 0; border-bottom: 1px solid var(--line); color: var(--ink);
}
.person-row:hover { text-decoration: none; }
.person-row:hover .person-name { color: var(--accent); }
.person-row.off { color: var(--muted); }
.person-login { width: 110px; flex: none; color: var(--muted); font-size: 14px; }
.person-role { width: 110px; flex: none; color: var(--muted); font-size: 14px; }
.person-state { width: 90px; text-align: right; flex: none; color: var(--muted); font-size: 14px; }

.history { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.history li { display: flex; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.history .when { color: var(--muted); width: 130px; flex: none; }
.empty-state { color: var(--muted); }

@media (max-width: 600px) {
  /* Телефон: две вкладки во всю ширину, ФИО справа сверху. */
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 12px 12px; }
  .brand { display: none; }
  .nav-wide { display: none; }

  .who {
    order: 1; width: 100%; flex: none;
    font-size: 15px; color: var(--ink); font-weight: 500;
  }
  .nav { order: 2; width: 100%; margin: 0; }
  .nav a { flex: 1; text-align: center; font-size: 16px; padding: 10px 0; }
  .cabinet-links { display: flex; }

  .page { padding: 0 12px; margin: 14px auto 40px; }
  .card { padding: 16px; }

  /* Форма дня: дата по центру, под ней сообщение, часы и УЕ, задачи, кнопки. */
  .dayhead { flex-direction: column; align-items: stretch; gap: 12px; }
  .daynav { justify-content: space-between; }
  .daynav-date { flex: 1; text-align: center; }
  .daynav-date input { font-size: 20px; text-align: center; }
  .monthbtn { font-size: 20px; }
  .daynav-step { padding: 4px 13px; font-size: 20px; }
  .dayhead .lead { text-align: center; font-size: 15px; }
  .total-pair { justify-content: center; gap: 24px; }
  .total { text-align: center; }
  .total-value { font-size: 26px; }

  .row-main { flex-wrap: wrap; }
  input.task { flex: 1 1 100%; }
  input.hours, input.ue { flex: 1 1 0; width: auto; }
  .row-extra { flex-direction: column; }
  input.link { width: 100%; }
  input, select, button { font-size: 16px; }   /* iOS иначе увеличивает страницу при фокусе */
  .drop { width: 44px; height: 40px; }


  .stats { gap: 20px; flex-wrap: wrap; }

  .day { flex-wrap: wrap; }
  .day-date { width: 72px; }
  .task-hours { width: 44px; }
  .person-name { width: 100%; }
  .person-meta { display: none; }
  .person-login, .person-role { display: none; }
  .week-name { width: 86px; }
  .week-range { display: none; }
  .total-pair-center { gap: 28px; }

  .card-fields { grid-template-columns: 1fr; gap: 2px 0; }
  .card-fields dt { text-align: center; }
  .profile .card-fields { text-align: center; }
  .card-fields dd { margin-bottom: 8px; }
}
