@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* LIGHT (default) */
:root {
    --tm-bg: #f5f7fb;
    --tm-bg-2: #ebeef6;
    --tm-panel: rgba(255, 255, 255, 0.85);
    --tm-panel-hi: rgba(255, 255, 255, 1);
    --tm-panel-line: rgba(17, 24, 39, 0.08);
    --tm-ink: #111827;
    --tm-ink-dim: #6b7280;
    --tm-muted: #9ca3af;
    --tm-brand: #6366f1;
    --tm-brand-2: #8b5cf6;
    --tm-danger: #ef4444;
    --tm-warn: #f59e0b;
    --tm-ok: #10b981;
    --tm-info: #06b6d4;
    --tm-input-bg: #ffffff;
    --tm-input-bg-focus: #ffffff;
    --tm-hover-bg: rgba(17, 24, 39, 0.04);
    --tm-hover-bg-strong: rgba(17, 24, 39, 0.07);
    --tm-sidebar-bg: rgba(255, 255, 255, 0.85);
    --tm-topbar-bg: rgba(255, 255, 255, 0.85);
    --tm-card-bg: rgba(255, 255, 255, 1);
    --tm-shadow: 0 6px 24px rgba(17, 24, 39, 0.08);
    --tm-shadow-hi: 0 20px 60px rgba(99, 102, 241, 0.25);
    --tm-stat-halo: rgba(99, 102, 241, 0.18);
    --tm-modal-bg: linear-gradient(180deg, #ffffff, #f8fafc);
    --tm-modal-backdrop: rgba(17, 24, 39, 0.35);
    --tm-login-card-bg: rgba(255, 255, 255, 0.85);
    --tm-hint-bg: rgba(99, 102, 241, 0.08);
    --tm-hint-border: rgba(99, 102, 241, 0.22);
    --tm-ghost-chip-bg: rgba(107, 115, 136, 0.14);
    --tm-radius: 14px;
    --tm-radius-sm: 10px;
    --sidebar-w: 84px;
}

/* DARK */
[data-theme="dark"] {
    --tm-bg: #0b1020;
    --tm-bg-2: #0e1530;
    --tm-panel: rgba(255, 255, 255, 0.04);
    --tm-panel-hi: rgba(255, 255, 255, 0.08);
    --tm-panel-line: rgba(255, 255, 255, 0.08);
    --tm-ink: #e6e8ef;
    --tm-ink-dim: #9aa3b8;
    --tm-muted: #6b7388;
    --tm-input-bg: rgba(255, 255, 255, 0.04);
    --tm-input-bg-focus: rgba(255, 255, 255, 0.07);
    --tm-hover-bg: rgba(255, 255, 255, 0.05);
    --tm-hover-bg-strong: rgba(255, 255, 255, 0.09);
    --tm-sidebar-bg: rgba(11, 16, 32, 0.6);
    --tm-topbar-bg: rgba(11, 16, 32, 0.7);
    --tm-card-bg: rgba(255, 255, 255, 0.04);
    --tm-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    --tm-stat-halo: rgba(99, 102, 241, 0.25);
    --tm-modal-bg: linear-gradient(180deg, rgba(22, 28, 54, 0.95), rgba(14, 21, 48, 0.98));
    --tm-modal-backdrop: rgba(0, 0, 0, 0.6);
    --tm-login-card-bg: rgba(15, 20, 42, 0.6);
    --tm-hint-bg: rgba(99, 102, 241, 0.12);
    --tm-hint-border: rgba(99, 102, 241, 0.25);
    --tm-ghost-chip-bg: rgba(107, 115, 136, 0.2);
}

* { box-sizing: border-box; }
html { scrollbar-gutter: stable; scroll-behavior: smooth; }
html, body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--tm-ink);
    background:
        radial-gradient(1200px 600px at 10% -10%, rgba(99, 102, 241, 0.18), transparent 60%),
        radial-gradient(1000px 500px at 100% 0%, rgba(139, 92, 246, 0.14), transparent 60%),
        linear-gradient(180deg, var(--tm-bg) 0%, var(--tm-bg-2) 100%);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background 0.3s, color 0.3s;
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
[data-theme="dark"] body {
    background:
        radial-gradient(1200px 600px at 10% -10%, rgba(99, 102, 241, 0.25), transparent 60%),
        radial-gradient(1000px 500px at 100% 0%, rgba(139, 92, 246, 0.2), transparent 60%),
        linear-gradient(180deg, var(--tm-bg) 0%, var(--tm-bg-2) 100%);
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

#app .loading-progress { position: fixed; inset: 0; margin: auto; width: 60px; height: 60px; }
.loading-progress circle { stroke: var(--tm-brand); }
.loading-progress-text { color: var(--tm-ink); }
#blazor-error-ui { display: none !important; }

.tm-spinner {
    width: 40px; height: 40px; border-radius: 50%;
    border: 3px solid var(--tm-panel-line);
    border-top-color: var(--tm-brand);
    animation: spin 0.8s linear infinite;
}
.tm-spinner-sm {
    width: 16px; height: 16px; border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.tm-center { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.tm-center-sm { display: flex; align-items: center; justify-content: center; padding: 40px; }
.tm-auth-shell { min-height: 100vh; }

/* LOGIN */
.tm-login { min-height: 100vh; display: grid; place-items: center; padding: 24px; position: relative; overflow: hidden; }
.tm-login-aurora {
    position: absolute; inset: -20% -10%;
    background:
        radial-gradient(circle at 30% 40%, rgba(99, 102, 241, 0.30), transparent 50%),
        radial-gradient(circle at 70% 60%, rgba(236, 72, 153, 0.22), transparent 50%),
        radial-gradient(circle at 50% 100%, rgba(6, 182, 212, 0.20), transparent 50%);
    filter: blur(40px); z-index: 0; animation: float 10s ease-in-out infinite alternate;
}
@keyframes float { from { transform: translate(-2%, -2%) scale(1); } to { transform: translate(2%, 2%) scale(1.05); } }
.tm-login-card {
    position: relative; z-index: 1; width: 100%; max-width: 440px;
    background: var(--tm-login-card-bg); backdrop-filter: blur(24px);
    border: 1px solid var(--tm-panel-line); border-radius: 20px;
    padding: 36px; box-shadow: var(--tm-shadow);
}
/* Wider variant for forms with side-by-side fields (e.g. Register). */
.tm-login-card-wide { max-width: 640px; padding: 28px 32px; }
.tm-login-title { font-size: 28px; font-weight: 700; margin: 20px 0 4px; }
.tm-login-sub { color: var(--tm-ink-dim); margin: 0 0 24px; font-size: 14px; }
/* Tight spacing for fit-on-one-screen layouts. */
.tm-login-title-tight { font-size: 22px; margin: 14px 0 4px; }
.tm-login-sub-tight { margin: 0 0 16px; font-size: 13px; }

/* BRAND */
.tm-brand { display: flex; gap: 12px; align-items: center; }
.tm-brand-lg { gap: 14px; }
.tm-brand-mark {
    width: 44px; height: 44px; border-radius: 12px;
    background: linear-gradient(135deg, var(--tm-brand), var(--tm-brand-2));
    display: grid; place-items: center; font-weight: 800; color: white;
    font-size: 16px; box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
}
.tm-brand-title { font-weight: 700; font-size: 15px; }
.tm-brand-sub { font-size: 11px; color: var(--tm-ink-dim); letter-spacing: 0.5px; text-transform: uppercase; }

/* FORM */
.tm-form { display: flex; flex-direction: column; gap: 14px; }
.tm-field { display: flex; flex-direction: column; gap: 6px; }
.tm-field label { font-size: 12px; color: var(--tm-ink-dim); font-weight: 600; letter-spacing: 0.2px; }
/* Bigger gap BETWEEN stacked fields than WITHIN a field, so each label visually groups with the input below
   it instead of appearing close to the input above. Direct-child only so side-by-side fields inside a
   .tm-field-grid / .tm-field-grid-2 row do NOT inherit this top margin (which would knock them out of line
   with their row neighbour). */
.tm-form > .tm-field + .tm-field,
.tm-modal-body > .tm-field + .tm-field { margin-top: 18px; }
.tm-input {
    width: 100%; padding: 10px 14px; border-radius: var(--tm-radius-sm);
    background: var(--tm-input-bg); border: 1px solid var(--tm-panel-line);
    color: var(--tm-ink); font-size: 14px; line-height: 1.4; outline: none;
    box-sizing: border-box; height: 42px;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
/* Normalise native date/time inputs so they line up next to text inputs in the same row.
   Chrome adds extra padding around the calendar-picker indicator and date-edit field — strip it. */
input.tm-input[type="date"],
input.tm-input[type="datetime-local"],
input.tm-input[type="time"],
input.tm-input[type="month"],
input.tm-input[type="week"] { padding: 8px 14px; }
input.tm-input[type="date"]::-webkit-datetime-edit,
input.tm-input[type="datetime-local"]::-webkit-datetime-edit,
input.tm-input[type="time"]::-webkit-datetime-edit { padding: 0; }
input.tm-input[type="date"]::-webkit-calendar-picker-indicator,
input.tm-input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input.tm-input[type="time"]::-webkit-calendar-picker-indicator { padding: 0; margin-left: 4px; }
.tm-textarea.tm-input { height: auto; }
.tm-input:focus {
    border-color: var(--tm-brand);
    background: var(--tm-input-bg-focus);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}
.tm-input::placeholder { color: var(--tm-muted); }
.tm-input-sm { padding: 6px 10px; font-size: 13px; height: 34px; }
.tm-textarea { min-height: 90px; height: auto; resize: vertical; font-family: inherit; }
.tm-field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* password with eye */
.tm-password-wrap { position: relative; }
.tm-password-wrap .tm-input { padding-right: 40px; }
.tm-eye-btn {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    width: 28px; height: 28px; border-radius: 8px; border: none; cursor: pointer;
    background: transparent; color: var(--tm-ink-dim);
    display: grid; place-items: center; transition: color 0.15s, background 0.15s;
}
.tm-eye-btn:hover { color: var(--tm-ink); background: var(--tm-hover-bg); }

/* BUTTONS */
.tm-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 9px 16px; border-radius: var(--tm-radius-sm); border: 1px solid transparent;
    font-weight: 600; font-size: 13px; cursor: pointer;
    transition: transform 0.08s, box-shadow 0.15s, background 0.15s;
    white-space: nowrap;
}
.tm-btn:hover:not(:disabled) { transform: translateY(-1px); }
.tm-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.tm-btn-primary {
    background: linear-gradient(135deg, var(--tm-brand), var(--tm-brand-2));
    color: white; box-shadow: 0 6px 18px rgba(99, 102, 241, 0.35);
}
.tm-btn-primary:hover:not(:disabled) { box-shadow: 0 10px 24px rgba(99, 102, 241, 0.5); }
.tm-btn-ghost { background: var(--tm-hover-bg); color: var(--tm-ink); border-color: var(--tm-panel-line); }
.tm-btn-ghost:hover:not(:disabled) { background: var(--tm-hover-bg-strong); }
.tm-btn-danger { background: var(--tm-danger); color: white; }
.tm-btn-block { width: 100%; }

.tm-icon-btn {
    width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--tm-panel-line);
    background: var(--tm-hover-bg); color: var(--tm-ink);
    display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.tm-icon-btn:hover { background: var(--tm-hover-bg-strong); }
.tm-icon-sm { width: 26px; height: 26px; font-size: 13px; }
.tm-icon-danger:hover { background: rgba(239, 68, 68, 0.12); color: var(--tm-danger); border-color: rgba(239, 68, 68, 0.3); }

/* ALERTS */
.tm-alert { padding: 10px 14px; border-radius: var(--tm-radius-sm); font-size: 13px; }
.tm-alert-error { background: rgba(239, 68, 68, 0.10); color: #b91c1c; border: 1px solid rgba(239, 68, 68, 0.3); }
[data-theme="dark"] .tm-alert-error { color: #fecaca; }

/* SHELL / SIDEBAR */
.tm-shell {
    display: grid; grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
}

.tm-sidebar {
    background: linear-gradient(180deg, #4f46e5 0%, #6d28d9 100%);
    border-right: 1px solid rgba(255,255,255,0.08);
    padding: 16px 4px; display: flex; flex-direction: column;
    min-height: 100vh;
}
.tm-sidebar-inner {
    position: sticky; top: 16px; display: flex; flex-direction: column; gap: 10px;
    height: calc(100vh - 32px); align-items: center;
}
.tm-sidebar .tm-brand { margin-bottom: 8px; }
.tm-sidebar .tm-brand-mark {
    background: rgba(255,255,255,0.15); backdrop-filter: blur(4px);
    color: #fff;
    box-shadow: 0 4px 14px rgba(0,0,0,0.25);
    border: 1px solid rgba(255,255,255,0.22);
}

.tm-nav {
    display: flex; flex-direction: column; gap: 4px;
    flex: 1; width: 100%; align-items: stretch;
    padding: 4px;
}
.tm-nav-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 4px; padding: 10px 4px;
    border-radius: 10px;
    color: rgba(255,255,255,0.72); font-size: 10.5px; font-weight: 600;
    letter-spacing: 0.2px; text-align: center;
    transition: background 0.15s, color 0.15s, transform 0.08s;
    text-decoration: none;
}
.tm-nav-item:hover { background: rgba(255,255,255,0.10); color: #fff; }
.tm-nav-item.active {
    background: rgba(255,255,255,0.18);
    color: #fff;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12);
}
.tm-ni-icon {
    display: grid; place-items: center;
    width: 28px; height: 28px; border-radius: 8px;
    font-size: 18px; color: #fff;
    background: rgba(255,255,255,0.06);
}
.tm-nav-item.active .tm-ni-icon {
    background: linear-gradient(135deg, #8b5cf6, #ec4899);
    box-shadow: 0 4px 12px rgba(139,92,246,0.45);
}
.tm-ni-text { display: block; line-height: 1.2; }

.tm-side-footer { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }

/* MAIN */
.tm-main { display: flex; flex-direction: column; min-width: 0; }
.tm-topbar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 20px 32px; border-bottom: 1px solid var(--tm-panel-line);
    position: sticky; top: 0; z-index: 10;
    background: var(--tm-topbar-bg); backdrop-filter: blur(12px);
    transition: background 0.3s;
}
.tm-topbar-left { display: flex; align-items: center; gap: 16px; }
.tm-topbar-right { display: flex; align-items: center; gap: 12px; }
.tm-toggle { font-size: 18px; }
.tm-eyebrow { font-size: 11px; color: var(--tm-ink-dim); text-transform: uppercase; letter-spacing: 1.5px; }
.tm-title { margin: 2px 0 0; font-size: 22px; font-weight: 700; }
h1:focus, h1:focus-visible, .tm-title:focus, .tm-title:focus-visible,
.tm-login-title:focus, .tm-login-title:focus-visible { outline: none; box-shadow: none; }

.tm-user-chip { display: flex; align-items: center; gap: 12px; }
.tm-user-meta { display: flex; flex-direction: column; text-align: right; }
.tm-user-name { font-size: 13px; font-weight: 600; }
.tm-user-role { font-size: 11px; color: var(--tm-ink-dim); }

.tm-avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: linear-gradient(135deg, var(--tm-brand), var(--tm-brand-2));
    display: grid; place-items: center; font-weight: 700; color: white;
    font-size: 13px; flex-shrink: 0;
}
.tm-avatar-lg { width: 56px; height: 56px; font-size: 18px; }
.tm-avatar-sm { width: 30px; height: 30px; font-size: 11px; }
.tm-avatar-xs { width: 24px; height: 24px; font-size: 10px; }

.tm-content { padding: 28px 32px; display: flex; flex-direction: column; gap: 24px; }

/* PANEL */
.tm-panel {
    background: var(--tm-panel); border: 1px solid var(--tm-panel-line);
    border-radius: var(--tm-radius); padding: 24px; backdrop-filter: blur(10px);
    transition: background 0.3s, border-color 0.3s;
}
.tm-panel-narrow { max-width: 700px; }
.tm-panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.tm-panel-head h2 { margin: 0; font-size: 18px; font-weight: 700; }
.tm-panel-head p { margin: 2px 0 0; color: var(--tm-ink-dim); font-size: 13px; }

.tm-empty {
    padding: 40px; text-align: center; color: var(--tm-ink-dim);
    background: var(--tm-hover-bg); border-radius: var(--tm-radius-sm);
    border: 1px dashed var(--tm-panel-line);
}

/* STATS */
.tm-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.tm-stat {
    background: var(--tm-panel); border: 1px solid var(--tm-panel-line);
    border-radius: var(--tm-radius); padding: 20px; backdrop-filter: blur(10px);
    position: relative; overflow: hidden;
}
.tm-stat::before {
    content: ''; position: absolute; top: -30px; right: -30px;
    width: 100px; height: 100px; border-radius: 50%;
    background: radial-gradient(circle, var(--tm-stat-halo), transparent 70%);
}
.tm-stat-label { font-size: 12px; color: var(--tm-ink-dim); text-transform: uppercase; letter-spacing: 1px; }
.tm-stat-value { font-size: 32px; font-weight: 800; margin: 8px 0 4px; }
.tm-stat-hint { font-size: 12px; color: var(--tm-ink-dim); }
.tm-stat-clickable { cursor: pointer; transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s; }
.tm-stat-clickable:hover { border-color: rgba(99,102,241,0.45); transform: translateY(-1px); box-shadow: 0 6px 18px rgba(17,24,39,0.08); }
[data-theme="dark"] .tm-stat-clickable:hover { box-shadow: 0 6px 18px rgba(0,0,0,0.3); }

/* PROJECT GRID */
.tm-project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.tm-project-tile {
    position: relative; display: block;
    background: var(--tm-panel); border: 1px solid var(--tm-panel-line);
    border-radius: var(--tm-radius); padding: 20px; text-decoration: none; color: inherit;
    transition: transform 0.15s, border-color 0.15s, box-shadow 0.2s;
    overflow: hidden;
}
.tm-project-tile::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: var(--accent, var(--tm-brand));
}
.tm-project-tile:hover {
    transform: translateY(-3px); border-color: var(--accent, var(--tm-brand));
    box-shadow: 0 14px 40px rgba(17, 24, 39, 0.10);
}
[data-theme="dark"] .tm-project-tile:hover { box-shadow: 0 14px 40px rgba(0, 0, 0, 0.4); }
.tm-clickable { cursor: pointer; }
.tm-project-dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--accent, var(--tm-brand)); margin-bottom: 10px;
    box-shadow: 0 0 16px var(--accent, var(--tm-brand));
}
.tm-project-name { font-weight: 700; font-size: 16px; margin-bottom: 6px; }
.tm-project-desc { font-size: 13px; color: var(--tm-ink-dim); margin-bottom: 16px; min-height: 18px; }
.tm-project-foot { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--tm-ink-dim); }
.tm-tile-actions { display: flex; gap: 6px; }

/* TABLE */
.tm-table-wrap { overflow-x: auto; }
.tm-table-scroll { max-height: calc(100vh - 280px); overflow: auto; border-radius: var(--tm-radius-sm); }
.tm-table { width: 100%; border-collapse: collapse; }
.tm-table th, .tm-table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--tm-panel-line); font-size: 13px; }
.tm-table th { color: var(--tm-ink-dim); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }
.tm-table tbody tr:hover { background: var(--tm-hover-bg); }
.tm-table-sticky thead th {
    position: sticky; top: 0; z-index: 3;
    background: var(--tm-panel-hi); backdrop-filter: blur(8px);
    box-shadow: 0 1px 0 var(--tm-panel-line);
}
.tm-col-seq {
    position: sticky; left: 0; z-index: 2;
    width: 56px; text-align: center; color: var(--tm-ink-dim); font-weight: 600;
    background: var(--tm-panel-hi);
}
.tm-table-sticky thead th.tm-col-seq { z-index: 4; }
.tm-user-row { display: flex; align-items: center; gap: 10px; }
.tm-row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* CHIPS */
.tm-chip { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; letter-spacing: 0.3px; }
.tm-chip-purple { background: rgba(139, 92, 246, 0.15); color: #6d28d9; }
.tm-chip-blue { background: rgba(59, 130, 246, 0.15); color: #1d4ed8; }
.tm-chip-green { background: rgba(16, 185, 129, 0.15); color: #047857; }
.tm-chip-muted { background: var(--tm-ghost-chip-bg); color: var(--tm-ink-dim); }
[data-theme="dark"] .tm-chip-purple { color: #c4b5fd; }
[data-theme="dark"] .tm-chip-blue { color: #93c5fd; }
[data-theme="dark"] .tm-chip-green { color: #6ee7b7; }
.tm-chips { display: flex; gap: 8px; margin-top: 8px; }

/* COLOR SWATCHES */
.tm-color-row { display: flex; gap: 8px; flex-wrap: wrap; }
.tm-swatch { width: 32px; height: 32px; border-radius: 8px; cursor: pointer; border: 2px solid transparent; transition: transform 0.1s, border-color 0.1s; }
.tm-swatch:hover { transform: scale(1.08); }
.tm-swatch.active { border-color: var(--tm-ink); box-shadow: 0 0 0 2px var(--tm-brand); }

/* MODAL */
.tm-modal-backdrop {
    position: fixed; inset: 0; background: var(--tm-modal-backdrop); backdrop-filter: blur(6px);
    display: grid; place-items: center; z-index: 100; padding: 20px;
    animation: fadeIn 0.15s ease;
}
.tm-modal {
    width: 100%; max-width: 520px;
    max-height: calc(100vh - 40px);
    background: var(--tm-modal-bg);
    border: 1px solid var(--tm-panel-line); border-radius: 18px;
    padding: 24px; box-shadow: var(--tm-shadow-hi);
    animation: slideUp 0.2s ease;
    overflow-y: auto;
    overscroll-behavior: contain;
}
.tm-modal-head {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px;
    position: sticky; top: -24px; background: var(--tm-modal-bg);
    padding: 18px 0 12px; margin-top: -24px; z-index: 200;
    border-bottom: 1px solid var(--tm-panel-line);
}
.tm-modal-head h3 { margin: 0; font-size: 18px; }
.tm-modal-actions {
    display: flex; gap: 10px; justify-content: flex-end; align-items: center; margin-top: 12px;
    position: sticky; bottom: -24px; background: var(--tm-modal-bg);
    padding: 12px 0 18px; z-index: 200; border-top: 1px solid var(--tm-panel-line);
}
.tm-flex-spacer { flex: 1; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* BOARD / KANBAN */
.tm-board-toolbar { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; padding: 4px 0; }
.tm-filter { display: flex; flex-direction: column; gap: 4px; min-width: 220px; }
.tm-filter label { font-size: 11px; color: var(--tm-ink-dim); text-transform: uppercase; letter-spacing: 1px; }

.tm-kanban { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 16px; min-height: 60vh; }
.tm-column {
    flex: 0 0 300px; display: flex; flex-direction: column;
    background: var(--tm-panel); border: 1px solid var(--tm-panel-line);
    border-radius: var(--tm-radius); max-height: calc(100vh - 220px);
}
.tm-column-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--tm-panel-line); }
.tm-column-title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.tm-col-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--col-accent, var(--tm-brand)); box-shadow: 0 0 10px var(--col-accent, var(--tm-brand)); }
.tm-col-count { margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: var(--tm-ghost-chip-bg); font-size: 11px; color: var(--tm-ink-dim); }
.tm-column-body { padding: 12px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; flex: 1; min-height: 100px; }

.tm-card {
    background: var(--tm-card-bg); border: 1px solid var(--tm-panel-line);
    border-radius: 10px; padding: 12px 14px; cursor: grab;
    transition: transform 0.1s, box-shadow 0.15s, border-color 0.15s;
    position: relative;
}
.tm-card::before { content: ''; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 3px; background: var(--priority, var(--tm-brand)); }
.tm-card:hover { border-color: rgba(99, 102, 241, 0.4); box-shadow: 0 6px 18px rgba(17, 24, 39, 0.08); }
[data-theme="dark"] .tm-card:hover { box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3); }
.tm-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.tm-priority { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--priority, var(--tm-brand)); }
.tm-due { font-size: 11px; color: var(--tm-ink-dim); }
.tm-due-over { color: var(--tm-danger); font-weight: 600; }
.tm-card-title { font-size: 13.5px; font-weight: 500; margin-bottom: 6px; line-height: 1.35; color: var(--tm-ink); }
.tm-card-desc { font-size: 12px; color: var(--tm-ink-dim); margin-bottom: 8px; line-height: 1.4; }
.tm-card-foot { display: flex; justify-content: flex-end; align-items: center; }
.tm-unassigned { font-size: 11px; color: var(--tm-muted); }

.tm-card-ghost { opacity: 0.4; }
.tm-card-chosen { border-color: var(--tm-brand) !important; }
.tm-card-drag { box-shadow: var(--tm-shadow-hi); transform: rotate(2deg); }

/* MULTISELECT */
.tm-multiselect { position: relative; }
.tm-ms-trigger { display: flex; justify-content: space-between; align-items: center; cursor: pointer; text-align: left; }
/* Inside a form field, the SearchableSelect/multiselect trigger should match the standard input height
   so it lines up with adjacent .tm-input controls (e.g. Project + Due date in the task wizard). */
.tm-field .tm-ms-trigger.tm-input-sm,
.tm-field-grid-2 .tm-ms-trigger.tm-input-sm,
.tm-field-grid .tm-ms-trigger.tm-input-sm { height: 42px; padding: 10px 14px; font-size: 14px; }
.tm-ms-caret { color: var(--tm-ink-dim); font-size: 12px; }
.tm-ms-panel {
    position: absolute; z-index: 300; top: calc(100% + 4px); left: 0; right: 0;
    background: var(--tm-modal-bg); border: 1px solid var(--tm-panel-line);
    border-radius: var(--tm-radius-sm); box-shadow: var(--tm-shadow);
    max-height: 280px; overflow-y: auto; padding: 6px;
    display: flex; flex-direction: column;
}
.tm-multiselect.tm-ms-open { position: relative; z-index: 250; }
.tm-ms-panel.tm-ms-panel-up { top: auto; bottom: calc(100% + 4px); }
/* Used when the dropdown sits inside a scrollable modal — JS switches to position:fixed
   and sets top/left/width/maxHeight in pixels so the panel floats over the modal instead
   of being clipped by its overflow. The bumped z-index keeps it above sticky modal headers. */
.tm-ms-panel.tm-ms-panel-fixed { position: fixed !important; z-index: 1000; right: auto; }
.tm-ms-search-wrap {
    position: sticky; top: -6px; z-index: 2;
    background: var(--tm-modal-bg); padding: 4px 2px;
    margin: -6px -6px 4px; border-bottom: 1px solid var(--tm-panel-line);
}
.tm-ms-search {
    width: 100%; padding: 7px 10px; font-size: 13px;
    border: 1px solid var(--tm-panel-line); border-radius: 6px;
    background: var(--tm-input-bg); color: var(--tm-ink); outline: none;
}
.tm-ms-search:focus { border-color: var(--tm-brand); box-shadow: 0 0 0 2px rgba(99,102,241,0.15); }
.tm-ms-item {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 8px; border-radius: 8px; cursor: pointer;
    transition: background 0.1s;
}
.tm-ms-item:hover { background: var(--tm-hover-bg); }
.tm-ms-locked { opacity: 0.8; cursor: not-allowed; }
.tm-ms-locked input[type=checkbox] { cursor: not-allowed; }
.tm-ms-item input[type=checkbox] { accent-color: var(--tm-brand); width: 16px; height: 16px; }
.tm-ms-name { display: flex; flex-direction: column; font-size: 13px; line-height: 1.2; }
.tm-ms-email { font-size: 11px; color: var(--tm-ink-dim); }
.tm-ms-empty { padding: 12px; text-align: center; color: var(--tm-ink-dim); font-size: 13px; }
.tm-assignee-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tm-assignee-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--tm-ink-dim); }

/* VIEW SWITCH (segmented pill with text) */
.tm-view-switch {
    display: inline-flex; padding: 4px; border-radius: 999px; gap: 2px;
    background: var(--tm-hover-bg);
    border: 1px solid var(--tm-panel-line);
}
.tm-view-opt {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 14px; border-radius: 999px; border: none; cursor: pointer;
    background: transparent; color: var(--tm-ink-dim);
    font-size: 12px; font-weight: 600; letter-spacing: 0.3px;
    transition: background 0.18s, color 0.18s, box-shadow 0.18s, transform 0.08s;
    white-space: nowrap;
}
.tm-view-opt:hover:not(.active) { color: var(--tm-ink); background: var(--tm-hover-bg-strong); }
.tm-view-opt.active {
    background: linear-gradient(135deg, var(--tm-brand), var(--tm-brand-2));
    color: #fff; box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}
.tm-view-opt.active .tm-view-dot { box-shadow: 0 0 0 2px rgba(255,255,255,0.35); }
.tm-view-dot {
    width: 7px; height: 7px; border-radius: 50%; display: inline-block;
}

/* THEME SWITCH */
.tm-theme-switch {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px; border-radius: 999px; background: var(--tm-hover-bg);
    border: 1px solid var(--tm-panel-line);
}
.tm-theme-opt {
    width: 28px; height: 28px; border-radius: 999px; border: none; cursor: pointer;
    background: transparent; color: var(--tm-ink-dim);
    display: grid; place-items: center; transition: background 0.15s, color 0.15s;
}
.tm-theme-opt.active { background: linear-gradient(135deg, var(--tm-brand), var(--tm-brand-2)); color: white; }
.tm-theme-opt:hover:not(.active) { background: var(--tm-hover-bg-strong); color: var(--tm-ink); }

/* INBOX / MAIL */
.tm-mail {
    display: flex; flex-direction: column; gap: 12px;
    height: calc(100vh - 180px); min-height: 520px;
}
.tm-mail-toolbar {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px;
    background: var(--tm-panel-bg); border: 1px solid var(--tm-panel-line);
    border-radius: var(--tm-radius); backdrop-filter: blur(10px);
}
.tm-mail-pane {
    display: grid; grid-template-columns: minmax(300px, 380px) 1fr; gap: 12px;
    flex: 1; min-height: 0;
}
.tm-mail-list {
    background: var(--tm-panel-bg); border: 1px solid var(--tm-panel-line);
    border-radius: var(--tm-radius); overflow-y: auto; padding: 6px;
}
.tm-mail-item {
    display: flex; gap: 10px; align-items: flex-start;
    width: 100%; text-align: left; padding: 10px 12px;
    background: transparent; border: 1px solid transparent; border-radius: 10px;
    cursor: pointer; margin-bottom: 2px; color: var(--tm-ink);
    transition: background 0.1s, border-color 0.1s;
}
.tm-mail-item:hover { background: var(--tm-hover-bg); }
.tm-mail-item.active { background: rgba(99,102,241,0.10); border-color: rgba(99,102,241,0.3); }
.tm-mail-item.unread .tm-mail-item-subject, .tm-mail-item.unread .tm-mail-item-name { font-weight: 600; color: var(--tm-ink); }
.tm-mail-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white; display: grid; place-items: center;
    font-size: 13px; font-weight: 600; flex-shrink: 0;
}
.tm-mail-avatar-lg { width: 40px; height: 40px; font-size: 14px; }
.tm-mail-item-body { flex: 1; min-width: 0; }
.tm-mail-item-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.tm-mail-item-name { font-size: 13px; color: var(--tm-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-mail-item-time { font-size: 11px; color: var(--tm-ink-dim); flex-shrink: 0; }
.tm-mail-item-subject { font-size: 13px; color: var(--tm-ink); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-mail-item-snippet { font-size: 12px; color: var(--tm-ink-dim); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-mail-unread-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #6366f1; margin-right: 6px; vertical-align: middle; }

.tm-mail-detail {
    background: var(--tm-panel-bg); border: 1px solid var(--tm-panel-line);
    border-radius: var(--tm-radius); overflow: hidden;
    display: flex; flex-direction: column; min-width: 0;
}
.tm-mail-empty {
    flex: 1; display: grid; place-items: center;
    color: var(--tm-ink-dim); text-align: center;
}
.tm-mail-empty-icon { font-size: 48px; opacity: 0.3; margin-bottom: 12px; }
.tm-mail-empty-text { font-size: 14px; }
.tm-mail-detail-head {
    padding: 16px 20px; border-bottom: 1px solid var(--tm-panel-line);
    background: var(--tm-panel-hi);
}
.tm-mail-subject { margin: 0; font-size: 18px; font-weight: 600; color: var(--tm-ink); }
.tm-mail-thread-count { font-size: 12px; color: var(--tm-ink-dim); margin-top: 4px; }
.tm-mail-thread { flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 12px; }
.tm-mail-msg {
    background: var(--tm-panel-hi); border: 1px solid var(--tm-panel-line);
    border-radius: 12px;
    flex: 0 0 auto;
}
.tm-mail-msg.mine { background: rgba(99,102,241,0.05); border-color: rgba(99,102,241,0.2); }
.tm-mail-msg-head {
    display: flex; gap: 12px; align-items: center;
    padding: 12px 16px; border-bottom: 1px solid var(--tm-panel-line);
    border-top-left-radius: 12px; border-top-right-radius: 12px;
}
.tm-mail-msg-meta { flex: 1; min-width: 0; }
.tm-mail-msg-from { font-size: 13px; color: var(--tm-ink); }
.tm-mail-msg-time { font-size: 11px; color: var(--tm-ink-dim); margin-top: 2px; }
.tm-mail-msg-body {
    padding: 14px 16px; font-size: 14px; line-height: 1.55;
    color: var(--tm-ink);
    white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word;
    min-height: 1.55em;
}

.tm-mail-reply {
    padding: 12px 20px; border-top: 1px solid var(--tm-panel-line);
    background: var(--tm-panel-hi);
}
.tm-mail-reply-actions { display: flex; gap: 8px; margin-top: 8px; }

@media (max-width: 900px) {
    .tm-mail-pane { grid-template-columns: 1fr; }
}

/* SCHEDULE MODAL */
.tm-schedule-modal { max-width: 520px; }
.tm-sched-section {
    background: var(--tm-panel-hi); border: 1px solid var(--tm-panel-line);
    border-radius: 12px; padding: 14px 16px; margin-bottom: 12px;
}
.tm-sched-section-label {
    font-size: 11px; color: var(--tm-ink-dim); font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 10px;
}
.tm-sched-source-locked {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; background: var(--tm-panel-hi);
    border-radius: 10px; font-size: 14px;
}
.tm-sched-freq {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.tm-sched-freq-opt {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 14px 10px; background: transparent;
    border: 1px solid var(--tm-panel-line); border-radius: 10px;
    cursor: pointer; color: var(--tm-ink); font-size: 13px; font-weight: 500;
    transition: background 0.1s, border-color 0.1s, transform 0.1s;
}
.tm-sched-freq-opt:hover { background: var(--tm-hover-bg); border-color: var(--tm-brand); }
.tm-sched-freq-opt.active {
    background: linear-gradient(135deg, rgba(99,102,241,0.10), rgba(139,92,246,0.10));
    border-color: var(--tm-brand); color: var(--tm-brand);
}
.tm-sched-freq-icon { font-size: 22px; line-height: 1; }

.tm-sched-subfield { margin-top: 12px; }
.tm-sched-sublabel {
    display: block; font-size: 12px; color: var(--tm-ink-dim);
    font-weight: 500; margin-bottom: 6px;
}

.tm-sched-dow { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.tm-sched-dow-opt {
    padding: 8px 0; text-align: center; background: transparent;
    border: 1px solid var(--tm-panel-line); border-radius: 8px;
    cursor: pointer; font-weight: 600; font-size: 13px; color: var(--tm-ink);
}
.tm-sched-dow-opt:hover { background: var(--tm-hover-bg); }
.tm-sched-dow-opt.active { background: var(--tm-brand); color: white; border-color: var(--tm-brand); }

.tm-sched-timing { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tm-sched-yearly { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; }

/* Profile two-column grid */
.tm-profile-grid {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px;
    margin-top: 16px;
}
@media (max-width: 900px) {
    .tm-profile-grid { grid-template-columns: 1fr; }
}

/* Settings-style left rail nav + right content (Profile page, etc.) */
.tm-settings-shell {
    display: grid; grid-template-columns: 260px 1fr; gap: 20px; margin-top: 16px;
    align-items: start;
}
.tm-settings-nav {
    display: flex; flex-direction: column; gap: 6px;
    background: var(--tm-panel); border: 1px solid var(--tm-panel-line);
    border-radius: var(--tm-radius); padding: 10px;
    box-shadow: var(--tm-shadow);
    position: sticky; top: 16px;
}
.tm-settings-nav-item {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 10px 12px; border-radius: 10px;
    background: transparent; border: 1px solid transparent;
    text-align: left; cursor: pointer; color: var(--tm-ink);
    transition: background 0.15s, border-color 0.15s;
}
.tm-settings-nav-item:hover { background: var(--tm-hover-bg); }
.tm-settings-nav-item.active {
    background: rgba(99,102,241,0.10);
    border-color: rgba(99,102,241,0.35);
    color: #4f46e5;
}
.tm-settings-nav-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; flex-shrink: 0;
    border-radius: 8px;
    background: var(--tm-panel-hi); border: 1px solid var(--tm-panel-line);
    font-size: 16px;
}
.tm-settings-nav-title { display: block; font-size: 14px; font-weight: 600; line-height: 1.2; }
.tm-settings-nav-sub { display: block; font-size: 12px; color: var(--tm-ink-dim); margin-top: 2px; }
.tm-settings-nav-item.active .tm-settings-nav-sub { color: #6366f1; }
.tm-settings-content { min-width: 0; }

@media (max-width: 900px) {
    .tm-settings-shell { grid-template-columns: 1fr; }
    .tm-settings-nav { position: static; flex-direction: row; overflow-x: auto; }
    .tm-settings-nav-item { flex: 1 0 auto; }
}

/* iOS-style toggle switch */
.tm-toggle-row {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 14px 16px;
    background: var(--tm-panel-hi); border: 1px solid var(--tm-panel-line);
    border-radius: 12px;
}
.tm-toggle-label { font-size: 14px; font-weight: 600; color: var(--tm-ink); }
.tm-switch {
    position: relative; display: inline-block; width: 48px; height: 28px; flex-shrink: 0;
    cursor: pointer;
}
.tm-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.tm-switch-slider {
    position: absolute; inset: 0;
    background: #cbd5e1;
    border-radius: 999px;
    transition: background 0.2s;
}
.tm-switch-slider::before {
    content: ""; position: absolute;
    width: 22px; height: 22px; left: 3px; top: 3px;
    background: white; border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    transition: transform 0.2s;
}
.tm-switch input:checked + .tm-switch-slider {
    background: linear-gradient(135deg, var(--tm-brand), var(--tm-brand-2));
}
.tm-switch input:checked + .tm-switch-slider::before {
    transform: translateX(20px);
}
.tm-switch input:disabled + .tm-switch-slider { opacity: 0.5; cursor: not-allowed; }
.tm-switch:hover .tm-switch-slider { box-shadow: 0 0 0 4px rgba(99,102,241,0.10); }

/* Assignees picker (used in source-task editor) */
.tm-assignees-grid {
    display: flex; flex-wrap: wrap; gap: 8px;
    max-height: 220px; overflow-y: auto;
    padding: 14px;
    background: var(--tm-panel-hi);
    border: 1px solid var(--tm-panel-line);
    border-radius: 10px;
}
.tm-assignee-chip {
    position: relative;
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 14px 7px 28px; /* fixed left padding reserves space for the tick */
    border-radius: 999px;
    border: 1px solid var(--tm-panel-line);
    background: transparent;
    color: var(--tm-ink); font-size: 13px; font-weight: 600; /* same weight selected/unselected — stable width */
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.tm-assignee-chip:hover {
    background: var(--tm-hover-bg);
    border-color: var(--tm-brand);
}
.tm-assignee-chip.active {
    background: rgba(99,102,241,0.12);
    color: #4f46e5;
    border-color: rgba(99,102,241,0.45);
}
.tm-assignee-tick {
    position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
    display: inline-flex; align-items: center; justify-content: center;
    width: 14px; height: 14px; border-radius: 50%;
    background: #4f46e5; color: white; font-size: 9px; font-weight: 700;
    line-height: 1;
}

.tm-search-combo { position: relative; }
.tm-sched-section-source { position: relative; z-index: 50; }
.tm-search-chip {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px; padding: 8px 10px; margin-top: 8px;
    background: rgba(99,102,241,0.08); border: 1px solid rgba(99,102,241,0.35);
    border-radius: 10px; font-size: 13px; color: var(--tm-brand);
}
.tm-search-dropdown {
    position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 100;
    max-height: 260px; overflow-y: auto;
    background: var(--tm-panel-hi); border: 1px solid var(--tm-panel-line);
    border-radius: 10px; box-shadow: var(--tm-shadow-hi);
    padding: 4px;
}
.tm-search-item {
    width: 100%; text-align: left; padding: 10px 12px;
    background: transparent; border: 1px solid transparent; border-radius: 8px;
    cursor: pointer; color: var(--tm-ink); margin-bottom: 2px;
}
.tm-search-item:hover { background: var(--tm-hover-bg); }
.tm-search-item-title { font-size: 13px; font-weight: 500; }
.tm-search-item-sub { font-size: 11px; color: var(--tm-ink-dim); margin-top: 2px; }
.tm-search-empty { padding: 12px; color: var(--tm-ink-dim); font-size: 12px; text-align: center; }

@media (max-width: 600px) {
    .tm-sched-freq { grid-template-columns: repeat(2, 1fr); }
    .tm-sched-timing { grid-template-columns: 1fr; }
}

/* SWEETALERT OVERRIDES */
.tm-swal .swal2-actions { gap: 6px; margin-top: 14px; flex-wrap: nowrap; }
.tm-swal .swal2-actions button { margin: 0 !important; }
.tm-swal .swal2-textarea, .tm-swal .swal2-input {
    box-sizing: border-box; width: calc(100% - 32px); margin: 14px 16px 0;
    padding: 10px 12px; border-radius: 10px;
    border: 1px solid var(--tm-panel-line);
    background: var(--tm-input-bg); color: var(--tm-ink);
    font-family: inherit; font-size: 14px;
    resize: vertical; min-height: 80px;
}
.tm-swal .swal2-textarea:focus, .tm-swal .swal2-input:focus {
    outline: none; border-color: var(--tm-brand);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

/* USER MENU DROPDOWN */
.tm-user-menu { position: relative; }
.tm-user-chip-btn {
    display: flex; align-items: center; gap: 12px;
    background: transparent; border: 1px solid transparent;
    padding: 6px 10px; border-radius: 999px; cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.tm-user-chip-btn:hover { background: var(--tm-hover-bg); border-color: var(--tm-panel-line); }
.tm-user-chip-btn .tm-ms-caret { color: var(--tm-ink-dim); font-size: 12px; }
.tm-user-dropdown {
    position: absolute; top: calc(100% + 6px); right: 0; min-width: 200px;
    background: var(--tm-modal-bg); border: 1px solid var(--tm-panel-line);
    border-radius: var(--tm-radius-sm); box-shadow: var(--tm-shadow-hi);
    padding: 6px; z-index: 50;
}
.tm-user-dropdown-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: 8px;
    font-size: 13px; font-weight: 500; color: var(--tm-ink);
    background: transparent; border: none; width: 100%; text-align: left; cursor: pointer;
    text-decoration: none;
}
.tm-user-dropdown-item:hover { background: var(--tm-hover-bg); }
/* .tm-ni-icon is styled for the dark sidebar (white-on-white-translucent) — re-skin it
   so the Profile / Sign out icons are visible inside the light user dropdown. */
.tm-user-dropdown-item .tm-ni-icon {
    width: 22px; height: 22px;
    background: transparent;
    color: var(--tm-ink-dim);
    font-size: 14px;
}
.tm-user-dropdown-item:hover .tm-ni-icon { color: var(--tm-ink); }
.tm-user-dropdown-context {
    display: flex; flex-direction: column; gap: 2px;
    padding: 9px 12px 11px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--tm-panel-line);
}
.tm-user-dropdown-label {
    font-size: 10px; text-transform: uppercase; letter-spacing: 0.6px;
    color: var(--tm-ink-dim); font-weight: 600;
}
.tm-user-dropdown-value {
    font-size: 13px; font-weight: 600; color: var(--tm-ink);
    overflow-wrap: anywhere; word-break: break-word;
}

/* NOTIFICATION BELL */
.tm-bell-wrap { position: relative; }
.tm-bell { position: relative; font-size: 15px; }
.tm-bell-badge {
    position: absolute; top: -4px; right: -4px;
    min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 999px; background: var(--tm-danger); color: #fff;
    font-size: 10px; font-weight: 700; display: grid; place-items: center;
    border: 2px solid var(--tm-topbar-bg);
}
.tm-bell-panel {
    position: absolute; top: calc(100% + 6px); right: 0; width: 340px;
    background: var(--tm-modal-bg); border: 1px solid var(--tm-panel-line);
    border-radius: var(--tm-radius); box-shadow: var(--tm-shadow-hi);
    z-index: 50; max-height: 420px; display: flex; flex-direction: column;
}
.tm-bell-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 14px; border-bottom: 1px solid var(--tm-panel-line);
}
.tm-bell-list { overflow-y: auto; flex: 1; padding: 6px; }
.tm-bell-item { display: flex; gap: 10px; padding: 10px; border-radius: 10px; }
.tm-bell-item:hover { background: var(--tm-hover-bg); }
.tm-bell-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.tm-bell-text { font-size: 13px; line-height: 1.3; color: var(--tm-ink); }
.tm-bell-meta { font-size: 11px; color: var(--tm-ink-dim); margin-top: 2px; }

/* ARCHIVE LIST */
.tm-archive-list { display: flex; flex-direction: column; gap: 12px; }
.tm-archive-item {
    padding: 0; border-radius: 11px;
    background: #fff; border: 1px solid var(--tm-panel-line);
    cursor: pointer; transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s;
    position: relative; overflow: hidden;
    flex-shrink: 0;
}
.tm-archive-item::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
    background: var(--accent, var(--tm-brand));
}
.tm-archive-item:hover {
    border-color: var(--accent, var(--tm-brand));
    box-shadow: 0 8px 24px rgba(17,24,39,0.10);
    transform: translateY(-2px);
}

/* Header: seq + (title & people) on the left, chips on the right */
.tm-archive-head {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 13px 16px 13px 20px;
}
.tm-archive-seq {
    font-size: 13px; font-weight: 800; color: var(--accent, var(--tm-brand));
    background: var(--tm-hover-bg); border-radius: 7px;
    padding: 4px 9px; line-height: 1; letter-spacing: -0.3px;
    font-variant-numeric: tabular-nums; flex-shrink: 0; margin-top: 1px;
}
.tm-archive-head-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.tm-archive-title {
    margin: 0; font-size: 14px; font-weight: 700; color: var(--tm-ink); line-height: 1.3;
    overflow-wrap: anywhere; word-break: break-word;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
/* Inline ownership row right under the title */
.tm-archive-people {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    font-size: 11.5px; color: var(--tm-ink-dim);
}
.tm-archive-dot { color: var(--tm-panel-line); font-weight: 700; }
.tm-archive-head-right {
    display: flex; align-items: center; gap: 7px; flex-shrink: 0; flex-wrap: wrap;
    justify-content: flex-end; margin-top: 1px;
}
.tm-archive-chip {
    padding: 3px 10px; border-radius: 999px; font-size: 10.5px; font-weight: 600;
    letter-spacing: 0.2px; white-space: nowrap;
}
.tm-archive-chip.tm-archive-column {
    background: var(--tm-ghost-chip-bg); color: var(--tm-ink-dim);
}
.tm-archive-prio-badge {
    padding: 3px 10px; border-radius: 999px; font-size: 10.5px; font-weight: 700;
    letter-spacing: 0.3px; text-transform: uppercase; white-space: nowrap;
}

/* Closing note */
.tm-archive-note {
    margin: 0 16px 13px 20px; padding: 8px 12px; border-radius: 8px;
    background: rgba(16,185,129,0.08); border-left: 3px solid var(--tm-ok);
    font-size: 12.5px;
    overflow-wrap: anywhere; word-break: break-word;
}
.tm-archive-note-label {
    display: block; text-transform: uppercase; letter-spacing: 0.6px;
    font-size: 9.5px; font-weight: 700; color: var(--tm-ok); margin-bottom: 2px;
}
.tm-archive-note-text { color: var(--tm-ink); overflow-wrap: anywhere; word-break: break-word; }

/* Inline ownership group: label · date · avatar · name */
.tm-archive-field-label {
    font-size: 9px; font-weight: 800; letter-spacing: 0.7px; text-transform: uppercase;
    color: var(--tm-ink-soft, #9aa1ad);
}
.tm-archive-field-date { font-weight: 600; color: var(--tm-ink); white-space: nowrap; }
.tm-archive-person {
    display: inline-flex; align-items: center; gap: 5px;
    color: var(--tm-ink-dim); font-weight: 500;
    white-space: nowrap;            /* keep "label date avatar name" on one line per item */
}
.tm-archive-person-name { color: var(--tm-ink); font-weight: 500; white-space: nowrap; }
.tm-archive-person .tm-avatar { width: 17px; height: 17px; font-size: 8.5px; flex-shrink: 0; }
.tm-archive-pager {
    display: flex; align-items: center; gap: 10px; margin-top: 14px;
    padding: 12px 14px; border-radius: var(--tm-radius);
    background: var(--tm-panel); border: 1px solid var(--tm-panel-line);
}

/* TIMELINE */
.tm-timeline { display: flex; flex-direction: column; gap: 12px; position: relative; padding-left: 20px; }
.tm-timeline::before { content: ''; position: absolute; left: 6px; top: 4px; bottom: 4px; width: 2px; background: var(--tm-panel-line); }
.tm-timeline-item { display: flex; gap: 12px; position: relative; }
.tm-timeline-dot { position: absolute; left: -20px; top: 6px; width: 12px; height: 12px; border-radius: 50%; box-shadow: 0 0 0 3px var(--tm-panel); z-index: 1; }
.tm-timeline-body { flex: 1; }
.tm-timeline-head { display: flex; gap: 10px; align-items: baseline; }
.tm-timeline-type { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--tm-ink); }
.tm-timeline-time { font-size: 11px; color: var(--tm-ink-dim); }
.tm-timeline-detail { font-size: 13px; color: var(--tm-ink); margin-top: 2px; }
.tm-timeline-user { font-size: 11px; color: var(--tm-ink-dim); margin-top: 2px; }

/* PROFILE */
.tm-profile-card { display: flex; align-items: center; gap: 20px; }
.tm-profile-card h2 { margin: 0; }
.tm-muted { color: var(--tm-ink-dim); font-size: 13px; margin: 4px 0 0; }

@media (max-width: 900px) {
    .tm-content { padding: 20px; }
    .tm-topbar { padding: 16px 20px; }
    .tm-user-meta { display: none; }
}
@media (max-width: 600px) {
    .tm-field-grid { grid-template-columns: 1fr; }
    .tm-title { font-size: 18px; }
    .tm-stat-value { font-size: 26px; }
}

/* Wide modal + radio pills */
.tm-modal-wide { max-width: 720px !important; width: 92vw; }
.tm-input-lg { font-size: 16px; padding: 12px 14px; font-weight: 500; }
.tm-field-grid-2 {
    display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
}
.tm-radio-row {
    display: flex; flex-wrap: wrap; gap: 8px;
}
.tm-radio-pill {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 14px; border-radius: 999px;
    border: 1.5px solid var(--tm-panel-line, rgba(148,163,184,0.3));
    background: var(--tm-panel, #fff);
    cursor: pointer; font-size: 13px; font-weight: 500;
    transition: all 0.15s ease;
    --pill-accent: #6366f1;
}
.tm-radio-pill input { position: absolute; opacity: 0; pointer-events: none; }
.tm-radio-pill .tm-radio-dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--pill-accent);
    box-shadow: 0 0 0 2px rgba(255,255,255,0.5) inset;
}
.tm-radio-pill:hover { border-color: var(--pill-accent); }
.tm-radio-pill.active {
    border-color: var(--pill-accent);
    background: color-mix(in srgb, var(--pill-accent) 12%, transparent);
    color: var(--pill-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--pill-accent) 18%, transparent);
}
.tm-radio-pill.active .tm-radio-dot {
    background: var(--pill-accent);
    box-shadow: none;
}

@media (max-width: 600px) {
    .tm-field-grid-2 { grid-template-columns: 1fr; }
}

/* Stepper */
.tm-stepper {
    display: flex; align-items: center; gap: 6px;
    margin: 6px 0 18px;
}
.tm-step-node {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    cursor: pointer; flex-shrink: 0;
}
.tm-step-num {
    width: 30px; height: 30px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 600;
    background: var(--tm-panel-soft, rgba(99,102,241,0.08));
    color: var(--tm-ink-dim);
    border: 2px solid var(--tm-panel-line);
    transition: all 0.15s;
}
.tm-step-label {
    font-size: 11px; color: var(--tm-ink-dim);
    text-transform: uppercase; letter-spacing: 0.5px;
    white-space: nowrap;
}
.tm-step-node.active .tm-step-num {
    background: var(--tm-brand, #6366f1); color: #fff;
    border-color: var(--tm-brand, #6366f1);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--tm-brand, #6366f1) 18%, transparent);
}
.tm-step-node.active .tm-step-label { color: var(--tm-brand, #6366f1); font-weight: 600; }
.tm-step-node.done .tm-step-num {
    background: var(--tm-ok, #10b981); color: #fff;
    border-color: var(--tm-ok, #10b981);
}
.tm-step-node.done .tm-step-label { color: var(--tm-ink); }
.tm-step-bar {
    flex: 1; height: 2px; background: var(--tm-panel-line);
    margin-bottom: 16px; border-radius: 2px;
    transition: background 0.15s;
}
.tm-step-bar.done { background: var(--tm-ok, #10b981); }

/* Archive page: topbar + filters + pager fixed, list scrolls */
.tm-archive-page {
    display: flex; flex-direction: column;
    /* Fit within the viewport minus the topbar, content padding, AdminHeader and gap so the
       only scrollbar is the inner list — no second page-level scroll. */
    height: calc(100vh - 150px);
    gap: 14px;
    min-height: 0;
}
.tm-archive-page > .tm-board-toolbar { flex-shrink: 0; }
.tm-archive-page > .tm-archive-pager { flex-shrink: 0; }
/* The list is a single white panel that fills remaining height; items are rows inside it. */
.tm-archive-page > .tm-archive-list {
    flex: 1 1 auto; min-height: 0;
    overflow-y: auto;
    background: #fff; border: 1px solid var(--tm-panel-line); border-radius: 14px;
    box-shadow: 0 1px 2px rgba(17,24,39,0.04);
    padding: 8px;
    gap: 8px;
}
.tm-archive-page > .tm-archive-list > .tm-archive-item { flex-shrink: 0; }

/* When the content area hosts the archive page, don't let it grow past the viewport —
   the inner list owns the only scrollbar. Guards against the fixed-offset above drifting
   if the chrome height changes. */
.tm-content:has(> .tm-archive-page) { overflow: hidden; }

/* Mobile filter toggle — hidden on desktop; the toolbar shows inline. */
.tm-filters-toggle { display: none; }
.tm-filters-mobile-head { display: none; }
.tm-filters-mobile-actions { display: none; }
.tm-filters-backdrop { display: none; }
.tm-filters-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
    background: var(--tm-brand); color: #fff; font-size: 11px; font-weight: 700;
}

/* Dashboard kanban stretches its 4 buckets to fill the available width */
#tm-dashboard-root { overflow-x: visible; }
#tm-dashboard-root .tm-column { flex: 1 1 0; min-width: 240px; }

/* Red border for required fields that fail validation */
.tm-input-error {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.18) !important;
}

/* Wizard body – step 1's natural height is the anchor for all steps */
.tm-wizard-step {
    min-height: 300px;
    display: flex; flex-direction: column; gap: 14px;
}
.tm-wizard-step > .tm-field:only-child { flex: 1; display: flex; flex-direction: column; }
.tm-wizard-step > .tm-field:only-child > .tm-textarea-lg { flex: 1; }

/* Description textarea fills whatever the wizard step provides */
.tm-textarea-lg { min-height: 300px; font-size: 14px; line-height: 1.55; resize: vertical; }

/* Drop zone */
.tm-dropzone {
    position: relative;
    border: 2px dashed var(--tm-panel-line);
    border-radius: 14px;
    padding: 36px 20px;
    text-align: center;
    background: var(--tm-panel-soft, rgba(99,102,241,0.04));
    transition: all 0.15s;
    cursor: pointer;
}
.tm-dropzone:hover {
    border-color: var(--tm-brand, #6366f1);
    background: color-mix(in srgb, var(--tm-brand, #6366f1) 6%, transparent);
}
.tm-dropzone input[type="file"] {
    position: absolute; inset: 0; width: 100%; height: 100%;
    opacity: 0; cursor: pointer;
}
.tm-dropzone-icon {
    width: 56px; height: 56px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: color-mix(in srgb, var(--tm-brand, #6366f1) 15%, transparent);
    color: var(--tm-brand, #6366f1);
    font-size: 22px; font-weight: 700;
    margin-bottom: 10px;
}
.tm-dropzone-title { font-size: 15px; font-weight: 600; color: var(--tm-ink); }
.tm-dropzone-sub { font-size: 12px; color: var(--tm-ink-dim); margin-top: 4px; }

/* Taller member grid for step 4 */
.tm-member-grid-tall { max-height: 340px; }

/* Inline member picker */
.tm-member-picker {
    border: 1px solid var(--tm-panel-line);
    border-radius: 10px;
    padding: 10px;
    background: var(--tm-panel);
    display: flex; flex-direction: column; gap: 10px;
}
.tm-member-chips {
    display: flex; flex-wrap: wrap; gap: 6px;
    padding-bottom: 8px; border-bottom: 1px dashed var(--tm-panel-line);
}
.tm-member-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 8px 4px 4px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--tm-brand, #6366f1) 12%, transparent);
    color: var(--tm-brand, #6366f1);
    font-size: 12px; font-weight: 500;
}
.tm-member-chip.locked { opacity: 0.7; }
.tm-member-chip-x {
    width: 18px; height: 18px;
    border: none; background: rgba(99,102,241,0.18); color: inherit;
    border-radius: 50%; cursor: pointer; font-size: 10px;
    display: inline-flex; align-items: center; justify-content: center;
}
.tm-member-chip-x:hover { background: #ef4444; color: #fff; }
.tm-member-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 6px;
    max-height: 220px; overflow-y: auto;
}
.tm-member-tile {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 6px 10px;
    border-radius: 8px; border: 1px solid transparent;
    background: transparent; color: inherit;
    cursor: pointer; text-align: left; font-size: 13px;
    transition: background 0.1s;
}
.tm-member-tile:hover:not(.locked) { background: color-mix(in srgb, var(--tm-brand, #6366f1) 8%, transparent); }
.tm-member-tile.active {
    background: color-mix(in srgb, var(--tm-brand, #6366f1) 14%, transparent);
    border-color: color-mix(in srgb, var(--tm-brand, #6366f1) 30%, transparent);
    color: var(--tm-brand, #6366f1); font-weight: 500;
}
.tm-member-tile.locked { opacity: 0.6; cursor: not-allowed; }
.tm-member-tile-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tm-member-tile-check { font-size: 12px; }

/* Attachments */
.tm-attach-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 8px;
}
.tm-attach-thumb {
    position: relative;
    aspect-ratio: 1 / 1;
    border-radius: 10px;
    overflow: hidden;
    background: var(--tm-panel-soft, rgba(99,102,241,0.06));
    border: 1px solid var(--tm-panel-line, rgba(148,163,184,0.3));
}
.tm-attach-thumb img {
    width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; display: block;
}
.tm-attach-file {
    display: flex; align-items: center; justify-content: center;
    text-align: center; padding: 8px; font-size: 11px;
    width: 100%; height: 100%; word-break: break-all;
    color: var(--tm-ink-dim);
}
.tm-attach-pending { background: rgba(99,102,241,0.12); color: #4f46e5; }
.tm-attach-x {
    position: absolute; top: 4px; right: 4px;
    width: 22px; height: 22px; border-radius: 50%;
    border: none; background: rgba(15,23,42,0.75); color: #fff;
    cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
    font-size: 12px; line-height: 1;
}
.tm-attach-x:hover { background: #ef4444; }

/* Download icon — same pill-style as tm-attach-x but tucked into the BOTTOM-right corner so
   it doesn't clash with the delete X (when present) and stays visible over the image. */
.tm-attach-download {
    position: absolute; bottom: 4px; right: 4px;
    width: 24px; height: 24px; border-radius: 50%;
    background: rgba(15,23,42,0.75); color: #fff;
    text-decoration: none;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 13px; line-height: 1;
    transition: background .15s;
}
.tm-attach-download:hover { background: var(--tm-brand, #6366f1); color: #fff; }

/* Lightbox */
.tm-lightbox {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.88);
    display: flex; align-items: center; justify-content: center;
    z-index: 2000;
    cursor: zoom-out;
    padding: 20px;
}
.tm-lightbox img {
    max-width: 95vw; max-height: 92vh;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    cursor: default;
}
.tm-lightbox-close {
    position: absolute; top: 16px; right: 20px;
    width: 40px; height: 40px; border-radius: 50%;
    border: none; background: rgba(255,255,255,0.15); color: #fff;
    font-size: 18px; cursor: pointer;
}
.tm-lightbox-close:hover { background: rgba(255,255,255,0.3); }

/* =========================================================
   RESPONSIVE PASS
   Breakpoints:
     ≤ 1024px  tablet
     ≤ 768px   mobile (sidebar becomes a drawer)
     ≤ 480px   tight mobile
   ========================================================= */

/* Hamburger toggle visible on mobile only */
.tm-hamburger {
    display: none;
    background: transparent; border: 1px solid var(--tm-panel-line);
    border-radius: 10px; padding: 8px 10px; cursor: pointer;
    font-size: 18px; line-height: 1; color: var(--tm-ink);
}

/* Mobile kanban tabs (hidden on desktop) */
.tm-kanban-tabs {
    display: none;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 6px;
    margin-bottom: 12px;
    scrollbar-width: thin;
}
.tm-kanban-tab {
    flex: 0 0 auto;
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 12px; border-radius: 999px;
    background: var(--tm-panel); border: 1px solid var(--tm-panel-line);
    color: var(--tm-ink); font-size: 12px; font-weight: 600;
    cursor: pointer; white-space: nowrap;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.tm-kanban-tab .tm-kanban-tab-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--tab-accent, var(--tm-brand));
}
.tm-kanban-tab-count {
    font-size: 11px; font-weight: 700; color: var(--tm-ink-dim);
    background: var(--tm-hover-bg);
    padding: 1px 7px; border-radius: 999px;
}
.tm-kanban-tab.active {
    background: rgba(99,102,241,0.10);
    border-color: var(--tab-accent, var(--tm-brand));
    color: var(--tm-ink);
}
.tm-kanban-tab.active .tm-kanban-tab-count {
    background: var(--tab-accent, var(--tm-brand));
    color: white;
}

/* Mobile role picker (hidden on desktop, shown on mobile via media query) */
.tm-role-picker { display: none; position: relative; }
.tm-role-trigger {
    display: inline-flex; align-items: center; gap: 6px;
    background: transparent; border: 1px solid var(--tm-panel-line);
    border-radius: 999px; padding: 6px 10px; cursor: pointer;
    font-size: 12px; font-weight: 600; color: var(--tm-ink);
}
.tm-role-trigger .tm-ms-caret { color: var(--tm-ink-dim); font-size: 10px; }
.tm-role-menu {
    position: absolute; top: calc(100% + 6px); right: 0; z-index: 1000;
    background: var(--tm-panel-hi); border: 1px solid var(--tm-panel-line);
    border-radius: 10px; box-shadow: var(--tm-shadow-hi);
    padding: 4px; min-width: 160px;
}
.tm-role-item {
    display: flex; align-items: center; gap: 8px; width: 100%;
    background: transparent; border: 1px solid transparent; border-radius: 8px;
    padding: 8px 10px; font-size: 13px; color: var(--tm-ink); cursor: pointer;
    text-align: left;
}
.tm-role-item:hover { background: var(--tm-hover-bg); }
.tm-role-item.active { background: rgba(99,102,241,0.10); color: var(--tm-brand); font-weight: 600; }

/* Sidebar scrim — always fixed so it never takes grid space; hidden until mobile drawer opens */
.tm-sidebar-scrim {
    position: fixed; inset: 0; background: rgba(0,0,0,0.45);
    backdrop-filter: blur(2px);
    z-index: 1090;
    opacity: 0; pointer-events: none;
    transition: opacity 0.18s ease;
}

@media (max-width: 1024px) {
    .tm-content { padding: 20px 16px; }
    .tm-topbar { padding: 14px 18px; }
    .tm-stats { grid-template-columns: repeat(2, 1fr); }
    .tm-board-toolbar { flex-wrap: wrap; }
    .tm-board-toolbar .tm-filter { min-width: 180px; flex: 1 1 180px; }
}

@media (max-width: 768px) {
    /* Layout: collapse the sidebar grid to a single column */
    .tm-shell { grid-template-columns: 1fr; }

    /* Sidebar becomes an overlay drawer */
    .tm-sidebar {
        position: fixed; top: 0; left: 0; bottom: 0;
        width: 84px; z-index: 1100;
        transform: translateX(-100%);
        transition: transform 0.22s ease;
        box-shadow: 0 0 30px rgba(0,0,0,0.25);
    }
    .tm-shell.tm-sidebar-open .tm-sidebar { transform: translateX(0); }

    /* Backdrop visibility when drawer is open */
    .tm-shell.tm-sidebar-open .tm-sidebar-scrim {
        opacity: 1; pointer-events: auto;
    }

    .tm-hamburger { display: inline-flex; align-items: center; justify-content: center; }

    /* Topbar — keep it tight */
    .tm-topbar { padding: 10px 12px; gap: 8px; }
    .tm-topbar-left { gap: 10px; min-width: 0; }
    .tm-topbar-right { gap: 6px; }
    .tm-eyebrow { font-size: 10px; }
    .tm-title { font-size: 16px; }
    .tm-user-meta { display: none; }
    .tm-theme-switch { display: none; }
    /* On mobile, swap the topbar pill row for a single dropdown trigger.
       Scoped to the topbar so other pages that use .tm-view-switch (Schedules / Inbox tabs) keep showing. */
    .tm-topbar-right .tm-view-switch { display: none; }
    .tm-role-picker { display: inline-flex; }

    .tm-content { padding: 14px 12px; gap: 16px; }

    /* Panels */
    .tm-panel { padding: 16px; border-radius: 14px; }
    .tm-panel-head { flex-direction: column; align-items: stretch; gap: 10px; }
    .tm-panel-head h2 { font-size: 16px; }

    /* Modals — fill the screen */
    .tm-modal {
        width: 100% !important; max-width: 100% !important;
        max-height: 100vh; min-height: 100vh; border-radius: 0;
    }
    .tm-modal-backdrop { padding: 0; align-items: stretch; }
    .tm-modal-head { padding: 14px 16px; }
    .tm-modal-body { padding: 14px 16px; }
    .tm-modal-actions { padding: 12px 16px; bottom: 0; }

    /* Stats — single column */
    .tm-stats { grid-template-columns: 1fr; }

    /* Mobile kanban: show tabs above; render only the active column full-width */
    .tm-kanban-tabs { display: flex; }
    .tm-kanban {
        display: block !important;
        overflow: visible !important;
        padding: 0;
        min-height: 0;
    }
    #tm-dashboard-root .tm-column { display: none; min-width: 0; width: 100%; }
    #tm-dashboard-root .tm-column.tm-column-mobile-active { display: flex; }

    /* Project tiles */
    .tm-project-grid { grid-template-columns: 1fr; }

    /* Tables → horizontal scroll wrapper */
    .tm-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .tm-table { font-size: 13px; }
    .tm-table th, .tm-table td { padding: 8px 10px; white-space: nowrap; }

    /* Forms — collapse multi-col grids */
    .tm-field-grid, .tm-field-grid-2, .tm-sched-timing, .tm-sched-yearly {
        grid-template-columns: 1fr !important;
    }
    .tm-sched-freq { grid-template-columns: repeat(2, 1fr); }

    /* Toolbar (board / archive filters) */
    .tm-board-toolbar { gap: 10px; }
    .tm-board-toolbar .tm-filter { width: 100%; flex: 1 1 auto; min-width: 0; }

    /* --- Archive filters as a slide-up sheet on mobile --- */
    .tm-filters-toggle {
        display: inline-flex; align-items: center; gap: 8px;
        align-self: flex-start; flex-shrink: 0;
        padding: 9px 14px; border-radius: 10px;
        background: var(--tm-panel); border: 1px solid var(--tm-panel-line);
        color: var(--tm-ink); font-size: 13px; font-weight: 600; cursor: pointer;
    }
    .tm-filters-toggle:active { transform: scale(0.98); }

    /* Hide the toolbar by default on mobile; only show it as a sheet when open */
    .tm-archive-page > .tm-board-toolbar { display: none; }
    .tm-archive-page > .tm-board-toolbar.is-open {
        display: flex; flex-direction: column;
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 1300;
        max-height: 85vh; overflow-y: auto;
        /* Solid background — --tm-panel is translucent and lets the cards behind bleed
           through, which looks broken for an overlay sheet. */
        background: var(--tm-bg);
        border-top-left-radius: 18px; border-top-right-radius: 18px;
        box-shadow: 0 -10px 40px rgba(0,0,0,0.25);
        padding: 0 16px 16px;
        animation: tmSheetUp 0.2s ease;
    }
    @keyframes tmSheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

    .tm-filters-mobile-head {
        display: flex; align-items: center; justify-content: space-between;
        position: sticky; top: 0; background: var(--tm-bg);
        padding: 16px 0 12px; margin-bottom: 4px;
        border-bottom: 1px solid var(--tm-panel-line);
        font-size: 15px; font-weight: 700; color: var(--tm-ink); z-index: 1;
    }
    .tm-filters-close {
        display: inline-flex; align-items: center; justify-content: center;
        width: 32px; height: 32px; border-radius: 8px;
        background: var(--tm-hover-bg); border: none; color: var(--tm-ink-dim); cursor: pointer;
    }
    .tm-filters-close:active { transform: scale(0.95); }
    .tm-filters-mobile-actions { display: block; margin-top: 8px; }

    .tm-filters-backdrop {
        display: block; position: fixed; inset: 0; z-index: 1290;
        background: rgba(15,23,42,0.45);
        animation: tmFade 0.18s ease;
    }
    @keyframes tmFade { from { opacity: 0; } to { opacity: 1; } }

    /* Drop the empty desktop spacer inside the sheet */
    .tm-archive-page > .tm-board-toolbar.is-open > div[style*="flex:1"] { display: none; }

    /* Inbox: collapse to single pane. List shows by default; thread takes over when open */
    .tm-mail-pane { grid-template-columns: 1fr; }
    .tm-mail-list { max-height: 50vh; }
    .tm-mail-detail { display: none; }
    .tm-mail-pane.tm-mail-thread-open .tm-mail-list { display: none; }
    .tm-mail-pane.tm-mail-thread-open .tm-mail-detail { display: flex; }

    /* Stat rows that use inline flex-wrap:nowrap (Master dashboard, Performance detail) —
       force them to wrap into 2-up so 4–6 cards don't jam into one overflowing row. */
    .tm-stats[style*="nowrap"] { flex-wrap: wrap !important; }
    .tm-stats[style*="nowrap"] > .tm-stat { flex: 1 1 calc(50% - 6px) !important; min-width: 0; }

    /* Board/archive filters wrap full-width earlier (was only ≤768 via display:none sheet;
       this covers the board toolbar which stays inline) */
    .tm-board-toolbar .tm-filter { width: 100%; flex: 1 1 100%; min-width: 0; max-width: 100%; }

    /* Schedule "tick status" banner — stack icon/text/button instead of overflowing */
    .tm-tick-status { flex-wrap: wrap; }

    /* Archive card on mobile: stack header so the title gets full width, chips drop below
       it, and the Created/Closed/Assigned rows read one-per-line. */
    .tm-archive-head { flex-direction: column; align-items: stretch; gap: 8px; padding: 12px 14px 12px 16px; }
    .tm-archive-seq { align-self: flex-start; }
    .tm-archive-title { -webkit-line-clamp: 3; }
    .tm-archive-people { flex-direction: column; align-items: flex-start; gap: 5px; }
    .tm-archive-dot { display: none; }
    .tm-archive-head-right { justify-content: flex-start; margin-top: 2px; }

    /* Schedule modal pills */
    .tm-schedule-modal { max-width: 100% !important; }

    /* Master Companies actions — wrap */
    .tm-table td button { margin-bottom: 4px; }

    /* SweetAlert popup */
    .swal2-popup { width: 92vw !important; max-width: 92vw !important; }
}

@media (max-width: 480px) {
    .tm-stat { padding: 14px; }
    .tm-stat-value { font-size: 22px; }
    .tm-modal-head h3 { font-size: 16px; }
    .tm-btn { padding: 8px 12px; font-size: 13px; }
    .tm-sched-freq { grid-template-columns: 1fr; }

    /* Stat rows that wrap to 2-up at 768 collapse to 1-up on phones */
    .tm-stats[style*="nowrap"] > .tm-stat { flex: 1 1 100% !important; }

    /* Inline filter capped at 360px (Performance) — let it fill the screen */
    .tm-filter[style*="360px"] { max-width: 100% !important; }

    /* Tick-status banner — full vertical stack */
    .tm-tick-status { flex-direction: column; align-items: flex-start !important; }
}

/* Archive pager: the inline 3-column grid collapses to a centered stack on phones */
@media (max-width: 640px) {
    .tm-archive-pager {
        grid-template-columns: 1fr !important;
        justify-items: center !important;
        gap: 10px !important;
        text-align: center;
    }
    .tm-archive-pager > div { justify-self: center !important; }
}

/* ==========================================================================
   PUBLIC LANDING PAGE (/)
   ========================================================================== */
.tm-landing { display: flex; flex-direction: column; min-height: 100vh; }
.tm-public-main { flex: 1; display: flex; flex-direction: column; }

/* Long-form public legal pages (privacy, terms). */
.tm-legal {
    max-width: 760px; margin: 0 auto;
    color: var(--tm-ink);
    font-size: 15px; line-height: 1.7;
}
.tm-legal p { margin: 0 0 14px; }
.tm-legal h2 {
    margin: 32px 0 10px;
    font-size: 18px; font-weight: 700;
    letter-spacing: -0.2px;
}
.tm-legal ul { margin: 0 0 14px 20px; padding: 0; }
.tm-legal ul li { margin: 0 0 6px; }
.tm-legal a { color: var(--tm-brand); font-weight: 600; }
.tm-legal a:hover { text-decoration: underline; }
.tm-legal code {
    background: var(--tm-input-bg); padding: 1px 6px; border-radius: 4px;
    font-size: 13px;
}

/* Mobile-app pairing QR (Profile page). */
.tm-pair-qr {
    display: flex; justify-content: center; align-items: center;
    background: #ffffff; border: 1px solid var(--tm-panel-line);
    border-radius: var(--tm-radius); padding: 18px;
    max-width: 320px; margin: 0 auto;
}
.tm-pair-qr svg { display: block; max-width: 280px; height: auto; }
.tm-pair-payload {
    display: flex; flex-direction: column; gap: 4px;
    margin-top: 14px; padding: 10px 14px;
    background: var(--tm-input-bg); border: 1px solid var(--tm-panel-line);
    border-radius: var(--tm-radius-sm); font-family: monospace;
}
.tm-pair-payload code { font-size: 13px; color: var(--tm-ink); word-break: break-all; }
/* Auth forms (.tm-login) use min-height:100vh when standalone — inside the public layout
   they need to fill the remaining space between nav and footer instead. */
.tm-public-main > .tm-login { min-height: 0; flex: 1; }
/* Avoid anchor targets being hidden under the sticky nav when smooth-scrolling. */
.tm-section[id] { scroll-margin-top: 80px; }

.tm-landing-nav {
    position: sticky; top: 0; z-index: 50;
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 32px;
    background: var(--tm-login-card-bg); backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--tm-panel-line);
}
.tm-landing-nav-links { display: flex; align-items: center; gap: 18px; }
.tm-landing-nav-links a:not(.tm-btn) {
    color: var(--tm-ink-dim); font-weight: 600; font-size: 14px; text-decoration: none;
    transition: color .15s;
}
.tm-landing-nav-links a:not(.tm-btn):hover { color: var(--tm-ink); }
.tm-landing-nav-links .tm-btn { padding: 8px 16px; }

.tm-hero {
    position: relative; overflow: hidden;
    padding: 96px 32px 80px;
    text-align: center;
}
.tm-hero-aurora {
    position: absolute; inset: -10%; pointer-events: none; z-index: 0;
    background:
        radial-gradient(circle at 20% 30%, rgba(99,102,241,.28), transparent 50%),
        radial-gradient(circle at 80% 50%, rgba(236,72,153,.20), transparent 50%),
        radial-gradient(circle at 50% 100%, rgba(6,182,212,.18), transparent 50%);
    filter: blur(50px); animation: float 12s ease-in-out infinite alternate;
}
.tm-hero-inner { position: relative; z-index: 1; max-width: 780px; margin: 0 auto; }
.tm-hero-eyebrow {
    display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: 1.5px;
    text-transform: uppercase; color: var(--tm-brand);
    background: rgba(99,102,241,.10); border: 1px solid rgba(99,102,241,.25);
    padding: 6px 14px; border-radius: 999px; margin-bottom: 24px;
}
.tm-hero-title {
    font-size: 56px; line-height: 1.05; font-weight: 800; margin: 0 0 18px;
    background: linear-gradient(135deg, var(--tm-ink), var(--tm-brand) 60%, var(--tm-brand-2));
    -webkit-background-clip: text; background-clip: text; color: transparent;
    letter-spacing: -1px;
}
.tm-hero-sub {
    font-size: 18px; line-height: 1.55; color: var(--tm-ink-dim);
    margin: 0 auto 32px; max-width: 600px;
}
.tm-hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.tm-hero-trust { margin-top: 24px; font-size: 12px; color: var(--tm-muted); letter-spacing: 0.5px; }

.tm-btn-lg { padding: 12px 24px; font-size: 14px; }

.tm-section { padding: 80px 32px; position: relative; }
.tm-section-alt { background: var(--tm-bg-2); }
.tm-section-head { max-width: 720px; margin: 0 auto 48px; text-align: center; }
.tm-eyebrow {
    display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: 1.5px;
    text-transform: uppercase; color: var(--tm-brand); margin-bottom: 12px;
}
.tm-section-title { font-size: 36px; font-weight: 800; margin: 0 0 12px; line-height: 1.15; letter-spacing: -0.5px; }
.tm-section-sub { color: var(--tm-ink-dim); font-size: 16px; line-height: 1.55; margin: 0; }

.tm-feature-grid {
    max-width: 1100px; margin: 0 auto;
    display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 18px;
}
.tm-feature {
    background: var(--tm-login-card-bg); border: 1px solid var(--tm-panel-line);
    border-radius: var(--tm-radius); padding: 28px;
    transition: transform .15s, border-color .15s, box-shadow .15s;
}
.tm-feature:hover { transform: translateY(-2px); border-color: rgba(99,102,241,.4); box-shadow: var(--tm-shadow); }
.tm-feature-icon {
    width: 44px; height: 44px; border-radius: 12px;
    background: linear-gradient(135deg, var(--tm-brand), var(--tm-brand-2));
    color: white; display: grid; place-items: center;
    font-size: 18px; font-weight: 800; margin-bottom: 16px;
}
.tm-feature-title { font-size: 17px; font-weight: 700; margin: 0 0 8px; }
.tm-feature-body { color: var(--tm-ink-dim); font-size: 14px; line-height: 1.6; margin: 0; }

.tm-steps {
    max-width: 1100px; margin: 0 auto;
    display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
}
.tm-step {
    background: var(--tm-login-card-bg); border: 1px solid var(--tm-panel-line);
    border-radius: var(--tm-radius); padding: 28px;
}
/* Scope these landing-page step styles to .tm-steps so they don't bleed into the wizard's
   .tm-step-num (which is a 30x30 numbered circle). */
.tm-steps .tm-step-num {
    font-size: 38px; font-weight: 800; line-height: 1; margin-bottom: 14px;
    background: linear-gradient(135deg, var(--tm-brand), var(--tm-brand-2));
    -webkit-background-clip: text; background-clip: text; color: transparent;
    width: auto; height: auto; border: 0; border-radius: 0;
}
.tm-steps .tm-step-title { font-size: 18px; font-weight: 700; margin: 0 0 8px; }
.tm-steps .tm-step-body { color: var(--tm-ink-dim); font-size: 14px; line-height: 1.6; margin: 0; }

.tm-cta-band { text-align: center; }
.tm-cta-inner {
    max-width: 720px; margin: 0 auto;
    background: linear-gradient(135deg, rgba(99,102,241,.10), rgba(139,92,246,.10));
    border: 1px solid rgba(99,102,241,.25);
    border-radius: 24px; padding: 56px 32px;
}
.tm-cta-title { font-size: 32px; font-weight: 800; margin: 0 0 12px; letter-spacing: -0.5px; }
.tm-cta-sub { color: var(--tm-ink-dim); font-size: 16px; margin: 0 0 28px; }

.tm-landing-footer {
    margin-top: auto;
    padding: 32px;
    border-top: 1px solid var(--tm-panel-line);
}
.tm-footer-inner {
    max-width: 1100px; margin: 0 auto;
    display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap;
}
.tm-footer-links { display: flex; gap: 18px; flex-wrap: wrap; }
.tm-footer-links a {
    color: var(--tm-ink-dim); font-weight: 600; font-size: 13px; text-decoration: none;
    transition: color .15s;
}
.tm-footer-links a:hover { color: var(--tm-ink); }

/* App-store badges in the public footer — black pills with sub-label + store name. */
.tm-footer-apps { display: flex; gap: 10px; flex-wrap: wrap; }
.tm-app-link {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 14px; border-radius: 999px;
    background: #111; color: #fff; text-decoration: none;
    border: 1px solid #1f2937;
    transition: transform .15s, background .15s;
}
.tm-app-link:hover { background: #000; transform: translateY(-1px); }
.tm-app-link-icon {
    width: 22px; height: 22px;
    background:
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'><path d='M16.365 1.43c0 1.14-.493 2.27-1.177 3.08-.744.9-1.99 1.57-2.987 1.57-.12-1.17.461-2.36 1.179-3.16C14.18 1.93 15.5 1.42 16.365 1.43Zm4.565 16.83c-.797 1.65-1.18 2.39-2.21 3.85-1.42 2.01-3.42 4.51-5.9 4.53-2.21.02-2.78-1.43-5.78-1.41-3 .02-3.62 1.43-5.83 1.41-2.48-.02-4.37-2.27-5.79-4.28-3.97-5.6-4.4-12.17-1.94-15.66 1.74-2.49 4.49-3.95 7.07-3.95 2.63 0 4.28 1.45 6.46 1.45 2.11 0 3.4-1.45 6.44-1.45 2.3 0 4.74 1.25 6.48 3.41-5.69 3.12-4.76 11.25.96 13.1Z'/></svg>")
        center/contain no-repeat;
}
.tm-app-link-icon-play {
    background:
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'><path d='M3.609 1.814v20.372L13.792 12zM14.5 12.7l2.566 2.566-12.06 6.793zM20.1 9.603c.76.434.76 1.626 0 2.06l-2.45 1.378-2.838-2.413 2.838-2.413zM5 1.94l12.06 6.793-2.566 2.566z'/></svg>")
        center/contain no-repeat;
}
.tm-app-link-text { display: flex; flex-direction: column; line-height: 1; }
.tm-app-link-sub { font-size: 10px; color: #d1d5db; letter-spacing: 0.5px; }
.tm-app-link-store { font-size: 14px; font-weight: 700; }

/* Cookie consent banner — fixed bottom, soft consent, single 'Got it' button. */
.tm-cookie-banner {
    position: fixed; left: 16px; right: 16px; bottom: 16px;
    z-index: 9000;
    display: flex; gap: 14px; align-items: center; flex-wrap: wrap; justify-content: space-between;
    background: rgba(17, 24, 39, 0.96);
    color: #e6e8ef;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    padding: 14px 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(8px);
    max-width: 980px;
    margin: 0 auto;
}
.tm-cookie-text { font-size: 13px; line-height: 1.5; flex: 1; min-width: 240px; }
.tm-cookie-text a { color: #a5b4fc; font-weight: 600; }
.tm-cookie-text a:hover { color: #c7d2fe; }

@media (max-width: 760px) {
    .tm-hero-title { font-size: 38px; }
    .tm-section-title { font-size: 28px; }
    .tm-cta-title { font-size: 26px; }
    .tm-landing-nav { padding: 12px 16px; }
    .tm-landing-nav-links { gap: 10px; }
    .tm-landing-nav-links a:not(.tm-btn) { display: none; }
    .tm-section { padding: 56px 16px; }
    .tm-hero { padding: 64px 16px 48px; }
    .tm-cta-inner { padding: 40px 20px; }
}

/* --- Comment reactions (chips + picker) --- */
.tm-reaction-chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px; border-radius: 999px; font-size: 12px;
    background: var(--tm-panel); border: 1px solid var(--tm-panel-line);
    cursor: pointer; transition: background .12s, border-color .12s;
}
.tm-reaction-chip:hover { background: var(--tm-hover-bg, rgba(99,102,241,0.06)); border-color: var(--tm-brand); }
.tm-reaction-chip.tm-reaction-active {
    background: rgba(99,102,241,0.12); border-color: var(--tm-brand); color: var(--tm-brand);
}
.tm-reaction-emoji { font-size: 14px; line-height: 1; }
.tm-reaction-count { font-weight: 600; min-width: 8px; text-align: center; }

/* The picker — a tiny button that reveals a row of emoji choices on hover/focus. */
.tm-reaction-picker { position: relative; }
.tm-reaction-add {
    padding: 2px 8px; border-radius: 999px; font-size: 12px; line-height: 1;
    background: transparent; border: 1px dashed var(--tm-panel-line); color: var(--tm-ink-dim); cursor: pointer;
}
.tm-reaction-add:hover { color: var(--tm-brand); border-color: var(--tm-brand); }
.tm-reaction-menu {
    position: absolute; bottom: 100%; left: 0; margin-bottom: 6px;
    display: none; gap: 4px; padding: 6px 8px;
    background: var(--tm-panel); border: 1px solid var(--tm-panel-line);
    border-radius: 999px; box-shadow: 0 8px 24px rgba(15,23,42,0.12); z-index: 10;
}
.tm-reaction-picker:hover .tm-reaction-menu,
.tm-reaction-picker:focus-within .tm-reaction-menu { display: inline-flex; }
.tm-reaction-option {
    font-size: 18px; line-height: 1; padding: 4px 6px; border-radius: 999px;
    background: transparent; border: none; cursor: pointer;
}
.tm-reaction-option:hover { background: var(--tm-hover-bg, rgba(99,102,241,0.08)); }
