@font-face {
    font-family: "YekanBakhFaNum";
    src: url("../fonts/YekanBakhFaNum-Light.woff2") format("woff2");
    font-weight: 300;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "YekanBakhFaNum";
    src: url("../fonts/YekanBakhFaNum-Regular.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "YekanBakhFaNum";
    src: url("../fonts/YekanBakhFaNum-SemiBold.woff2") format("woff2");
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "YekanBakhFaNum";
    src: url("../fonts/YekanBakhFaNum-Bold.woff2") format("woff2");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "YekanBakhFaNum";
    src: url("../fonts/YekanBakhFaNum-ExtraBold.woff2") format("woff2");
    font-weight: 800;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Vazirmatn";
    src: url("../fonts/vazirmatn.woff2") format("woff2 supports variations"),
         url("../fonts/vazirmatn.woff2") format("woff2-variations");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

/* ============================================================
   Design tokens
   ============================================================ */
:root {
    --paper: #f7f8fa;
    --surface: #ffffff;
    --surface-2: #f5f6f9;
    --surface-sunken: #f0f2f6;

    --ink: #1a2233;
    --ink-dim: #6b7385;
    --ink-faint: #9aa1b2;

    --border: #e6e8ef;
    --border-strong: #d4d8e2;
    --border-focus: var(--signal);

    --signal: #2f5eff;
    --signal-light: #eef2ff;
    --signal-dark: #244bd1;
    --signal-accent: #5b7fff;

    --success: #1c9a6c;
    --success-bg: #e7f6ef;
    --warning: #b7791f;
    --warning-bg: #fbf0dd;
    --danger: #d6493a;
    --danger-bg: #fbeae8;
    --info: var(--signal);
    --info-bg: var(--signal-light);

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --shadow-sm: 0 1px 3px rgba(47, 94, 255, 0.06);
    --shadow: 0 4px 16px rgba(47, 94, 255, 0.10);
    --shadow-lg: 0 8px 32px rgba(47, 94, 255, 0.14);

    --font-ui: "YekanBakhFaNum", "Vazirmatn", -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, sans-serif;

    --header-h: 62px;
    --sidebar-w: 240px;

    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --transition: 0.15s ease;

    font-family: var(--font-ui);
}

/* ============================================================
   Reset & base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

button, a, input[type="checkbox"], input[type="radio"], select, .site-card, .employee-card {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

a { text-decoration: none; color: inherit; }

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 14px;
    line-height: 1.7;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 { margin: 0 0 .5rem; font-weight: 700; line-height: 1.3; }
p { margin: 0 0 1rem; }
ul, ol { list-style: none; margin: 0; padding: 0; }

/* Form controls and buttons don't inherit the page font in every browser —
   set it explicitly so nothing silently falls back to the OS UI font. */
button, input, select, textarea, optgroup {
    font-family: inherit;
}

:focus-visible {
    outline: 2px solid var(--signal);
    outline-offset: 2px;
}

.loading { padding: 60px; text-align: center; color: var(--ink-dim); }

/* ============================================================
   Login page
   ============================================================ */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: radial-gradient(circle at 20% 20%, #eef2ff 0%, var(--paper) 55%);
}
.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: 44px 40px;
    width: 360px;
}
.login-card h1 { margin: 0 0 4px; color: var(--ink); font-size: 25px; font-weight: 800; }
.login-card .subtitle { color: var(--ink-dim); margin: 0 0 26px; font-size: 13px; }
.login-card form { display: flex; flex-direction: column; gap: 16px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-dim); }
.login-card input {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 11px 13px;
    color: var(--ink);
    font-size: 14px;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.login-card input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(47, 94, 255, .15);
    outline: none;
}
.login-card button {
    background: var(--signal);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 6px;
    transition: background var(--transition), box-shadow var(--transition);
}
.login-card button:hover { background: var(--signal-dark); box-shadow: var(--shadow); }
.error-text { color: var(--danger); font-size: 13px; margin: 0; }

/* ============================================================
   App shell — fixed header + sidebar grid
   ============================================================ */
.shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    grid-template-rows: var(--header-h) 1fr;
    grid-template-areas: "header header" "sidebar content";
    min-height: 100vh;
}

.app-header {
    grid-area: header;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}
.app-header .brand {
    font-size: 16px;
    font-weight: 800;
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: 9px;
    text-decoration: none;
    flex-shrink: 0;
}
.app-header .brand .brand-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--signal);
    box-shadow: 0 0 0 4px var(--signal-light);
    flex-shrink: 0;
}
.app-header-breadcrumb {
    font-size: 13px;
    color: var(--ink-faint);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.app-header-breadcrumb .crumb-current { color: var(--ink-dim); font-weight: 500; }
.app-header-breadcrumb .crumb-link { color: var(--ink-faint); text-decoration: none; }
.app-header-breadcrumb .crumb-link:hover { color: var(--signal); }
.app-header-breadcrumb .crumb-sep { color: var(--ink-faint); }
.app-header-spacer { flex: 1; }

.sidebar-toggle {
    display: none;
    width: 34px; height: 34px;
    border: none; background: transparent;
    font-size: 17px; color: var(--ink-dim);
    border-radius: var(--radius-sm);
    cursor: pointer;
    flex-shrink: 0;
}
.sidebar-toggle:hover { background: var(--surface-2); }

.pin-toggle, .command-palette-btn {
    width: 32px; height: 32px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--ink-dim);
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color var(--transition), color var(--transition);
}
.pin-toggle:hover, .command-palette-btn:hover { color: var(--signal); border-color: var(--border-strong); }
.pin-toggle.pinned { color: var(--signal); border-color: var(--signal); }

.sidebar {
    grid-area: sidebar;
    background: var(--surface);
    border-left: 1px solid var(--border);
    position: sticky;
    top: var(--header-h);
    height: calc(100vh - var(--header-h));
    display: flex;
    flex-direction: column;
    padding: 18px 0;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }

.quick-access-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 22px 14px;
}
.quick-access-link {
    display: inline-flex;
    align-items: center;
    padding: 5px 11px;
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-dim);
    background: var(--surface-2);
    border-radius: 999px;
    text-decoration: none;
    transition: background var(--transition), color var(--transition);
}
.quick-access-link:hover, .quick-access-link.active { background: var(--signal-light); color: var(--signal); text-decoration: none; }

.sidebar nav { display: flex; flex-direction: column; gap: 10px; flex: 1; }
.nav-group { display: flex; flex-direction: column; gap: 0; }
.nav-group-label {
    padding: 0 22px;
    font-size: 10px;
    color: var(--ink-faint);
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    margin-bottom: 3px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.nav-group-label[data-collapsible] { cursor: pointer; user-select: none; }
.nav-group-label[data-collapsible]:hover { color: var(--ink-dim); }
.nav-group-label .nav-group-caret {
    font-size: 9px;
    transition: transform var(--transition);
    flex-shrink: 0;
}
.nav-group.collapsed .nav-group-caret { transform: rotate(-90deg); }
.nav-group.collapsed > a { display: none; }
.sidebar nav a {
    padding: 7px 22px;
    color: var(--ink-dim);
    text-decoration: none;
    font-size: 12.5px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 9px;
    position: relative;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    margin-left: 10px;
    transition: background var(--transition), color var(--transition);
}
.sidebar nav a:hover { background: var(--signal-light); color: var(--signal); text-decoration: none; }
.sidebar nav a.active {
    color: var(--signal);
    background: var(--signal-light);
    font-weight: 600;
}
.sidebar nav a.active::before {
    content: '';
    position: absolute;
    right: -1px;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--signal);
    border-radius: 999px 0 0 999px;
}
.sidebar nav a .nav-icon { font-size: 13.5px; width: 16px; text-align: center; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; }
.icon { display: inline-block; vertical-align: -3px; flex-shrink: 0; }
.btn .icon, button .icon { vertical-align: -3px; }

.user-box {
    border-top: 1px solid var(--border);
    padding: 14px 22px 0;
    margin-top: 14px;
}
.user-box-row { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.user-box-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--signal);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700;
    flex-shrink: 0;
}
.user-box .user-name { font-weight: 600; color: var(--ink); font-size: 13px; line-height: 1.3; }
.user-box .user-role { font-size: 11px; color: var(--ink-faint); }
.user-box button {
    width: 100%;
    background: transparent;
    border: 1px solid var(--border-strong);
    color: var(--ink-dim);
    border-radius: var(--radius-sm);
    padding: 7px 12px;
    cursor: pointer;
    font-size: 12.5px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: border-color var(--transition), color var(--transition), background var(--transition);
}
.user-box button:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-bg); }

main#app-main { grid-area: content; padding: 28px 32px; overflow-y: auto; min-height: 0; min-width: 0; }

/* ============================================================
   Page header
   ============================================================ */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
h2.page-title { margin: 0; font-size: 21px; font-weight: 700; letter-spacing: -.01em; display: flex; align-items: center; gap: 10px; }
h2.page-title i { color: var(--signal); }
.page-subtitle { color: var(--ink-dim); font-size: 13.5px; margin: 5px 0 0; line-height: 1.6; }

/* ============================================================
   Cards
   ============================================================ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 22px;
    margin-bottom: 20px;
}
.card.flush { padding: 0; }
.card > h3 {
    margin: 0 0 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
    font-size: 15px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ============================================================
   Stat tiles — icon-circle style
   ============================================================ */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: box-shadow var(--transition);
}
.stat-tile:hover { box-shadow: var(--shadow); }
button.stat-tile { cursor: pointer; font: inherit; text-align: inherit; color: inherit; width: 100%; }
.stat-tile.is-active { border-color: var(--signal); box-shadow: 0 0 0 2px var(--signal-light); }
.stat-tile-icon {
    width: 46px; height: 46px;
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 19px;
    flex-shrink: 0;
}
.stat-tile.accent-signal .stat-tile-icon { background: var(--signal-light); color: var(--signal); }
.stat-tile.accent-success .stat-tile-icon { background: var(--success-bg); color: var(--success); }
.stat-tile.accent-warning .stat-tile-icon { background: var(--warning-bg); color: var(--warning); }
.stat-tile.accent-danger .stat-tile-icon { background: var(--danger-bg); color: var(--danger); }
.stat-tile .value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1; }
.stat-tile .label { color: var(--ink-dim); font-size: 12.5px; margin-top: 4px; }

/* ============================================================
   Tables
   ============================================================ */
.table-scroll {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table-scroll table { min-width: 640px; border: none; border-radius: 0; }
thead th {
    position: sticky;
    top: 0;
    background: var(--surface-2);
    z-index: 1;
}
th, td { padding: 13px 14px; text-align: right; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--ink-dim); font-weight: 600; font-size: 12.5px; white-space: nowrap; }
thead tr th:first-child { border-radius: 0 var(--radius-lg) 0 0; }
thead tr th:last-child { border-radius: var(--radius-lg) 0 0 0; }
tbody tr { transition: background .1s; }
tbody tr:hover td { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }

/* When .table-scroll wraps the table directly, no separate wrapper radius needed */
.card .table-scroll { border-radius: var(--radius); }
.card .table-scroll thead tr th:first-child,
.card .table-scroll thead tr th:last-child { border-radius: 0; }

/* ============================================================
   Badges — pill style
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 11px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.4;
}
/* Small sliding toggle switch — e.g. the employees list's "نمایش در بخش بررسی" column. */
.toggle-switch { position: relative; display: inline-block; width: 34px; height: 20px; flex-shrink: 0; vertical-align: middle; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-switch-slider {
    position: absolute; inset: 0; cursor: pointer;
    background: var(--border-strong); border-radius: 999px;
    transition: background var(--transition);
}
.toggle-switch-slider::before {
    content: ''; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px;
    background: #fff; border-radius: 50%;
    transition: transform var(--transition);
}
.toggle-switch input:checked + .toggle-switch-slider { background: var(--signal); }
.toggle-switch input:checked + .toggle-switch-slider::before { transform: translateX(14px); }
.toggle-switch input:disabled + .toggle-switch-slider { opacity: .5; cursor: not-allowed; }

.badge-pending { background: var(--warning-bg); color: var(--warning); }
.badge-approved { background: var(--success-bg); color: var(--success); }
.badge-revoked { background: var(--danger-bg); color: var(--danger); }
.badge-done { background: var(--success-bg); color: var(--success); }
.badge-failed { background: var(--danger-bg); color: var(--danger); }
.badge-in_progress { background: var(--signal-light); color: var(--signal); }
.badge-meta { background: var(--surface-2); border: 1px solid var(--border); color: var(--ink-dim); font-weight: 500; }
/* Generic color-named aliases (reference project's convention) for badges
   whose meaning isn't tied to a specific connection/command status. */
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info { background: var(--signal-light); color: var(--signal); }
.badge-neutral { background: var(--surface-2); border: 1px solid var(--border); color: var(--ink-dim); font-weight: 500; }

/* A wp_user row belonging to an employee outside the viewer's scope: shown
   (never hidden, so a scoped project_manager knows the account exists) but
   visually inert — every action button in the row is also given the native
   `disabled` attribute server-side data, which this just makes legible. */
tr.row-locked { background: var(--surface-2); opacity: 0.65; }
tr.row-locked td { color: var(--ink-faint); }

/* Signature element: a live status pulse next to sites, reflecting the
   wake-up/heartbeat architecture itself rather than a decorative dot. */
.status-pulse { position: relative; display: inline-flex; width: 9px; height: 9px; flex-shrink: 0; }
.status-pulse::before, .status-pulse::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
}
.status-pulse::before { background: var(--ink-faint); }
.status-pulse.online::before { background: var(--success); }
.status-pulse.online::after {
    background: var(--success);
    animation: pulse-ring 2s cubic-bezier(0.2, 0.6, 0.4, 1) infinite;
}
.status-pulse.stale::before { background: var(--warning); }
@keyframes pulse-ring {
    0% { transform: scale(1); opacity: .55; }
    100% { transform: scale(2.6); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
    .status-pulse.online::after { animation: none; display: none; }
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    background: var(--signal);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 9px 18px;
    font-family: var(--font-ui);
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.4;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--transition), transform .05s, box-shadow var(--transition), border-color var(--transition), color var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
}
.btn:hover { background: var(--signal-dark); box-shadow: var(--shadow); color: #fff; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.btn.danger { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger); }
.btn.danger:hover { background: var(--danger); color: #fff; }
.btn.success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success); }
.btn.success:hover { background: var(--success); color: #fff; }
.btn.secondary {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--ink);
}
.btn.secondary:hover { background: var(--signal-light); color: var(--signal); border-color: var(--signal-accent); }
.btn.ghost { background: transparent; color: var(--ink-dim); padding: 8px 12px; border: 1px solid transparent; }
.btn.ghost:hover { background: var(--signal-light); color: var(--signal); }
.btn.sm { padding: 6px 13px; font-size: 12.5px; }
.btn.icon { width: 36px; height: 36px; padding: 0; border-radius: var(--radius-sm); }
.btn.icon.sm { width: 28px; height: 28px; }

/* ============================================================
   Forms
   ============================================================ */
input.field, select.field, textarea.field {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 10px 13px;
    color: var(--ink);
    font-size: 13.5px;
    font-family: var(--font-ui);
    line-height: 1.4;
    width: 100%;
    transition: border-color var(--transition), box-shadow var(--transition);
}
select.field { cursor: pointer; }
input.field:focus, select.field:focus, textarea.field:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(47, 94, 255, .15);
    outline: none;
}
input.field::placeholder, textarea.field::placeholder { color: var(--ink-faint); }
input.field:disabled, select.field:disabled { background: var(--surface-2); color: var(--ink-faint); cursor: not-allowed; }

/* Inline per-field validation errors (see FormErrors in ui.js) — additive
   on top of the existing generic Toast.error, not a replacement. */
input.field[aria-invalid="true"], select.field[aria-invalid="true"], textarea.field[aria-invalid="true"] {
    border-color: var(--danger);
}
.field-error {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    color: var(--danger);
}

/* Searchable single-select combobox (site pickers with many options) — a
   text input filters a dropdown list; the actual selected id lives in a
   sibling hidden input so the enclosing <form>'s FormData picks it up
   exactly like a native <select> would. */
.combo-wrap { position: relative; }
.combo-list {
    position: absolute;
    top: calc(100% + 4px);
    inset-inline: 0;
    z-index: 20;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    max-height: 240px;
    overflow-y: auto;
    display: none;
}
.combo-list.open { display: block; }
.combo-option {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 9px 13px;
    cursor: pointer;
    font-size: 13.5px;
}
.combo-option:hover, .combo-option.active { background: var(--surface-2); }
.combo-option .combo-option-domain { color: var(--ink-dim); font-size: 12px; }
.combo-empty { padding: 12px 13px; color: var(--ink-dim); font-size: 13px; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }

.filter-bar {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding: 16px 18px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}
.filter-field { display: flex; flex-direction: column; gap: 5px; cursor: default; }
.filter-field > span:first-child { font-size: 12px; color: var(--ink-dim); font-weight: 600; }
.filter-select { min-width: 180px; }

/* Sites page: instant client-side filters (no form submit, no refetch — see sites.js). */
.sites-filter-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.sites-filter-search {
    flex: 1 1 220px;
    min-width: 180px;
}
.filter-btn-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.filter-btn-group-label {
    font-size: 12px;
    color: var(--ink-dim);
    font-weight: 600;
    margin-inline-end: 2px;
}

.actions-rail { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.actions-rail > .btn { flex: 0 0 auto; }
td.actions-col, th.actions-col { white-space: nowrap; }
/* Icon-only action rails (employees/wp-users tables) never need to wrap — force one line so a narrow column can't collapse them into a vertical stack. */
td.actions-col .actions-rail { flex-wrap: nowrap; }

/* ============================================================
   Modals
   ============================================================ */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(26, 34, 51, .4);
    backdrop-filter: blur(2px);
    display: flex; align-items: center; justify-content: center; z-index: 200;
    padding: 16px;
    opacity: 0;
    transition: opacity .16s ease;
}
.modal-backdrop.modal-in { opacity: 1; }
.modal {
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: 26px;
    width: 440px;
    max-width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: scale(.96) translateY(-8px);
    transition: transform .18s ease;
}
.modal-backdrop.modal-in .modal { transform: scale(1) translateY(0); }
/* Sticky to the modal's own scrollport (not just visually pinned) — on a
   tall modal (e.g. the keyword rank-trend modal with two charts + two
   history tables) the close button in .actions could scroll out of view,
   forcing a page refresh to escape it. The negative margin/top/bottom pair
   cancels out .modal's own padding on that edge so the sticky element
   spans flush to the scrollport edge, then restores the padding on itself. */
.modal h3 {
    position: sticky; top: -26px; z-index: 1;
    margin: -26px -26px 18px;
    padding: 26px 26px 14px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    font-size: 16px;
}
.modal .actions {
    position: sticky; bottom: -26px; z-index: 1;
    display: flex; justify-content: flex-end; gap: 10px;
    margin: 20px -26px -26px;
    padding: 16px 26px 26px;
    background: var(--surface);
    border-top: 1px solid var(--border);
}

/* Searchable-select — a lightweight combobox (text input + filtered dropdown), see ui.js's SearchableSelect. Used wherever a plain <select> would be unwieldy (site/employee pickers with 100+ options). */
.searchable-select { position: relative; }
.searchable-select-dropdown {
    position: absolute; inset-inline: 0; top: calc(100% + 4px); z-index: 40;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); max-height: 220px; overflow-y: auto;
}
.searchable-select-item { padding: 9px 12px; font-size: 13.5px; cursor: pointer; }
.searchable-select-item:hover, .searchable-select-item.is-active { background: var(--surface-2); }
.searchable-select-empty { padding: 9px 12px; font-size: 13px; color: var(--ink-faint); }

/* Command palette (Ctrl/Cmd+K, see CommandPalette in nav-quick-access.js) — built on Modal. */
.cmdk-results { max-height: 320px; overflow-y: auto; margin: 10px -26px -26px; padding: 6px 0; }
.cmdk-item { padding: 10px 26px; font-size: 13.5px; cursor: pointer; color: var(--ink-dim); }
.cmdk-item:hover, .cmdk-item.is-active { background: var(--signal-light); color: var(--signal); }
.cmdk-empty { padding: 14px 26px; font-size: 13px; color: var(--ink-faint); }

/* Daily-report entry rows (see DailyReportEntry in my-daily-reports.js, shared with dashboard.js's widget) — one repeating row per task entry: title-combo (search-or-freetext), duration, status toggle, remove. */
.dre-rows { display: flex; flex-direction: column; gap: 10px; }
.dre-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dre-title-combo { position: relative; flex: 1 1 220px; min-width: 180px; }
.dre-dropdown {
    position: absolute; inset-inline: 0; top: calc(100% + 4px); z-index: 40;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); max-height: 200px; overflow-y: auto;
}
.dre-dropdown-item { padding: 8px 12px; font-size: 13px; cursor: pointer; }
.dre-dropdown-item:hover { background: var(--surface-2); }
.dre-duration { width: 90px; flex: 0 0 90px; text-align: center; }
.dre-status-toggle { display: flex; gap: 6px; flex: 0 0 auto; }
@media (max-width: 560px) {
    .dre-row { flex-wrap: wrap; }
    .dre-title-combo { flex-basis: 100%; }
}

.dre-readonly-list { display: flex; flex-direction: column; gap: 8px; }
.dre-readonly-row {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    background: var(--surface-2); border-radius: 10px; padding: 8px 14px; font-size: 13px;
}
.dre-readonly-title { flex: 1 1 auto; }

.modal-lg { width: 640px; }
.assign-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.assign-column h4 { margin: 0 0 10px; font-size: 13px; color: var(--ink-dim); }
.assign-checklist {
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 10px;
}
.assign-checklist .checkbox-row { padding: 7px 2px; border-bottom: 1px solid var(--border); }
.assign-checklist .checkbox-row:last-child { border-bottom: none; }
@media (max-width: 640px) {
    .assign-columns { grid-template-columns: 1fr; }
}

.graph-scroll {
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px 0;
}
.graph-scroll svg { display: block; }
.graph-link {
    stroke: var(--border-strong);
    stroke-width: 1.5;
}
.graph-node {
    fill: var(--surface-2);
    stroke: var(--border);
    stroke-width: 1;
}
.graph-node-pm {
    fill: var(--signal-light);
    stroke: var(--signal);
    stroke-width: 1.5;
}
.graph-node-site {
    fill: var(--success-bg);
    stroke: var(--success);
}
.graph-node-employee {
    fill: var(--surface-2);
    stroke: var(--border-strong);
}
.graph-node-label {
    font-family: var(--font-ui);
    font-size: 12.5px;
    font-weight: 600;
    fill: var(--ink);
}
.graph-node-sub {
    font-family: var(--font-ui);
    font-size: 11px;
    fill: var(--ink-dim);
}

.text-center { text-align: center; }

/* Search Console page: domain + copy button on one line, file name/verify
   date as small secondary text under the status badge in the same cell. */
.search-console-table td { vertical-align: middle; }
.sc-domain-cell { display: flex; align-items: center; gap: 4px; }
.sc-site-label { font-size: 11.5px; margin-top: 2px; }
.sc-file-name { font-size: 11px; margin-top: 4px; }

/* Connectivity Diagnostics page: label/value rows for a single live ping result. */
.kv-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.kv-table td { padding: 6px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.kv-table td:first-child { color: var(--ink-dim); white-space: nowrap; width: 160px; }
.kv-table td:last-child { word-break: break-all; }

/* Command queue details modal: raw payload/result JSON. */
.command-json {
    margin: 0;
    padding: 10px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 12px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 240px;
    overflow-y: auto;
    direction: ltr;
    text-align: left;
}

/* Per-site Search Console tab: two single-axis small-multiple trend charts
   (clicks, impressions) side by side — never one chart with two y-scales,
   since the two measures differ by orders of magnitude. */
.trend-chart-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.trend-chart {
    flex: 1 1 260px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 14px 16px;
}
.trend-chart-label { font-size: 12.5px; font-weight: 600; color: var(--ink-dim); margin-bottom: 6px; }
.trend-chart-wrap { position: relative; }
.trend-chart-svg { width: 100%; height: 140px; display: block; cursor: crosshair; }
.trend-tooltip {
    position: absolute;
    top: 2px;
    transform: translateX(-50%);
    background: var(--ink);
    color: #fff;
    padding: 6px 9px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    line-height: 1.5;
    white-space: nowrap;
    pointer-events: none;
    display: none;
    z-index: 5;
}
.trend-tooltip-value { font-weight: 700; }

.dialog-modal { width: 380px; text-align: center; }
.dialog-modal h3 { border-bottom: none; padding-bottom: 0; margin-bottom: 8px; }
.dialog-modal .actions { justify-content: center; border-top: none; padding-top: 0; }
.dialog-icon {
    width: 46px; height: 46px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; font-weight: 800;
    margin: 0 auto 16px;
}
.dialog-icon-warning, .dialog-icon-info { background: var(--signal-light); color: var(--signal); }
.dialog-icon-danger { background: var(--danger-bg); color: var(--danger); }
.dialog-icon-success { background: var(--success-bg); color: var(--success); }

.text-dim { color: var(--ink-dim); }
.text-faint { color: var(--ink-faint); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-success { color: var(--success); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; }
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    color: var(--ink-faint);
    text-align: center;
    font-size: 13px;
}

/* ============================================================
   Toasts
   ============================================================ */
.toast-stack {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 360px;
}
.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 13px 14px;
    font-size: 13px;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .18s ease, transform .18s ease;
}
.toast-in { opacity: 1; transform: translateY(0); }
.toast-out { opacity: 0; transform: translateY(8px); }
.toast-icon {
    width: 22px; height: 22px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 800; flex-shrink: 0; margin-top: 1px;
    background: var(--surface-2); color: var(--ink-dim);
}
.toast-success .toast-icon { background: var(--success-bg); color: var(--success); }
.toast-danger .toast-icon { background: var(--danger-bg); color: var(--danger); }
.toast-warning .toast-icon { background: var(--warning-bg); color: var(--warning); }
.toast-info .toast-icon { background: var(--signal-light); color: var(--signal); }
.toast-message { flex: 1; color: var(--ink); }
.toast-close {
    background: none; border: none; cursor: pointer; color: var(--ink-faint);
    font-size: 16px; line-height: 1; padding: 0;
}

/* ============================================================
   Notification popups — sticky, bottom-right (Toast owns bottom-left)
   ============================================================ */
.notif-stack {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 310;
    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
    max-width: 340px;
    width: calc(100% - 40px);
}
.notif-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 14px 16px;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .18s ease, transform .18s ease;
}
.notif-card.notif-in { opacity: 1; transform: translateY(0); }
.notif-card.notif-out { opacity: 0; transform: translateY(8px); }
.notif-card-head { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 6px; }
.notif-card-icon { color: var(--signal); flex-shrink: 0; margin-top: 2px; }
.notif-card-title { font-weight: 700; font-size: 13.5px; flex: 1; }
.notif-card-body { font-size: 12.5px; color: var(--ink-dim); margin: 0 0 10px; white-space: pre-wrap; }
.notif-card-link { display: block; font-size: 12px; margin: -4px 0 10px; }
.notif-card-actions { display: flex; gap: 8px; }
.notif-snooze-wrap { position: relative; flex: 1; }
.notif-snooze-menu {
    position: absolute; bottom: calc(100% + 6px); right: 0; left: 0;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); padding: 8px; display: flex; flex-direction: column; gap: 4px; z-index: 1;
}
.notif-snooze-menu button { text-align: start; }
.notif-snooze-custom { display: flex; gap: 6px; margin-top: 4px; padding-top: 6px; border-top: 1px solid var(--border); }
.toast-close:hover { color: var(--ink); }

/* ============================================================
   Tooltips
   ============================================================ */
.tooltip-bubble {
    position: absolute;
    background: var(--ink);
    color: #fff;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    max-width: 220px;
    z-index: 400;
    pointer-events: none;
    opacity: 0;
    transition: opacity .12s ease;
}
.tooltip-visible { opacity: 1; }

/* ============================================================
   Bulk select
   ============================================================ */
.select-col { width: 34px; }
.actions-col { width: 1%; }
input[type="checkbox"].bulk-checkbox { width: 15px; height: 15px; accent-color: var(--signal); cursor: pointer; }

.bulk-toolbar {
    display: none;
    align-items: center;
    gap: 12px;
    background: var(--signal-light);
    border: 1px solid #c7d5ff;
    border-radius: var(--radius-lg);
    padding: 11px 16px;
    margin-bottom: 16px;
    font-size: 13px;
}
.bulk-toolbar.visible { display: flex; }
.bulk-toolbar .count { font-weight: 700; color: var(--signal); }

/* ============================================================
   Settings / form layout helpers
   ============================================================ */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }
.settings-field { display: flex; flex-direction: column; gap: 6px; cursor: default; }
.settings-field > span:first-child { font-size: 13px; font-weight: 600; }
.hint { font-size: 12px; color: var(--ink-dim); }
.settings-actions { justify-content: flex-start; margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--border); }

.version-current { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--success); font-weight: 700; }

.upload-form { display: flex; flex-direction: column; gap: 16px; max-width: 480px; }
.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-row-label { font-size: 13px; font-weight: 600; color: var(--ink); }
.form-row-btn { align-self: flex-start; }
.form-stack { display: flex; flex-direction: column; gap: 14px; }
.checkbox-row {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 13.5px;
    cursor: pointer;
}
.checkbox-row input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--signal); cursor: pointer; }

.file-drop {
    position: relative;
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    background: var(--surface-2);
    padding: 24px 18px;
    text-align: center;
    transition: border-color var(--transition), background var(--transition);
    cursor: pointer;
}
.file-drop:hover, .file-drop.drag-over { border-color: var(--signal); background: var(--signal-light); }
.file-drop input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}
.file-drop .file-drop-icon { font-size: 22px; color: var(--ink-faint); margin-bottom: 6px; }
.file-drop .file-drop-text { font-size: 13.5px; color: var(--ink-dim); }
.file-drop .file-drop-text strong { color: var(--signal); font-weight: 600; }
.file-drop .file-drop-name { font-size: 13px; color: var(--ink); font-weight: 600; margin-top: 4px; }
.file-drop .file-drop-hint { font-size: 12px; color: var(--ink-faint); margin-top: 4px; }

.release-version-cell { display: flex; align-items: center; gap: 8px; font-weight: 600; }

.changelog-details { margin-top: 4px; }
.changelog-details summary {
    cursor: pointer;
    font-size: 11.5px;
    color: var(--ink-dim);
    font-weight: 500;
    list-style: none;
}
.changelog-details summary::-webkit-details-marker { display: none; }
.changelog-details summary::before { content: '▸ '; font-size: 10px; }
.changelog-details[open] summary::before { content: '▾ '; }
.changelog-details summary:hover { color: var(--ink); }
.changelog-text {
    margin: 6px 0 0;
    padding: 10px 12px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    color: var(--ink);
    line-height: 1.6;
    max-width: 420px;
    white-space: normal;
}

.site-picker-group-title {
    margin: 16px 0 8px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink-dim);
}
.site-picker-group-title:first-of-type { margin-top: 12px; }

.site-picker-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px;
}
.site-picker-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background .1s;
}
.site-picker-row:hover { background: var(--surface-2); }
.site-picker-row .site-domain { flex: 1; font-size: 13.5px; color: var(--ink); }
.site-picker-row .site-version { font-size: 12px; color: var(--ink-dim); }
.site-picker-empty { padding: 24px; text-align: center; color: var(--ink-dim); font-size: 13px; }

/* ============================================================
   Site details tab (details-grid, plugin/theme lists)
   ============================================================ */
.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
    padding: 18px;
    background: var(--surface-2);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}
.details-stat { display: flex; flex-direction: column; gap: 4px; }
.details-label { font-size: 11.5px; color: var(--ink-dim); font-weight: 600; }
.details-value { font-size: 14.5px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.details-list {
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 4px 16px;
    max-height: 220px;
    overflow-y: auto;
    font-size: 13px;
}
.details-list li { padding: 5px 0; border-bottom: 1px solid var(--border); }
.card details summary { cursor: pointer; font-size: 12.5px; color: var(--ink-dim); margin-top: 10px; }
.card details summary:hover { color: var(--ink); }

.details-list-plugins { display: flex; flex-direction: column; gap: 0; max-height: 260px; }
.plugin-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 0 !important;
}
.plugin-name { font-size: 13px; }
.plugin-row-actions { display: flex; gap: 4px; flex-shrink: 0; }
.plugin-row-actions .btn.danger-text { color: var(--danger); }
.plugin-row-actions .btn.danger-text:hover { background: var(--danger-bg); }

/* ============================================================
   Card grid listings (sites, employees)
   ============================================================ */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 16px;
}

.site-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 20px 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    transition: box-shadow var(--transition), border-color var(--transition);
}
.site-card:hover {
    box-shadow: var(--shadow);
    border-color: var(--signal-accent);
}
.site-card:focus-within {
    box-shadow: var(--shadow), 0 0 0 2px var(--signal);
}

/* Stretched-link pattern: the whole card is clickable for navigation (a real
   <a>, not a div+click handler), while nested controls (menu button, etc.)
   sit above it with their own z-index so they keep working independently. */
.site-card-link {
    position: absolute;
    inset: 0;
    z-index: 1;
    border-radius: inherit;
}
.site-card-link:focus-visible {
    outline: 2px solid var(--signal);
    outline-offset: 2px;
}

.site-card-top { display: flex; align-items: center; gap: 14px; }
.site-card-favicon {
    position: relative;
    width: 52px; height: 52px;
    flex-shrink: 0;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--signal-light);
    display: flex; align-items: center; justify-content: center;
}
.site-card-favicon img { width: 28px; height: 28px; object-fit: contain; }
.site-card-favicon-fallback {
    display: none;
    position: absolute; inset: 0;
    align-items: center; justify-content: center;
    font-size: 17px; font-weight: 700;
    color: var(--signal);
    background: var(--signal-light);
}
.site-card-favicon.fallback img { display: none; }
.site-card-favicon.fallback .site-card-favicon-fallback { display: flex; }

.site-card-heading { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.site-card-label { font-size: 16px; font-weight: 700; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-card-domain { font-size: 12px; font-weight: 400; color: var(--ink-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.site-card-tags { display: flex; flex-wrap: wrap; gap: 6px; }

.site-card-info {
    display: flex;
    flex-direction: column;
    gap: 9px;
    padding: 12px 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}
.site-card-info-item { display: flex; align-items: center; gap: 8px; min-width: 0; }
.site-card-info-icon { font-size: 13px; color: var(--signal); flex-shrink: 0; width: 14px; text-align: center; }
.site-card-info-icon.danger { color: var(--danger); }
.site-card-info-label { flex-shrink: 0; font-size: 12px; color: var(--ink-faint); }
.site-card-info-value {
    margin-right: auto;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.site-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.site-card-menu-wrap { position: relative; z-index: 2; flex-shrink: 0; }
.site-card-menu-btn { padding: 2px 8px; font-size: 15px; line-height: 1; }
.site-card-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 170px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 5px;
    flex-direction: column;
    z-index: 10;
}
.site-card-menu.open { display: flex; }
.site-card-menu button, .site-card-menu a {
    background: none; border: none;
    text-align: right;
    padding: 9px 11px;
    font-size: 13px;
    font-family: var(--font-ui);
    color: var(--ink);
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    display: block;
}
.site-card-menu button:hover, .site-card-menu a:hover { background: var(--signal-light); color: var(--signal); }
.site-card-menu button.danger-text { color: var(--danger); }
.site-card-menu button.danger-text:hover { background: var(--danger-bg); }

.employee-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 22px 18px;
    text-align: center;
    transition: box-shadow var(--transition), border-color var(--transition);
}
.employee-card:hover {
    box-shadow: var(--shadow);
    border-color: var(--signal-accent);
}
.employee-card:focus-within {
    box-shadow: var(--shadow), 0 0 0 2px var(--signal);
}
.employee-card-link {
    position: absolute;
    inset: 0;
    z-index: 1;
    border-radius: inherit;
}
.employee-card-link:focus-visible {
    outline: 2px solid var(--signal);
    outline-offset: 2px;
}
.employee-card-checkbox-wrap { position: absolute; top: 14px; left: 14px; z-index: 2; }
.employee-card-avatar {
    width: 50px; height: 50px;
    border-radius: 50%;
    background: var(--signal-light);
    color: var(--signal);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 16px;
    margin: 0 auto 12px;
}
.employee-card-avatar.lg { width: 64px; height: 64px; font-size: 20px; }
.employee-card-name { font-size: 14.5px; font-weight: 700; color: var(--ink); }
.employee-card-dept { font-size: 12.5px; margin-top: 3px; }
.employee-card-meta { margin-top: 12px; }
.employee-card-actions { position: relative; z-index: 2; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.employee-card-actions .btn { width: 100%; }

.employee-row-link {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    font-weight: 600;
}
.employee-row-link:hover .employee-row-name { color: var(--signal); }
.employee-row-avatar {
    flex-shrink: 0;
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--signal-light);
    color: var(--signal);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px;
}
.employee-row-name { display: block; font-size: 13.5px; color: var(--ink); transition: color var(--transition); }
.employee-row-email { display: block; font-size: 12px; margin-top: 1px; }

.employee-profile-header { display: flex; align-items: center; gap: 18px; }

/* Employee detail page — two-column profile grid, modeled on the reference's user-show layout */
.entity-profile-grid {
    display: grid;
    grid-template-columns: minmax(240px, 320px) 1fr;
    gap: 20px;
    align-items: start;
}
@media (max-width: 768px) {
    .entity-profile-grid { grid-template-columns: 1fr; }
}
.entity-profile-avatar-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin-bottom: 20px;
}
.entity-profile-avatar-block .employee-card-avatar { margin: 0 0 6px; }
.entity-profile-name { font-size: 16px; font-weight: 700; color: var(--ink); }
.entity-profile-username { font-size: 12.5px; }

.info-row-stack { display: flex; flex-direction: column; gap: 10px; }
.info-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.info-row-label { font-size: 12px; color: var(--ink-faint); }
.info-row-value { font-size: 13px; font-weight: 600; color: var(--ink); }
.ltr { direction: ltr; }

/* Employee "گزارش عملکرد" timeline — one row per activity event, newest first. */
.activity-timeline {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 420px;
    overflow-y: auto;
}
.activity-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 4px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.activity-item:last-child { border-bottom: none; }
.activity-icon { flex: 0 0 auto; font-size: 14px; }
.activity-text { flex: 1; color: var(--ink); }
.activity-time { flex: 0 0 auto; font-size: 12px; white-space: nowrap; }

/* ============================================================
   Dedicated site/employee pages
   ============================================================ */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--ink-dim);
    text-decoration: none;
    margin-bottom: 18px;
}
.back-link:hover { color: var(--signal); text-decoration: none; }

.page-header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Entity header card — shared by the site and employee detail pages, modeled
   on the reference project's "project header" card: big icon tile, title +
   subtitle, an inline meta row of small stats, actions on the opposite side. */
.entity-header-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 18px;
    margin-bottom: 20px;
}
.entity-header-main { display: flex; align-items: center; gap: 18px; }
.entity-icon-tile {
    position: relative;
    width: 56px; height: 56px;
    border-radius: var(--radius-lg);
    background: var(--signal-light);
    color: var(--signal);
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
    overflow: hidden;
}
.entity-icon-tile.lg { width: 60px; height: 60px; }
.entity-icon-fallback {
    display: none;
    position: absolute; inset: 0;
    align-items: center; justify-content: center;
    font-size: 20px; font-weight: 700;
    color: var(--signal);
    background: var(--signal-light);
}
.entity-icon-tile.fallback img { display: none; }
.entity-icon-tile.fallback .entity-icon-fallback { display: flex; }

.entity-header-info { min-width: 0; }
.entity-header-title { font-size: 20px; font-weight: 700; margin: 0; display: flex; align-items: center; gap: 9px; }
.entity-header-desc { font-size: 13px; color: var(--ink-faint); margin: 4px 0 0; }
.entity-header-meta { display: flex; gap: 18px; margin-top: 8px; font-size: 12px; color: var(--ink-faint); flex-wrap: wrap; }
.entity-header-meta-icon { color: var(--signal); }
.entity-header-meta-icon.danger { color: var(--danger); }
.entity-header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.tab-bar {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}
.tab-link {
    padding: 11px 4px;
    margin-left: 22px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--ink-dim);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: color var(--transition);
}
.tab-link:hover { color: var(--ink); text-decoration: none; }
.tab-link.active { color: var(--signal); border-bottom-color: var(--signal); }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1024px) {
    :root { --sidebar-w: 210px; }
}

@media (max-width: 768px) {
    .shell {
        grid-template-columns: 1fr;
        grid-template-areas: "header" "content";
    }
    .sidebar {
        position: fixed;
        top: var(--header-h);
        right: 0;
        height: calc(100vh - var(--header-h));
        width: var(--sidebar-w);
        z-index: 80;
        transform: translateX(100%);
        transition: transform .25s ease;
        box-shadow: var(--shadow-lg);
    }
    .sidebar.open { transform: translateX(0); }
    main#app-main { padding: 18px; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .card-grid { grid-template-columns: 1fr; }
    .sidebar-toggle { display: flex; align-items: center; justify-content: center; }
    .app-header-breadcrumb { display: none; }
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    top: var(--header-h);
    background: rgba(26, 34, 51, .4);
    z-index: 70;
}
@media (max-width: 768px) {
    .sidebar-backdrop.open { display: block; }
}
