/* =============================================================================
   Patient Registry — visual system
   Hatzalah palette (#5B78ED primary), Poppins, self-hosted.
   ============================================================================= */

@font-face { font-family: Poppins; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/poppins-400.woff2') format('woff2'); }
@font-face { font-family: Poppins; font-style: normal; font-weight: 500; font-display: swap; src: url('/fonts/poppins-500.woff2') format('woff2'); }
@font-face { font-family: Poppins; font-style: normal; font-weight: 600; font-display: swap; src: url('/fonts/poppins-600.woff2') format('woff2'); }

:root {
    --primary: #5B78ED;
    --primary-dark: #4762D1;
    --primary-1: #6885F7;
    --primary-light: #F4F4FF;
    --violet-light: #E6EAFD;
    --grad: linear-gradient(135deg, #6E8BFA 0%, #5B78ED 55%, #4762D1 100%);

    --ink: #1B2437;
    --ink-2: #3F4A5F;
    --muted: #7C869A;
    --faint: #AEB6C6;

    --line: #E4E8F0;
    --line-soft: #EEF1F6;
    --surface: #FFFFFF;
    --canvas: #F3F5FA;
    --hover: #F7F8FE;

    --danger: #CD504B;
    --danger-light: #FDEDEC;

    /* one tint per kind of record: pills, chips and section markers */
    --k-doctors-bg: #EEF1FE;      --k-doctors-fg: #4762D1;      --k-doctors: #5B78ED;
    --k-diseases-bg: #FDEEF1;     --k-diseases-fg: #B8395A;     --k-diseases: #E05577;
    --k-procedures-bg: #E6F6F3;   --k-procedures-fg: #1C7A6A;   --k-procedures: #2AA48F;
    --k-specialties-bg: #FFF3E0;  --k-specialties-fg: #9A5B08;  --k-specialties: #E9962A;
    --k-affiliations-bg: #F2ECFE; --k-affiliations-fg: #6A3FC7; --k-affiliations: #8A5CF0;

    --r: 14px;
    --r-sm: 9px;
    --shadow-1: 0 1px 2px rgba(27, 36, 55, .05), 0 2px 6px rgba(27, 36, 55, .04);
    --shadow-2: 0 6px 20px rgba(27, 36, 55, .08), 0 1px 3px rgba(27, 36, 55, .05);
    --shadow-3: -24px 0 60px rgba(27, 36, 55, .18);
    --glow: 0 6px 18px rgba(91, 120, 237, .32);
    --ease: cubic-bezier(.4, 0, .2, 1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }

body {
    margin: 0;
    color: var(--ink);
    font-family: Poppins, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    background:
        radial-gradient(900px 420px at 8% -10%, rgba(104, 133, 247, .16), transparent 60%),
        radial-gradient(700px 380px at 100% 0%, rgba(138, 92, 240, .10), transparent 55%),
        var(--canvas);
    background-attachment: fixed;
}
body.panel-open { overflow: hidden; }

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.012em; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.05rem; }
.muted { color: var(--muted); }

/* ----- top bar --------------------------------------------------------------- */

.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    height: 60px; padding: 0 1.5rem;
    background: rgba(255, 255, 255, .78);
    backdrop-filter: saturate(160%) blur(12px);
    -webkit-backdrop-filter: saturate(160%) blur(12px);
    border-bottom: 1px solid rgba(228, 232, 240, .9);
}
.brand { display: inline-flex; align-items: center; gap: .7rem; font-weight: 600; font-size: 1.02rem; letter-spacing: -.01em; }

.brand-mark {
    position: relative; display: inline-block; flex: none;
    width: 30px; height: 30px; border-radius: 9px;
    background: var(--grad); box-shadow: var(--glow);
}
.brand-mark::before, .brand-mark::after {
    content: ""; position: absolute; left: 50%; top: 50%;
    background: #fff; border-radius: 2px; transform: translate(-50%, -50%);
}
.brand-mark::before { width: 3px; height: 15px; }
.brand-mark::after { width: 15px; height: 3px; }
.brand-mark.lg { width: 52px; height: 52px; border-radius: 16px; margin-bottom: 1.25rem; }
.brand-mark.lg::before { width: 4px; height: 26px; }
.brand-mark.lg::after { width: 26px; height: 4px; }

.topbar-right { display: flex; align-items: center; gap: .85rem; }
.who-avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--grad); color: #fff; font-size: .72rem; font-weight: 600; box-shadow: var(--glow);
}
.who { color: var(--ink-2); font-size: .875rem; font-weight: 500; }
.inline { display: inline; }
.linkish {
    background: none; border: 0; padding: .35rem .6rem; border-radius: 999px;
    font: inherit; font-size: .82rem; color: var(--muted); cursor: pointer;
    transition: background .16s var(--ease), color .16s var(--ease);
}
.linkish:hover { background: var(--line-soft); color: var(--ink); }

/* ----- list tabs: a segmented control ---------------------------------------- */

.tab_buttons {
    display: inline-flex; gap: .2rem;
    margin: 1.25rem 1.5rem 0; padding: .3rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, .7);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-1);
    max-width: calc(100% - 3rem);
    overflow-x: auto; scrollbar-width: none;
}
.tab_buttons::-webkit-scrollbar { display: none; }
.tab_buttons button {
    display: inline-flex; align-items: center; gap: .45rem;
    border: 0; padding: .5rem 1rem; border-radius: 999px; background: transparent;
    font: inherit; font-weight: 500; color: var(--ink-2); white-space: nowrap; cursor: pointer;
    transition: background .18s var(--ease), color .18s var(--ease), box-shadow .18s var(--ease);
}
.tab_buttons button:hover { background: var(--line-soft); color: var(--ink); }
.tab_buttons button.selected { background: var(--grad); color: #fff; box-shadow: var(--glow); }
.tab_buttons .count {
    min-width: 1.45rem; padding: .05rem .4rem; border-radius: 999px;
    background: var(--line-soft); color: var(--muted);
    font-size: .7rem; font-weight: 600; line-height: 1.5; text-align: center;
    transition: background .18s var(--ease), color .18s var(--ease);
}
.tab_buttons .count:empty { display: none; }
.tab_buttons button.selected .count { background: rgba(255, 255, 255, .22); color: #fff; }

/* ----- toolbar --------------------------------------------------------------- */

.toolbar { display: flex; align-items: center; gap: .75rem; padding: 1rem 1.5rem .25rem; }
.search-field { position: relative; flex: 1 1 auto; max-width: 520px; }
.search-field::before {
    content: ""; position: absolute; left: 1rem; top: 50%;
    width: 16px; height: 16px; margin-top: -8px; background: var(--muted); pointer-events: none;
    -webkit-mask: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.2-3.2'/%3E%3C/svg%3E");
    mask: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.2-3.2'/%3E%3C/svg%3E");
    transition: background .16s var(--ease);
}
.search-field:focus-within::before { background: var(--primary); }

input[type=text], input[type=search], input[type=password], input[type=email], textarea, select {
    width: 100%; padding: .68rem .9rem;
    border: 1px solid var(--line); border-radius: var(--r-sm);
    background: var(--surface); color: var(--ink); font: inherit;
    box-shadow: inset 0 1px 2px rgba(27, 36, 55, .03);
    transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
.search-field .search-input { padding-left: 2.75rem; border-radius: 999px; }
.toolbar .search-input { height: 46px; box-shadow: var(--shadow-1); border-color: transparent; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary-1); box-shadow: 0 0 0 4px rgba(91, 120, 237, .14); }
input::placeholder, textarea::placeholder { color: var(--faint); }
textarea { min-height: 92px; resize: vertical; }

.search-hint {
    position: absolute; right: .9rem; top: 50%; transform: translateY(-50%);
    padding: .05rem .45rem; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px;
    background: var(--canvas); color: var(--muted); font-family: inherit; font-size: .72rem;
    pointer-events: none; transition: opacity .15s var(--ease);
}
.search-field:focus-within .search-hint { opacity: 0; }

/* ----- buttons --------------------------------------------------------------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
    height: 46px; padding: 0 1.25rem; border: 0; border-radius: 999px;
    background: var(--grad); color: #fff; font: inherit; font-weight: 600;
    cursor: pointer; white-space: nowrap; box-shadow: var(--glow);
    transition: transform .12s var(--ease), box-shadow .16s var(--ease), filter .16s var(--ease);
}
.btn:hover { filter: brightness(1.05); box-shadow: 0 8px 22px rgba(91, 120, 237, .4); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px rgba(91, 120, 237, .25); }
.btn.block { width: 100%; }
.btn.secondary { background: var(--surface); color: var(--primary-dark); border: 1px solid var(--line); box-shadow: var(--shadow-1); }
.btn.secondary:hover { background: var(--primary-light); border-color: var(--violet-light); filter: none; }
.btn.danger { background: var(--surface); color: var(--danger); border: 1px solid var(--line); box-shadow: none; }
.btn.danger:hover { background: var(--danger-light); border-color: #F1C7C5; filter: none; box-shadow: none; }
.add-btn .plus { font-size: 1.25rem; line-height: 1; margin-top: -2px; }

.icon-btn {
    display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
    border: 0; width: 34px; height: 34px; border-radius: 50%;
    background: var(--line-soft); font-size: 1.3rem; line-height: 1; color: var(--ink-2); cursor: pointer;
    transition: background .16s var(--ease), color .16s var(--ease);
}
.icon-btn:hover { background: var(--line); color: var(--ink); }

/* ----- table ----------------------------------------------------------------- */

.content { padding: .75rem 1.5rem 2.5rem; }
.table-wrap {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
    box-shadow: var(--shadow-2); overflow: auto; max-height: calc(100vh - 232px);
}
table.table-default { width: 100%; border-collapse: separate; border-spacing: 0; }
table.table-default th {
    position: sticky; top: 0; z-index: 1; text-align: left;
    padding: .85rem 1.1rem; background: #FAFBFE; border-bottom: 1px solid var(--line);
    white-space: nowrap; vertical-align: middle;
}
table.table-default th, table.table-default th button.sort {
    font-size: .7rem; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--muted);
}
table.table-default th:has(button.sort) { padding: 0; }
table.table-default th button.sort {
    display: block; width: 100%; padding: .85rem 1.1rem; border: 0; background: none;
    text-align: left; font-family: inherit; cursor: pointer; transition: color .16s var(--ease);
}
table.table-default th button.sort:hover { color: var(--primary); }
table.table-default td { padding: .8rem 1.1rem; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.table-default tbody tr { cursor: pointer; transition: background .14s var(--ease); }
table.table-default tbody tr:hover { background: var(--hover); }
table.table-default tbody tr:hover td:first-child { box-shadow: inset 3px 0 0 var(--primary-1); }
table.table-default tbody tr:focus-visible { outline: 2px solid var(--primary-1); outline-offset: -2px; }
table.table-default tbody tr:last-child td { border-bottom: 0; }

.numeric { text-align: right; font-variant-numeric: tabular-nums; }
.tabular { font-variant-numeric: tabular-nums; }
.grid-status { margin: .85rem .25rem 0; font-size: .82rem; }

.person { display: inline-flex; align-items: center; gap: .7rem; }
.strong { font-weight: 500; color: var(--ink); }

.avatar {
    display: flex; align-items: center; justify-content: center; flex: none;
    width: 40px; height: 40px; border-radius: 50%;
    color: #fff; font-size: .82rem; font-weight: 600; letter-spacing: .02em;
    background: var(--grad); box-shadow: 0 3px 8px rgba(27, 36, 55, .12);
}
.avatar.sm { width: 32px; height: 32px; font-size: .68rem; }
.avatar.c0 { background: linear-gradient(135deg, #6E8BFA, #4762D1); }
.avatar.c1 { background: linear-gradient(135deg, #F07C9B, #C93A62); }
.avatar.c2 { background: linear-gradient(135deg, #3FBFA9, #1C7A6A); }
.avatar.c3 { background: linear-gradient(135deg, #F5A64B, #C96F0E); }
.avatar.c4 { background: linear-gradient(135deg, #A57CF5, #6A3FC7); }
.avatar.c5 { background: linear-gradient(135deg, #58B4F0, #2B7DC1); }
.avatar.is-new { background: var(--grad); font-size: 1.3rem; font-weight: 400; }

.cell-chips { display: flex; flex-wrap: wrap; gap: .32rem; }
.pill {
    padding: .16rem .6rem; border-radius: 999px;
    background: var(--line-soft); color: var(--ink-2);
    font-size: .78rem; font-weight: 500; white-space: nowrap;
}
.pill[data-kind="doctors"], .tag[data-kind="doctors"], .pill[data-kind="patients"], .tag[data-kind="patients"] { background: var(--k-doctors-bg); color: var(--k-doctors-fg); }
.pill[data-kind="diseases"], .tag[data-kind="diseases"] { background: var(--k-diseases-bg); color: var(--k-diseases-fg); }
.pill[data-kind="procedures"], .tag[data-kind="procedures"] { background: var(--k-procedures-bg); color: var(--k-procedures-fg); }
.pill[data-kind="specialties"], .tag[data-kind="specialties"] { background: var(--k-specialties-bg); color: var(--k-specialties-fg); }
.pill[data-kind="affiliations"], .tag[data-kind="affiliations"] { background: var(--k-affiliations-bg); color: var(--k-affiliations-fg); }

mark { background: #FFEFA8; color: inherit; border-radius: 3px; padding: 0 .12em; }

.skeleton-row td { padding: .9rem 1.1rem; }
.skeleton {
    display: block; height: .72rem; border-radius: 4px;
    background: linear-gradient(90deg, var(--line-soft) 25%, #E6E9F1 37%, var(--line-soft) 63%);
    background-size: 400% 100%; animation: shimmer 1.3s var(--ease) infinite;
}
@keyframes shimmer { from { background-position: 100% 50% } to { background-position: 0 50% } }
.skeleton.dot { width: 32px; height: 32px; border-radius: 50%; flex: none; }
.skeleton.chip-skel { display: inline-block; width: 6.5rem; height: 1.7rem; border-radius: 999px; margin-right: .4rem; }
.skeleton-row:nth-child(odd) .skeleton:not(.dot) { width: 78%; }
.skeleton-row:nth-child(even) .skeleton:not(.dot) { width: 58%; }
.skeleton-row .person .skeleton:not(.dot) { width: 7rem; }

.empty-row td { padding: 0; border-bottom: 0; }
.empty-state { padding: 4rem 1rem; text-align: center; }
.empty-title { margin: 1rem 0 .2rem; font-weight: 600; }
.empty-state p { margin: 0; }
.empty-mark {
    position: relative; width: 52px; height: 52px; margin: 0 auto; border-radius: 16px;
    background: var(--primary-light); border: 1px solid var(--violet-light);
}
.empty-mark::after {
    content: ""; position: absolute; inset: 0; margin: auto;
    width: 18px; height: 18px; border: 2.5px solid var(--primary-1); border-radius: 50%;
    box-shadow: 8px 8px 0 -6px var(--primary-1);
}
.empty-mark.small { width: 36px; height: 36px; border-radius: 11px; }
.empty-mark.small::after { width: 13px; height: 13px; border-width: 2px; box-shadow: 6px 6px 0 -4px var(--primary-1); }

/* ----- side panel ------------------------------------------------------------ */

.scrim {
    position: fixed; inset: 0; z-index: 40;
    background: rgba(27, 36, 55, .36);
    backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
    animation: fade .22s var(--ease);
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

.side-panel {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 50;
    width: min(480px, 100%); display: flex; flex-direction: column;
    background: var(--surface); box-shadow: var(--shadow-3);
    animation: slide-in .3s var(--ease);
}
@keyframes slide-in { from { transform: translateX(100%) } to { transform: translateX(0) } }

.side-panel-header {
    display: flex; align-items: center; gap: .9rem;
    padding: 1.25rem 1.5rem 1rem;
    background:
        radial-gradient(420px 160px at 0% 0%, rgba(104, 133, 247, .16), transparent 70%),
        linear-gradient(180deg, #FAFBFF, #fff);
}
.side-panel-header .avatar { width: 48px; height: 48px; font-size: .95rem; }
.side-panel-heading { flex: 1; min-width: 0; }
.side-panel-heading h2 { font-size: 1.15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-panel-sub { display: block; font-size: .82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-panel-sub:empty { display: none; }

.side-panel-actions { display: flex; flex-wrap: wrap; gap: .45rem; padding: 0 1.5rem 1rem; border-bottom: 1px solid var(--line); }
.side-panel-actions:empty { display: none; }
.chip-action {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .38rem .85rem; border-radius: 999px;
    background: var(--primary-light); color: var(--primary-dark); border: 1px solid var(--violet-light);
    font-size: .8rem; font-weight: 500; text-decoration: none;
    transition: background .15s var(--ease), transform .12s var(--ease);
}
.chip-action:hover { background: var(--violet-light); transform: translateY(-1px); }

.side-panel-body { flex: 1; overflow-y: auto; padding: 1.25rem 1.5rem 1.5rem; }
.side-panel-body > * { animation: rise .22s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(4px) } to { opacity: 1; transform: none } }

.side-panel-footer {
    display: flex; align-items: center; justify-content: space-between; gap: .75rem;
    padding: 1rem 1.5rem; border-top: 1px solid var(--line); background: rgba(255, 255, 255, .92);
}
.side-panel-footer .btn { height: 44px; }

/* read mode */
.profile { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem 1rem; padding: .15rem 0 .5rem; }
.fact { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.fact.wide { grid-column: 1 / -1; }
.fact-k { font-size: .68rem; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--faint); }
.fact-v { font-size: .98rem; color: var(--ink); overflow-wrap: anywhere; white-space: pre-line; }
.fact-v a { color: var(--primary-dark); text-decoration: none; font-weight: 500; }
.fact-v a:hover { text-decoration: underline; }
.profile-empty {
    display: block; width: 100%; padding: 1rem; border-radius: var(--r-sm);
    border: 1.5px dashed var(--line); background: transparent; color: var(--muted);
    font: inherit; font-size: .9rem; cursor: pointer; text-align: left;
}
.profile-empty:hover { border-color: var(--primary); color: var(--primary-dark); background: var(--primary-light); }
.icon-btn.active { background: var(--primary-light); color: var(--primary-dark); }

.form { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .9rem; }
.form .field { grid-column: 1 / -1; }
.form .field.half { grid-column: auto; }
.field { margin-bottom: 1rem; }
.field:last-child { margin-bottom: 0; }
label { display: block; margin-bottom: .38rem; font-size: .78rem; font-weight: 500; color: var(--ink-2); }

.panel-section {
    margin-top: 1.5rem; padding: 1.1rem 1.15rem 1.15rem;
    border-radius: var(--r); background: var(--canvas); border: 1px solid var(--line-soft);
}
.panel-section h3 {
    display: flex; align-items: center; gap: .55rem; margin: 0 0 .85rem;
    font-size: .72rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.panel-section h3::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.panel-section[data-section="doctors"] h3::before, .panel-section[data-section="patients"] h3::before { background: var(--k-doctors); }
.panel-section[data-section="diseases"] h3::before { background: var(--k-diseases); }
.panel-section[data-section="procedures"] h3::before { background: var(--k-procedures); }
.panel-section[data-section="affiliations"] h3::before { background: var(--k-affiliations); }
.panel-section[data-section="comments"] h3::before { background: var(--k-specialties); }
.panel-section h3 .count {
    min-width: 1.4rem; padding: .05rem .4rem; border-radius: 999px;
    background: var(--surface); border: 1px solid var(--line); color: var(--ink-2);
    font-size: .68rem; text-align: center; letter-spacing: 0;
}
.panel-section .none { font-size: .85rem; }
.save-first {
    margin: 1.5rem 0 0; padding: 1rem 1.15rem; border-radius: var(--r);
    background: var(--primary-light); border: 1px dashed var(--violet-light); color: var(--primary-dark); font-size: .85rem;
}

.mapped-list { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; }
.tag {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .38rem .45rem .38rem .8rem; border-radius: 999px;
    background: var(--violet-light); color: var(--primary-dark);
    font-size: .82rem; font-weight: 500; animation: pop .18s var(--ease);
    transition: transform .12s var(--ease), box-shadow .16s var(--ease);
}
.tag[data-open] { cursor: pointer; }
.tag:hover { transform: translateY(-1px); box-shadow: var(--shadow-1); }
.tag[data-open]:hover, .tag[data-open]:focus-visible { text-decoration: underline; text-underline-offset: 3px; outline: none; }
.tag .tag-x { text-decoration: none; }
@keyframes fade-in { from { opacity: 0; transform: translateY(-4px) } to { opacity: 1; transform: none } }
@keyframes pop { from { opacity: 0; transform: scale(.94) } to { opacity: 1; transform: scale(1) } }
.tag-x {
    display: inline-flex; align-items: center; justify-content: center;
    width: 20px; height: 20px; border: 0; border-radius: 50%;
    background: rgba(255, 255, 255, .55); color: inherit; font-size: 1rem; line-height: 1; cursor: pointer;
    transition: background .15s var(--ease);
}
.tag-x:hover { background: rgba(255, 255, 255, .95); }

.add-link {
    display: inline-flex; align-items: center; gap: .3rem;
    min-width: 32px; height: 32px; padding: 0 .7rem; border-radius: 999px;
    border: 1.5px dashed var(--line); background: transparent; color: var(--muted);
    font: inherit; font-size: .8rem; font-weight: 500; cursor: pointer;
    transition: border-color .15s var(--ease), color .15s var(--ease), background .15s var(--ease), transform .12s var(--ease);
}
.add-link .plus { font-size: 1.15rem; line-height: 1; font-weight: 500; }
.add-link:hover, .add-link.open { border-style: solid; border-color: var(--primary); color: var(--primary-dark); background: var(--primary-light); transform: translateY(-1px); }
.add-link.open .plus { transform: rotate(45deg); display: inline-block; }
.panel-search { max-width: none; margin-top: .15rem; animation: fade-in .18s var(--ease); }

/* calls */
.calls { display: flex; flex-direction: column; gap: .5rem; }
.call-card {
    padding: .7rem .85rem; border-radius: var(--r-sm);
    background: var(--surface); border: 1px solid var(--line-soft); box-shadow: var(--shadow-1);
    display: flex; flex-direction: column; gap: .3rem; animation: pop .18s var(--ease);
}
.call-top { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.call-type { font-weight: 600; color: var(--ink); }
.call-status {
    flex: 0 0 auto; padding: .15rem .55rem; border-radius: 999px;
    font-size: .7rem; font-weight: 600; letter-spacing: .02em;
    background: var(--line-soft); color: var(--muted);
}
.call-status.open { background: #e6f4ea; color: #1e7b3a; }
.call-status.complete { background: var(--primary-light); color: var(--primary-dark); }
.call-status.cancelled { background: #fbe9e7; color: #b23a2a; }
.call-meta { display: flex; flex-wrap: wrap; gap: .25rem .7rem; font-size: .8rem; color: var(--muted); }
.call-cad { font-variant-numeric: tabular-nums; }
.call-seg { display: inline-block; margin-right: .45rem; padding: .05rem .4rem; border-radius: 4px; background: #fbe9e7; color: #b23a2a; font-size: .66rem; font-weight: 700; letter-spacing: .04em; vertical-align: 2px; }
.call-card.archived { opacity: .75; }
.call-members { display: flex; flex-wrap: wrap; gap: .3rem; }
.member-tag {
    display: inline-flex; align-items: center; padding: .12rem .5rem; border-radius: 999px;
    background: var(--primary-light); color: var(--primary-dark); border: 1px solid var(--violet-light);
    font-size: .72rem; font-weight: 700; letter-spacing: .02em; font-variant-numeric: tabular-nums;
}
.member-tag.bus { background: #fff4e5; color: #9a5b00; border-color: #ffe2b8; }
.call-lines { display: flex; flex-wrap: wrap; gap: .2rem .7rem; font-size: .84rem; color: var(--ink-2); }
.call-dispo { color: var(--primary-dark); font-weight: 500; }
.skeleton-card { gap: .5rem; }
.skeleton-card .skeleton { height: .8rem; width: 60%; }
.skeleton-card .skeleton.short { width: 35%; }
.panel-search .search-input { border-radius: var(--r-sm); background: var(--surface); }
.doctor-results { display: flex; flex-direction: column; gap: .2rem; margin-top: .4rem; }
.doctor-item {
    display: flex; align-items: baseline; gap: .55rem; width: 100%;
    padding: .6rem .75rem; border: 0; border-radius: var(--r-sm);
    background: var(--surface); font: inherit; text-align: left; cursor: pointer; box-shadow: var(--shadow-1);
    transition: background .14s var(--ease), transform .12s var(--ease);
}
.doctor-item:hover { background: var(--primary-light); transform: translateX(2px); }
.doctor-name { font-weight: 500; }
.doctor-item .muted { font-size: .8rem; }
.results-none { padding: .5rem .7rem; font-size: .85rem; }

.comments { margin-bottom: .85rem; }
.comments-item {
    padding: .8rem .95rem; margin-bottom: .5rem; border-radius: var(--r-sm);
    background: var(--surface); border: 1px solid var(--line-soft); box-shadow: var(--shadow-1);
}
.comments-item:last-child { margin-bottom: 0; }
.comments-date { margin-top: .3rem; font-size: .75rem; color: var(--muted); }
.comment-form textarea { min-height: 72px; background: var(--surface); }
.comment-form .btn { margin-top: .6rem; height: 40px; }
.panel-empty { padding: 1.25rem 0 1rem; text-align: center; }
.panel-empty p { margin: .7rem 0 0; font-size: .875rem; }

/* ----- toasts ---------------------------------------------------------------- */

.toasts {
    position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); z-index: 60;
    display: flex; flex-direction: column; align-items: center; gap: .5rem; pointer-events: none;
}
.toast {
    padding: .65rem 1.2rem; border-radius: 999px;
    background: var(--ink); color: #fff; font-size: .85rem; font-weight: 500;
    box-shadow: 0 10px 30px rgba(27, 36, 55, .28); animation: toast-in .24s var(--ease);
}
.toast.warn { background: var(--danger); }
.toast.leaving { animation: toast-out .22s var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.97) } to { opacity: 1; transform: none } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px) scale(.98) } }

/* ----- sign in --------------------------------------------------------------- */

.signin-wrap { display: grid; grid-template-columns: 1.1fr 1fr; min-height: 100vh; }
.signin-side {
    position: relative; display: flex; flex-direction: column; justify-content: flex-end;
    padding: 3rem; color: #fff; background: var(--grad); overflow: hidden;
}
.signin-side::before, .signin-side::after { content: ""; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .10); }
.signin-side::before { width: 520px; height: 520px; right: -160px; top: -200px; }
.signin-side::after { width: 360px; height: 360px; left: -120px; bottom: -160px; background: rgba(255, 255, 255, .07); }
.signin-side .brand-mark.lg { background: rgba(255, 255, 255, .18); box-shadow: none; margin-bottom: 1.5rem; position: relative; }
.signin-side h1 { font-size: 2rem; line-height: 1.15; max-width: 22ch; position: relative; }
.signin-side p { margin: .9rem 0 0; max-width: 40ch; color: rgba(255, 255, 255, .82); font-size: .95rem; position: relative; }
.signin-form-wrap { display: flex; align-items: center; justify-content: center; padding: 2rem; }
.signin { width: 100%; max-width: 380px; }
.signin h2 { font-size: 1.5rem; margin-bottom: .25rem; }
.signin > p { margin: 0 0 1.75rem; font-size: .9rem; }
.signin .btn { margin-top: .5rem; }
.signin .field { margin-bottom: 1.1rem; }

.alert {
    padding: .7rem .9rem; margin-bottom: 1.1rem; border-radius: var(--r-sm);
    background: var(--danger-light); border: 1px solid #F3C9C7; color: var(--danger); font-size: .85rem;
}

/* ----- phone ----------------------------------------------------------------- */

@media (max-width: 760px) {
    .topbar { height: 56px; padding: 0 1rem; }
    .who { display: none; }
    /* all six tabs stay visible: two rows instead of a strip you have to guess scrolls */
    .tab_buttons { display: flex; flex-wrap: wrap; gap: .15rem; margin: .85rem 1rem 0; max-width: calc(100% - 2rem); border-radius: 22px; overflow: visible; }
    .tab_buttons button { flex: 1 1 30%; justify-content: center; padding: .45rem .5rem; font-size: .9rem; }
    .tab_buttons .count { min-width: 1.3rem; font-size: .66rem; }
    .toolbar { padding: .85rem 1rem .25rem; }
    .search-field { max-width: none; }
    .content { padding: .5rem 1rem 6rem; }

    .add-btn {
        position: fixed; right: 1.1rem; bottom: 1.2rem; z-index: 30;
        width: 58px; height: 58px; padding: 0; border-radius: 50%;
        box-shadow: 0 10px 26px rgba(91, 120, 237, .45);
    }
    .add-btn .plus { font-size: 1.8rem; margin: 0; }
    .add-btn .add-label { display: none; }
    body.panel-open .add-btn { display: none; }

    .table-wrap { max-height: none; border: 0; background: none; box-shadow: none; overflow: visible; }
    table.table-default, table.table-default tbody, table.table-default tr { display: block; width: 100%; }
    table.table-default thead { display: none; }
    table.table-default tbody tr {
        margin-bottom: .75rem; padding: .8rem 1rem .9rem;
        background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-1);
    }
    table.table-default tbody tr:hover td:first-child { box-shadow: none; }
    table.table-default td:first-child { display: block; padding: 0 0 .6rem; margin: 0 0 .45rem; border-bottom: 1px solid var(--line-soft); }
    table.table-default td:first-child .strong { font-size: 1.02rem; }
    table.table-default td:first-child .avatar.sm { width: 38px; height: 38px; font-size: .78rem; }
    table.table-default td:not(:first-child) { display: inline; width: auto; padding: 0; margin: 0; border: 0; font-size: .9rem; line-height: 1.95; }
    table.table-default td::before { content: none; }
    table.table-default td[data-label]:empty { display: none; }
    table.table-default td[data-label="Address"], table.table-default td[data-label="Memo"],
    table.table-default td[data-label="Note"], table.table-default td[data-label="Email"] { display: block; }
    table.table-default td[data-label="Memo"], table.table-default td[data-label="Note"] { color: var(--muted); font-style: italic; }
    table.table-default td[data-label*="phone" i], table.table-default td[data-label="Fax"], table.table-default td.numeric { display: inline-block; margin-right: 1rem; text-align: left; }
    table.table-default td[data-label*="phone" i]::before, table.table-default td[data-label="Fax"]::before, table.table-default td.numeric::before {
        content: attr(data-short); display: inline; margin-right: .3rem;
        font-size: .62rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--faint);
    }
    table.table-default td:has(.cell-chips) { display: block; padding-top: .35rem; }
    .cell-chips { gap: .35rem; }
    .grid-status { margin-top: .4rem; }

    .side-panel { width: 100%; animation: slide-up .3s var(--ease); }
    @keyframes slide-up { from { transform: translateY(100%) } to { transform: translateY(0) } }
    .side-panel-header, .side-panel-body, .side-panel-footer, .side-panel-actions { padding-left: 1.1rem; padding-right: 1.1rem; }
    .form { grid-template-columns: 1fr; }
    .form .field.half { grid-column: 1 / -1; }

    .search-hint { display: none; }
    .toasts { bottom: 5.6rem; width: calc(100% - 2rem); }
    .toast { width: 100%; text-align: center; }

    .signin-wrap { grid-template-columns: 1fr; }
    .signin-side { min-height: 38vh; padding: 2rem 1.5rem; }
    .signin-side h1 { font-size: 1.5rem; }
    .signin-form-wrap { padding: 1.75rem 1.5rem 2.5rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
