:root {
  --bg: #f4f8f8;
  --paper: #ffffff;
  --ink: #10292e;
  --muted: #546c73;
  --line: #dbe6e8;
  --aqua: #dcf1ee;
  --aqua-2: #b4e0da;
  --teal: #0f5e63;
  --teal-2: #0b4a4e;
  --rose: #fbe9e7;
  --enamel: #f5f2ec;
  --row: 32px;           /* высота получаса в расписании */
  --ease: cubic-bezier(.2, .8, .2, 1);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--ink); font: 400 15px/1.5 "Golos Text", system-ui, sans-serif; -webkit-font-smoothing: antialiased; overflow-x: clip; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
ol, ul { list-style: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.muted { color: var(--muted); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 46px; padding: 0 20px; border-radius: 6px; border: 0; cursor: pointer; font-weight: 500; white-space: nowrap; transition: background-color .2s, color .2s, box-shadow .2s; }
.btn--teal { background: var(--teal); color: #fff; }
.btn--teal:hover { background: var(--teal-2); }
.btn--line { background: var(--paper); box-shadow: inset 0 0 0 1px var(--line); }
.btn--line:hover { box-shadow: inset 0 0 0 1px var(--teal); }
.btn--ghost { background: transparent; color: var(--muted); }
.btn--ghost:hover { color: var(--ink); background: var(--paper); }
.btn--danger { background: transparent; color: #a8423a; box-shadow: inset 0 0 0 1px #efcdc8; }
.btn--danger:hover { background: var(--rose); }
.btn--sm { height: 38px; padding: 0 14px; font-size: 14px; }
.btn--block { width: 100%; }
.icon-btn { width: 38px; height: 38px; border-radius: 6px; border: 0; background: transparent; cursor: pointer; font-size: 20px; color: var(--muted); display: grid; place-items: center; }
.icon-btn:hover { background: var(--paper); color: var(--ink); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login__card { width: min(400px, 100%); background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 36px 32px 28px; }
.login h1 { font: 300 32px/1.1 "Commissioner", sans-serif; letter-spacing: -.03em; margin-top: 20px; }
.login .muted { margin: 8px 0 24px; }
.err { color: #a8423a; font-size: 13px; margin: -4px 0 12px; }
.err:empty { display: none; }
.hint { margin-top: 14px; font-size: 13px; color: var(--muted); text-align: center; }
.back { display: block; text-align: center; margin-top: 8px; font-size: 13px; color: var(--teal); }

.field { display: block; margin-bottom: 14px; min-width: 0; }
.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.field input, .field select, .field textarea { width: 100%; border: 0; border-radius: 6px; background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); padding: 11px 12px; font-size: 15px; resize: vertical; }
.field select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 52%, calc(100% - 12px) 52%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; box-shadow: inset 0 0 0 1.5px var(--teal); }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--ink); color: #cfe3e5; padding: 22px 14px; display: flex; flex-direction: column; gap: 28px; position: sticky; top: 0; height: 100vh; }
.side__brand { display: flex; align-items: center; gap: 10px; padding: 0 10px; color: var(--aqua-2); }
.side__brand span { font: 500 20px "Commissioner", sans-serif; color: #fff; letter-spacing: -.02em; }
.side__brand i { font-style: normal; font-size: 12px; color: #8fb3b7; letter-spacing: .1em; margin-left: 4px; }
.side__nav { display: flex; flex-direction: column; gap: 2px; }
.side__nav button { display: flex; justify-content: space-between; align-items: center; text-align: left; border: 0; background: none; color: #cfe3e5; padding: 10px 12px; border-radius: 6px; cursor: pointer; font-size: 15px; }
.side__nav button:hover { background: rgba(255, 255, 255, .06); }
.side__nav button.is-on { background: rgba(180, 224, 218, .16); color: #fff; }
.badge { background: var(--aqua-2); color: var(--ink); font-size: 12px; font-weight: 600; border-radius: 10px; padding: 1px 8px; }
.side__foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.side__foot a, .side__foot button { text-align: left; border: 0; background: none; color: #8fb3b7; padding: 7px 12px; border-radius: 6px; cursor: pointer; }
.side__foot a:hover, .side__foot button:hover { color: #fff; }

.main { padding: 22px clamp(16px, 2.6vw, 36px) 48px; min-width: 0; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.top h1 { font: 300 30px/1.1 "Commissioner", sans-serif; letter-spacing: -.03em; }
.lead { color: var(--muted); max-width: 70ch; margin-bottom: 18px; }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 8px; background: var(--paper); }
.kpi { padding: 14px 18px; min-width: 0; }
.kpi + .kpi { border-left: 1px solid var(--line); }
.kpi__t { font-size: 12px; color: var(--muted); }
.kpi__v { font: 400 26px/1.25 "Commissioner", sans-serif; letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi__v.is-alert { color: #a8423a; }
.kpi__s { font-size: 12px; color: var(--muted); }
.kpi__bar { height: 4px; border-radius: 2px; background: var(--line); margin-top: 8px; overflow: hidden; }
.kpi__bar i { display: block; height: 100%; background: var(--teal); }

/* ---------- date bar ---------- */
.datebar { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin: 18px 0 12px; }
.datebar__nav { display: flex; align-items: center; gap: 6px; }
.datebar__t { font: 400 20px "Commissioner", sans-serif; margin-left: 10px; text-transform: capitalize; }
.week { display: flex; gap: 4px; }
.week button { border: 0; background: var(--paper); box-shadow: inset 0 0 0 1px var(--line); border-radius: 6px; padding: 5px 10px 6px; min-width: 52px; cursor: pointer; display: flex; flex-direction: column; align-items: center; line-height: 1.25; }
.week button span { font-size: 11px; color: var(--muted); text-transform: capitalize; }
.week button b { font: 500 16px "Commissioner", sans-serif; }
.week button small { font-size: 10px; color: var(--teal); }
.week button.is-on { background: var(--ink); color: #fff; box-shadow: none; }
.week button.is-on span, .week button.is-on small { color: #a9cbcf; }
.week button.is-off { opacity: .45; }

/* ---------- schedule grid ---------- */
.sched { background: var(--paper); border: 1px solid var(--line); border-radius: 8px; overflow: auto; max-height: calc(100vh - 250px); min-height: 420px; }
.sched__grid { display: grid; grid-template-columns: 58px repeat(var(--cols), minmax(190px, 1fr)); min-width: max-content; }
.sched__corner, .sched__doc { position: sticky; top: 0; z-index: 3; background: var(--paper); border-bottom: 1px solid var(--line); }
.sched__corner { left: 0; z-index: 4; }
.sched__doc { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-left: 1px solid var(--line); min-width: 0; }
.sched__ava { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font: 400 13px "Commissioner", sans-serif; flex: none; }
.sched__doc b { display: block; font-weight: 500; font-size: 14px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sched__doc small { color: var(--muted); font-size: 12px; }
.sched__times { position: sticky; left: 0; z-index: 2; background: var(--paper); }
.sched__times span { display: block; height: calc(var(--row) * 2); font-size: 12px; color: var(--muted); text-align: right; padding-right: 10px; transform: translateY(-8px); font-variant-numeric: tabular-nums; }
.sched__times span:first-child { transform: none; padding-top: 2px; }
.sched__col {
  position: relative; border-left: 1px solid var(--line); cursor: copy;
  /* линия каждый час и бледная каждые полчаса */
  background: repeating-linear-gradient(to bottom, var(--line) 0 1px, transparent 1px var(--row), #edf3f4 var(--row) calc(var(--row) + 1px), transparent calc(var(--row) + 1px) calc(var(--row) * 2));
}
.sched__col:hover { background-color: #fbfdfd; }
.sched__ghost { position: absolute; left: 4px; right: 4px; height: calc(var(--row) - 2px); border-radius: 5px; background: var(--aqua); opacity: 0; pointer-events: none; font-size: 12px; color: var(--teal); padding: 6px 8px; transition: opacity .15s; }
.sched__col:hover .sched__ghost.is-on { opacity: 1; }
.now { position: absolute; left: 0; right: 0; height: 2px; background: #d65a4f; z-index: 1; pointer-events: none; }
.now::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: #d65a4f; }

.appt {
  position: absolute; left: 4px; right: 4px; z-index: 1; border: 0; text-align: left; cursor: pointer; overflow: hidden;
  border-radius: 5px; padding: 5px 8px; font-size: 12px; line-height: 1.3; display: flex; flex-direction: column; gap: 1px;
  transition: box-shadow .2s, transform .2s var(--ease);
}
.appt:hover { box-shadow: 0 6px 16px -8px rgba(16, 41, 46, .45); z-index: 2; }
.appt__time { font-variant-numeric: tabular-nums; color: var(--muted); }
.appt__name { font-weight: 500; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt__svc { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt__tooth { position: absolute; right: 6px; top: 5px; font-size: 11px; background: rgba(255, 255, 255, .7); border-radius: 4px; padding: 0 5px; }
.appt.is-short { flex-direction: row; align-items: center; gap: 6px; }
.appt.is-short .appt__svc { display: none; }
.appt.is-flash { animation: flash 1.8s var(--ease); }
@keyframes flash { 0%, 50% { box-shadow: 0 0 0 3px var(--teal); } }

.st-new { background: #fff; box-shadow: inset 0 0 0 1.5px var(--teal); background-image: repeating-linear-gradient(135deg, transparent 0 6px, rgba(15, 94, 99, .06) 6px 12px); }
.st-confirmed { background: var(--aqua); }
.st-came { background: #e6efe9; }
.st-came .appt__name::before { content: "✓ "; color: var(--teal); }
.st-noshow { background: var(--rose); }
.st-cancel { background: transparent; box-shadow: inset 0 0 0 1px var(--line); opacity: .55; }
.st-cancel .appt__name { text-decoration: line-through; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 12px; color: var(--ink); margin-top: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- inbox ---------- */
.inbox { display: grid; gap: 8px; }
.req { display: grid; grid-template-columns: 150px minmax(0, 1fr) auto; gap: 18px; align-items: center; background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; }
.req > * { min-width: 0; }
.req__when { font: 400 18px/1.25 "Commissioner", sans-serif; text-transform: capitalize; }
.req__when small { display: block; font: 400 12px "Golos Text", sans-serif; color: var(--muted); text-transform: none; }
.req__who { font-weight: 500; }
.req__who a { color: var(--teal); font-weight: 400; margin-left: 8px; }
.req__what { color: var(--muted); font-size: 14px; }
.req__meta { font-size: 12px; color: var(--muted); margin-top: 3px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.src { font-size: 11px; padding: 2px 7px; border-radius: 4px; background: var(--aqua); color: var(--teal); }
.late { color: #a8423a; font-weight: 500; }
.req__act { display: flex; gap: 6px; }
.empty { background: var(--paper); border: 1px dashed var(--line); border-radius: 8px; padding: 40px 20px; text-align: center; color: var(--muted); }

/* ---------- patients ---------- */
.search { display: flex; align-items: center; gap: 10px; background: var(--paper); border: 1px solid var(--line); border-radius: 6px; padding: 0 12px; height: 42px; max-width: 420px; color: var(--muted); margin-bottom: 14px; }
.search input { border: 0; outline: 0; background: none; flex: 1; min-width: 0; color: var(--ink); }
.ptable { background: var(--paper); border: 1px solid var(--line); border-radius: 8px; overflow-x: auto; }
.ptable table { width: 100%; border-collapse: collapse; min-width: 760px; }
.ptable th { text-align: left; font-weight: 400; font-size: 12px; color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--line); }
.ptable td { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.ptable tr:last-child td { border-bottom: 0; }
.ptable tbody tr { cursor: pointer; }
.ptable tbody tr:hover { background: var(--bg); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- drawer ---------- */
.drawer { position: fixed; inset: 0; z-index: 30; }
.drawer__shade { position: absolute; inset: 0; background: rgba(16, 41, 46, .32); animation: fade .2s both; }
.drawer__panel { position: absolute; right: 0; top: 0; bottom: 0; width: min(560px, 100%); background: var(--paper); display: flex; flex-direction: column; animation: slide .3s var(--ease) both; }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(32px); opacity: 0; } }
.drawer__head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px 6px; gap: 12px; }
.drawer__head h2 { font: 300 26px/1.15 "Commissioner", sans-serif; letter-spacing: -.02em; }
.drawer__body { padding: 8px 22px 22px; overflow-y: auto; flex: 1; }
.stbar { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 18px; }
.stbar button { border: 0; padding: 7px 11px; border-radius: 5px; font-size: 13px; cursor: pointer; background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); }
.stbar button.is-on { background: var(--ink); color: #fff; box-shadow: none; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 12px; }
.links { display: flex; gap: 6px; flex-wrap: wrap; margin: -4px 0 14px; }
.links a { font-size: 13px; padding: 6px 10px; border-radius: 5px; background: var(--aqua); color: var(--teal); }
.links a:hover { background: var(--aqua-2); }
.note-add { display: flex; gap: 6px; margin: 6px 0 12px; }
.note-add input { flex: 1; min-width: 0; border: 0; border-radius: 6px; background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); padding: 0 12px; height: 38px; }
.note-add input:focus { outline: none; box-shadow: inset 0 0 0 1.5px var(--teal); }
.timeline { border-left: 1px solid var(--line); margin-left: 4px; padding-left: 14px; display: grid; gap: 10px; font-size: 14px; }
.timeline time { display: block; font-size: 12px; color: var(--muted); }
.h3 { font: 500 15px "Commissioner", sans-serif; margin: 18px 0 8px; }
.dfoot { position: sticky; bottom: -22px; background: var(--paper); padding: 14px 0 22px; margin-top: 18px; border-top: 1px solid var(--line); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.remind { font-size: 13px; color: var(--teal); background: var(--aqua); border-radius: 6px; padding: 8px 12px; margin-bottom: 14px; }
.warn { font-size: 13px; color: #a8423a; margin: -6px 0 12px; }
.warn:empty { display: none; }

.pcard__kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 8px; margin: 6px 0 16px; }
.pcard__kpis div { padding: 10px 14px; }
.pcard__kpis div + div { border-left: 1px solid var(--line); }
.pcard__kpis span { display: block; font-size: 12px; color: var(--muted); }
.pcard__kpis b { font: 400 20px "Commissioner", sans-serif; }
.pjaw { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px 4px; }
.pjaw svg { display: block; width: 100%; height: auto; }
.pjaw .gum { fill: none; stroke: var(--line); stroke-dasharray: 2 5; }
.pjaw .mid { stroke: var(--line); }
.pjaw .tooth .crown { fill: var(--enamel); stroke: #c6d3d5; stroke-width: 1.2; }
.pjaw .tooth .groove { fill: none; stroke: #cfd9db; }
.pjaw .tooth .hit { fill: transparent; }
.pjaw .tooth.is-done .crown { fill: var(--teal); stroke: var(--teal); }
.pjaw .tooth.is-done .groove { stroke: rgba(255, 255, 255, .4); }
.pjaw .num { font-size: 10px; fill: #9ab0b5; text-anchor: middle; dominant-baseline: middle; }
.pjaw .tooth.is-done .num { fill: var(--teal); font-weight: 600; }
.pjaw .jaw__label { font-size: 10px; fill: var(--muted); text-anchor: middle; letter-spacing: .08em; text-transform: uppercase; }
.pjaw p { font-size: 12px; color: var(--muted); padding: 4px 2px 6px; }
.visits { display: grid; gap: 6px; }
.visit { display: grid; grid-template-columns: 118px minmax(0, 1fr) auto; gap: 12px; align-items: center; font-size: 14px; padding: 9px 12px; border-radius: 6px; background: var(--bg); cursor: pointer; }
.visit:hover { background: var(--aqua); }
.visit > * { min-width: 0; }
.visit small { color: var(--muted); display: block; font-size: 12px; }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 4px; white-space: nowrap; }

.snack { position: fixed; left: 50%; bottom: 22px; z-index: 40; transform: translate(-50%, 16px); opacity: 0; background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 8px; font-size: 14px; transition: opacity .25s, transform .25s var(--ease); pointer-events: none; max-width: calc(100% - 32px); }
.snack.is-on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi:nth-child(4) { border-left: 0; }
  .kpi:nth-child(n+4) { border-top: 1px solid var(--line); }
}
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: sticky; top: 0; z-index: 20; height: auto; flex-direction: row; align-items: center; gap: 8px; padding: 8px 12px; overflow-x: auto; scrollbar-width: none; }
  .side::-webkit-scrollbar { display: none; }
  .side__brand { padding: 0 6px 0 0; flex: none; }
  .side__brand i { display: none; }
  .side__nav { flex-direction: row; flex: none; }
  .side__nav button { padding: 8px 10px; white-space: nowrap; gap: 6px; }
  .side__foot { display: none; }
  .main { padding-top: 16px; }
  .top h1 { font-size: 24px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { border-left: 0 !important; border-top: 1px solid var(--line); }
  .kpi:nth-child(-n+2) { border-top: 0; }
  .kpi:nth-child(even) { border-left: 1px solid var(--line) !important; }
  .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .kpi__v { font-size: 22px; }
  .week { overflow-x: auto; scrollbar-width: none; width: 100%; }
  .week::-webkit-scrollbar { display: none; }
  .week button { flex: none; }
  .sched { max-height: 70vh; }
  .sched__grid { grid-template-columns: 50px repeat(var(--cols), 160px); }
  .req { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .drawer__head, .drawer__body { padding-left: 16px; padding-right: 16px; }
  .visit { grid-template-columns: minmax(0, 1fr) auto; }
  .visit > :first-child { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
