/* СОМНОЛОГ — оформление в цветах Little Dream Care */
:root {
  --bg: #FDF9F1;
  --surface: #FFFFFF;
  --surface-2: #F7F2E8;
  --line: #E7DECD;
  --line-2: #D9CFBC;
  --ink: #2E4442;
  --ink-2: #516965;
  --muted: #7C8E8A;
  --brand: #516965;
  --brand-ink: #FFFFFF;
  --brand-soft: #E3EBE8;
  --sage: #AFBEB4;
  --sage-2: #98B2AF;
  --sand: #EBD2AB;
  --sand-soft: #F7EDDC;
  --gold: #C9A46E;
  --important: #B0503D;
  --important-soft: #F6E2DC;
  --attention: #B9832A;
  --attention-soft: #F8EDD8;
  --info: #557C9B;
  --info-soft: #E3ECF3;
  --good: #4F8A62;
  --good-soft: #E1EFE4;
  --c-night: #516965;
  --c-nap: #98B2AF;
  --c-latency: #E7C996;
  --c-waking: #C9785B;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(46, 68, 66, .06), 0 6px 20px rgba(46, 68, 66, .07);
  --serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
[data-theme="night"] {
  --bg: #171E1D;
  --surface: #212A29;
  --surface-2: #1C2423;
  --line: #33403E;
  --line-2: #42504E;
  --ink: #E9E2D4;
  --ink-2: #C9D5D1;
  --muted: #8FA09C;
  --brand: #9DB7B2;
  --brand-ink: #142020;
  --brand-soft: #2B3836;
  --sand-soft: #3A3427;
  --important-soft: #4A2C26;
  --attention-soft: #45391F;
  --info-soft: #24343F;
  --good-soft: #233A2B;
  --important: #E0907E;
  --attention: #E2B566;
  --info: #93B6D2;
  --good: #8CC79C;
  --shadow: 0 1px 2px rgba(0,0,0,.3);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.45 var(--sans); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; color: var(--ink-2); margin: 0 0 .4em; letter-spacing: .01em; }
h1 { font-size: 28px; } h2 { font-size: 22px; } h3 { font-size: 17px; }
a { color: var(--brand); }
p { margin: .3em 0 .8em; }
small, .muted { color: var(--muted); }
.hidden { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }

/* кнопки */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 16px;
  border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); cursor: pointer;
  font-weight: 600; text-decoration: none; transition: background .15s, border-color .15s, transform .05s; }
.btn:hover { border-color: var(--brand); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--brand-soft); }
.btn.danger { color: var(--important); border-color: var(--important-soft); }
.btn.small { min-height: 32px; padding: 4px 12px; font-size: 13px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; font-size: 18px; color: var(--ink-2); }

/* поля */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field > span { font-size: 13px; color: var(--muted); font-weight: 600; }
input[type=text], input[type=password], input[type=date], input[type=time], input[type=number], input[type=email],
input[type=tel], select, textarea {
  width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); outline: none; }
textarea { min-height: 64px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
input[type=time] { min-width: 96px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > .field { flex: 1 1 140px; }
.grid { display: grid; gap: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line-2); background: var(--surface); padding: 6px 12px; border-radius: 999px; cursor: pointer;
  font-size: 14px; user-select: none; }
.chip.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 6px 14px; border-radius: 999px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* карточки */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 14px; }
.card h3 { margin-bottom: 10px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.kpi .label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.kpi .value { font-family: var(--serif); font-size: 26px; color: var(--ink-2); margin-top: 2px; }
.kpi .sub { font-size: 12.5px; color: var(--muted); }
.kpi.warn .value { color: var(--attention); } .kpi.bad .value { color: var(--important); } .kpi.ok .value { color: var(--good); }
.band { position: relative; height: 8px; border-radius: 4px; background: var(--surface-2); margin-top: 8px; }
.band .ok { position: absolute; top: 0; bottom: 0; background: var(--good-soft); border-radius: 4px; }
.band .mark { position: absolute; top: -3px; width: 3px; height: 14px; border-radius: 2px; background: var(--ink-2); }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge.important { background: var(--important-soft); color: var(--important); }
.badge.attention { background: var(--attention-soft); color: var(--attention); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.neutral { background: var(--surface-2); color: var(--muted); }

.rec { border: 1px solid var(--line); border-left: 4px solid var(--info); border-radius: var(--radius-sm); padding: 12px 14px;
  background: var(--surface); }
.recs { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 12px; }
@media (max-width: 700px) { .recs { grid-template-columns: 1fr; } }
.rec.important { border-left-color: var(--important); } .rec.attention { border-left-color: var(--attention); }
.rec.good { border-left-color: var(--good); }
.rec .t { font-weight: 700; margin: 4px 0; }
.rec .adv { color: var(--ink-2); font-size: 14px; margin-top: 6px; }
.rec .src { color: var(--muted); font-size: 12px; margin-top: 6px; }

table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { padding: 7px 9px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.data th { font-size: 12.5px; color: var(--muted); font-weight: 700; background: var(--surface-2); position: sticky; top: 0; }
table.data td.num, table.data th.num { text-align: center; white-space: nowrap; }
table.data tr.avg td { font-weight: 700; background: var(--sand-soft); }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.dyn th:first-child, .dyn td:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; min-width: 140px; }
.dyn th:first-child { background: var(--surface-2); }

/* уведомления, окна */
#toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 1000; display: flex; flex-direction: column;
  gap: 8px; align-items: center; pointer-events: none; width: min(92vw, 460px); }
@media (max-width: 760px) { #toasts { bottom: calc(86px + env(safe-area-inset-bottom)); } }
.toast { pointer-events: auto; background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: 12px; box-shadow: var(--shadow);
  display: flex; gap: 12px; align-items: center; justify-content: space-between; width: 100%; font-size: 14.5px; }
.toast.err { background: var(--important); color: #fff; }
.toast button { background: transparent; border: 1px solid currentColor; color: inherit; border-radius: 999px; padding: 3px 10px; cursor: pointer; }
.overlay { position: fixed; inset: 0; background: rgba(30, 40, 38, .38); z-index: 900; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--surface); border-radius: 18px; width: min(720px, 100%); max-height: 92vh; overflow: auto; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { width: min(1100px, 100%); }
.modal .actions, .sheet .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.sheet-wrap { position: fixed; inset: 0; background: rgba(20, 30, 28, .45); z-index: 900; display: flex; align-items: flex-end; }
.sheet { background: var(--surface); width: 100%; max-height: 90vh; overflow: auto; border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
.sheet .grab { width: 44px; height: 5px; border-radius: 3px; background: var(--line-2); margin: -6px auto 12px; }

/* ===== вход ===== */
.entry { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.entry .box { width: min(560px, 100%); text-align: center; }
.entry .logo { width: min(300px, 70vw); height: auto; display: block; margin: 0 auto 6px; }
.entry .choices { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 18px; }
.choice { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 20px 16px; cursor: pointer; text-align: center;
  box-shadow: var(--shadow); transition: border-color .15s, transform .1s; }
.choice:hover { border-color: var(--brand); transform: translateY(-1px); }
.choice .ic { font-size: 30px; }
.choice .t { font-family: var(--serif); font-size: 19px; color: var(--ink-2); margin: 6px 0 4px; }
.choice .d { font-size: 13.5px; color: var(--muted); }
.choice.rec { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.entry form { text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 20px; margin-top: 16px; box-shadow: var(--shadow); }
.entry .foot { margin-top: 18px; font-size: 12.5px; color: var(--muted); }
@media (max-width: 520px) { .entry .choices { grid-template-columns: 1fr; } }

/* ===== владелец ===== */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 18px 14px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px; }
.side .brand { display: flex; gap: 10px; align-items: center; padding: 4px 6px 14px; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.side .brand img { width: 52px; height: 52px; object-fit: contain; }
.side .brand .n { font-family: var(--serif); font-size: 17px; color: var(--ink-2); line-height: 1.15; }
.side .brand .s { font-size: 11.5px; color: var(--muted); }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: var(--ink); text-decoration: none; font-weight: 600; }
.nav a:hover { background: var(--surface-2); }
.nav a.on { background: var(--brand-soft); color: var(--ink-2); }
.nav .sub a { padding-left: 30px; font-weight: 500; font-size: 14px; }
.side .bottom { margin-top: auto; font-size: 12px; color: var(--muted); padding: 8px; }
.main { padding: 26px 32px 60px; max-width: 1320px; width: 100%; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.head .sub { color: var(--muted); }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tabs a { padding: 9px 14px; text-decoration: none; color: var(--muted); font-weight: 700; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--ink-2); border-bottom-color: var(--brand); }
.period { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.period input[type=date] { width: 150px; }
.cols { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.client-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.cc .name { font-family: var(--serif); font-size: 20px; color: var(--ink-2); }
.cc .meta { font-size: 13px; color: var(--muted); }
.cc .line { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.cc .acts { display: flex; gap: 8px; flex-wrap: wrap; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.codebox { font-family: ui-monospace, Menlo, monospace; font-size: 26px; letter-spacing: .12em; background: var(--sand-soft); padding: 8px 16px;
  border-radius: 10px; display: inline-block; color: var(--ink); }
@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .side .brand { border: 0; margin: 0; padding: 0 8px 0 0; }
  .nav { display: flex; flex-wrap: wrap; } .nav .sub { display: contents; }
  .side .bottom { margin: 0 0 0 auto; }
  .main { padding: 18px 16px 60px; }
  .cols { grid-template-columns: 1fr; }
}

/* ===== дневник дня (ПК и редактор) ===== */
.day-nav { display: flex; align-items: center; gap: 8px; }
.day-nav .d { font-family: var(--serif); font-size: 20px; color: var(--ink-2); min-width: 220px; text-align: center; }
.sect { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; overflow: hidden; }
.sect > header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.sect > header h3 { margin: 0; }
.sect.morning > header { background: var(--sand-soft); }
.sect.night > header { background: #E6E3F0; }
[data-theme="night"] .sect.night > header { background: #2C2A3A; }
.sect .body { padding: 14px 16px; }
.sleep-card { border: 1px dashed var(--line-2); border-radius: 12px; padding: 12px; margin-bottom: 12px; background: var(--bg); }
.sleep-card .top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; gap: 8px; flex-wrap: wrap; }
.sleep-card .top b { font-family: var(--serif); font-size: 17px; color: var(--ink-2); }
.times { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.times .field { margin: 0; }
.computed { display: flex; gap: 8px; flex-wrap: wrap; }
.computed .badge { font-weight: 600; }
.phase-notes { display: grid; grid-template-columns: 130px 1fr 1fr; gap: 6px 10px; align-items: start; margin-top: 10px; }
.phase-notes .h { font-size: 12px; color: var(--muted); font-weight: 700; }
.phase-notes textarea { min-height: 40px; }
details > summary { cursor: pointer; color: var(--brand); font-weight: 600; margin-top: 8px; }
.saved { font-size: 13px; color: var(--good); opacity: 0; transition: opacity .3s; }
.saved.on { opacity: 1; }
.issues { background: var(--attention-soft); color: var(--attention); border-radius: 10px; padding: 8px 12px; font-size: 14px; margin-bottom: 12px; }
.wk { width: 100%; border-collapse: collapse; }
.wk td, .wk th { padding: 5px 4px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 13.5px; }
.wk th { color: var(--muted); font-size: 12px; text-align: left; }
.wk input, .wk select { min-height: 34px; padding: 4px 8px; }
@media (max-width: 760px) { .phase-notes { grid-template-columns: 1fr; } }

/* ===== клиент: смартфон ===== */
.m-app { max-width: 560px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
.m-top { display: flex; align-items: center; gap: 10px; padding: 12px 14px; position: sticky; top: 0; background: var(--bg); z-index: 10;
  border-bottom: 1px solid var(--line); }
.m-top img { width: 40px; height: 40px; object-fit: contain; }
.m-top .who { flex: 1; min-width: 0; }
.m-top .who b { font-family: var(--serif); font-size: 18px; color: var(--ink-2); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-top .who small { display: block; }
.m-body { padding: 14px; }
.m-tabs { position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--line); display: flex;
  justify-content: center; padding-bottom: env(safe-area-inset-bottom); z-index: 20; }
.m-tabs .in { display: flex; width: min(560px, 100%); }
.m-tabs button { flex: 1; border: 0; background: transparent; padding: 8px 4px 10px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--muted); font-size: 12px; font-weight: 700; cursor: pointer; }
.m-tabs button .i { font-size: 21px; line-height: 1; }
.m-tabs button.on { color: var(--brand); }
.status { border-radius: 20px; padding: 18px; background: var(--brand); color: var(--brand-ink); margin-bottom: 14px; }
.status.sleeping { background: linear-gradient(135deg, #516965, #3F5652); color: #fff; }
.status.awake { background: linear-gradient(135deg, #F3E3C6, #EBD2AB); color: #3C3222; }
.status.settling { background: linear-gradient(135deg, #E3EBE8, #CBDAD6); color: var(--ink); }
.status.night_waking { background: linear-gradient(135deg, #C9785B, #A9614A); color: #fff; }
[data-theme="night"] .status.awake { background: linear-gradient(135deg, #4C4130, #3A3226); color: #F2E6CF; }
[data-theme="night"] .status.settling { background: linear-gradient(135deg, #2B3836, #253130); color: var(--ink); }
.status .lbl { font-size: 13px; font-weight: 700; opacity: .85; text-transform: uppercase; letter-spacing: .06em; }
.status .big { font-family: var(--serif); font-size: 36px; line-height: 1.1; margin: 4px 0; }
.status .hint { font-size: 14.5px; opacity: .92; }
.acts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.act { min-height: 74px; border-radius: 16px; border: 1px solid var(--line-2); background: var(--surface); font-weight: 700; font-size: 16px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; cursor: pointer; color: var(--ink); padding: 8px; }
.act .i { font-size: 22px; }
.act.main { grid-column: 1 / -1; min-height: 86px; background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-size: 18px; }
.act.main.warm { background: #C9785B; border-color: #C9785B; color: #fff; }
.act:active { transform: scale(.98); }
.when { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 12px; }
.when .pill { display: inline-flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line-2); border-radius: 999px;
  padding: 4px 6px 4px 12px; font-size: 14px; }
.when .pill input { border: 0; min-height: 30px; width: 104px; padding: 2px 6px; background: transparent; }
.tl { list-style: none; margin: 0; padding: 0; }
.tl li { display: flex; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.tl .tm { font-family: var(--serif); font-size: 17px; color: var(--ink-2); width: 92px; flex: none; }
.tl .tx { flex: 1; min-width: 0; }
.tl .tx b { display: block; }
.tl .tx small { display: block; }
.tl .ed { border: 0; background: transparent; color: var(--brand); font-weight: 700; cursor: pointer; padding: 4px 6px; }
.hist-day { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 10px; cursor: pointer; }
.hist-day .h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.hist-day .m { display: flex; gap: 12px; flex-wrap: wrap; font-size: 13.5px; color: var(--muted); margin-top: 6px; }
.plan-text { white-space: pre-wrap; background: var(--sand-soft); border-radius: 12px; padding: 12px 14px; }

/* ===== клиент: компьютер ===== */
.pc-top { display: flex; align-items: center; gap: 16px; padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10; flex-wrap: wrap; }
.pc-top img { width: 46px; height: 46px; object-fit: contain; }
.pc-top .bn { font-family: var(--serif); font-size: 18px; color: var(--ink-2); }
.pc-top .sp { flex: 1; }
.pc-top .tabs { border: 0; margin: 0; }
.pc-main { max-width: 1280px; margin: 0 auto; padding: 22px 24px 60px; }
.pc-cols { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.pc-side { position: sticky; top: 90px; }
@media (max-width: 1000px) { .pc-cols { grid-template-columns: 1fr; } .pc-side { position: static; } }

/* графики */
.chart svg { width: 100%; height: auto; display: block; }
.chart text { font-family: var(--sans); fill: var(--muted); font-size: 11px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 5px; }
