/* iRehab · стиль «Дала»: степной синий, золото, тёплый беж */
:root {
  --blue: #22304A; --gold: #E9C46A; --gold-ink: #8A5A12; --bg: #F3EEE4; --card: #FFFDF8;
  --ink: #1F2430; --muted: #6B5F4B; --line: #E4DCCB; --soft: #EFE8DA;
  --ok: #24583A; --ok-bg: #E3EFE6; --bad: #8A2A1A; --bad-bg: #F6E3DE; --warn-bg: #FBF0D4;
  --r: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink); background: var(--bg); }
h1, h2, h3, .serif { font-family: Lora, Georgia, serif; font-weight: 600; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.02rem; }
a { color: var(--blue); }
small, .muted { color: var(--muted); }

/* Каркас персонала */
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--blue); color: #E6E9F0; padding: 20px 14px; position: sticky; top: 0; height: 100vh; overflow: auto; }
.side .brand { font-family: Lora, Georgia, serif; font-size: 1.4rem; color: #fff; margin: 0 8px 4px; }
.side .brand b { color: var(--gold); }
.side .who { font-size: .8rem; color: #C9CFDB; margin: 0 8px 18px; }
.side a { display: block; padding: 8px 10px; border-radius: 10px; color: #E6E9F0; text-decoration: none; }
.side a:hover, .side a.on { background: rgba(233,196,106,.16); color: #fff; }
.side .sep { border-top: 1px solid rgba(255,255,255,.12); margin: 12px 0; }
.main { padding: 26px 30px 60px; max-width: 1200px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }

/* Компоненты */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; margin-bottom: 14px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-2 { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
.stat { font-family: Lora, Georgia, serif; font-size: 1.9rem; color: var(--blue); }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; background: var(--soft); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); } .pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.gold { background: var(--warn-bg); color: var(--gold-ink); } .pill.blue { background: #E6E9F0; color: var(--blue); }
.bar { height: 8px; background: var(--soft); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--gold); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack > * + * { margin-top: 8px; }

/* Формы */
input, select, textarea { font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; max-width: 100%; }
textarea { width: 100%; }
label { font-size: .85rem; color: var(--muted); }
.form p { margin: 0 0 12px; } .form p label { display: block; margin-bottom: 4px; }
.form input:not([type=checkbox]):not([type=radio]), .form select, .form textarea { width: 100%; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 10px; padding: 9px 16px; font: 600 .92rem Inter, system-ui, sans-serif; cursor: pointer; text-decoration: none; background: var(--blue); color: #fff; }
.btn.gold { background: var(--gold); color: var(--ink); }
.btn.ghost { background: transparent; color: var(--blue); border: 1px solid var(--line); }
.btn.sm { padding: 5px 10px; font-size: .82rem; }
.btn.danger { background: var(--bad); }
.errorlist { color: var(--bad); margin: 4px 0; padding-left: 18px; font-size: .85rem; }
.msgs { list-style: none; padding: 0; margin: 0 0 14px; }
.msgs li { padding: 10px 14px; border-radius: 10px; margin-bottom: 6px; background: #E6E9F0; }
.msgs .success { background: var(--ok-bg); color: var(--ok); } .msgs .error { background: var(--bad-bg); color: var(--bad); }
.msgs .info { background: var(--warn-bg); color: var(--gold-ink); }

/* Шкала 1–5 в ежедневном отчёте */
.scale { display: inline-flex; gap: 3px; }
.scale input { display: none; }
.scale label { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--soft); color: var(--ink); cursor: pointer; font-size: .8rem; }
.scale input:checked + label { background: var(--blue); color: #fff; }
.flag { font-size: .8rem; margin-right: 8px; white-space: nowrap; }

/* Чат */
.chat { display: flex; flex-direction: column; height: 62vh; }
.chat .log { flex: 1; overflow-y: auto; padding: 6px 2px; display: flex; flex-direction: column; gap: 6px; }
.bubble { max-width: 78%; padding: 8px 12px; border-radius: 14px; background: var(--soft); align-self: flex-start; white-space: pre-wrap; }
.bubble.mine { background: var(--blue); color: #fff; align-self: flex-end; }
.bubble small { display: block; font-size: .7rem; opacity: .7; margin-top: 2px; }
.chat form { display: flex; gap: 8px; margin-top: 10px; } .chat form textarea { flex: 1; height: 44px; }

/* Приложение родственника (мобильное) */
.app { max-width: 480px; margin: 0 auto; min-height: 100vh; padding: 18px 16px 90px; }
.app-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.hero { background: var(--blue); color: #fff; border-radius: 20px; padding: 18px; margin-bottom: 14px; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -30px; top: -30px; width: 120px; height: 120px; border: 18px solid rgba(233,196,106,.22); border-radius: 50%; }
.hero .muted { color: #C9CFDB; } .hero .bar { background: rgba(255,255,255,.16); }
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; background: var(--card); border-top: 1px solid var(--line); display: flex; justify-content: center; padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); }
.tabbar a { flex: 0 1 96px; text-align: center; font-size: .75rem; color: var(--muted); text-decoration: none; }
.tabbar a.on { color: var(--blue); font-weight: 600; }
.tabbar a span { display: block; font-size: 1.15rem; }

/* Вход, публичная страница */
.center { max-width: 420px; margin: 8vh auto; padding: 0 16px; }
.logo { font-family: Lora, Georgia, serif; font-size: 2rem; color: var(--blue); } .logo b { color: var(--gold-ink); }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: static; height: auto; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
  .side .who, .side .sep { display: none; }
  .main { padding: 18px 14px 50px; }
  .grid-2 { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
}
