:root {
  --bg: #f7f6f2;
  --card: #ffffff;
  --text: #1c1d1a;
  --muted: #61645d;
  --line: #e3e1d9;
  --accent: #3f6f58;
  --accent-soft: #e8f0eb;
  --danger: #a33a2a;
  --radius: 14px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141614; --card: #1d201d; --text: #ecebe6; --muted: #a3a69e; --line: #2f332f;
    --accent: #7fb398; --accent-soft: #23302a; --danger: #e07a68; color-scheme: dark;
  }
  .logo, .boot-logo { filter: invert(1); }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
h1 { font-size: 26px; line-height: 1.25; margin: 0 0 8px; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 18px; margin: 0 0 12px; font-weight: 600; }
p { margin: 0 0 12px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }

.boot { min-height: 100vh; display: grid; place-items: center; }
.boot-logo { width: 180px; opacity: .8; }

/* ---------- buttons and fields ---------- */
button, .btn {
  font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 12px; padding: 12px 18px; min-height: 48px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
}
button:hover, .btn:hover { border-color: var(--muted); }
button:disabled { opacity: .6; cursor: default; }
.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.primary:hover { border-color: var(--accent); filter: brightness(1.05); }
@media (prefers-color-scheme: dark) { .primary { color: #10170f; } }
.link-btn { border: 0; background: none; color: var(--accent); padding: 8px 0; min-height: 0; }
.danger { color: var(--danger); }
.danger-fill { background: var(--danger); border-color: var(--danger); color: #fff; }
.wide { width: 100%; }
label { display: block; font-size: 14px; color: var(--muted); margin: 0 0 6px; }
input[type=email], input[type=text], input[type=tel], input[inputmode=numeric] {
  font: inherit; width: 100%; padding: 12px 14px; min-height: 48px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
}
input:focus, button:focus-visible, .btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.code-input { letter-spacing: .4em; font-size: 22px !important; text-align: center; }
.field { margin-bottom: 16px; }
.error { color: var(--danger); font-size: 14px; margin: 8px 0 0; min-height: 1px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: flex; flex-direction: column; align-items: center;
  padding: calc(32px + var(--safe-t)) 20px calc(24px + var(--safe-b)); }
.login-box { width: 100%; max-width: 400px; margin: auto 0; }
.login .logo { width: 170px; display: block; margin: 0 0 40px; }
.login-foot { width: 100%; max-width: 400px; display: flex; justify-content: space-between;
  align-items: center; margin-top: 32px; font-size: 14px; }
.lang-switch { display: flex; gap: 4px; }
.lang-switch button { min-height: 36px; padding: 4px 10px; font-size: 14px; border-radius: 8px; }
.lang-switch button[aria-pressed=true] { background: var(--accent-soft); border-color: var(--accent); }
.become { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); }
.dev-note { background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin: 12px 0 0; }

/* ---------- app shell: bottom bar on phones, side menu on computers ---------- */
.shell { min-height: 100vh; }
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--card); border-top: 1px solid var(--line); display: flex;
}
.nav .logo, .nav a.nav-user { display: none; }
.nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 12px; color: var(--muted); text-decoration: none;
}
.nav a svg { width: 24px; height: 24px; }
.nav a[aria-current=page] { color: var(--accent); font-weight: 600; }
.main { padding: calc(20px + var(--safe-t)) 20px calc(var(--nav-h) + var(--safe-b) + 24px); }
.content { max-width: 720px; margin: 0 auto; }

@media (min-width: 900px) {
  .nav {
    top: 0; right: auto; width: 248px; height: auto; flex-direction: column; gap: 4px;
    border-top: 0; border-right: 1px solid var(--line); padding: 28px 16px; justify-content: flex-start;
  }
  .nav .logo { display: block; width: 150px; margin: 0 10px 32px; }
  .nav a { flex: 0 0 auto; flex-direction: row; justify-content: flex-start; gap: 12px;
    font-size: 16px; padding: 10px 12px; border-radius: 10px; }
  .nav a:hover { background: var(--bg); }
  .nav a[aria-current=page] { background: var(--accent-soft); }
  .nav a svg { width: 22px; height: 22px; }
  .nav a.nav-phone { display: none; }
  .nav a.nav-user { display: flex; margin-top: auto; align-items: center; gap: 10px; padding: 10px; }
  .nav-user-name { flex: 1; min-width: 0; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav-user .gear { display: inline-flex; color: var(--muted); }
  .nav-user:hover .gear, .nav-user[aria-current=page] .gear { color: var(--accent); }
  .main { margin-left: 248px; padding: 48px 40px; }
}

/* ---------- cards and lists ---------- */
.page-head { margin-bottom: 24px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.empty { text-align: center; padding: 48px 20px; }
.empty svg { width: 44px; height: 44px; color: var(--accent); margin-bottom: 12px; }
.empty .badge { display: inline-block; background: var(--accent-soft); color: var(--accent);
  font-size: 13px; font-weight: 600; border-radius: 999px; padding: 4px 12px; margin-bottom: 12px; }
.list { list-style: none; padding: 0; margin: 0; }
.list > li > a, .list > li > button {
  width: 100%; display: flex; justify-content: space-between; align-items: center; text-align: left;
  padding: 14px 0; border: 0; border-bottom: 1px solid var(--line); border-radius: 0;
  background: none; color: var(--text); text-decoration: none; min-height: 52px;
}
.list > li:last-child > a, .list > li:last-child > button { border-bottom: 0; }
.list .chev { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 40px; padding: 6px 14px; border-radius: 999px; font-size: 15px; }
.chip[aria-pressed=true] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.kv { display: grid; grid-template-columns: minmax(120px, 1fr) 2fr; gap: 8px 16px; margin: 0; }
.kv dt { color: var(--muted); font-size: 14px; }
.kv dd { margin: 0; overflow-wrap: anywhere; }

textarea, select, input[type=date], input[type=number] {
  font: inherit; width: 100%; padding: 12px 14px; min-height: 48px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
}
textarea { resize: vertical; line-height: 1.5; }
textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 2px; }
::placeholder { color: var(--muted); opacity: .7; }
.grid2 { display: grid; grid-template-columns: 1fr; gap: 0 16px; }
@media (min-width: 600px) { .grid2 { grid-template-columns: 1fr 1fr; } }

.head-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.head-row .btn { flex: none; }
.back-link { display: inline-block; margin: 0 0 16px; text-decoration: none; font-size: 15px; }
.filter { margin-bottom: 16px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.badges:empty { display: none; }
.badge { display: inline-block; background: var(--accent-soft); color: var(--accent); font-size: 13px;
  font-weight: 600; border-radius: 999px; padding: 3px 10px; vertical-align: middle; }
.badge.ok { background: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .badge.ok { color: #10170f; } }
.badge.grey { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.task-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 1100px) { .task-grid { grid-template-columns: 1fr 1fr; } }
.task-card { display: block; margin: 0; text-decoration: none; color: var(--text); }
.task-card:hover { border-color: var(--muted); }
.task-card h2 { margin: 0 0 4px; }
.task-card p { margin: 0 0 4px; }
.task-card .count { margin: 8px 0 0; color: var(--muted); }
.task-card.is-closed { opacity: .65; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.card .kv { margin-top: 4px; }
.action .ok-line { color: var(--accent); font-weight: 600; margin-bottom: 12px; }
.action p:last-child { margin: 0; }
.people { list-style: none; padding: 0; margin: 0 0 16px; }
.people li { padding: 10px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.people li b { display: block; }
.empty h2 { margin-top: 4px; }

/* events */
input[type=time] { font: inherit; width: 100%; padding: 12px 10px; min-height: 48px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--text); }
.event-list { display: grid; gap: 12px; }
.event-card { display: flex; gap: 16px; align-items: flex-start; margin: 0; text-decoration: none; color: var(--text); }
.event-card:hover { border-color: var(--muted); }
.event-card.is-closed { opacity: .65; }
.event-card h2 { margin: 0 0 4px; }
.event-card p { margin: 0 0 4px; }
.event-card .count { margin-top: 8px; color: var(--muted); }
.event-body { min-width: 0; flex: 1; }
.date-block { flex: none; width: 56px; text-align: center; background: var(--accent-soft); color: var(--accent);
  border-radius: 12px; padding: 8px 0; line-height: 1.1; }
.date-block b { display: block; font-size: 22px; }
.date-block span { font-size: 13px; text-transform: lowercase; }
.shifts { list-style: none; padding: 0; margin: 0; }
.shift { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 14px 0;
  border-bottom: 1px solid var(--line); }
.shift:last-child { border-bottom: 0; padding-bottom: 0; }
.shift-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.shift-act { flex: none; }
.shift-act button { min-height: 44px; }
.shift .link-btn { padding: 0; font-size: 14px; text-decoration: underline; }
.shift-people { margin-top: 6px; font-size: 14px; overflow-wrap: anywhere; }
.shift-people div { padding: 2px 0; }
.admin-row { margin-top: 12px; }
.form-sub { margin: 8px 0 4px; }
.shift-edit { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; padding: 12px 0;
  border-top: 1px solid var(--line); position: relative; }
.shift-edit .grow { grid-column: 1 / -1; padding-right: 36px; }
.shift-edit .field { margin-bottom: 10px; }
.remove-shift { position: absolute; top: 34px; right: 0; font-size: 18px; min-height: 40px; }
@media (min-width: 700px) {
  .shift-edit { grid-template-columns: 1fr 1fr 100px; align-items: end; }
  .shift-edit:has([data-k=date]) { grid-template-columns: 1.3fr 1fr 1fr 100px; }
}
.form-end { margin-top: 20px; }

/* groups + chat */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.hint { margin: 6px 0 0; }
.group-actions { margin-top: 12px; }
.card > .group-actions:first-child { margin-top: 0; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 8px 0 12px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.group-head { margin-bottom: 8px; }
.group-head h1 { margin-bottom: 4px; }
.group-head p { margin: 0 0 6px; }
.group-links { margin: 0 0 4px; font-size: 15px; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--muted);
  padding: 10px 14px; min-height: 44px; white-space: nowrap; }
.tabs button[aria-selected=true] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.chat { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.chat-list { height: clamp(220px, calc(100dvh - 430px), 560px); overflow-y: auto; padding: 8px 16px; overscroll-behavior: contain; }
.chat-list.thread { height: clamp(240px, calc(100dvh - 330px), 600px); }
@media (min-width: 900px) { .chat-list { height: clamp(300px, calc(100dvh - 330px), 640px); } }
.small-empty { padding: 40px 12px; text-align: center; }
.msg { padding: 10px 0; border-bottom: 1px solid var(--line); }
.msg:last-child { border-bottom: 0; }
.msg-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.msg-head b { font-size: 15px; }
.msg-text { margin: 2px 0 0; overflow-wrap: anywhere; }
.msg-foot { font-size: 14px; margin-top: 4px; color: var(--muted); }
.msg-foot a, .msg-foot .link-btn { font-size: 14px; color: var(--accent); padding: 0; min-height: 0; }
.msg.is-mine .msg-head b { color: var(--accent); }
.tag { font-size: 12px; border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; color: var(--muted); }
.thread-replies { margin-left: 14px; padding-left: 12px; border-left: 2px solid var(--line); }
.composer { display: flex; gap: 8px; align-items: flex-end; padding: 12px; border-top: 1px solid var(--line); background: var(--card); }
.composer textarea { min-height: 44px; max-height: 160px; resize: none; padding: 10px 12px; }
.composer button { min-height: 44px; flex: none; }

.install-banner { display: flex; gap: 14px; align-items: center; }
.install-banner img { width: 48px; height: 48px; border-radius: 12px; flex: none; }
.install-banner div { flex: 1; }
.install-banner p { margin: 0; }

/* ---------- overlay sheets ---------- */
#overlay:empty { display: none; }
.backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.45);
  display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--card); width: 100%; max-width: 480px; border-radius: 20px 20px 0 0;
  padding: 24px 20px calc(24px + var(--safe-b)); }
@media (min-width: 600px) { .backdrop { align-items: center; } .sheet { border-radius: 20px; } }
.backdrop.top { align-items: flex-start; }
.backdrop.top .sheet { border-radius: 0 0 20px 20px; padding-top: calc(24px + var(--safe-t)); padding-bottom: 24px; }
.steps { padding-left: 22px; margin: 0 0 20px; }
.steps li { margin-bottom: 10px; }
.steps svg { width: 20px; height: 20px; vertical-align: -4px; color: var(--accent); }
.arrow { position: fixed; z-index: 51; color: #fff; font-size: 64px; font-weight: 700; line-height: 1; pointer-events: none;
  animation: bob 1.2s ease-in-out infinite; }
.arrow.down { bottom: calc(8px + var(--safe-b)); left: 50%; transform: translateX(-50%); }
.arrow.up { top: calc(4px + var(--safe-t)); right: 64px; }
@keyframes bob { 50% { translate: 0 8px; } }
.arrow.up { animation-name: bobup; }
@keyframes bobup { 50% { translate: 0 -8px; } }
@media (prefers-reduced-motion: reduce) { .arrow { animation: none; } }

#toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 16px); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-size: 15px;
  opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 60; }
#toast.show { opacity: 1; }
@media (min-width: 900px) { #toast { bottom: 32px; } }

/* ---------- notifications ---------- */
.nav-icon { position: relative; display: inline-flex; }
.nav-count { position: absolute; top: -5px; right: -9px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700;
  line-height: 18px; text-align: center; box-sizing: border-box; }
.nav-count[hidden] { display: none; }
.notice-list { padding: 4px 0; }
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 20px; color: var(--text);
  text-decoration: none; border-bottom: 1px solid var(--line); }
.notice:last-child { border-bottom: 0; }
.notice:hover { background: var(--bg); }
.notice-dot { flex: 0 0 8px; height: 8px; margin-top: 7px; border-radius: 50%; }
.notice.unread .notice-dot { background: var(--accent); }
.notice-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; overflow-wrap: anywhere; }
.notice:not(.unread) .notice-text b { font-weight: 500; }
.push-box { background: var(--accent-soft); border-radius: 10px; padding: 12px 14px; margin: 12px 0 8px; }
.push-box p { margin: 0 0 8px; }
.push-box .row { margin: 0; }
.push-head { margin-bottom: 4px !important; }
.switches { display: flex; flex-direction: column; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0;
  padding: 12px 0; border-bottom: 1px solid var(--line); color: var(--text); font-size: 16px; cursor: pointer; }
.switch-row:last-child { border-bottom: 0; }
.switch-row > span { display: flex; flex-direction: column; gap: 2px; }
.switch-row input { appearance: none; -webkit-appearance: none; flex: 0 0 44px; width: 44px; height: 26px; margin: 0;
  padding: 0; min-height: 0; border-radius: 13px; border: 1px solid var(--line); background: var(--line);
  position: relative; cursor: pointer; transition: background .15s; }
.switch-row input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch-row input:checked { background: var(--accent); border-color: var(--accent); }
.switch-row input:checked::after { transform: translateX(18px); }
.push-box .ok-line { color: var(--accent); font-weight: 600; }

/* ---------- picture with initials (no photos are stored) ---------- */
.avatar { flex: 0 0 34px; width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft);
  color: var(--accent); font-weight: 700; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; }
.avatar.big { flex-basis: 48px; width: 48px; height: 48px; font-size: 18px; }
.profile-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.profile-head h2 { margin: 0; }
.profile-head p { margin: 2px 0 0; }

img.avatar { object-fit: cover; padding: 0; }
.photo-actions { display: flex; gap: 14px; margin: 4px 0 0; }
.photo-actions .link-btn { padding: 0; font-size: 14px; }

/* ---------- unsaved changes bar ---------- */
.save-bar { position: fixed; left: 50%; transform: translateX(-50%); z-index: 50;
  bottom: calc(var(--nav-h) + var(--safe-b) + 20px); width: min(520px, calc(100% - 24px)); box-sizing: border-box;
  display: flex; align-items: center; gap: 12px; padding: 10px 10px 10px 18px; border-radius: 999px;
  background: var(--text); color: var(--bg); box-shadow: 0 6px 24px rgba(0, 0, 0, .25); animation: bar-in .18s ease-out; }
.save-bar[hidden] { display: none; }
.save-bar .save-msg { flex: 1; min-width: 0; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.save-bar .short { display: none; }
.save-bar .link-btn { color: var(--bg); opacity: .8; padding: 8px 6px; }
.save-bar .link-btn:hover { opacity: 1; }
.save-bar .primary { margin: 0; padding: 10px 18px; border-radius: 999px; white-space: nowrap; }
#profile-form:has(.save-bar:not([hidden])) { padding-bottom: 72px; }
@keyframes bar-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
@media (min-width: 900px) { .save-bar { left: calc(50% + 124px); bottom: 24px; } }
@media (max-width: 420px) { .save-bar { gap: 6px; padding-left: 14px; } .save-bar .save-msg { font-size: 14px; } .save-bar .long { display: none; } .save-bar .short { display: inline; } .save-bar .primary { padding: 9px 14px; } }
