:root {
  color-scheme: light;
  --ink: #29243a;
  --muted: #665f74;
  --line: #e6e1ec;
  --paper: #f8f7fb;
  --surface: #fff;
  --accent: #574078;
  --accent-strong: #37294b;
  --accent-soft: #eeebfb;
  --radius: 16px;
  font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-synthesis: none;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, select, input { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button, a { touch-action: manipulation; }
button { color: inherit; cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #8b71bd; outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
.icon { width: 20px; height: 20px; flex: none; vertical-align: middle; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; }
.brand-mark { flex: none; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 11px; background: #ded3f6; color: var(--accent-strong); }
.brand-mark svg { width: 26px; height: 26px; }
.brand strong { display: block; font-size: 19px; line-height: 1.05; letter-spacing: .015em; }
.brand small { display: block; font-size: 12px; margin-top: 5px; color: #ded2ed; }
.button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 8px 14px; font-weight: 600; font-size: 14px; text-decoration: none; white-space: nowrap; }
.button:hover, .icon-button:hover { background: var(--accent-soft); border-color: #d5c9e5; }
.button .icon { width: 18px; height: 18px; }
.primary { background: var(--accent); color: white; border-color: var(--accent); }
.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.ghost { background: transparent; border-color: transparent; }
.icon-button { display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none; background: transparent; border: 1px solid transparent; border-radius: 10px; }
.muted { color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

.login { min-height: 100vh; min-height: 100svh; display: grid; grid-template-columns: minmax(340px, .95fr) minmax(340px, 1fr); }
.login-story { color: white; background: radial-gradient(ellipse at 87% 5%, #604583 0, transparent 62%), var(--accent-strong); min-height: 100%; padding: clamp(28px, 5vw, 76px); display: flex; flex-direction: column; justify-content: space-between; gap: 42px; overflow: hidden; }
.login-story h2 { font-size: clamp(42px, 5.2vw, 78px); line-height: 1; font-weight: 650; letter-spacing: -.065em; max-width: 620px; }
.login-story p { margin-top: 22px; max-width: 370px; color: #e3d8ee; line-height: 1.55; }
.login-art { position: relative; width: min(420px, 94%); height: 150px; }
.login-art span { position: absolute; width: 42%; min-width: 108px; height: 114px; display: grid; align-content: space-between; padding: 14px; border: 1px solid #ffffff32; border-radius: 14px; background: #543e6b; color: #f0e7fc; font-weight: 600; box-shadow: 0 10px 28px #20133155; }
.login-art span:nth-child(1) { left: 0; transform: rotate(-9deg); top: 22px; }
.login-art span:nth-child(2) { left: 28%; transform: rotate(-2deg); top: 8px; }
.login-art span:nth-child(3) { left: 57%; transform: rotate(8deg); top: 14px; color: var(--accent-strong); background: #ded3f6; }
.login-art .icon { width: 26px; height: 26px; }
.login-panel { display: grid; place-items: center; padding: 36px; }
.login-form { width: min(100%, 388px); }
.login-form h1 { font-size: clamp(32px, 4vw, 43px); letter-spacing: -.05em; line-height: 1.1; }
.login-form > p { margin: 12px 0 26px; color: var(--muted); line-height: 1.5; }
.login-form label { margin-bottom: 15px; }
.login-form .button { width: 100%; margin-top: 10px; }
.login-form .form-error { margin: 0; color: #a43744; font-size: 14px; }

.shell { min-height: 100vh; }
.topbar { position: sticky; z-index: 2; top: 0; min-height: 74px; background: #fff; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 18px; padding: 0 clamp(16px, 4vw, 58px); }
.topbar .brand { color: var(--accent-strong); width: fit-content; }
.topbar .brand small { color: var(--muted); }
.nav { display: flex; gap: 6px; }
.nav a { display: flex; gap: 8px; align-items: center; color: var(--muted); padding: 10px 13px; min-height: 43px; text-decoration: none; border-radius: 9px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.nav a:hover { background: #f7f4fa; }
.nav a[aria-current=page] { color: var(--accent-strong); background: var(--accent-soft); }
.nav .icon { width: 17px; height: 17px; }
.account { display: flex; gap: 9px; align-items: center; justify-self: end; }
.account .icon { width: 18px; height: 18px; }
.account strong { font-size: 14px; }
.account span:not(.avatar) { display: block; color: var(--muted); font-size: 12px; }
.account .icon-button { margin-left: 4px; }
.main { margin: 0 auto; max-width: 1050px; padding: 38px 26px 60px; }
.page-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 25px; }
.page-heading h1 { font-size: clamp(34px, 4.2vw, 48px); line-height: 1; letter-spacing: -.045em; font-weight: 650; }
.page-heading p { margin-top: 10px; line-height: 1.45; }
.toolbar { display: flex; gap: 9px; }
.search { display: flex; flex: 1; align-items: center; gap: 9px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; min-width: 0; color: var(--muted); }
.search:focus-within { outline: 2px solid #967fbd; }
.search input { min-height: 43px; width: 100%; border: 0; padding: 0; outline: none; color: var(--ink); background: transparent; }
.search input:focus-visible { outline: none; }
.search input::placeholder { color: var(--muted); }
.search .icon { width: 18px; height: 18px; }
.filters { margin-top: 10px; padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.filter-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.filter-footer { display: flex; justify-content: flex-end; margin-top: 10px; }
.filter-footer .button { min-height: 38px; }
label.field { display: grid; gap: 6px; min-width: 0; font-size: 14px; font-weight: 600; }
.field input:not([type=range]), .field select, .sort { width: 100%; min-width: 0; min-height: 42px; border: 1px solid #dcd5e6; border-radius: 9px; background-color: #fff; color: var(--ink); padding: 9px 10px; font-weight: 400; }
.field select, .sort { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18' fill='none' stroke='%235c6d65' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 7 4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; background-size: 18px; }
.list-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 21px 0 8px; }
.list-heading h2 { font-size: 19px; letter-spacing: -.025em; }
.list-heading h2 span { color: var(--muted); font-size: 14px; font-weight: 500; margin-left: 5px; }
.sort { width: auto; min-height: 39px; font-size: 14px; background-color: transparent; }
.visit-list, .client-list { display: grid; gap: 7px; }
.visit { display: grid; grid-template-columns: minmax(216px, 1.55fr) minmax(130px, 1fr) minmax(120px, .8fr) auto 20px; align-items: center; gap: 14px; min-width: 0; min-height: 76px; border: 1px solid var(--line); border-radius: 12px; padding: 12px 13px; background: #fff; text-decoration: none; transition: border-color .15s, background .15s; }
.visit:hover, .client-row:hover { background: #fefcff; border-color: #b9a6d2; }
.date-rule { display: flex; align-items: center; gap: 12px; padding: 6px 1px 2px; margin-top: 4px; color: var(--accent-strong); font-size: 14px; font-weight: 650; }
.date-rule::after { content: ''; height: 1px; background: var(--line); flex: 1; }
.date-rule:first-child { margin-top: 0; }
.visit-patient { display: flex; align-items: center; min-width: 0; gap: 11px; }
.visit-patient > div { min-width: 0; }
.visit-thumbnail { width: 44px; height: 44px; background: var(--accent-soft); border-radius: 9px; flex: none; overflow: hidden; }
.visit-thumbnail img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar { display: grid; place-items: center; width: 42px; height: 42px; flex: none; border-radius: 11px; font-size: 15px; font-weight: 650; background: #e1eee4; color: #316549; }
.avatar[data-tone="1"] { background: #eee8f7; color: #654f82; }
.avatar[data-tone="2"] { background: #f8eae2; color: #805238; }
.avatar[data-tone="3"] { background: #e4edf6; color: #345d7c; }
.avatar[data-tone="4"] { background: #f6efd9; color: #745c26; }
.avatar.account-avatar { width: 35px; height: 35px; font-size: 13px; }
.visit strong, .visit time { display: block; font-size: 14px; font-weight: 650; overflow-wrap: anywhere; }
.visit small { display: block; margin-top: 4px; font-size: 13px; line-height: 1.2; color: var(--muted); }
.visit > .icon, .client-row > .icon { width: 17px; height: 17px; color: var(--muted); }
.client-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(135px, 1fr) minmax(76px, .65fr) 20px; gap: 14px; align-items: center; min-width: 0; min-height: 67px; padding: 9px 13px; border: 1px solid var(--line); border-radius: 12px; background: #fff; text-decoration: none; }
.client-row strong { display: block; font-size: 14px; overflow-wrap: anywhere; }
.client-row small { display: block; margin-top: 3px; color: var(--muted); font-size: 13px; }
.client-heading .detail-head { margin-bottom: 0; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 13px; color: var(--muted); font-size: 14px; }
.pagination:empty { padding: 0; }
.archive-report { color: var(--muted); margin: 12px 0; font-size: 14px; line-height: 1.45; }
.consent { display: inline-flex; align-items: center; justify-self: start; gap: 5px; border-radius: 7px; padding: 5px 7px; font-size: 13px; line-height: 1.27; font-weight: 600; white-space: nowrap; background: #f4f0e7; color: #715321; }
.consent[data-status=allowed] { background: #e6f3e9; color: #265c41; }
.consent[data-status=denied] { background: #faeaeb; color: #8a4149; }
.consent .icon { width: 14px; height: 14px; }
.empty { border: 1px dashed #ccbedf; border-radius: var(--radius); background: #fdfbff; padding: 37px 19px; text-align: center; }
.empty > .icon { width: 30px; height: 30px; color: var(--accent); margin-bottom: 9px; }
.empty h3 { font-size: 19px; }
.empty p { margin: 7px auto 0; max-width: 420px; color: var(--muted); line-height: 1.4; }
.empty .button { margin-top: 13px; }

.detail-back { margin: -4px 0 12px; padding-left: 0; }
.detail-head { display: flex; gap: 13px; align-items: center; margin-bottom: 18px; min-width: 0; overflow-wrap: anywhere; }
.detail-head .avatar { width: 57px; height: 57px; font-size: 20px; border-radius: 15px; }
.detail-head h1 { font-size: clamp(30px, 4.2vw, 45px); line-height: 1.04; letter-spacing: -.045em; }
.detail-head p { margin-top: 5px; color: var(--muted); }
.visit-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 0 0 12px; padding: 15px; border: 1px solid var(--line); border-radius: 13px; background: white; }
.visit-facts dt { font-size: 13px; color: var(--muted); }
.visit-facts dd { margin: 4px 0 0; font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.consent-row { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 12px 15px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.consent-row label { font-weight: 600; font-size: 14px; }
.consent-row .sort { background-color: #fff; }
.phase-tabs { display: flex; gap: 5px; margin: 23px 0 12px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; width: fit-content; background: var(--accent-soft); }
.phase-tabs button { padding: 8px 13px; min-height: 41px; border: 1px solid transparent; background: transparent; border-radius: 8px; color: var(--muted); font-size: 14px; font-weight: 650; }
.phase-tabs button[aria-pressed=true] { color: var(--accent-strong); background: #fff; border-color: var(--line); }
.phase-tabs span { margin-left: 4px; font-weight: 450; }
.media-bar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.media-bar h2 { font-size: 20px; }
.actions { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.media-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 11px; }
.media-card { border: 1px solid var(--line); border-radius: 12px; background: #fff; min-width: 0; overflow: hidden; }
.media-preview { display: grid; place-items: center; position: relative; border: 0; width: 100%; background: #e3ece5; padding: 0; aspect-ratio: 4 / 3; overflow: hidden; }
.media-preview img, .media-preview video { display: block; width: 100%; height: 100%; object-fit: cover; }
.media-preview .play { position: absolute; inset: auto 8px 8px auto; background: var(--accent-strong); color: white; border-radius: 50%; padding: 6px; }
.media-preview .play .icon { width: 17px; height: 17px; }
.media-caption { display: flex; align-items: center; gap: 8px; padding: 6px 7px 6px 11px; }
.media-caption div { flex: 1; min-width: 0; }
.media-caption strong, .media-caption small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-caption strong { font-size: 14px; }
.media-caption small { font-size: 13px; color: var(--muted); margin-top: 3px; }
.publish-group { margin-bottom: 18px; padding: 14px; border: 1px solid var(--line); background: #fff; border-radius: 13px; }
.publish-group > header { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-bottom: 12px; }
.publish-group h2 { font-size: 19px; }
.publish-group header p { color: var(--muted); font-size: 14px; margin-top: 3px; }

dialog { color: var(--ink); border: 1px solid var(--line); border-radius: 16px; background: #fff; box-shadow: 0 20px 70px #10291e48; padding: 0; width: min(94vw, 570px); max-height: 92vh; }
dialog::backdrop { background: #10251db0; }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.dialog-header h2 { font-size: 22px; line-height: 1.15; overflow-wrap: anywhere; }
.dialog-body { padding: 16px; }
.dialog-body > p { color: var(--muted); margin: 9px 0 13px; line-height: 1.4; }
.dialog-body .form-error { color: #a43744; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.dialog-actions { justify-content: flex-end; margin-top: 12px; }
.dialog-media, .camera, .collage { display: block; width: 100%; max-height: 58vh; object-fit: contain; border-radius: 10px; background: #e5eee7; }
.camera { min-height: 215px; background: #172f27; }
.collage { margin: 12px 0; }
.toast { position: fixed; z-index: 3; right: 16px; bottom: 16px; width: fit-content; max-width: calc(100vw - 32px); padding: 12px 15px; color: #fff; background: var(--accent-strong); border: 1px solid #765f90; border-radius: 10px; box-shadow: 0 6px 20px #0002; }

@media (max-width: 1020px) {
  .main { padding-right: 23px; padding-left: 23px; }
  .visit { grid-template-columns: minmax(175px, 1.3fr) minmax(106px, 1fr) auto 16px; gap: 10px; }
  .visit-when { display: none; }
  .visit .compact-date { display: block; }
  .topbar { padding: 8px 12px 0; grid-template-columns: 1fr auto; gap: 3px 8px; }
  .nav { grid-column: 1 / -1; grid-row: 2; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; padding-bottom: 6px; }
  .nav a { justify-content: center; padding: 7px 5px; min-height: 40px; font-size: 13px; gap: 5px; text-align: center; white-space: normal; }
  .nav .icon { width: 15px; height: 15px; flex: none; }
  .account .icon-button { margin-left: 0; }
  .account-text { display: none; }
}
@media (min-width: 1021px) { .visit .compact-date { display: none; } }
@media (max-width: 730px) {
  .login { grid-template-columns: 1fr; align-content: start; }
  .login-story { gap: 22px; padding: 23px 24px 27px; }
  .login-story h2 { font-size: clamp(30px, 8vw, 45px); }
  .login-story p { margin-top: 8px; }
  .login-art { display: none; }
  .login-panel { padding: 26px 23px 36px; }
  .topbar .brand { padding-left: 0; gap: 7px; }
  .topbar .brand-mark { width: 33px; height: 33px; border-radius: 8px; }
  .topbar .brand-mark svg { width: 21px; height: 21px; }
  .topbar .brand strong { font-size: 17px; }
  .topbar .brand small { display: none; }
  .main { padding: 21px 12px 35px; }
  .page-heading { margin-bottom: 15px; }
  .page-heading h1 { font-size: clamp(28px, 7.5vw, 38px); }
  .page-heading p { font-size: 14px; margin-top: 6px; }
  .page-heading .button { padding: 6px 8px; min-height: 39px; }
  .filter-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .visit { grid-template-columns: minmax(0, 1fr) auto 13px; min-height: 70px; padding: 9px; gap: 7px; }
  .visit-who { display: none; }
  .visit-patient { gap: 7px; }
  .visit .avatar { width: 34px; height: 34px; border-radius: 8px; font-size: 13px; }
  .visit-thumbnail { width: 34px; height: 34px; border-radius: 8px; }
  .visit > .icon { width: 13px; }
  .visit-list { gap: 6px; }
  .visit-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .media-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .client-row { grid-template-columns: minmax(0, 1fr) minmax(65px, auto) 16px; gap: 7px; padding: 9px; }
  .client-row .client-meta:nth-child(2) { display: none; }
  .client-row .avatar { width: 34px; height: 34px; font-size: 13px; }
  .page-actions { justify-content: flex-end; }
  .client-heading { flex-wrap: wrap; }
}
@media (max-width: 430px) {
  .nav a { padding-inline: 3px; font-size: 12px; }
  .nav .icon { display: none; }
  .compact-button .hide-small { display: none; }
  .visit .consent .icon { display: none; }
  .visit .consent { padding: 5px; font-size: 12px; }
  .actions .button { padding-right: 8px; padding-left: 8px; }
  .media-caption { padding-left: 6px; gap: 2px; }
  .media-caption .icon-button { width: 31px; }
}
