/* ============================================================
   THEME POLISH LAYER
   ------------------------------------------------------------
   Loaded LAST. Turns the token system from base.css into the
   "floating glass on an ambient glow" look:
     • a soft coloured light source behind everything (body::before)
     • frosted, hairline-bordered panels with a top highlight
     • a floating sidebar + topbar, inset from the window edge
   Works for all three themes because it only uses tokens.
   No layout-affecting class names are introduced — the app's
   markup and JS behaviour stay exactly as they were.
   ============================================================ */

/* ── Ambient light source ───────────────────────────────────── */
html { background: var(--bg); }
body { background: transparent; }
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(55% 60% at 70% 12%, var(--glow-1) 0%, transparent 70%),
        radial-gradient(40% 50% at 8% 100%, var(--glow-2) 0%, transparent 72%);
}

/* ── Shared glass surface ───────────────────────────────────── */
.stat-card,
.task-table-wrap,
.user-card,
.user-group,
.tt-panel-card,
.cal-body,
.cal-mini-panel,
.cal-upcoming-panel,
.stg-section,
.chat-shell,
.sp-tab,
.sp-file-card {
    background-color: var(--glass-bg);
    background-image: var(--surface);
    border: 1px solid var(--border);
    box-shadow: inset 0 1px 0 var(--highlight), var(--shadow-md);
    -webkit-backdrop-filter: blur(var(--blur)) saturate(140%);
    backdrop-filter: blur(var(--blur)) saturate(140%);
}

/* Floating layers (need to read clearly over busy content) */
.modal,
.confirm-box,
.sp-modal,
.chat-modal,
.notif-panel,
.cal-settings-popover,
.login-card {
    background-color: var(--bg-2);
    background-image: var(--surface);
    border: 1px solid var(--border);
    box-shadow: inset 0 1px 0 var(--highlight), var(--shadow-lg);
}

.task-drawer,
.watch-drawer {
    background-color: var(--bg-2);
    background-image: var(--surface);
    border-left: 1px solid var(--border-hover);
    box-shadow: none;
}
.task-drawer.open,
.watch-drawer.open { box-shadow: var(--shadow-lg); }
.notif-panel.expanded { box-shadow: var(--shadow-lg); }

.modal-overlay,
.drawer-overlay,
.watch-overlay,
.confirm-overlay,
.sp-modal-overlay,
.chat-modal-overlay {
    background: var(--overlay);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}

/* ======================================================
   SHELL — floating sidebar + topbar
   ====================================================== */
.sidebar {
    top: var(--shell-gap);
    left: var(--shell-gap);
    bottom: var(--shell-gap);
    width: calc(var(--sidebar-w) - var(--shell-gap) * 2);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    background-color: var(--glass-bg);
    background-image: var(--surface);
    box-shadow: inset 0 1px 0 var(--highlight), var(--shadow-lg);
    -webkit-backdrop-filter: blur(24px) saturate(150%);
    backdrop-filter: blur(24px) saturate(150%);
    overflow: hidden;
}
.sidebar.collapsed { width: 52px; }
.sidebar.collapsed + .main-content { margin-left: calc(52px + var(--shell-gap) * 2); }
.sidebar.collapsed .sidebar-header { padding: 12px 6px; }

.sidebar-header { padding: 14px 12px 6px 16px; }
.sidebar-logo {
    padding: 0;
    height: auto;
    gap: 10px;
}
.sidebar-logo > span:first-child {
    width: 30px; height: 30px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    background: var(--fill-2);
    border: 1px solid var(--border);
    box-shadow: inset 0 1px 0 var(--highlight);
    font-size: 0.95rem !important;
}
.sidebar-logo-text {
    font-family: var(--font-head);
    font-weight: 800;
    font-size: 1rem;
    letter-spacing: -0.02em;
    color: var(--text-1);
}

.sidebar-nav { padding: 8px 10px 16px; gap: 1px; }

/* Sentence-case group labels, quieter than the items they group */
.nav-section-label {
    text-transform: none;
    letter-spacing: 0.01em;
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--text-3);
    padding: 16px 12px 6px;
}
.nav-item {
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-2);
    border: 1px solid transparent;
}
.nav-item:hover { background: var(--fill-1); color: var(--text-1); }
.nav-item.active {
    background: var(--fill-2);
    color: var(--text-1);
    border-color: var(--border);
    box-shadow: inset 0 1px 0 var(--highlight), var(--shadow-sm);
}
.nav-item.active::before {
    content: '';
    position: absolute;
    left: -1px; top: 9px; bottom: 9px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--accent-strong);
}
.nav-item .nav-icon { font-size: 1rem; }
a.nav-item { color: var(--text-2); }

.sidebar-footer { padding: 10px; border-top: 1px solid var(--border); }
.sidebar-user { border-radius: 12px; padding: 8px 10px; }
.sidebar-user:hover { background: var(--fill-1); }
.sidebar-user-role { text-transform: none; letter-spacing: 0.02em; }

/* Main column */
.main-content { margin-left: var(--sidebar-w); }
.topbar {
    top: var(--shell-gap);
    margin: var(--shell-gap) var(--shell-gap) 0 0;
    height: 56px;
    padding: 0 12px 0 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background-color: var(--topbar-bg);
    background-image: var(--surface);
    box-shadow: inset 0 1px 0 var(--highlight), var(--shadow-md);
    -webkit-backdrop-filter: blur(24px) saturate(150%);
    backdrop-filter: blur(24px) saturate(150%);
    gap: 10px;
}
.topbar-title {
    font-size: 1.12rem;
    font-weight: 700;
    letter-spacing: -0.015em;
}
.topbar-search { background: var(--input-bg); border-radius: 10px; }
.page-content { padding: 24px var(--shell-gap) 40px 0; }

/* ======================================================
   TYPOGRAPHY TOUCHES
   ====================================================== */
h1, h2, h3,
.modal-header h2,
.drawer-title,
.confirm-title,
.cal-month-year { letter-spacing: -0.015em; }

/* Small labels: sentence case reads calmer than tracked caps */
.stat-label,
.form-group label,
.drawer-info-item label,
.task-table th,
.sp-task-table th,
.sp-list-table th,
.tt-panel-title,
.chat-sidebar-header,
.taskref-group-label,
.drawer-section-title {
    text-transform: none;
    letter-spacing: 0.005em;
}

/* ======================================================
   DASHBOARD
   ====================================================== */
.stats-row { gap: 14px; }
.stat-card {
    border-radius: var(--radius-lg);
    padding: 18px 18px 20px;
    position: relative;
    overflow: hidden;
    transition: border-color var(--transition), transform var(--transition);
}
.stat-card:hover { border-color: var(--border-hover); }
.stat-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 14px;
}
.stat-value {
    font-size: 2.1rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
}

/* ======================================================
   TABLES
   ====================================================== */
.task-table-wrap { border-radius: var(--radius-lg); }
.task-table th,
.sp-task-table th,
.sp-list-table th {
    background: transparent;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-3);
    padding-top: 14px;
    padding-bottom: 12px;
}
.task-table td { font-size: 0.88rem; }
.task-table tbody tr:hover,
.sp-task-table tbody tr:hover,
.sp-list-table tbody tr:hover { background: var(--fill-1); }
.task-uid {
    font-family: var(--font-mono);
    background: var(--fill-1);
    border: 1px solid var(--border);
}

/* Badges — a hairline in their own colour gives them a crisp edge */
.badge {
    padding: 3px 10px;
    font-weight: 600;
    font-size: 0.74rem;
    box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 22%, transparent);
}

/* Pagination */
.page-btn { border-radius: 8px; }
.page-btn:hover { background: var(--fill-1); }

/* ======================================================
   BUTTONS
   ====================================================== */
.btn { border-radius: 10px; font-weight: 600; letter-spacing: 0; }
.btn-primary {
    background-color: var(--accent-strong);
    background-image: linear-gradient(180deg, rgba(255,255,255,0.20) 0%, rgba(255,255,255,0) 100%);
    border-color: transparent;
    color: var(--on-accent);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.28), 0 8px 22px -10px var(--accent-ring);
}
.btn-primary:hover {
    background-color: var(--accent-strong);
    border-color: transparent;
    filter: brightness(1.08);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.28), 0 10px 26px -10px var(--accent-ring);
}
.btn-secondary {
    background: var(--fill-1);
    border-color: var(--border);
    box-shadow: inset 0 1px 0 var(--highlight);
}
.btn-secondary:hover { background: var(--fill-2); border-color: var(--border-hover); }
.btn-ghost:hover { background: var(--fill-1); }
.btn-danger { border-color: transparent; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--danger) 30%, transparent); }

/* Segmented controls (view toggles share one look) */
.user-view-btn.active,
.sp-view-btn.active,
.sp-task-filter.active {
    background: var(--fill-2);
    color: var(--text-1);
    box-shadow: inset 0 1px 0 var(--highlight), var(--shadow-sm);
}

/* ======================================================
   FORMS
   ====================================================== */
.form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 7px;
}
.form-group input,
.form-group select,
.form-group textarea,
.filter-bar select,
.filter-bar input,
.drawer-state-select,
#audit-search {
    background-color: var(--input-bg) !important;
    border: 1px solid var(--border) !important;
    border-radius: 10px !important;
    color: var(--text-1);
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.12);
}
.form-group input:hover,
.form-group select:hover,
.form-group textarea:hover,
.filter-bar select:hover,
.filter-bar input:hover { border-color: var(--border-hover) !important; }
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.filter-bar select:focus,
.filter-bar input:focus,
.drawer-state-select:focus,
#audit-search:focus,
.topbar-search:focus {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px var(--accent-dim);
}
.filter-bar select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238a93ad' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent-strong); }
select option { background: var(--bg-2); color: var(--text-1); }

/* ======================================================
   SETTINGS — each category becomes its own glass card
   ====================================================== */
.stg-layout { gap: 12px; width: 100%; max-width: none; }
.stg-section {
    border-radius: var(--radius-lg);
    padding: 0 20px;
}
.stg-header { padding: 16px 0; gap: 10px; }
.stg-title { font-size: 0.95rem; color: var(--text-1); }
.stg-header:hover .stg-title { color: var(--accent); }
.stg-divider-right { opacity: 0; }
.stg-content {
    padding: 4px 0 22px 26px;
    border-top: 1px solid var(--border);
    padding-top: 18px;
}
/* Inline "option row" labels in settings used --bg-3 tiles */
.stg-content label[style*="background:var(--bg-3)"] {
    background: var(--fill-1) !important;
    border: 1px solid var(--border);
}

/* ======================================================
   PANELS, DRAWERS, MODALS
   ====================================================== */
.modal, .confirm-box, .sp-modal { border-radius: var(--radius-xl); }
.drawer-header, .watch-header { border-bottom-color: var(--border); }
.drawer-resize-controls { background: var(--fill-1); }
.drawer-width-btn,
.drawer-float-close { background: var(--fill-1); border-radius: 8px; }
.file-item,
.watch-task-row,
.watch-readonly-note { background: var(--fill-1); }
.task-editor-container,
.task-editor-container .ql-container { background: var(--input-bg); }
.task-editor-container .ql-toolbar,
.task-editor-resize-handle { background: var(--fill-1); }
.task-editor-readonly { background: var(--fill-1); }

/* Notifications */
.notif-panel { border-radius: var(--radius-lg); }
.notif-tab:hover, .notif-tab.active { background: var(--fill-2); }
.notif-item-body:hover { background: var(--fill-1); }
.notif-icon { background: var(--fill-2); }

/* ======================================================
   TIME TRACKING — tabs become a segmented control
   ====================================================== */
.tt-tabs {
    display: inline-flex;
    gap: 2px;
    padding: 4px;
    margin-bottom: 18px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--fill-1);
}
.tt-tab {
    border: none;
    border-radius: 9px;
    padding: 7px 16px;
    font-size: 0.85rem;
    color: var(--text-2);
}
.tt-tab:hover { color: var(--text-1); }
.tt-tab.active {
    color: var(--text-1);
    background: var(--fill-2);
    box-shadow: inset 0 1px 0 var(--highlight), var(--shadow-sm);
}
.timer-chip { background: var(--fill-1); border-radius: 10px; }
.tt-panel-card { border-radius: var(--radius-lg); }
.tt-panel-title { font-size: 0.85rem; font-weight: 600; color: var(--text-2); }

/* ======================================================
   CALENDAR
   ====================================================== */
.cal-view-toggle { background: var(--fill-1); border: 1px solid var(--border); border-radius: 12px; }
.cal-view-btn.active { background: var(--fill-2); box-shadow: inset 0 1px 0 var(--highlight), var(--shadow-sm); }

/* ======================================================
   CHAT
   ====================================================== */
.chat-shell { border-radius: var(--radius-lg); }
.chat-sidebar { background: var(--fill-1); }
.chat-main, .chat-header, .chat-search-bar, .chat-input-wrapper, .chat-input-bar { background: transparent; }
.chat-input { border: 1px solid var(--border); background: var(--input-bg); border-radius: 12px; }
.chat-input:focus { border-color: var(--accent); }
.chat-list-item { border-radius: 10px; }
.chat-list-item:hover { background: var(--fill-1); }
.chat-list-item.active { background: var(--fill-2); box-shadow: inset 0 1px 0 var(--highlight); }
.chat-message:hover { background: var(--fill-1); }
.chat-message.theirs .chat-msg-content { background: var(--fill-2); border: 1px solid var(--border); }
.chat-message.mine .chat-msg-content {
    background-image: linear-gradient(180deg, rgba(255,255,255,0.16), rgba(255,255,255,0));
}

/* ======================================================
   SHAREPOINT
   ====================================================== */
.sp-file-card { border-width: 1px; }
.sp-file-card:hover { background-color: var(--fill-2); border-color: var(--border-hover); }
.sp-tab.active { border-color: var(--accent); background-color: var(--accent-dim); }

/* ======================================================
   LOGIN
   ====================================================== */
.login-page { background: transparent; }
.login-page::before,
.login-page::after { display: none; }   /* replaced by body::before glow */
.login-card { border-radius: var(--radius-xl); }
.login-logo-icon {
    color: var(--on-accent);
    font-family: var(--font-head);
    font-weight: 800;
    font-size: 16px;
    background-image: linear-gradient(180deg, rgba(255,255,255,0.22), rgba(255,255,255,0));
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.3), 0 10px 24px -10px var(--accent-ring);
}
.login-card h2 { letter-spacing: -0.025em; }

/* ======================================================
   SETTINGS → DESIGN  (theme preset picker)
   ====================================================== */
.dz-intro { font-size: 0.86rem; color: var(--text-2); margin-bottom: 16px; max-width: 60ch; }
.dz-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 14px;
}
.dz-option {
    position: relative;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--fill-1);
    padding: 10px;
    cursor: pointer;
    transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}
.dz-option:hover { border-color: var(--border-hover); }
.dz-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.dz-option:has(input:checked) {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}
.dz-option:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 3px; }

/* Miniature of the app, rendered in the option's own theme
   (the data-theme attribute on .dz-preview scopes the tokens). */
.dz-preview {
    position: relative;
    height: 128px;
    border-radius: 11px;
    overflow: hidden;
    background: var(--bg);
    border: 1px solid var(--border);
    isolation: isolate;
}
.dz-preview::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(70% 80% at 75% 10%, var(--glow-1), transparent 70%),
        radial-gradient(50% 60% at 0% 100%, var(--glow-2), transparent 70%);
}
.dz-window {
    position: absolute;
    inset: 12px;
    display: grid;
    grid-template-columns: 22% 1fr;
    gap: 6px;
}
.dz-panel {
    background-color: var(--glass-bg);
    background-image: var(--surface);
    border: 1px solid var(--border);
    box-shadow: inset 0 1px 0 var(--highlight);
    border-radius: 7px;
}
.dz-side { padding: 7px 5px; display: flex; flex-direction: column; gap: 4px; }
.dz-side i { display: block; height: 5px; border-radius: 3px; background: var(--fill-2); }
.dz-side i.on { background: var(--accent-strong); width: 80%; }
.dz-main { display: grid; grid-template-rows: 12px 34px 1fr; gap: 6px; }
.dz-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.dz-cards .dz-panel { padding: 5px 6px; }
.dz-cards b { display: block; width: 55%; height: 4px; border-radius: 2px; background: var(--text-3); opacity: 0.6; }
.dz-cards span { display: block; width: 40%; height: 7px; border-radius: 2px; background: var(--text-1); margin-top: 6px; }
.dz-chart { position: relative; overflow: hidden; }
.dz-chart svg { position: absolute; inset: 0; width: 100%; height: 100%; }

.dz-meta { padding: 12px 4px 4px; display: flex; flex-direction: column; gap: 4px; }
.dz-name-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dz-name { font-family: var(--font-head); font-weight: 700; font-size: 0.95rem; color: var(--text-1); }
.dz-desc { font-size: 0.78rem; color: var(--text-3); line-height: 1.45; }
.dz-check {
    width: 18px; height: 18px;
    border-radius: 50%;
    border: 1.5px solid var(--border-hover);
    display: grid; place-items: center;
    flex-shrink: 0;
    transition: var(--transition);
}
.dz-option:has(input:checked) .dz-check {
    background: var(--accent-strong);
    border-color: var(--accent-strong);
}
.dz-option:has(input:checked) .dz-check::after {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--on-accent);
}
.dz-swatches { display: flex; gap: 5px; margin-top: 8px; }
.dz-swatches span {
    width: 16px; height: 16px;
    border-radius: 50%;
    box-shadow: inset 0 0 0 1px rgba(127,127,127,0.25);
}
.dz-note { font-size: 0.78rem; color: var(--text-3); margin-top: 14px; }

/* ======================================================
   ACCESSIBILITY & MOTION
   ====================================================== */
:where(button, a, [tabindex], .nav-item, .stg-header):focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Smooth hand-off when the person switches theme */
html.theme-switching *,
html.theme-switching *::before,
html.theme-switching *::after {
    transition: background-color 0.25s ease, border-color 0.25s ease, color 0.2s ease !important;
}

/* ======================================================
   RESPONSIVE (overrides for the floating shell)
   ====================================================== */
@media (max-width: 768px) {
    .sidebar {
        width: 240px;
        transform: translateX(calc(-100% - var(--shell-gap) * 2));
    }
    .sidebar.open { transform: translateX(0); width: 240px; }
    .main-content,
    .sidebar.collapsed + .main-content { margin-left: 0; }
    .topbar { margin: var(--shell-gap) var(--shell-gap) 0; padding: 0 10px 0 16px; }
    .page-content { padding: 16px var(--shell-gap) 32px; }
    .stg-section { padding: 0 14px; }
    .stg-content { padding-left: 0; }
    .dz-grid { grid-template-columns: 1fr; }
}
.dz-note.is-error { color: var(--danger); }

/* ======================================================
   ICONS  (js/icons.js — inline SVG, inherit currentColor)
   ====================================================== */
.ico {
    width: 1.15em;
    height: 1.15em;
    display: inline-block;
    vertical-align: -0.2em;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;
}
.btn .ico            { width: 16px; height: 16px; vertical-align: middle; }
.btn-icon .ico       { width: 17px; height: 17px; }
.btn-sm .ico         { width: 15px; height: 15px; }
.nav-icon            { display: inline-flex; align-items: center; justify-content: center; color: var(--text-3); transition: color var(--transition); }
.nav-icon .ico       { width: 18px; height: 18px; }
.nav-item:hover .nav-icon  { color: var(--text-2); }
.nav-item.active .nav-icon { color: var(--accent); }
.sidebar-logo > span:first-child { color: var(--accent); }
.sidebar-logo > span:first-child .ico { width: 16px; height: 16px; fill: currentColor; stroke-width: 1.5; }
.sidebar-user .ico-settings { width: 17px; height: 17px; }
.stat-label .ico     { width: 15px; height: 15px; margin-right: 3px; color: var(--text-3); }
.stg-title .ico      { width: 17px; height: 17px; margin-right: 6px; color: var(--text-2); vertical-align: -0.22em; }
.stg-arrow           { display: inline-flex; align-items: center; justify-content: center; }
.stg-arrow .ico      { width: 15px; height: 15px; }
.empty-state-icon .ico { width: 44px; height: 44px; stroke-width: 1.4; }
.confirm-icon .ico   { width: 40px; height: 40px; stroke-width: 1.5; }
.confirm-icon        { display: flex; justify-content: center; color: var(--accent); }
.confirm-icon.is-danger  { color: var(--danger); }
.confirm-icon.is-warning { color: var(--warning); }
.notif-icon .ico     { width: 15px; height: 15px; }
.sp-folder-icon .ico,
.sp-file-icon .ico   { width: 38px; height: 38px; stroke-width: 1.4; }
.sp-folder-icon      { color: var(--accent); }
.sp-file-icon        { color: var(--text-2); }
.file-icon .ico      { width: 20px; height: 20px; color: var(--text-2); }
.chat-list-avatar .ico { width: 17px; height: 17px; }
.ico-dot             { width: 0.75em; height: 0.75em; vertical-align: -0.05em; }
.ico-big             { width: 2em; height: 2em; stroke-width: 1.5; }
.ico-status-ok       { color: var(--success); }
.ico-status-bad      { color: var(--danger); }

/* Linked task/project chips live inside stored task HTML, so older entries
   still contain an emoji in .task-ref-icon. Hide that text and draw the icon
   with a mask instead — renders the same for old and new content alike. */
.task-ref-icon {
    font-size: 0 !important;
    width: 13px;
    height: 13px;
    display: inline-block;
    flex-shrink: 0;
    background-color: currentColor;
    -webkit-mask: var(--ref-icon) center / contain no-repeat;
    mask: var(--ref-icon) center / contain no-repeat;
    --ref-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71'/%3E%3Cpath d='M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71'/%3E%3C/svg%3E");
}
.task-ref-chip[data-ref-type="project"] .task-ref-icon {
    --ref-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z'/%3E%3Cpath d='M8 10v4'/%3E%3Cpath d='M12 10v2'/%3E%3Cpath d='M16 10v6'/%3E%3C/svg%3E");
}
/* Quill toolbar button for "link a task" */
.ql-toolbar .ql-taskref .ico { width: 17px; height: 17px; }
.ql-toolbar .ql-taskref { color: var(--text-2); }
.ql-toolbar .ql-taskref:hover { color: var(--accent); }
.cal-pill .ico, .cal-bar .ico { width: 11px; height: 11px; vertical-align: -1px; }
.drawer-header h3 .ico { color: var(--text-2); }
.notif-icon { color: var(--text-2); }

/* ======================================================
   SHAREPOINT — floating rounded rows instead of a boxed grid
   ------------------------------------------------------
   Rows are separate pills (border-spacing) with rounded ends,
   icons sit in soft tiles, actions are round ghost buttons.
   ====================================================== */
.sp-content {
    background-color: var(--glass-bg);
    background-image: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: inset 0 1px 0 var(--highlight), var(--shadow-md);
    -webkit-backdrop-filter: blur(var(--blur)) saturate(140%);
    backdrop-filter: blur(var(--blur)) saturate(140%);
}
.sp-toolbar {
    background: transparent;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}
.sp-user-picker { background: transparent; padding: 10px 18px; }
.sp-browser { padding: 12px 14px 16px; }

/* Breadcrumb: zone label as a soft pill, separators as quiet chevrons */
.bc-item { border-radius: 8px; padding: 4px 8px; display: inline-flex; align-items: center; gap: 6px; }
.bc-root { background: var(--fill-1); border: 1px solid var(--border); color: var(--text-1); font-weight: 600; }
.bc-root .ico { color: var(--accent); }
.bc-sep { display: inline-flex; color: var(--text-3); }
.bc-sep .ico { width: 14px; height: 14px; }

/* Table → separated rounded rows */
.sp-list-table,
.sp-task-table {
    border-collapse: separate;
    border-spacing: 0 6px;
    margin-top: -6px;
}
.sp-list-table th,
.sp-task-table th {
    background: transparent;
    border: none;
    padding: 8px 14px 4px;
}
.sp-list-table td,
.sp-task-table td {
    background: var(--fill-1);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 11px 14px;
    transition: background-color var(--transition), border-color var(--transition);
}
.sp-list-table tr:last-child td,
.sp-task-table tr:last-child td { border-bottom: 1px solid var(--border); }
.sp-list-table td:first-child,
.sp-task-table td:first-child {
    border-left: 1px solid var(--border);
    border-radius: 12px 0 0 12px;
}
.sp-list-table td:last-child,
.sp-task-table td:last-child {
    border-right: 1px solid var(--border);
    border-radius: 0 12px 12px 0;
}
.sp-list-table tbody tr:hover,
.sp-task-table tbody tr:hover,
.sp-folder-row,
.sp-folder-row:hover { background: transparent !important; }
.sp-list-table tbody tr:hover td,
.sp-task-table tbody tr:hover td {
    background: var(--fill-2);
    border-color: var(--border-hover);
}

/* Locked file: amber edge drawn inside the rounded end */
.sp-file-row.sp-locked td:first-child {
    border-left: 1px solid var(--border);
    box-shadow: inset 3px 0 0 var(--warning);
}

/* Drag & drop onto a folder row */
tr.sp-drop-target { transform: none; box-shadow: none; background: transparent !important; }
tr.sp-drop-target td {
    background: var(--accent-dim) !important;
    border-color: var(--accent) !important;
}

/* Icon tiles in the name column */
.sp-row-icon {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    display: inline-grid;
    place-items: center;
    border-radius: 10px;
    background: var(--accent-dim);
    color: var(--accent);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 18%, transparent);
}
.sp-row-icon .ico { width: 16px; height: 16px; }
.sp-row-icon.is-file {
    background: var(--fill-2);
    color: var(--text-2);
    box-shadow: inset 0 0 0 1px var(--border);
}

/* Row actions: round ghost buttons, quieter until the row is hovered */
.sp-list-table td:last-child .btn,
.sp-task-table td:last-child .btn {
    width: 32px;
    height: 32px;
    padding: 0;
    justify-content: center;
    border-radius: 50%;
    opacity: 0.7;
    transition: opacity var(--transition), background-color var(--transition);
}
.sp-list-table tr:hover td:last-child .btn,
.sp-task-table tr:hover td:last-child .btn { opacity: 1; }
.sp-list-table td:last-child .btn:hover,
.sp-task-table td:last-child .btn:hover { background: var(--fill-2); }
.sp-list-table td:last-child .btn-danger,
.sp-task-table td:last-child .btn-danger { background: transparent; color: var(--danger); box-shadow: none; }
.sp-list-table td:last-child .btn-danger:hover,
.sp-task-table td:last-child .btn-danger:hover { background: var(--danger-dim); }

/* Grid view cards match the rounded language */
.sp-folder-card,
.sp-file-card { border-radius: var(--radius-lg); }
.sp-folder-card:hover,
.sp-file-card:hover { transform: translateY(-2px); }

/* Zone tabs */
.sp-tab { border-radius: var(--radius-lg); }
.sp-tab-icon {
    width: 40px; height: 40px;
    display: inline-grid; place-items: center;
    border-radius: 12px;
    background: var(--fill-2);
    border: 1px solid var(--border);
    color: var(--text-2);
    font-size: 1rem;
}
.sp-tab-icon .ico { width: 19px; height: 19px; }
.sp-tab.active .sp-tab-icon { background: var(--accent-dim); color: var(--accent); border-color: transparent; }

/* ======================================================
   ACTIVITY LOG (task drawer) — js/activityLog.js
   ====================================================== */
.history-list { gap: 0; padding-top: 4px; }
.alog-count {
    display: inline-grid;
    place-items: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    margin-left: 6px;
    border-radius: 99px;
    background: var(--fill-2);
    border: 1px solid var(--border);
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-2);
}
.activity-log-chevron { display: inline-flex; margin-left: auto; color: var(--text-3); }
.activity-log-chevron .ico { width: 15px; height: 15px; }
.activity-log-toggle { display: flex; align-items: center; }

.alog-empty { color: var(--text-3); font-size: 0.86rem; }
.alog-day {
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--text-3);
    padding: 14px 0 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.alog-day::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.alog-day:first-child { padding-top: 2px; }

.alog-item {
    position: relative;
    display: grid;
    grid-template-columns: 30px 1fr;
    gap: 12px;
    padding-bottom: 16px;
}
/* Timeline rail between avatars */
.alog-item::before {
    content: '';
    position: absolute;
    left: 14.5px;
    top: 34px;
    bottom: 2px;
    width: 1px;
    background: var(--border);
}
.alog-item:last-child::before,
.alog-item:has(+ .alog-day)::before { display: none; }

.alog-avatar {
    position: relative;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 0.66rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.02em;
    box-shadow: 0 0 0 3px var(--bg-2);
}
/* Small badge showing what kind of change it was */
.alog-kind {
    position: absolute;
    right: -5px;
    bottom: -4px;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--bg-3);
    border: 1px solid var(--border-hover);
    color: var(--accent);
}
.alog-kind .ico { width: 10px; height: 10px; stroke-width: 2.2; }

.alog-body { min-width: 0; padding-top: 4px; }
.alog-line { display: flex; align-items: baseline; gap: 10px; }
.alog-text { flex: 1; font-size: 0.86rem; color: var(--text-2); line-height: 1.45; }
.alog-text strong { color: var(--text-1); font-weight: 600; }
.alog-time { font-size: 0.74rem; color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }

.alog-change {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 7px;
}
.alog-arrow { display: inline-flex; color: var(--text-3); }
.alog-arrow .ico { width: 13px; height: 13px; }
.alog-val {
    display: inline-block;
    max-width: 100%;
    padding: 2px 9px;
    border-radius: 7px;
    background: var(--fill-1);
    border: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-1);
    overflow-wrap: anywhere;
}
.alog-val.is-empty { color: var(--text-3); font-style: italic; }

/* Before / after for long text fields */
.alog-diff { margin-top: 6px; }
.alog-diff summary {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    list-style: none;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--accent);
    user-select: none;
}
.alog-diff summary::-webkit-details-marker { display: none; }
.alog-diff summary .ico { width: 13px; height: 13px; transition: transform var(--transition); }
.alog-diff[open] summary .ico { transform: rotate(90deg); }
.alog-diff-block {
    margin-top: 8px;
    padding: 9px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--fill-1);
}
.alog-diff-block p { font-size: 0.82rem; color: var(--text-2); line-height: 1.5; overflow-wrap: anywhere; }
.alog-diff-block.is-before p { color: var(--text-3); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--danger) 55%, transparent); }
.alog-diff-block.is-before { box-shadow: inset 3px 0 0 color-mix(in srgb, var(--danger) 60%, transparent); }
.alog-diff-block.is-after  { box-shadow: inset 3px 0 0 color-mix(in srgb, var(--success) 70%, transparent); }
.alog-diff-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-3);
    margin-bottom: 3px;
}

/* ======================================================
   TASK DRAWER — collapsible sections (Attachments, Time
   Tracked, Activity Log). Closed by default; tasks.js
   collapsibleSection() / wireCollapsibleSections().
   ====================================================== */
.drawer-collapsible {
    margin-bottom: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--fill-1);
    transition: border-color var(--transition), background-color var(--transition);
}
.drawer-collapsible:hover { border-color: var(--border-hover); }
.drawer-collapsible.is-open { background: transparent; }
/* Space before the first collapsible so it doesn't hug the section above */
.drawer-section:not(.drawer-collapsible) + .drawer-collapsible { margin-top: 4px; }
.drawer-collapsible:last-of-type { margin-bottom: 28px; }

.drawer-collapse-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    background: none;
    border: none;
    border-radius: var(--radius-lg);
    color: var(--text-1);
    font-size: 0.88rem;
    font-weight: 600;
    text-align: left;
}
.drawer-collapse-icon {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: var(--fill-2);
    border: 1px solid var(--border);
    color: var(--text-2);
    flex-shrink: 0;
}
.drawer-collapse-icon .ico { width: 15px; height: 15px; }
.drawer-collapsible.is-open .drawer-collapse-icon { color: var(--accent); background: var(--accent-dim); border-color: transparent; }
.drawer-collapse-title { flex: 1; }
.drawer-collapse-meta:not(:empty) {
    padding: 2px 9px;
    border-radius: 99px;
    background: var(--fill-2);
    border: 1px solid var(--border);
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--text-2);
    font-variant-numeric: tabular-nums;
}
.drawer-collapse-chevron { display: inline-flex; color: var(--text-3); transition: transform var(--transition); }
.drawer-collapse-chevron .ico { width: 16px; height: 16px; }
.drawer-collapsible.is-open .drawer-collapse-chevron { transform: rotate(180deg); }
.drawer-collapse-body {
    padding: 4px 14px 16px;
    border-top: 1px solid var(--border);
    padding-top: 14px;
}
.drawer-collapse-body[hidden] { display: none; }

/* ── Time Tracked timeline (reuses .alog-* from the Activity Log) ── */
.tlog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 4px;
}
.tlog-total { font-size: 0.84rem; color: var(--text-2); }
.tlog-total strong { color: var(--text-1); font-size: 1rem; margin-left: 4px; font-variant-numeric: tabular-nums; }

.tlog-day { display: flex; }
.tlog-day::after { order: 1; }
.tlog-day-total {
    order: 2;
    font-variant-numeric: tabular-nums;
    color: var(--text-2);
}

.tlog-duration {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-1);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.tlog-running {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--success);
    white-space: nowrap;
}
.tlog-locked { display: inline-flex; color: var(--text-3); vertical-align: -2px; }
.tlog-locked .ico { width: 13px; height: 13px; }

/* Row actions appear on hover (always visible on touch screens) */
.tlog-actions { display: inline-flex; gap: 2px; opacity: 0; transition: opacity var(--transition); }
.tlog-item:hover .tlog-actions,
.tlog-item:focus-within .tlog-actions { opacity: 1; }
@media (hover: none) { .tlog-actions { opacity: 1; } }
.tlog-actions .btn { width: 28px; height: 28px; padding: 0; justify-content: center; border-radius: 50%; }
.tlog-actions .ico { width: 14px; height: 14px; }
.tlog-actions .tt-del-btn:hover { color: var(--danger); background: var(--danger-dim); }

.tlog-desc { font-size: 0.85rem; color: var(--text-2); margin-top: 3px; line-height: 1.5; overflow-wrap: anywhere; }
.tlog-desc.is-empty { color: var(--text-3); font-style: italic; }

.tlog-more summary .tlog-less-label { display: none; }
.tlog-more[open] summary .tlog-more-label { display: none; }
.tlog-more[open] summary .tlog-less-label { display: inline; }
.tlog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px 16px;
    margin-top: 8px;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--fill-1);
}
.tlog-field dt { font-size: 0.7rem; font-weight: 600; color: var(--text-3); margin-bottom: 2px; }
.tlog-field dd { font-size: 0.82rem; color: var(--text-1); display: flex; align-items: center; gap: 6px; overflow-wrap: anywhere; }
.tlog-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.tlog-none { color: var(--text-3); font-style: italic; }

/* ======================================================
   EXTERNAL LINKS (sidebar) — js/externalLinks.js
   ====================================================== */
.nav-section-row { display: flex; align-items: center; justify-content: space-between; padding-right: 6px; }
.nav-section-action {
    width: 22px; height: 22px;
    display: grid; place-items: center;
    border-radius: 7px;
    border: 1px solid var(--border);
    background: var(--fill-1);
    color: var(--text-2);
    transition: var(--transition);
}
.nav-section-action:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-dim); }
.nav-section-action .ico { width: 13px; height: 13px; }
.nav-link-item { position: relative; }
.nav-link-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-link-remove {
    width: 22px; height: 22px;
    display: grid; place-items: center;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-3);
    opacity: 0;
    transition: var(--transition);
}
.nav-link-item:hover .nav-link-remove,
.nav-link-remove:focus-visible { opacity: 1; }
@media (hover: none) { .nav-link-remove { opacity: 1; } }
.nav-link-remove:hover { color: var(--danger); background: var(--danger-dim); }
.nav-link-remove .ico { width: 13px; height: 13px; }
.nav-empty { font-size: 0.78rem; color: var(--text-3); padding: 4px 12px 8px; }

.icon-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 6px; }
.icon-pick { position: relative; cursor: pointer; }
.icon-pick input { position: absolute; opacity: 0; pointer-events: none; }
.icon-pick span {
    height: 40px; display: grid; place-items: center;
    border-radius: 10px; border: 1px solid var(--border);
    background: var(--fill-1); color: var(--text-2);
    transition: var(--transition);
}
.icon-pick span .ico { width: 18px; height: 18px; }
.icon-pick:hover span { border-color: var(--border-hover); color: var(--text-1); }
.icon-pick input:checked + span { border-color: var(--accent); background: var(--accent-dim); color: var(--accent); }
.icon-pick input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.form-hint { font-size: 0.8rem; color: var(--text-3); margin: 4px 0 12px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* ======================================================
   PERMISSIONS — shared rows (Settings view, user editor)
   ====================================================== */
.perm-summary { font-size: 0.86rem; color: var(--text-2); margin-bottom: 16px; }
.perm-summary strong { color: var(--text-1); }
.perm-group { margin-bottom: 16px; }
.perm-group-title { font-size: 0.74rem; font-weight: 700; color: var(--text-3); margin-bottom: 6px; letter-spacing: 0.01em; }
.perm-row {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--fill-1);
    margin-bottom: 5px;
}
.perm-row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.perm-row-label { font-size: 0.86rem; color: var(--text-1); font-weight: 500; }
.perm-row-desc { font-size: 0.75rem; color: var(--text-3); line-height: 1.4; }
.perm-state, .perm-effective {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 0.76rem; font-weight: 600; white-space: nowrap;
}
.perm-row.is-allowed .perm-state, .perm-effective.is-allowed { color: var(--success); }
.perm-row.is-denied .perm-state, .perm-effective.is-denied { color: var(--text-3); }
.perm-state .ico, .perm-effective .ico { width: 13px; height: 13px; }
.perm-key { font-family: var(--font-mono); font-size: 0.68rem; color: var(--text-3); opacity: 0.8; }

/* Edit-user dialog */
#modal-box.modal-wide { max-width: 760px; width: min(760px, calc(100vw - 32px)); }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 600px) { .form-row-2 { grid-template-columns: 1fr; } }
.perm-editor { margin-top: 6px; border-top: 1px solid var(--border); padding-top: 16px; }
.perm-editor-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.perm-editor-title { font-weight: 700; font-size: 0.95rem; display: flex; align-items: center; gap: 6px; }
.perm-editor-sub { font-size: 0.78rem; color: var(--text-3); margin-top: 2px; }
.perm-editor-count { font-size: 0.74rem; font-weight: 600; color: var(--text-2); padding: 3px 10px; border-radius: 99px; background: var(--fill-2); border: 1px solid var(--border); white-space: nowrap; }
.perm-search {
    width: 100%; margin-bottom: 12px;
    padding: 8px 12px; border-radius: 10px;
    border: 1px solid var(--border); background: var(--input-bg); color: var(--text-1);
    font-size: 0.85rem; outline: none;
}
.perm-search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.perm-editor-list { max-height: 46vh; overflow-y: auto; padding-right: 4px; }
.perm-override-row { flex-wrap: wrap; }
.perm-override-row .perm-effective { min-width: 92px; justify-content: flex-end; }
.perm-override-row.is-overridden { border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: var(--accent-dim); }

/* Three-way segmented control: Role default / Allow / Deny */
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 9px; background: var(--fill-1); border: 1px solid var(--border); }
.seg-opt { position: relative; cursor: pointer; }
.seg-opt input { position: absolute; opacity: 0; pointer-events: none; }
.seg-opt span { display: block; padding: 4px 10px; border-radius: 7px; font-size: 0.74rem; font-weight: 600; color: var(--text-3); white-space: nowrap; transition: var(--transition); }
.seg-opt:hover span { color: var(--text-1); }
.seg-opt input:checked + span { background: var(--fill-2); color: var(--text-1); box-shadow: inset 0 1px 0 var(--highlight), var(--shadow-sm); }
.seg-grant input:checked + span { background: var(--success-dim); color: var(--success); }
.seg-revoke input:checked + span { background: var(--danger-dim); color: var(--danger); }
.seg-opt input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ======================================================
   ROLES & PERMISSIONS tab
   ====================================================== */
#users-tabs { margin-bottom: 16px; }
#users-tabs .tt-tab { display: inline-flex; align-items: center; gap: 6px; }
#users-tabs .tt-tab .ico { width: 15px; height: 15px; }
.roles-layout { display: grid; grid-template-columns: 280px 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .roles-layout { grid-template-columns: 1fr; } }
.roles-list, .role-editor {
    background-color: var(--glass-bg);
    background-image: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: inset 0 1px 0 var(--highlight), var(--shadow-md);
}
.roles-list { padding: 10px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: calc(var(--shell-gap) + 72px); }
.roles-list-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 10px; font-weight: 700; font-size: 0.9rem; }
.role-item {
    display: flex; align-items: center; gap: 10px;
    width: 100%; padding: 9px 10px;
    border: 1px solid transparent; border-radius: 11px;
    background: none; color: var(--text-2); text-align: left;
    transition: var(--transition);
}
.role-item:hover { background: var(--fill-1); color: var(--text-1); }
.role-item.active { background: var(--fill-2); border-color: var(--border); color: var(--text-1); box-shadow: inset 0 1px 0 var(--highlight); }
.role-item-icon { width: 30px; height: 30px; flex-shrink: 0; display: grid; place-items: center; border-radius: 9px; background: var(--fill-2); border: 1px solid var(--border); color: var(--text-2); }
.role-item.active .role-item-icon { background: var(--accent-dim); color: var(--accent); border-color: transparent; }
.role-item-icon .ico { width: 15px; height: 15px; }
.role-item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.role-item-name { font-weight: 600; font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-item-meta { font-size: 0.72rem; color: var(--text-3); }
.role-tag { font-size: 0.66rem; font-weight: 700; padding: 2px 7px; border-radius: 99px; background: var(--fill-2); border: 1px solid var(--border); color: var(--text-2); white-space: nowrap; }

.role-editor { padding: 18px 20px 14px; min-width: 0; }
.role-editor-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.role-editor-fields { flex: 1; min-width: 240px; display: flex; flex-direction: column; gap: 4px; }
.role-name-input, .role-desc-input {
    background: transparent; border: 1px solid transparent; border-radius: 8px;
    color: var(--text-1); outline: none; padding: 4px 8px; margin-left: -8px;
    transition: var(--transition);
}
.role-name-input { font-family: var(--font-head); font-size: 1.25rem; font-weight: 700; letter-spacing: -0.015em; }
.role-desc-input { font-size: 0.85rem; color: var(--text-2); }
.role-name-input:not(:disabled):hover, .role-desc-input:not(:disabled):hover { border-color: var(--border); }
.role-name-input:focus, .role-desc-input:focus { border-color: var(--accent); background: var(--input-bg); }
.role-editor-meta { display: flex; align-items: center; gap: 8px; font-size: 0.76rem; color: var(--text-3); }
.role-editor-meta code { font-family: var(--font-mono); padding: 2px 7px; border-radius: 6px; background: var(--fill-1); border: 1px solid var(--border); }
.role-perm-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
.role-perm-group { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px 6px; background: var(--fill-1); }
.role-perm-group-head { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.role-perm-group-head .perm-group-title { margin: 0; flex: 1; }
.role-perm-group-count { font-size: 0.72rem; font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; margin-right: 4px; }
.role-perm-group-head .btn { padding: 2px 8px; font-size: 0.72rem; }
.role-perm-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--border); cursor: pointer; }
.role-perm-row:first-of-type { border-top: none; }
.role-editor-footer { display: flex; align-items: center; gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); position: sticky; bottom: 0; }
.role-dirty { font-size: 0.76rem; color: var(--warning); font-weight: 600; }

/* Toggle switch (checkbox) */
.switch {
    appearance: none; -webkit-appearance: none;
    flex-shrink: 0;
    width: 36px; height: 20px; border-radius: 99px;
    background: var(--fill-2); border: 1px solid var(--border-hover);
    position: relative; cursor: pointer; transition: var(--transition);
}
.switch::after {
    content: ''; position: absolute; top: 2px; left: 2px;
    width: 14px; height: 14px; border-radius: 50%;
    background: var(--text-3); transition: var(--transition);
}
.switch:checked { background: var(--accent-strong); border-color: transparent; }
.switch:checked::after { left: 18px; background: var(--on-accent); }
.switch:disabled { opacity: 0.55; cursor: not-allowed; }
.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* "Your permissions were updated" banner */
.perm-change-notice {
    position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
    z-index: 9000;
    display: flex; align-items: center; gap: 12px;
    padding: 10px 10px 10px 16px;
    border-radius: 14px; border: 1px solid var(--border-hover);
    background-color: var(--bg-2); background-image: var(--surface);
    box-shadow: var(--shadow-lg);
    font-size: 0.88rem; color: var(--text-1);
}
.perm-change-notice > .ico { color: var(--accent); }

/* ======================================================
   PROJECTS — sub-project navigation (js/projects.js)
   ====================================================== */
.projects-breadcrumb { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; min-width: 0; }
.pb-item {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 6px 11px; border-radius: 10px;
    border: 1px solid transparent; background: none;
    color: var(--text-2); font-size: 0.86rem; font-weight: 600;
    transition: var(--transition);
}
.pb-item .ico { width: 15px; height: 15px; }
.pb-item:hover { background: var(--fill-1); color: var(--text-1); }
.pb-item.is-current { background: var(--fill-2); border-color: var(--border); color: var(--text-1); box-shadow: inset 0 1px 0 var(--highlight); }
.pb-sep { display: inline-flex; color: var(--text-3); }
.pb-sep .ico { width: 14px; height: 14px; }
.pb-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.pb-tasks { margin-left: 6px; }

.project-stats { display: flex; gap: 10px; }
.project-stats > div {
    flex: 1; padding: 8px; text-align: center;
    border-radius: 10px; background: var(--fill-1); border: 1px solid var(--border);
    display: flex; flex-direction: column;
}
.project-stats strong { font-family: var(--font-head); font-size: 1.3rem; font-weight: 700; }
.project-stats strong.is-accent { color: var(--accent); }
.project-stats span { font-size: 0.72rem; color: var(--text-3); }

/* ── Project cards: equal height, fixed action row ─────────── */
.project-grid { grid-auto-rows: 1fr; }
.project-card { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.project-card-head { display: flex; align-items: flex-start; gap: 12px; min-width: 0; }
.project-tile {
    width: 42px; height: 42px; flex-shrink: 0;
    display: grid; place-items: center;
    border-radius: 12px; color: #fff;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.25), 0 6px 16px -8px rgba(0,0,0,0.5);
}
.project-card-title { min-width: 0; flex: 1; }
.project-name {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    padding: 0; border: none; background: none; text-align: left; cursor: pointer;
    font-family: var(--font-head); font-weight: 700; font-size: 1rem; line-height: 1.3;
    color: var(--text-1); overflow-wrap: anywhere;
}
.project-name:hover { color: var(--accent); }
.project-card-body { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.project-desc {
    margin: 0; font-size: 0.85rem; line-height: 1.5; color: var(--text-2);
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
    min-height: calc(1.5em * 3); overflow-wrap: anywhere;
}
.project-desc.is-empty { color: var(--text-3); font-style: italic; }
.project-more {
    display: inline-flex; align-items: center; gap: 2px; padding: 0;
    border: none; background: none; color: var(--accent); font-size: 0.78rem; font-weight: 600; cursor: pointer;
}
.project-more .ico { width: 13px; height: 13px; }
.project-more[hidden] { display: none; }
.project-card-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 26px; }
.project-created { margin-left: auto; font-size: 0.76rem; color: var(--text-3); white-space: nowrap; }
.project-card-actions {
    display: flex; align-items: center; gap: 4px;
    padding-top: 12px; border-top: 1px solid var(--border);
}
.project-card-actions .btn-icon { width: 32px; height: 32px; padding: 0; justify-content: center; border-radius: 9px; }
.project-subs {
    display: inline-flex; align-items: center; gap: 5px; max-width: 100%;
    padding: 3px 6px 3px 9px; border-radius: 99px;
    border: 1px solid var(--border); background: var(--fill-1);
    color: var(--text-2); font-size: 0.74rem; font-weight: 600; white-space: nowrap;
    transition: var(--transition);
}
.project-subs .ico { width: 13px; height: 13px; }
.project-subs:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
.view-toggle { display: flex; gap: 2px; padding: 3px; border-radius: var(--radius-md); background: var(--fill-1); border: 1px solid var(--border); }

/* ── Project list view ─────────────────────────────────────── */
.project-table td { vertical-align: middle; }
.project-grid + * , .task-table-wrap:has(.project-table) { overflow-x: auto; }
.project-table { min-width: 680px; }
.pt-name { display: flex; align-items: flex-start; gap: 10px; min-width: 200px; max-width: 300px; }
.pt-name .pt-dot { margin-top: 6px; }
.pt-name-text { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.pt-name .project-name { display: block; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.9rem; }
.pt-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.pt-desc { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); font-size: 0.85rem; }
.pt-num { font-variant-numeric: tabular-nums; font-weight: 600; }
.pt-open-sub { display: block; font-size: 0.72rem; font-weight: 600; color: var(--accent); }
@media (max-width: 1380px) { .pt-col-created { display: none; } }
.pt-date { color: var(--text-3); font-size: 0.8rem; white-space: nowrap; }
.pt-none { color: var(--text-3); }
.pt-actions { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.pt-actions .filter-spacer { display: none; }
.pt-actions .btn-icon { width: 30px; height: 30px; padding: 0; justify-content: center; }

/* ── Project details dialog ────────────────────────────────── */
.pd-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.pd-title h2 { overflow-wrap: anywhere; }
.pd-desc {
    max-height: 40vh; overflow-y: auto;
    white-space: pre-wrap; overflow-wrap: anywhere;
    font-size: 0.9rem; line-height: 1.6; color: var(--text-2);
    padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--fill-1);
    margin-bottom: 14px;
}
.pd-stats { margin-bottom: 12px; }
.pd-meta { display: flex; align-items: center; gap: 10px; font-size: 0.82rem; color: var(--text-3); margin-bottom: 14px; }
.pd-section-title { font-size: 0.74rem; font-weight: 700; color: var(--text-3); margin-bottom: 6px; }
.pd-children { display: flex; flex-direction: column; gap: 4px; max-height: 30vh; overflow-y: auto; margin-bottom: 8px; }
.pd-child {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--fill-1);
    color: var(--text-1); font-size: 0.86rem; text-align: left; transition: var(--transition);
}
.pd-child:hover { border-color: var(--border-hover); background: var(--fill-2); }
.pd-child-count { margin-left: auto; color: var(--text-3); font-size: 0.76rem; }
.pd-child .ico { width: 14px; height: 14px; color: var(--text-3); }
.project-path { font-size: 0.74rem; color: var(--text-3); margin-top: 2px; overflow-wrap: anywhere; }

/* The main column is a flex item: without min-width:0 it grows with wide
   content (tables) and pushes the whole page sideways instead of letting
   the table scroll inside its own container. */
.main-content { min-width: 0; }
#projects-grid { min-width: 0; }

/* ======================================================
   SERVER STATUS — tabs + Discord status board
   ====================================================== */
#ss-tabs .tt-tab { display: inline-flex; align-items: center; gap: 6px; }
#ss-tabs .tt-tab .ico { width: 15px; height: 15px; }
.ss-pane[hidden] { display: none; }

.sb-grid { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(320px, 2fr); gap: 16px; margin-bottom: 16px; align-items: start; }
@media (max-width: 1000px) { .sb-grid { grid-template-columns: 1fr; } }
.sb-card {
    background-color: var(--glass-bg); background-image: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius-lg);
    box-shadow: inset 0 1px 0 var(--highlight), var(--shadow-md);
    padding: 16px 18px;
}
.sb-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.sb-card-head h3 { font-family: var(--font-head); font-size: 0.98rem; flex: 1; }
.sb-icon { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; background: var(--accent-dim); color: var(--accent); }
.sb-icon .ico { width: 16px; height: 16px; }
.sb-count { font-size: 0.76rem; font-weight: 600; color: var(--text-2); padding: 2px 9px; border-radius: 99px; background: var(--fill-2); border: 1px solid var(--border); }

.sb-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; background: var(--text-3); }
.sb-dot.is-ok   { background: var(--success); box-shadow: 0 0 0 4px var(--success-dim); }
.sb-dot.is-warn { background: var(--warning); box-shadow: 0 0 0 4px var(--warning-dim); }
.sb-dot.is-bad  { background: var(--danger);  box-shadow: 0 0 0 4px var(--danger-dim); }
.sb-bot { display: flex; align-items: center; gap: 14px; }
.sb-bot .sb-dot { width: 14px; height: 14px; }
.sb-big { font-family: var(--font-head); font-size: 1.25rem; font-weight: 700; }
.sb-sub { font-size: 0.8rem; color: var(--text-3); }
.sb-sub code { font-family: var(--font-mono); font-size: 0.78rem; }

.sb-last {
    display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
    padding: 9px 12px; margin-bottom: 14px; border-radius: 10px;
    background: var(--fill-1); border: 1px solid var(--border); font-size: 0.84rem; color: var(--text-2);
}
.sb-last .ico { width: 15px; height: 15px; }
.sb-last.is-ok  { border-color: color-mix(in srgb, var(--success) 35%, transparent); }
.sb-last.is-ok > .ico { color: var(--success); }
.sb-last.is-bad { border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: var(--danger-dim); color: var(--text-1); }
.sb-last.is-bad > .ico { color: var(--danger); }
.sb-last a { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; }
.sb-last a .ico { width: 13px; height: 13px; }
.sb-hint { display: block; font-size: 0.75rem; color: var(--text-3); margin-top: 5px; line-height: 1.45; }
.sb-form-row { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.sb-form-row .form-group { flex: 1; min-width: 160px; margin-bottom: 0; }
.sb-switch { display: inline-flex; align-items: center; gap: 10px; padding-bottom: 9px; font-size: 0.86rem; color: var(--text-2); cursor: pointer; }
.sb-actions { display: flex; justify-content: flex-end; margin-top: 14px; }

.sb-site-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.sb-site {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: 12px;
    border: 1px solid var(--border); background: var(--fill-1);
    transition: var(--transition);
}
.sb-site:hover { border-color: var(--border-hover); background: var(--fill-2); }
.sb-site-text { flex: 1; min-width: 0; }
.sb-site-name { font-weight: 600; font-size: 0.88rem; }
.sb-site-url { font-size: 0.78rem; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.sb-site-url:hover { color: var(--accent); }
.sb-site-state { font-size: 0.78rem; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--text-3); }
.sb-site-state.is-ok { color: var(--success); }
.sb-site-state.is-warn { color: var(--warning); }
.sb-site-state.is-bad { color: var(--danger); }
.sb-site-actions { display: flex; gap: 2px; }
.sb-site-actions .btn-icon { width: 28px; height: 28px; padding: 0; justify-content: center; border-radius: 8px; }
.sb-site-actions .sb-del:hover { color: var(--danger); background: var(--danger-dim); }
.sb-empty { color: var(--text-3); font-size: 0.86rem; }
.sb-add { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.sb-add input {
    flex: 2; min-width: 200px; padding: 8px 12px; border-radius: 10px;
    border: 1px solid var(--border); background: var(--input-bg); color: var(--text-1); font-size: 0.86rem; outline: none;
}
.sb-add input#sb-new-label { flex: 1; min-width: 140px; }
.sb-add input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }

@keyframes ico-spin { to { transform: rotate(360deg); } }
.ico-spin { animation: ico-spin 0.9s linear infinite; }
