:root {
    color-scheme: light;
    --ink: #092d32;
    --muted: #4c6368;
    --teal: #07575b;
    --teal-deep: #034247;
    --canvas: #f9f6f2;
    --paper: #fffcf9;
    --line: #ded8d2;
    --border: #a7b3b0;
    --violet: #e8ddf8;
    --blue: #d3ecfb;
    --green: #daeee7;
    --good: #dff4e3;
    --good-text: #165527;
    --danger: #942a31;
    --sidebar: 184px;
    --hour-size: 80px;
    font: 16px/1.45 "Segoe UI", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--canvas); color: var(--ink); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .62; }
input, select { min-width: 0; }
h1, h2, p { margin: 0; }
a { color: var(--teal); }
:focus-visible { outline: 3px solid #008b91; outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }
.skip { position: fixed; top: -60px; z-index: 20; padding: 8px; background: var(--paper); }
.skip:focus { top: 8px; left: 8px; }
.icon { width: 1em; height: 1em; fill: currentColor; flex: 0 0 auto; vertical-align: -.1em; }

.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--sidebar); display: flex;
    flex-direction: column; padding: 26px 9px 16px; background: var(--teal-deep); color: white;
}
.brand { color: white; text-decoration: none; font-size: 1.8rem; font-weight: 750; padding-left: 14px; letter-spacing: -.055em; }
.sidebar nav { display: grid; gap: 7px; margin-top: 37px; }
.nav-link {
    display: flex; align-items: center; gap: 13px; width: 100%; padding: 11px 14px;
    border: 0; border-radius: 9px; color: white; background: transparent; text-align: left; text-decoration:none;
}
.nav-link .icon { width: 22px; height: 22px; }
.nav-link:hover, .nav-link[aria-pressed=true] { background: #216b70; }
.nav-link[aria-pressed=true] { font-weight: 700; }
.workspace-label { margin-top: auto; padding: 12px 14px 0; color: #e0efed; font-size: .79rem; }

main { margin-left: var(--sidebar); padding: 16px 16px 23px; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 0 3px 15px; }
h1 { font-size: clamp(2rem,4vw,2.85rem); line-height: 1.18; letter-spacing: -.037em; font-weight: 760; }
h2 { font-size: clamp(1.35rem,2.4vw,2.02rem); line-height: 1.2; letter-spacing: -.024em; }
.button, .icon-button {
    min-height: 41px; display: inline-flex; align-items: center; justify-content: center;
    gap: 8px; border: 1px solid transparent; border-radius: 8px; padding: 7px 12px; line-height: 1.2; font-weight: 650;
}
.button .icon { font-size: 1.15em; }
.primary { background: var(--teal); border-color: var(--teal); color: white; }
.primary:hover { background: var(--teal-deep); }
.outline { background: var(--paper); border-color: var(--teal); color: var(--teal-deep); }
.outline:hover, .plain:hover, .icon-button:not(.primary):hover { background: #e3efec; }
.plain { background: transparent; color: var(--teal-deep); }
.danger { border-color: #e1b5b7; color: var(--danger); background: #fff7f5; }
.danger:hover { background: #f8e0de; }
.icon-button { min-width: 40px; padding: 6px; border-color: var(--line); background: var(--paper); }
.icon-button.primary { background: var(--teal); border-color: var(--teal); }
.icon-button.primary:hover { background: var(--teal-deep); }
.notice { border: 1px solid #bddfc6; color: var(--good-text); background: var(--good); border-radius: 8px; padding: 9px 12px; margin-bottom: 12px; font-size: .92rem; }
.notice.is-error { border-color: #eac1c1; color: var(--danger); background: #fff0ef; }

.dashboard { display: grid; gap: 12px; grid-template-columns: minmax(0, 2.45fr) minmax(248px, 1fr); align-items: stretch; }
.dashboard.chat-first { grid-template-columns: minmax(248px, 1fr) minmax(0, 2.45fr); }
.dashboard.chat-first #chat-panel { order: -1; }
.dashboard.single { grid-template-columns: minmax(0,1fr); }
.panel { border: 1px solid var(--line); border-radius: 13px; background: var(--paper); padding: 15px; min-width: 0; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 16px; }
.panel-heading h2 { display: flex; gap: 9px; align-items: center; }
.panel-heading h2 .icon { color: var(--teal-deep); }
.calendar-controls, .date-controls, .calendar-filters { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.calendar-controls { justify-content: space-between; gap: 8px; }
.date-controls { position: relative; }
.date-button { font-weight: 650; color: var(--ink); border-color: var(--line); }
.date-button .icon { font-size: .95em; }
.date-picker { position: absolute; left: 53px; bottom: 1px; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.segmented { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: #f6f2ee; }
.segmented button { border: 0; border-radius: 6px; background: transparent; padding: 7px 9px; min-height: 32px; font-size: .88rem; font-weight: 650; }
.segmented button:hover { background: #e1eeec; }
.segmented button[aria-pressed=true] { background: var(--teal); color: white; }
.calendar-filters { gap: 7px 11px; margin: 12px 0 14px; }
.calendar-filters label { display: flex; align-items: center; gap: 4px; font-size: .87rem; cursor: pointer; }
input[type=checkbox] { accent-color: var(--teal); width: 17px; height: 17px; margin: 0; flex: 0 0 auto; }
.calendar-filters input[type=checkbox] { width: 15px; height: 15px; }
.calendar-scroll { overflow: auto; }
.calendar-hint { color: var(--muted); font-size: .86rem; padding: 11px 0 1px; }

.day-grid { display: grid; grid-template-columns: 61px repeat(var(--columns), minmax(116px,1fr)); min-width: var(--grid-min); }
.lane-head { padding: 12px 8px; text-align: center; background: #eae9e6; border-right: 1px solid #c9c7c1; font-weight: 710; font-size: .95rem; }
.lane-head:last-of-type { border-right: 0; }
.day-hours, .day-lane { position: relative; height: calc(var(--hours) * var(--hour-size)); }
.day-hours time { display: block; position: absolute; left: 7px; transform: translateY(-53%); font-size: .87rem; background: var(--paper); }
.day-lane { display: grid; grid-template-rows: repeat(calc(var(--hours) * 2), 1fr); border-left: 1px solid #cdcac3; border-top: 1px solid #cdcac3; }
.time-slot { background: transparent; border: 0; padding: 0; position: relative; }
.time-slot:nth-of-type(even) { border-bottom: 1px solid #dedbd4; }
.time-slot:hover, .time-slot:focus-visible { background: #e0f3ef; outline-offset: -2px; }
.occupied-slot:hover { background: transparent; }
.event {
    position: absolute; z-index: 1; left: 5px; right: 5px; top: var(--top); height: var(--height);
    border: 0; border-radius: 8px; padding: 7px 8px; color: var(--ink); text-align: left; overflow: hidden;
    display: block; background: var(--blue); line-height: 1.22;
}
.event strong { display: block; font-size: .91rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event small { display: block; margin-top: 3px; font-size: .8rem; color: #345057; }
.event.violet { background: var(--violet); }
.event.green { background: var(--green); }
.event.masked { background: #e0e0df; cursor: default; }
.event:not(.masked):hover { outline: 2px solid var(--teal); outline-offset: -2px; }
.period-grid { display: grid; grid-template-columns: repeat(7,minmax(78px,1fr)); min-width: 555px; gap: 3px; }
.period-weekday { text-align: center; color: var(--muted); font-weight: 650; padding: 7px 2px; font-size: .8rem; }
.period-day { min-height: 88px; border: 1px solid var(--line); border-radius: 6px; padding: 5px; background: transparent; text-align: left; display: flex; flex-direction: column; align-items: stretch; gap: 4px; }
.period-day:hover, .period-day.is-today { background: #eaf3f0; border-color: #94bab3; }
.period-day.is-other-month { color: var(--muted); background: #f5f2ee; }
.period-day span { padding: 3px 4px; border-radius: 4px; font-size: .75rem; background: var(--blue); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.period-day span.violet { background: var(--violet); }
.period-day span.green { background: var(--green); }
.period-day span.masked { background: #e6e5e3; }
.period-week .period-day { min-height: 210px; }

.chat-panel { display: flex; flex-direction: column; min-height: 460px; max-height: 820px; }
.select-icon { display: flex; align-items: center; position: relative; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); }
.select-icon .icon { position: absolute; left: 11px; color: var(--teal-deep); pointer-events: none; }
.select-icon select { padding: 8px 8px 8px 35px; border: 0; width: 100%; border-radius: 8px; background: transparent; font-weight: 650; }
.messages { flex: 1; min-height: 150px; overflow: auto; margin: 16px 0 12px; display: flex; flex-direction: column; gap: 16px; }
.message { display: grid; grid-template-columns: 38px minmax(0,1fr); gap: 9px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--violet); font-size: .85rem; font-weight: 750; }
.message:nth-of-type(even) .avatar { background: var(--blue); }
.message.own .avatar { background: var(--green); }
.message-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; }
.message-head time { color: var(--muted); font-size: .77rem; }
.message-copy { display: inline-block; margin-top: 4px; padding: 8px 9px; border-radius: 0 10px 10px; background: #f0eeec; color: #1c3034; font-size: .92rem; overflow-wrap: anywhere; white-space: pre-wrap; }
.message.own .message-copy { background: #e0eeeb; }
.chat-compose { border: 1px solid var(--line); padding: 4px; border-radius: 8px; display: flex; gap: 4px; align-items: center; }
.chat-compose input { width: 100%; flex: 1; border: 0; padding: 6px; background: transparent; }
.chat-compose .icon-button { min-height: 35px; min-width: 36px; }
.chat-search { margin-top: 7px; color: var(--teal); font-weight: 650; font-size: .85rem; }
.chat-search summary { cursor: pointer; }
.chat-search input { width: 100%; margin-top: 5px; padding: 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--paper); }
.chat-reply, .quote { border-left: 2px solid var(--teal); background: #eaf3f1; font-size: .79rem; padding: 4px 7px; overflow-wrap: anywhere; }
.chat-reply { display: flex; justify-content: space-between; align-items: center; gap: 5px; }
.chat-reply .icon-button { min-width: 30px; min-height: 30px; }
.message .reply-link { display:block; min-height: 26px; padding: 3px 4px; background: transparent; border: 0; color: var(--teal); font-size: .76rem; font-weight: 650; }
.subtle, .empty-message { color: var(--muted); font-size: .86rem; }

.dialog {
    width: min(515px, calc(100vw - 24px)); padding: 18px; border: 1px solid var(--border);
    border-radius: 14px; background: var(--paper); color: var(--ink); box-shadow: 0 12px 30px #23312c24;
    max-height: min(790px, calc(100dvh - 26px)); overflow: auto;
}
.dialog::backdrop { background: #15373924; }
.appointment-dialog { position: fixed; inset: auto; top: clamp(12px, calc(100dvh - 650px), 29dvh); right: clamp(12px, 29vw, 430px); margin: 0; max-height: calc(100dvh - clamp(12px, calc(100dvh - 650px), 29dvh) - 12px); }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 11px; }
.dialog-heading h2 { font-size: 1.58rem; }
.dismiss { min-width: 35px; min-height: 35px; border-color: transparent; }
.form-body { display: grid; gap: 8px; }
.field { display: grid; grid-template-columns: 130px minmax(0,1fr); gap: 6px 9px; align-items: center; }
.field > label, .field-label { font-weight: 665; font-size: .92rem; line-height: 1.25; }
.field-label { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.required { color: var(--danger); }
.form-body :is(input:not([type=checkbox]), select) { width: 100%; border: 1px solid var(--border); padding: 5px 8px; min-height: 35px; border-radius: 7px; background: var(--paper); font-size: .89rem; }
.form-body input[aria-invalid=true] { border-color: var(--danger); }
.time-fields, .split-fields { display: grid; gap: 5px; grid-template-columns: repeat(2,minmax(0,1fr)); }
.split-fields { grid-template-columns: minmax(0,1fr) minmax(56px,27%); }
.postal-fields { grid-template-columns: minmax(68px,32%) minmax(0,1fr); }
.time-fields label { font-size: .77rem; color: var(--muted); display: block; }
.time-fields input[type=datetime-local] { padding-inline: 5px; font-size: .77rem; }
.address-fields { display: grid; gap: 7px; }
.location-switch { display: grid; grid-template-columns: 1fr 1fr; }
.location-switch button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.help { position: relative; font-weight: 400; flex: 0 0 auto; }
.help summary { list-style: none; cursor: pointer; padding: 3px; min-width: 21px; text-align: center; }
.help summary::-webkit-details-marker { display: none; }
.help p { position: absolute; inset: 25px auto auto 0; width: min(225px,65vw); z-index: 3; background: var(--teal-deep); color: white; border-radius: 7px; padding: 9px; font-size: .82rem; line-height: 1.4; }
.participants { position: relative; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chips:not(:empty) { margin-bottom: 4px; }
.chip { display: flex; align-items: center; gap: 5px; padding: 3px 7px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: #f3f5f2; font-size: .8rem; }
.chip:hover { background: var(--green); }
.participant-results { z-index: 5; position: absolute; left: 0; right: 0; bottom: calc(100% + 4px); margin: 0; list-style: none; padding: 4px; max-height: 190px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; background: var(--paper); box-shadow: 0 6px 16px #18352d25; }
.participant-results button { display: block; text-align: left; width: 100%; border: 0; background: transparent; padding: 6px; font-size: .84rem; }
.participant-results button:hover, .participant-results button:focus-visible { background: #e4f0ed; }
.participant-results small { display: block; color: var(--muted); }
.participant-results .empty-message { padding: 8px; }
.check { display: flex; align-items: center; gap: 8px; font-size: .9rem; margin-top: 1px; width: fit-content; cursor: pointer; }
.secondary-check { color: var(--muted); }
.invitation-preview { border-left: 2px solid var(--teal); background: #eaf3f1; padding: 5px 8px; font-size: .79rem; overflow-wrap: anywhere; }
.availability { display: flex; align-items: center; gap: 6px; border-radius: 7px; padding: 6px 9px; background: var(--good); color: var(--good-text); font-size: .88rem; font-weight: 680; }
.availability.conflict, .form-errors { color: var(--danger); background: #fff0ee; }
.form-errors { border: 1px solid #eac6c2; border-radius: 7px; padding: 7px 9px; font-size: .86rem; }
.form-errors ul { margin: 0; padding-left: 16px; }
.dialog-actions { margin-top: 10px; display: flex; gap: 6px; }
.dialog-actions .primary { flex: 1; }

@media (max-width: 1200px) {
    :root { --sidebar: 154px; --hour-size: 73px; }
    .sidebar { padding-top: 20px; }
    .brand { font-size: 1.5rem; }
    .nav-link { gap: 8px; }
    .dashboard { grid-template-columns: minmax(0, 2.3fr) minmax(225px, 1fr); }
    .dashboard.chat-first { grid-template-columns: minmax(225px, 1fr) minmax(0, 2.3fr); }
}
@media (max-width: 950px) {
    :root { --sidebar: 0px; --hour-size: 65px; }
    .sidebar { position: sticky; inset: 0 0 auto; z-index: 6; width: 100%; padding: 6px 12px; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 4px 15px; }
    .brand { padding: 0; }
    .sidebar nav { margin: 0; display: flex; gap: 4px; }
    .sidebar form { margin: 0; }
    .nav-link { width: auto; padding: 7px; font-size: .88rem; }
    .nav-link .icon { width: 17px; height: 17px; }
    .workspace-label { margin: 0 0 0 auto; padding: 3px 0; }
    main { padding: 12px; }
    .appointment-dialog { right: 12px; }
}
@media (max-width: 730px) {
    .dashboard, .dashboard.chat-first, .dashboard.single { grid-template-columns: minmax(0,1fr); }
    .chat-panel { min-height: 340px; max-height: 450px; }
    .page-header { align-items: flex-start; }
    .page-header .button { font-size: .83rem; }
    .panel, .dialog { padding: 11px; }
    .panel-heading .button { font-size: .86rem; }
    .workspace-label { display: none; }
}
@media (max-width: 510px) {
    .appointment-dialog { inset: auto 7px 7px; margin: auto; width: calc(100vw - 14px); max-height: calc(100dvh - 52px); }
    .field { grid-template-columns: minmax(0,1fr); }
    .date-button { font-size: .83rem; }
    .calendar-hint { font-size: .8rem; }
    .notice { margin-bottom: 7px; }
}
