:root {
  --blue: #087ea4;
  --blue-dark: #075d79;
  --blue-soft: #e7f7fc;
  --ink: #18313d;
  --muted: #607884;
  --line: #d8e4e9;
  --surface: #ffffff;
  --background: #f3f8fa;
  --danger: #a72c35;
  --success: #16714c;
  --shadow: 0 16px 44px rgba(18, 56, 72, .12);
  --initials-badge-width: 58px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--background);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: var(--background); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--blue-dark); }
h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(1.65rem, 3vw, 2.35rem); line-height: 1.12; letter-spacing: -.035em; }
h2 { font-size: 1.15rem; }

.login-stage { min-height: 100vh; display: grid; place-items: center; padding: 28px 18px; background: radial-gradient(circle at 15% 10%, #d9f6ff 0, transparent 34%), linear-gradient(145deg, #f9fcfd, #eaf4f7); }
.login-card { width: min(100%, 460px); padding: clamp(28px, 6vw, 46px); border: 1px solid rgba(8, 126, 164, .16); border-radius: 24px; background: rgba(255,255,255,.96); box-shadow: var(--shadow); }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-login { justify-content: center; margin-bottom: 30px; }
.brand h1, .brand strong { margin: 0; color: var(--blue-dark); }
.brand h1 { font-size: 1.65rem; }
.brand p, .brand small { display: block; margin: 2px 0 0; color: var(--muted); font-size: .8rem; letter-spacing: .025em; }
.brand-logo { width: 62px; height: 62px; flex: 0 0 auto; object-fit: contain; filter: drop-shadow(0 8px 16px rgba(8,126,164,.18)); }
.brand-logo.small { width: 46px; height: 46px; filter: drop-shadow(0 5px 10px rgba(0,0,0,.16)); }
.eyebrow { margin-bottom: 7px; color: var(--blue); font-size: .74rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.stack { display: grid; gap: 17px; }
label { display: grid; gap: 7px; color: #294653; font-size: .86rem; font-weight: 700; }
input, select, textarea { width: 100%; min-height: 46px; padding: 10px 12px; color: var(--ink); border: 1px solid #b9ccd4; border-radius: 10px; background: white; outline: none; transition: border-color .15s, box-shadow .15s; }
textarea { resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(8,126,164,.12); }
.password-field { display: flex; align-items: stretch; }
.password-field input { border-radius: 10px 0 0 10px; }
.password-field button { min-width: 82px; padding: 0 10px; border: 1px solid #b9ccd4; border-left: 0; border-radius: 0 10px 10px 0; color: var(--blue-dark); background: #f2f8fa; cursor: pointer; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 10px 16px; border: 1px solid transparent; border-radius: 10px; text-decoration: none; font-weight: 750; cursor: pointer; transition: transform .12s, background .15s; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .55; cursor: wait; transform: none; }
.button.primary { color: white; background: var(--blue); }
.button.primary:hover { background: var(--blue-dark); }
.button.secondary { color: var(--blue-dark); border-color: #b8d2dc; background: white; }
.button.danger { color: var(--danger); border-color: #e5b8bd; background: #fff7f8; }
.button.wide { width: 100%; }
.button.tiny { min-height: 32px; padding: 5px 9px; font-size: .76rem; }
.center-link { justify-self: center; font-size: .88rem; }
.form-message, .section-message { min-height: 1.25em; margin: 0; font-size: .86rem; }
.form-message:not(:empty), .section-message:not(:empty) { padding: 10px 12px; border-radius: 9px; color: var(--danger); background: #fff0f1; }
.form-message.success, .section-message.success { color: var(--success); background: #eaf9f2; }
.intro, .password-hint { color: var(--muted); line-height: 1.55; }
.password-hint { margin: 0; font-size: .83rem; }

.app-shell { min-height: 100vh; }
.app-header { min-height: 78px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 13px clamp(18px, 4vw, 52px); color: white; background: linear-gradient(110deg, #075d79, #087ea4); box-shadow: 0 6px 22px rgba(7,93,121,.18); }
.app-header .brand strong, .app-header .brand small { color: white; }
.app-header .brand small { opacity: .8; }
.account { display: flex; align-items: center; gap: 14px; text-align: right; }
.account span, .account small { display: block; }
.account small { margin-top: 2px; font-size: .75rem; opacity: .78; }
.icon-button { width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.35); border-radius: 11px; color: inherit; background: rgba(255,255,255,.12); font-size: 1.25rem; cursor: pointer; }
.icon-button svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.preview-banner { display: flex; align-items: center; justify-content: center; gap: 18px; padding: 10px clamp(14px, 4vw, 52px); color: #173b48; background: #fff4c7; border-bottom: 1px solid #eadb9c; }
.preview-banner .button { flex: 0 0 auto; min-height: 38px; }
.tabs { display: flex; gap: 4px; padding: 0 clamp(12px, 4vw, 52px); overflow-x: auto; border-bottom: 1px solid var(--line); background: white; box-shadow: 0 3px 12px rgba(25,56,70,.04); }
.tab { min-height: 52px; padding: 0 17px; border: 0; border-bottom: 3px solid transparent; color: var(--muted); background: none; font-weight: 720; white-space: nowrap; cursor: pointer; }
.tab:hover { color: var(--blue-dark); background: #f5fafb; }
.tab.active { color: var(--blue-dark); border-bottom-color: var(--blue); }
.tab-right { margin-left: auto; }
.scroll-zone { position: relative; min-width: 0; }
.scroll-zone-tabs { background: white; }
.scroll-zone-table { border-radius: 15px; }
.scroll-zone > .tabs, .scroll-zone > .table-wrap { scrollbar-width: none; -ms-overflow-style: none; }
.scroll-zone > .tabs::-webkit-scrollbar, .scroll-zone > .table-wrap::-webkit-scrollbar { width: 0; height: 0; }
.scroll-edge { position: absolute; z-index: 4; top: 0; bottom: 0; display: flex; width: 42px; padding: 0; flex-direction: column; align-items: center; justify-content: space-around; overflow: hidden; border: 0; color: #e07b17; background: transparent; cursor: pointer; }
.scroll-edge[hidden] { display: none; }
.scroll-edge-left { left: 0; background: linear-gradient(to right, #fff 35%, rgba(255,255,255,0)); }
.scroll-edge-right { right: 0; background: linear-gradient(to left, #fff 35%, rgba(255,255,255,0)); }
.scroll-edge span { display: grid; width: 100%; flex: 1 1 0; place-items: center; font-size: 1rem; line-height: 1; }
.scroll-edge-left span::before { content: "\25C0"; }
.scroll-edge-right span::before { content: "\25B6"; }
.scroll-edge:focus-visible { outline: 2px solid var(--blue); outline-offset: -3px; }
.page-area { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 34px 0 70px; }
.page { display: none; }
.page.active { display: block; animation: appear .18s ease-out; }
@keyframes appear { from { opacity: 0; transform: translateY(4px); } }
.hero-card { position: relative; overflow: hidden; padding: clamp(27px, 5vw, 48px); border-radius: 22px; color: white; background: linear-gradient(125deg, #075d79, #0d9ac5); box-shadow: var(--shadow); }
.hero-card::after { content: ""; position: absolute; width: 240px; height: 240px; right: -85px; top: -95px; border: 38px solid rgba(255,255,255,.1); border-radius: 50%; }
.hero-card h1 { max-width: 720px; margin-bottom: 14px; }
.hero-card p:last-child { max-width: 760px; margin: 0; color: rgba(255,255,255,.88); line-height: 1.6; }
.hero-card .eyebrow { color: #aeeaff; }
.card-grid, .role-grid { display: grid; gap: 18px; margin-top: 20px; }
.card-grid { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.role-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
.card { padding: 22px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: 0 8px 26px rgba(25,56,70,.06); }
.card h2 { margin-bottom: 8px; }
.card p { margin-bottom: 0; color: var(--muted); line-height: 1.5; }
.card-icon { display: grid; place-items: center; width: 38px; height: 38px; margin-bottom: 15px; border-radius: 10px; color: var(--blue-dark); background: var(--blue-soft); font-size: 1.25rem; }
.dashboard-card { display: flex; width: 100%; flex-direction: column; align-items: flex-start; justify-content: flex-start; color: var(--ink); text-align: left; cursor: pointer; }
.dashboard-card:hover { transform: translateY(-2px); border-color: #b8d2dc; }
.application-card { display: flex; flex-direction: column; align-items: flex-start; }
.application-card .button { width: 100%; margin-top: 18px; }
.restore-card .card-icon { color: #8a2632; background: #ffe4e7; }
.ics-note { margin-top: 14px; padding: 11px 12px; border-radius: 10px; color: #3c5d6a !important; background: #f1f8fa; font-size: .84rem; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.page-heading h1 { margin: 0; }
.empty-state { padding: 62px 24px; text-align: center; border: 1px dashed #abc5d0; border-radius: 18px; background: rgba(255,255,255,.6); }
.empty-state strong { display: block; margin-bottom: 8px; font-size: 1.2rem; }
.empty-state p { max-width: 580px; margin: 0 auto; color: var(--muted); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 15px; background: white; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 15px 16px; text-align: left; border-bottom: 1px solid #e6eef1; vertical-align: middle; }
th { color: var(--muted); background: #f7fafb; font-size: .74rem; letter-spacing: .06em; text-transform: uppercase; }
.table-sort { display: inline-flex; align-items: center; gap: 6px; padding: 0; border: 0; color: inherit; background: transparent; font: inherit; font-weight: inherit; letter-spacing: inherit; text-transform: inherit; cursor: pointer; }
.table-sort span { width: 1em; color: var(--blue); font-size: .78rem; text-align: center; }
.table-sort:focus-visible { outline: 2px solid var(--blue); outline-offset: 4px; border-radius: 3px; }
tr:last-child td { border-bottom: 0; }
td small { display: block; margin-top: 3px; color: var(--muted); }
.table-actions { display: table-cell; padding-block: 12px; white-space: nowrap; }
.table-actions .button { width: 145px; min-height: 46px; padding-inline: 10px; text-align: center; line-height: 1.15; }
.table-actions .button + .button { margin-left: 10px; }
.doctor-actions .button, .office-actions .button { width: 110px; }
.office-identity-head { display: flex; align-items: center; gap: 9px; }
.office-code { display: inline-flex; min-width: 64px; padding: 5px 8px; justify-content: center; border-radius: 8px; color: white; background: var(--blue); font-size: .76rem; letter-spacing: .04em; }
.office-kind { color: var(--muted); font-size: .7rem; font-weight: 750; text-transform: uppercase; }
.office-name { display: block; margin-top: 6px; }
.office-notes { white-space: pre-line; }
.office-schedule { min-width: 240px; color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.office-schedule span { display: block; line-height: 1.45; }
.status, .pill { display: inline-flex; padding: 4px 8px; border-radius: 999px; color: var(--blue-dark); background: var(--blue-soft); font-size: .74rem; font-weight: 800; }
.status.suspended { color: #885b00; background: #fff5d8; }
.status.archived { color: #666; background: #eee; }
.role-card .pill { margin-top: 16px; }
.role-card { display: flex; flex-direction: column; }
.role-card .button { margin-top: 16px; }
.permission-summary-groups { flex: 1; display: grid; align-content: start; gap: 13px; }
.permission-summary-group h3, .permission-group h3 { margin: 0 0 7px; color: var(--blue-dark); font-size: .82rem; letter-spacing: .035em; text-transform: uppercase; }
.permission-summary { margin: 0; padding-left: 18px; color: var(--muted); font-size: .84rem; line-height: 1.45; }
.permission-summary li + li { margin-top: 5px; }
.role-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.role-card-footer small { color: var(--muted); font-size: .76rem; }
.permission-list { display: grid; gap: 14px; }
.permission-group { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fbfdfe; }
.permission-group-options { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.permission-option { display: flex; grid-template-columns: none; align-items: flex-start; gap: 10px; min-height: 48px; padding: 11px; border: 1px solid var(--line); border-radius: 10px; background: #f8fbfc; }
.permission-option input { width: 19px; min-height: 19px; margin: 1px 0 0; accent-color: var(--blue); }
.permission-option span { line-height: 1.35; }
.permission-option small { color: var(--muted); font-weight: 600; }
.profile-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.profile-card { max-width: 650px; }
.profile-actions { display: grid; gap: 12px; margin: 20px 0 14px; }
dl { display: grid; grid-template-columns: 120px 1fr; gap: 13px 18px; margin: 0 0 24px; }
dt { color: var(--muted); font-size: .82rem; font-weight: 700; }
dd { margin: 0; font-weight: 650; }
.list-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.list-toolbar label { width: min(100%, 270px); }
.list-toolbar .section-message { flex: 1; }
.profile-preview-panel { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 18px; padding: 17px; border: 1px solid #bcd7e0; border-radius: 15px; background: #f3fafc; }
.profile-preview-panel h2 { margin: 0 0 4px; font-size: 1rem; }
.profile-preview-panel p { margin: 0; color: var(--muted); font-size: .86rem; }
.profile-preview-actions { display: grid; grid-template-columns: repeat(2, minmax(130px, 1fr)); gap: 8px; flex: 0 1 460px; }
.profile-preview-actions .button { width: 100%; }
.calendar-rules-card, .pdsa-rule-card { margin-bottom: 18px; padding: 18px; border: 1px solid #bfd6de; border-radius: 15px; background: white; }
.calendar-rules-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px 20px; align-items: center; }
.calendar-rules-card p, .pdsa-rule-card p { margin: 5px 0 0; color: var(--muted); line-height: 1.5; }
.calendar-rules-card > p { grid-column: 1 / -1; margin: 0; font-size: .83rem; }
.calendar-legend { display: flex; flex-wrap: wrap; gap: 9px; }
.calendar-chip { display: inline-flex; padding: 6px 10px; border-radius: 999px; font-size: .76rem; font-weight: 800; }
.calendar-chip.weekend { color: #5d3c84; background: #eee3ff; }
.calendar-chip.holiday { color: #8a2632; background: #ffe4e7; }
.calendar-chip.bridge { color: #805600; background: #fff1c6; }
.planning-heading { align-items: center; }
.planning-nav { display: flex; gap: 9px; }
.planning-nav .button { min-width: 48px; }
.planning-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.planning-toolbar h2 { margin: 0; text-transform: capitalize; }
.planning-legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px 14px; color: var(--muted); font-size: .77rem; }
.planning-legend span { display: inline-flex; align-items: center; gap: 6px; }
.exchange-dot { width: 12px; height: 12px; border-radius: 50%; }
.exchange-dot.red { background: #dc3545; }
.exchange-dot.blue { background: #1677d2; }
.special-day-key { padding: 3px 7px; border-radius: 6px; background: #e8ecef; }
.planning-scroll { position: relative; }
.planning-table-wrap { overflow: auto; max-height: calc(100vh - 245px); min-height: 420px; border: 1px solid var(--line); border-radius: 15px; background: white; }
.planning-table { width: max-content; min-width: 100%; table-layout: fixed; }
.planning-table th, .planning-table td { min-width: 112px; height: 58px; padding: 5px; text-align: center; }
.planning-table thead { position: sticky; z-index: 5; top: 0; }
.planning-table thead th { height: auto; background: #f2f7f9; }
.planning-table thead tr:first-child th { padding-top: 10px; padding-bottom: 7px; border-bottom-color: #d3e0e5; }
.planning-table thead tr:last-child th { padding-top: 5px; padding-bottom: 7px; }
.planning-table .schedule-date-head, .planning-table .schedule-date { position: sticky; z-index: 4; left: 0; min-width: 126px; width: 126px; box-shadow: 4px 0 8px rgba(26,63,77,.06); }
.planning-table .schedule-date-head { z-index: 7; }
.planning-table .schedule-date { padding: 7px 9px; text-align: left; background: #f8fbfc; text-transform: none; letter-spacing: 0; }
.planning-table .schedule-date strong { display: block; color: var(--ink); font-size: .78rem; text-transform: capitalize; }
.planning-table .schedule-date small { display: block; margin-top: 3px; color: var(--muted); font-size: .65rem; font-weight: 650; line-height: 1.15; }
.schedule-office-code { display: block; color: var(--blue); font-size: .65rem; letter-spacing: .04em; }
.planning-table thead strong { display: block; margin-top: 2px; color: var(--ink); font-size: .75rem; text-transform: none; letter-spacing: 0; }
.schedule-segment { color: var(--blue-dark) !important; font-size: .66rem !important; }
.planning-table tr.special-day > td, .planning-table tr.special-day > .schedule-date { background-color: #e8ecef; }
.schedule-cell { position: relative; display: flex; min-height: 46px; align-items: center; justify-content: center; gap: 4px; padding: 5px 23px 5px 5px; border: 1px solid #d6e2e7; border-radius: 9px; background: rgba(255,255,255,.9); }
.schedule-cell.assigned { background: color-mix(in srgb, var(--cell-doctor-color) 38%, white); border-color: color-mix(in srgb, var(--cell-doctor-color) 65%, #9db3bc); }
.special-day .schedule-cell { background-color: color-mix(in srgb, var(--cell-doctor-color) 28%, #e8ecef); }
.schedule-cell.editable { cursor: pointer; }
.schedule-cell.editable:hover { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(8,142,181,.12); }
.schedule-assignment { display: flex; align-items: center; justify-content: center; gap: 4px; }
.schedule-doctor-chip { display: inline-flex; width: var(--initials-badge-width); min-width: var(--initials-badge-width); min-height: 30px; padding: 4px 5px; align-items: center; justify-content: center; border-radius: 8px; color: #102d39; background: var(--doctor-color); font-size: .74rem; font-weight: 900; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.schedule-doctor-chip.small { width: auto; min-width: 27px; min-height: 24px; padding: 3px 5px; font-size: .62rem; }
.replacement-mark { color: #4f6873; font-size: .67rem; font-weight: 800; white-space: nowrap; }
.exchange-state { position: absolute; top: 4px; right: 4px; width: 14px; height: 14px; padding: 0; border: 1px solid #aebfc6; border-radius: 50%; background: white; cursor: pointer; }
.exchange-state.red { border-color: #b52031; background: #dc3545; }
.exchange-state.blue { border-color: #0c5fa9; background: #1677d2; }
.exchange-state:disabled { cursor: default; opacity: .75; }
.cell-history-button { position: absolute; right: 3px; bottom: 2px; width: 18px; height: 18px; padding: 0; border: 0; color: #55717c; background: transparent; font-size: .78rem; cursor: pointer; opacity: .55; }
.cell-history-button:hover, .cell-history-button:focus-visible { opacity: 1; color: var(--blue-dark); }
.history-dialog-content { padding: 26px; }
.history-list { display: grid; gap: 10px; max-height: 55vh; overflow-y: auto; }
.history-entry { padding: 12px; border: 1px solid var(--line); border-radius: 11px; background: #f8fbfc; }
.history-entry > div { display: flex; justify-content: space-between; gap: 12px; }
.history-entry time, .history-entry small { color: var(--muted); font-size: .75rem; }
.history-entry p { margin: 7px 0 4px; font-weight: 750; }
.restore-preview { min-height: 48px; margin: 0; padding: 13px; border-radius: 10px; color: var(--blue-dark); background: var(--blue-soft); font-weight: 750; }
.pdsa-rule-card { border-color: #9dcbd9; background: #eef9fc; }
.doctor-name { display: flex; align-items: flex-start; gap: 10px; min-width: 190px; }
.doctor-name small { max-width: 320px; line-height: 1.35; }
.doctor-dot { width: 12px; height: 12px; margin-top: 4px; flex: 0 0 auto; border-radius: 50%; background: #b9ccd4; box-shadow: 0 0 0 3px #e7eef2; }
.doctor-swatch { display: inline-flex; align-items: center; justify-content: center; width: var(--initials-badge-width); min-width: var(--initials-badge-width); min-height: 36px; padding: 6px; border-radius: 9px; color: var(--ink); background: #e7eef2; font-weight: 850; letter-spacing: .04em; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }

dialog { width: min(92vw, 560px); max-height: min(92vh, 900px); padding: 0; overflow-y: auto; border: 0; border-radius: 20px; box-shadow: 0 26px 80px rgba(14,42,54,.25); }
#doctor-dialog, #office-dialog { width: min(94vw, 720px); }
dialog::backdrop { background: rgba(13,40,52,.52); backdrop-filter: blur(3px); }
dialog form { padding: 26px; }
.dialog-heading { display: flex; justify-content: space-between; gap: 20px; }
.dialog-heading h2 { margin-bottom: 16px; }
.dialog-heading .icon-button { color: var(--muted); border-color: var(--line); background: white; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 8px; padding-top: 4px; }
.check-field { display: flex; align-items: center; gap: 10px; }
.check-field input { width: 20px; min-height: 20px; margin: 0; accent-color: var(--blue); }
.schedule-fieldset { display: grid; gap: 14px; min-width: 0; margin: 0; padding: 15px; border: 1px solid var(--line); border-radius: 13px; }
.schedule-fieldset legend { padding: 0 6px; color: #294653; font-size: .86rem; font-weight: 750; }
.check-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.check-grid .check-field { min-height: 44px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: #f8fbfc; }
.install-dialog-content { padding: 26px; }
.install-dialog-content [data-install-message] { color: var(--muted); line-height: 1.55; }
.color-fieldset { display: grid; gap: 13px; min-width: 0; margin: 0; padding: 15px; border: 1px solid var(--line); border-radius: 13px; }
.color-fieldset legend { padding: 0 6px; color: #294653; font-size: .86rem; font-weight: 750; }
.color-preview { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 10px 14px; border-radius: 11px; background: #0EA5E9; color: white; }
.color-preview span { width: var(--initials-badge-width); min-width: var(--initials-badge-width); padding-right: 11px; border-right: 1px solid currentColor; font-weight: 850; letter-spacing: .04em; }
.color-palette { display: grid; grid-template-columns: repeat(12, 1fr); gap: 7px; }
.color-choice { width: 100%; aspect-ratio: 1; min-width: 0; padding: 0; border: 2px solid white; border-radius: 8px; background: #e7eef2; box-shadow: 0 0 0 1px #b9ccd4; cursor: pointer; }
.color-choice.selected { box-shadow: 0 0 0 3px var(--blue-dark); }
.custom-color { grid-template-columns: 1fr 64px; align-items: center; }
.custom-color input { min-height: 40px; padding: 3px; cursor: pointer; }

@media (max-width: 760px) {
  .app-header { align-items: flex-start; padding: 12px 14px; }
  .app-header .brand small { max-width: 150px; }
  .account > span { display: none; }
  .tabs { padding: 0 8px; }
  .tab { min-height: 48px; padding: 0 12px; font-size: .86rem; }
  .tab-right { margin-left: 0; }
  .page-area { width: min(100% - 22px, 1180px); padding-top: 22px; }
  .card-grid, .role-grid, .profile-layout { grid-template-columns: 1fr; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .page-heading .button { width: 100%; }
  .planning-heading .planning-nav { display: grid; grid-template-columns: 48px 1fr 48px; width: 100%; }
  .planning-heading .planning-nav .button { width: 100%; }
  .planning-toolbar { align-items: flex-start; flex-direction: column; }
  .planning-legend { justify-content: flex-start; }
  .planning-table-wrap { max-height: calc(100vh - 280px); min-height: 460px; }
  .planning-table th, .planning-table td { min-width: 104px; }
  .planning-table .schedule-date-head, .planning-table .schedule-date { min-width: 104px; width: 104px; }
  .schedule-cell { padding-left: 3px; }
  .field-row { grid-template-columns: 1fr; }
  th, td { padding: 12px 10px; }
  .users-table, .doctors-table, .offices-table { overflow: visible; border: 0; border-radius: 0; background: transparent; }
  .users-table table, .users-table tbody, .doctors-table table, .doctors-table tbody, .offices-table table, .offices-table tbody { display: block; }
  .users-table thead, .doctors-table thead, .offices-table thead { display: none; }
  .users-table tbody, .doctors-table tbody, .offices-table tbody { display: grid; gap: 12px; }
  .users-table tr, .doctors-table tr, .offices-table tr { display: grid; gap: 7px 10px; overflow: hidden; padding: 13px 0; border: 1px solid var(--line); border-radius: 14px; background: white; box-shadow: 0 5px 18px rgba(25,56,70,.05); }
  .users-table tr.has-actions, .doctors-table tr.has-actions, .offices-table tr.has-actions { padding-bottom: 0; }
  .users-table td, .doctors-table td, .offices-table td { display: block; min-width: 0; padding: 0 12px; border: 0; }
  .users-table tr { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "identity role" "identity status" "actions actions"; }
  .users-table td:nth-child(1) { grid-area: identity; overflow-wrap: anywhere; }
  .users-table td:nth-child(2) { grid-area: role; justify-self: end; color: var(--muted); font-size: .82rem; font-weight: 700; }
  .users-table td:nth-child(3) { grid-area: status; justify-self: end; }
  .users-table td:nth-child(4) { grid-area: actions; }
  .doctors-table tr { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name initials" "contact initials" "type status" "actions actions"; }
  .doctors-table tr:not(.has-actions) { grid-template-areas: "name initials" "contact initials" "type status"; }
  .doctors-table td:nth-child(1) { grid-area: name; }
  .doctors-table td:nth-child(2) { grid-area: contact; color: var(--muted); font-size: .82rem; overflow-wrap: anywhere; }
  .doctors-table td:nth-child(3) { grid-area: type; }
  .doctors-table td:nth-child(4) { grid-area: status; justify-self: end; }
  .doctors-table td:nth-child(5) { grid-area: initials; justify-self: end; align-self: start; }
  .doctors-table td:nth-child(6) { grid-area: actions; }
  .offices-table tr { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name status" "schedule schedule" "days days" "linked linked" "actions actions"; }
  .offices-table td:nth-child(1) { grid-area: name; }
  .offices-table td:nth-child(2) { grid-area: schedule; min-width: 0; font-size: .78rem; font-weight: 650; text-align: right; }
  .offices-table td:nth-child(3) { grid-area: days; color: var(--muted); font-size: .83rem; }
  .offices-table td:nth-child(4) { grid-area: linked; }
  .offices-table td:nth-child(5) { grid-area: status; justify-self: end; }
  .offices-table td:nth-child(6) { grid-area: actions; }
  .doctor-name { min-width: 0; }
  .table-actions { display: flex; width: 100%; min-width: 0; gap: 7px; padding: 10px 12px 12px !important; border-top: 1px solid #e6eef1 !important; }
  .table-actions .button { min-width: 0; min-height: 44px; flex: 1 1 0; padding-inline: 6px; font-size: .75rem; }
  .list-toolbar { align-items: stretch; flex-direction: column; }
  .list-toolbar label { width: 100%; }
  .preview-banner, .profile-preview-panel { align-items: stretch; flex-direction: column; }
  .preview-banner .button { width: 100%; }
  .profile-preview-actions { width: 100%; flex-basis: auto; grid-template-columns: 1fr; }
  .calendar-rules-card { grid-template-columns: 1fr; }
  .calendar-rules-card > p { grid-column: auto; }
  .calendar-legend { margin-top: 4px; }
  .check-grid { grid-template-columns: 1fr; }
  .color-palette { grid-template-columns: repeat(8, 1fr); }
  .permission-group-options { grid-template-columns: 1fr; }
  .dialog-actions .button { flex: 1; }
  dl { grid-template-columns: 1fr; gap: 4px; }
  dd { margin-bottom: 10px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; } }
