/* ═══════════════════════════════════════════════════════
   יומן תיאום ניתוחים — עיצוב בהשראת אורטק
   ═══════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f2f7f4;
  --panel: #ffffff;
  --line: #dde9e1;
  --line-strong: #c6d6cb;
  --text: #16241c;
  --muted: #5f726a;
  --brand: #3f9e4d;
  --brand-dark: #2c7a39;
  --brand-soft: #7ec48b;
  --accent: #1792a6;
  --blue: #1f7d92;
  --blue-dark: #155e6e;
  --danger: #c02b3c;
  --ok: #2c7a39;
  --warning: #e09a3e;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(25,40,30,.06), 0 8px 24px rgba(25,40,30,.07);
  --shadow-md: 0 4px 18px rgba(25,40,30,.10);
  font-family: 'Assistant', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
}

:root[data-theme="dark"] {
  --bg: #0f0f11;
  --panel: #1a1a1d;
  --line: #2a2a30;
  --line-strong: #3a3a42;
  --text: #e4ede6;
  --muted: #93a89b;
  --brand: #57c06a;
  --brand-dark: #86e0a0;
  --brand-soft: #6fae8e;
  --accent: #35b6ce;
  --blue: #3fb6cc;
  --blue-dark: #6fd0e0;
  --danger: #e0616f;
  --ok: #6cc094;
  --warning: #e0965a;
  --shadow: 0 1px 2px rgba(0,0,0,.35), 0 10px 30px rgba(0,0,0,.30);
  --shadow-md: 0 4px 18px rgba(0,0,0,.35);
}

:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea { background: #141417; color: var(--text); border-color: var(--line); }

body { min-height: 100dvh; }
a { color: var(--brand); text-decoration: none; }
input, select, textarea, button { font: inherit; }

/* ═══ Login ═══ */
.screen { display: none; }
.screen.active { display: flex; justify-content: center; align-items: center; min-height: 100dvh; flex-direction: column; gap: 12px; }

.login-card {
  background: var(--panel); border-radius: 16px; box-shadow: var(--shadow);
  padding: 2.5rem; width: 100%; max-width: 400px;
}
.login-brand {
  display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 24px;
}
.login-brand h1 {
  font-size: 1.5rem; font-weight: 800; color: var(--brand-dark);
  letter-spacing: -.02em;
}
.login-brand p { font-size: .9rem; color: var(--muted); }

.login-card label { display: block; margin-bottom: 1rem; font-size: .85rem; color: var(--muted); font-weight: 600; }
.login-card input {
  display: block; width: 100%; margin-top: .3rem; padding: .65rem .8rem;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg);
  transition: border-color .15s, box-shadow .15s;
}
.login-card input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(63,158,77,.15); }
.error { color: var(--danger); font-size: .85rem; margin-top: .5rem; }

/* ═══ Logo SVG ═══ */
.logo-svg { width: 52px; height: 52px; filter: drop-shadow(0 6px 18px rgba(63,158,77,.35)); }

/* ═══ Buttons ═══ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .5rem 1rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); cursor: pointer; font-size: .85rem; color: var(--text);
  font-weight: 600; transition: all .15s; white-space: nowrap;
}
.btn:hover { background: var(--bg); border-color: var(--line-strong); }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.danger:hover { opacity: .9; }
.btn.ghost { border: none; background: none; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: rgba(63,114,106,.07); }
.btn.sm { padding: .3rem .55rem; font-size: .78rem; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

:root[data-theme="dark"] .btn { background: #242428; }
:root[data-theme="dark"] .btn:hover { background: #2e2e33; }
:root[data-theme="dark"] .btn.ghost { background: transparent; }
:root[data-theme="dark"] .btn.ghost:hover { background: #26262b; }

/* ═══ App Shell ═══ */
#app-shell { min-height: 100dvh; }

/* ═══ Topbar — glass float ═══ */
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 0 20px; height: 56px;
  background: rgba(255,255,255,.72);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,.85);
  border-radius: 14px;
  box-shadow: 0 4px 18px rgba(25,40,30,.08);
  position: sticky; top: 10px; z-index: 20;
  margin: 12px 14px 0;
}
:root[data-theme="dark"] .topbar {
  background: rgba(26,26,29,.78);
  border-color: rgba(58,58,66,.55);
  box-shadow: 0 4px 18px rgba(0,0,0,.35);
}

.topbar .brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 700; font-size: 15px; color: var(--brand-dark);
}
.topbar .brand svg { width: 28px; height: 28px; flex: none; }

.topbar-nav { display: flex; gap: 2px; }
.topbar-nav .tab {
  padding: .4rem .8rem; border: none; background: none; cursor: pointer;
  font-size: .88rem; font-weight: 600; color: var(--muted); border-radius: 8px;
  transition: all .15s;
}
.topbar-nav .tab:hover { background: rgba(63,158,77,.08); color: var(--text); }
.topbar-nav .tab.active { background: rgba(63,158,77,.12); color: var(--brand-dark); }
:root[data-theme="dark"] .topbar-nav .tab.active { background: #123021; color: var(--brand-dark); }

.topbar-left { margin-inline-start: auto; display: flex; align-items: center; gap: 12px; }

.notif-bell { position: relative; font-size: 1.2rem; }
.notif-count {
  position: absolute; top: -4px; inset-inline-end: -6px;
  background: var(--danger); color: #fff; font-size: .65rem; font-weight: 700;
  min-width: 16px; height: 16px; border-radius: 8px;
  display: grid; place-items: center; padding: 0 4px; line-height: 1;
}
.reorder-controls { display: flex; gap: 4px; }
.reorder-controls button { padding: 2px 10px; font-size: .8rem; }

.bulk-row + .bulk-row { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); }
@media (max-width: 600px) {
  .bulk-row { grid-template-columns: 1fr 1fr !important; }
  .bulk-row label:first-child { grid-column: 1 / -1; }
}

.user-info { display: flex; align-items: center; gap: 8px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #3d8a66, #204d39);
  color: #fff; font-weight: 700; font-size: 12.5px;
}
.badge {
  font-size: 11.5px; font-weight: 500; padding: 2px 8px; border-radius: 20px;
  background: #e6f0ea; color: var(--brand-dark); border: 1px solid #c2ddce;
}
:root[data-theme="dark"] .badge { background: #123021; border-color: #3f8a30; color: var(--brand-dark); }

.theme-toggle { font-size: 17px; }

/* nav toggle for mobile */
.nav-toggle { display: none; font-size: 20px; }

/* ═══ Main content ═══ */
#main-content { padding: 20px 18px; max-width: 1400px; margin: 0 auto; }

/* ═══ Views ═══ */
.view { display: none; }
.view.active { display: block; }

.view-header { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.view-header h3 { font-size: 1.2rem; font-weight: 700; }
.view-controls { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-inline-start: auto; }
.view-controls input, .view-controls select {
  padding: .4rem .6rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel);
}

/* ═══ Status badges ═══ */
.badge-draft { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }
.badge-open { background: #e6f0ea; color: var(--brand-dark); border: 1px solid #c2ddce; }
.badge-closed { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.badge-cancelled { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.badge-confirmed { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }
.badge-completed { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
:root[data-theme="dark"] .badge-draft { background: #202024; color: #c3d2c7; border-color: #37493c; }
:root[data-theme="dark"] .badge-open { background: #123021; color: #6cc094; border-color: #2f6b48; }
:root[data-theme="dark"] .badge-closed { background: #2e2212; color: #e0965a; border-color: #6d4a2a; }
:root[data-theme="dark"] .badge-cancelled { background: #3a1a1a; color: #e88a84; border-color: #7a3532; }
:root[data-theme="dark"] .badge-confirmed { background: #13283a; color: #6ab6e0; border-color: #2f5f86; }
:root[data-theme="dark"] .badge-completed { background: #123021; color: #6cc094; border-color: #2f6b48; }

/* ═══ View Mode Toggle ═══ */
.view-mode-toggle { display: flex; gap: 2px; background: var(--line); border-radius: var(--radius); padding: 2px; }
.view-mode-toggle .btn { background: transparent; border: 0; min-width: 34px; font-size: 1rem; }
.view-mode-toggle .btn.active { background: var(--panel); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

/* ═══ Month Navigation ═══ */
.month-nav {
  display: flex; align-items: center; gap: 12px; justify-content: center;
  padding: 8px 0 12px; font-size: 1.05rem; font-weight: 700;
}

/* ═══ Month Grid ═══ */
.month-grid { user-select: none; }
.month-header {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px;
  text-align: center; font-size: .78rem; font-weight: 700; color: var(--muted);
  padding-bottom: 6px; border-bottom: 1px solid var(--line); margin-bottom: 4px;
}
.month-body {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px;
}
.month-cell {
  min-height: 90px; padding: 4px; border: 1px solid var(--line); border-radius: 4px;
  background: var(--panel); position: relative; overflow: hidden;
}
.month-cell.empty { background: transparent; border-color: transparent; min-height: 0; }
.month-cell.today { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.month-cell.shabbat { background: color-mix(in srgb, var(--panel) 95%, var(--muted) 5%); }
.month-cell-num {
  font-size: .78rem; font-weight: 700; margin-bottom: 4px; color: var(--text);
}
.month-cell.today .month-cell-num {
  background: var(--brand); color: #fff; border-radius: 50%; width: 22px; height: 22px;
  display: grid; place-items: center; font-size: .72rem;
}
.month-block {
  font-size: .72rem; padding: 3px 5px; border-radius: 4px; margin-bottom: 2px;
  cursor: pointer; border-inline-start: 3px solid var(--brand);
  background: color-mix(in srgb, var(--brand) 8%, var(--panel) 92%);
  transition: background .15s;
}
.month-block:hover { background: color-mix(in srgb, var(--brand) 16%, var(--panel) 84%); }
.month-block.status-closed { border-inline-start-color: var(--warning); }
.month-block.status-cancelled { border-inline-start-color: var(--danger); opacity: .6; }
.month-block.status-draft { border-inline-start-color: var(--muted); }
.month-block-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.month-block-time { color: var(--muted); }
.month-block-free { color: var(--brand); font-weight: 600; }
.month-block-full { color: var(--muted); }

@media (max-width: 600px) {
  .month-cell { min-height: 60px; padding: 2px; }
  .month-block { font-size: .65rem; padding: 2px 3px; }
  .month-day-name { font-size: .68rem; }
  .month-block-time { display: none; }
}

/* ═══ Blocks Grid ═══ */
.blocks-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.block-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; cursor: pointer; transition: all .15s;
  border-inline-start: 3px solid var(--brand);
}
.block-card:hover { box-shadow: var(--shadow); border-color: var(--brand-soft); }
.block-card.status-closed { border-inline-start-color: var(--warning); }
.block-card.status-cancelled { border-inline-start-color: var(--danger); opacity: .7; }
.block-card.status-draft { border-inline-start-color: var(--muted); }

.block-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.block-card-head h4 { font-size: .95rem; font-weight: 700; }

.block-card .meta { font-size: .83rem; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }
.block-card .meta-row { display: flex; align-items: center; gap: 8px; }

/* utilization ring in block card */
.util-ring {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 10px; font-weight: 700;
  color: var(--brand-dark); position: relative;
}
.util-ring i { position: relative; z-index: 1; background: var(--panel); border-radius: 50%; width: 26px; height: 26px; display: grid; place-items: center; font-style: normal; }
:root[data-theme="dark"] .util-ring i { background: var(--panel); }

/* free time tag on block card */
.free-tag { color: var(--brand); font-weight: 600; }

/* ═══ Block Detail ═══ */
.block-summary-compact {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  padding: 8px 12px; font-size: .88rem; font-weight: 500;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 12px;
}
.block-summary-compact .muted { color: var(--muted); font-weight: 400; }
.block-inline-actions { display: flex; gap: 6px; margin-inline-start: auto; }

.summary {
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 16px;
}
.summary div {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: .88rem;
}
.summary div:last-child { border-bottom: 0; }
.summary span:first-child { color: var(--muted); }
.summary span:last-child { font-weight: 600; text-align: end; }

/* ═══ Surgery chips in block manager ═══ */
.surgery-list { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; }

.surg-chip {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 12px; cursor: pointer; transition: all .15s;
  border-inline-start: 3px solid var(--brand);
}
.surg-chip:hover { box-shadow: var(--shadow); }
.surg-chip .surg-time { font-weight: 700; font-size: .85rem; font-variant-numeric: tabular-nums; color: var(--text); white-space: nowrap; }
.surg-chip .surg-info { flex: 1; min-width: 0; }
.surg-chip .surg-name { font-weight: 600; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.surg-chip .surg-detail { font-size: .78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.surg-chip.cancelled { opacity: .5; border-inline-start-color: var(--danger); text-decoration: line-through; }

.surg-reorder { display: flex; flex-direction: column; gap: 2px; }
.surg-reorder .btn { padding: 2px 6px; font-size: .7rem; line-height: 1; min-width: 24px; }

/* free gap indicator */
.surg-gap {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; border: 1px dashed var(--line); border-radius: var(--radius);
  color: var(--muted); font-size: .82rem; cursor: pointer; transition: all .15s;
}
.surg-gap:hover { border-color: var(--brand); background: rgba(63,158,77,.04); color: var(--brand-dark); }
.surg-gap .gap-time { font-weight: 700; font-variant-numeric: tabular-nums; }
.surg-gap .gap-plus { margin-inline-start: auto; font-weight: 800; color: var(--brand); font-size: 14px; }

/* ═══ Actions bar ═══ */
.actions-bar { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.actions-bar .btn { flex: 1; min-width: 120px; }

/* ═══ Section heading in modal ═══ */
.section-title { font-size: .9rem; font-weight: 700; margin: 20px 0 8px; color: var(--text); }
.hint { font-size: .78rem; color: var(--muted); margin: 4px 0 8px; }

/* ═══ Tabs ═══ */
.block-tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--line); margin-bottom: 16px; }
.tab-btn {
  padding: .5rem 1rem; border: none; background: none; cursor: pointer;
  font-size: .9rem; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: all .15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--brand-dark); border-bottom-color: var(--brand); }
.tab-btn[hidden] { display: none; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.tab-header { display: flex; justify-content: flex-end; gap: 8px; margin-bottom: 1rem; }

/* ═══ Timeline ═══ */
.timeline { display: flex; flex-direction: column; gap: 6px; }
.timeline-slot { display: flex; gap: 12px; align-items: stretch; min-height: 3.2rem; }
.timeline-time {
  width: 70px; flex-shrink: 0; text-align: center;
  font-size: .8rem; font-weight: 700; color: var(--muted); padding-top: .6rem;
  font-variant-numeric: tabular-nums;
}
.timeline-content {
  flex: 1; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .75rem 1rem; cursor: pointer;
  border-inline-start: 3px solid var(--brand); transition: all .15s;
}
.timeline-content:hover { box-shadow: var(--shadow); }
.timeline-content h5 { font-size: .9rem; margin-bottom: .25rem; }
.timeline-content .detail { font-size: .8rem; color: var(--muted); }
.timeline-free {
  flex: 1; border: 1px dashed var(--line); border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center; gap: 6px;
  color: var(--muted); font-size: .82rem; cursor: pointer; transition: all .15s;
  padding: 6px 12px;
}
.timeline-free:hover { border-color: var(--brand); background: rgba(63,158,77,.04); color: var(--brand-dark); }
.timeline-free .gap-plus { font-weight: 800; color: var(--brand); font-size: 14px; }

/* ═══ Tables ═══ */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td {
  padding: .6rem .75rem; text-align: start; border-bottom: 1px solid var(--line); font-size: .85rem;
}
.data-table th { font-weight: 700; color: var(--muted); background: var(--bg); }
.data-table tr:hover td { background: rgba(63,158,77,.03); }
:root[data-theme="dark"] .data-table tr:hover td { background: #202024; }

/* ═══ Forms ═══ */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; max-width: 600px; }
.form-grid label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--muted); font-weight: 600; }
.form-grid label:has(textarea) { grid-column: 1 / -1; }
.form-grid input, .form-grid select, .form-grid textarea {
  padding: .5rem .6rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg);
}
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(63,158,77,.15);
}
.form-grid button { grid-column: 1 / -1; justify-self: start; }

.modal-form { display: flex; flex-direction: column; gap: .85rem; }
.modal-form label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--muted); font-weight: 600; }
.modal-form input, .modal-form select, .modal-form textarea {
  padding: .5rem .65rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg);
}
.modal-form input:focus, .modal-form select:focus, .modal-form textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(63,158,77,.15);
}
.modal-form .row { display: flex; gap: .75rem; }
.modal-form .row > * { flex: 1; }

/* ═══ Modal ═══ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex;
  align-items: center; justify-content: center; z-index: 1000;
  animation: fadeIn .15s ease;
}
.modal-overlay[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } }

.modal {
  background: var(--panel); border-radius: 14px; box-shadow: var(--shadow-md);
  width: 100%; max-width: 520px; max-height: 90dvh; overflow-y: auto;
  animation: modalIn .2s ease;
}
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(.97); } }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.modal-header h3 { font-size: 1rem; font-weight: 700; }
.modal-close { font-size: 1.3rem; padding: .2rem .5rem; }
#modal-body { padding: 18px; }

/* ═══ Toast ═══ */
#toast-container {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%); z-index: 2000;
  display: flex; flex-direction: column; gap: .5rem; pointer-events: none;
}
.toast {
  background: var(--text); color: #fff; padding: .65rem 1.25rem; border-radius: var(--radius);
  font-size: .85rem; font-weight: 600; box-shadow: var(--shadow-md); animation: toastIn .3s ease;
  max-width: 400px; pointer-events: auto;
}
.toast.success { background: var(--ok); }
.toast.error { background: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

/* ═══ Admin tabs ═══ */
.admin-tabs {
  display: flex; gap: 2px; border-bottom: 2px solid var(--line);
  padding: 0 4px; margin-bottom: 1rem; flex-wrap: wrap;
}
.admin-tab {
  padding: .55rem 1.1rem; background: none; border: none; border-bottom: 2px solid transparent;
  margin-bottom: -2px; font-weight: 600; font-size: .88rem; color: var(--muted);
  cursor: pointer; transition: .15s;
}
.admin-tab:hover { color: var(--text); }
.admin-tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.admin-panel { display: none; }
.admin-panel.active { display: block; }

/* ═══ User cards ═══ */
.user-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 6px; background: var(--panel); cursor: pointer; transition: all .15s;
}
.user-card:hover { border-color: var(--brand); box-shadow: var(--shadow); }
.user-card-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 15px; color: #fff;
  background: linear-gradient(135deg, #3d8a66, #204d39);
}
.user-card-avatar.role-admin { background: linear-gradient(135deg, #6366f1, #4338ca); }
.user-card-avatar.role-manager { background: linear-gradient(135deg, #0891b2, #0e7490); }
.user-card-avatar.role-operations_manager { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }
.user-card-avatar.role-clinic_manager { background: linear-gradient(135deg, #d97706, #b45309); }
.user-card-avatar.role-coordinator { background: linear-gradient(135deg, #059669, #047857); }
.user-card-avatar.role-surgeon { background: linear-gradient(135deg, #dc2626, #b91c1c); }
.user-card-avatar.role-hospital_coordinator { background: linear-gradient(135deg, #2563eb, #1d4ed8); }
.user-card-info { flex: 1; min-width: 0; }
.user-card-name { font-weight: 700; font-size: .92rem; }
.user-card-email { font-size: .78rem; color: var(--muted); margin-top: 1px; }
.user-card-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.user-card-branch { font-size: .75rem; color: var(--muted); }
.user-card-action { flex: none; }

.badge.role-admin { background: #eef2ff; color: #4338ca; border-color: #c7d2fe; }
.badge.role-manager { background: #ecfeff; color: #0e7490; border-color: #a5f3fc; }
.badge.role-operations_manager { background: #f5f3ff; color: #6d28d9; border-color: #ddd6fe; }
.badge.role-clinic_manager { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.badge.role-coordinator { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.badge.role-surgeon { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.badge.role-hospital_coordinator { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
:root[data-theme="dark"] .badge.role-admin { background: #1e1b4b; color: #a5b4fc; border-color: #3730a3; }
:root[data-theme="dark"] .badge.role-manager { background: #083344; color: #67e8f9; border-color: #155e75; }
:root[data-theme="dark"] .badge.role-operations_manager { background: #2e1065; color: #c4b5fd; border-color: #5b21b6; }
:root[data-theme="dark"] .badge.role-clinic_manager { background: #451a03; color: #fbbf24; border-color: #92400e; }
:root[data-theme="dark"] .badge.role-coordinator { background: #022c22; color: #6ee7b7; border-color: #065f46; }
:root[data-theme="dark"] .badge.role-surgeon { background: #450a0a; color: #fca5a5; border-color: #991b1b; }
:root[data-theme="dark"] .badge.role-hospital_coordinator { background: #1e3a5f; color: #93c5fd; border-color: #1e40af; }

/* ═══ CRUD cards ═══ */
.ref-card {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 6px; background: var(--panel); transition: all .15s;
}
.ref-card:hover { border-color: var(--brand); box-shadow: var(--shadow); }
.ref-card .ref-info { display: flex; flex-direction: column; gap: 2px; }
.ref-card .ref-main { font-weight: 600; font-size: .92rem; }
.ref-card .ref-sub { font-size: .78rem; color: var(--muted); }
.ref-card .ref-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.ref-card .ref-actions { display: flex; gap: 6px; align-items: center; }

/* ═══ Perms grid ═══ */
.perms-section { margin-bottom: 1.5rem; }
.perms-section h4 { margin-bottom: .5rem; font-size: .95rem; }
.perms-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.perm-chip {
  display: flex; align-items: center; gap: .4rem; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: var(--radius); font-size: .82rem;
  cursor: pointer; transition: .15s; background: var(--panel);
}
.perm-chip:hover { border-color: var(--brand); }
.perm-chip.active { background: rgba(63,158,77,.1); border-color: var(--brand); }

/* ═══ Permission checkboxes ═══ */
.perm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.perm-grid label { display: flex; align-items: center; gap: .4rem; font-size: .82rem; cursor: pointer; color: var(--text); font-weight: 400; }

/* ═══ Info box ═══ */
.note-box {
  background: rgba(63,158,77,.06); border: 1px solid rgba(63,158,77,.15);
  border-radius: var(--radius); padding: 10px 14px; font-size: .82rem; color: var(--muted);
}
:root[data-theme="dark"] .note-box { background: rgba(87,192,106,.06); border-color: rgba(87,192,106,.15); }

/* ═══ Empty state ═══ */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: .5rem; }

/* ═══ Block detail inline edit ═══ */
.inline-field { display: flex; gap: 8px; align-items: center; }
.inline-field label { font-size: .82rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
.inline-field input, .inline-field select {
  padding: .35rem .5rem; border: 1px solid var(--line); border-radius: 6px;
  font-size: .85rem; background: var(--bg);
}

/* ═══ Responsive ═══ */
@media (max-width: 768px) {
  .topbar { gap: 10px; padding: 0 12px; margin: 8px 8px 0; }
  .nav-toggle { display: block; }
  .topbar-nav { display: none; position: absolute; top: 60px; inset-inline-start: 0; inset-inline-end: 0;
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); flex-direction: column; padding: 8px; z-index: 50;
  }
  .topbar-nav.open { display: flex; }
  .topbar .brand span { display: none; }
  .user-info span:not(.avatar) { display: none; }
  .blocks-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .summary div { flex-direction: column; gap: 2px; }
  .view-controls { width: 100%; }
  #main-content { padding: 14px 10px; }
  .actions-bar .btn { min-width: 0; }
  .admin-tabs { gap: 0; overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .admin-tab { padding: .5rem .7rem; font-size: .8rem; white-space: nowrap; }
  .data-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .perms-grid { grid-template-columns: 1fr; }
  .perm-grid { grid-template-columns: 1fr; }
  .user-card-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
