/* ============================================================================
   Task Manager — Enterprise UI System
   Design tokens, layout shell, and component styles.
   Pairs with Bootstrap 5.3 (loaded from CDN). All overrides are scoped so
   raw bootstrap classes still render but inherit the premium look.
   ========================================================================== */

/* -------------------- Design tokens -------------------- */
:root {
    /* Surface */
    --tm-bg:            #f6f7fb;
    --tm-bg-alt:        #eef0f6;
    --tm-surface:       #ffffff;
    --tm-surface-2:     #f8fafc;

    /* Border */
    --tm-border:        #e6e8ee;
    --tm-border-strong: #d4d7de;
    --tm-divider:       #eef0f4;

    /* Text */
    --tm-text:          #0f172a;
    --tm-text-muted:    #64748b;
    --tm-text-subtle:   #94a3b8;
    --tm-text-invert:   #ffffff;

    /* Brand / semantic */
    --tm-primary:       #4f46e5;
    --tm-primary-600:   #4338ca;
    --tm-primary-700:   #3730a3;
    --tm-primary-soft:  #eef2ff;
    --tm-primary-ring:  rgba(79, 70, 229, .18);

    --tm-success:       #059669;
    --tm-success-soft:  #ecfdf5;
    --tm-warning:       #b45309;
    --tm-warning-soft:  #fffbeb;
    --tm-danger:        #b91c1c;
    --tm-danger-soft:   #fef2f2;
    --tm-info:          #0e7490;
    --tm-info-soft:     #ecfeff;

    /* Shadows */
    --tm-shadow-sm:  0 1px 2px rgba(15, 23, 42, .04);
    --tm-shadow:     0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
    --tm-shadow-md:  0 6px 16px rgba(15, 23, 42, .06), 0 2px 4px rgba(15, 23, 42, .04);
    --tm-shadow-lg:  0 18px 40px rgba(15, 23, 42, .10), 0 4px 10px rgba(15, 23, 42, .04);
    --tm-ring:       0 0 0 4px var(--tm-primary-ring);

    /* Radii */
    --tm-radius-sm: 6px;
    --tm-radius:    10px;
    --tm-radius-lg: 14px;
    --tm-radius-xl: 18px;

    /* Layout */
    --tm-sidebar-w:    248px;
    --tm-sidebar-w-c:  72px;
    --tm-topbar-h:     60px;
    --tm-content-pad:  32px;

    /* Motion */
    --tm-ease: cubic-bezier(.4, 0, .2, 1);
}

/* -------------------- Base / typography -------------------- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--tm-bg);
    color: var(--tm-text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
                 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body { min-height: 100vh; }

h1, h2, h3, h4, h5, h6 {
    color: var(--tm-text);
    font-weight: 600;
    letter-spacing: -0.01em;
    margin: 0 0 .25em;
    line-height: 1.25;
}
h1 { font-size: 28px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
h4 { font-size: 16px; }
h5 { font-size: 14px; }

a { color: var(--tm-primary); text-decoration: none; transition: color .15s var(--tm-ease); }
a:hover { color: var(--tm-primary-600); }

::selection { background: var(--tm-primary-soft); color: var(--tm-primary-700); }

/* Premium scrollbar */
::-webkit-scrollbar              { width: 10px; height: 10px; }
::-webkit-scrollbar-track        { background: transparent; }
::-webkit-scrollbar-thumb        { background: #cfd3dc; border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover  { background: #b6bbc6; background-clip: padding-box; border: 2px solid transparent; }

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

.tm-content {
    display: flex;
    flex-direction: column;
    min-width: 0;          /* allow tables to scroll inside */
    min-height: 100vh;
    background: var(--tm-bg);
}

.tm-main {
    flex: 1 1 auto;
    padding: var(--tm-content-pad);
    width: 100%;
    max-width: 1440px;
}

.tm-footer {
    padding: 16px var(--tm-content-pad);
    color: var(--tm-text-subtle);
    font-size: 12px;
    border-top: 1px solid var(--tm-divider);
    background: var(--tm-surface);
}

/* -------------------- Sidebar -------------------- */
.tm-sidebar {
    position: sticky;
    top: 0;
    align-self: start;
    height: 100vh;
    background: var(--tm-surface);
    border-right: 1px solid var(--tm-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 30;
}

.tm-sidebar__brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--tm-divider);
    min-height: var(--tm-topbar-h);
}
.tm-sidebar__brand-mark {
    width: 32px; height: 32px;
    flex: 0 0 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, #6366f1 0%, #4338ca 100%);
    display: grid; place-items: center;
    color: #fff; font-weight: 700; font-size: 15px;
    box-shadow: 0 4px 10px rgba(67,56,202,.25);
}
.tm-sidebar__brand-text {
    font-weight: 700; font-size: 15px; color: var(--tm-text);
    letter-spacing: -.01em; line-height: 1.1;
}
.tm-sidebar__brand-sub  {
    font-size: 11px; color: var(--tm-text-subtle); letter-spacing: .04em;
    text-transform: uppercase; font-weight: 500;
}

.tm-sidebar__nav {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 14px 12px 20px;
}

.tm-nav-section { margin-top: 18px; }
.tm-nav-section:first-child { margin-top: 4px; }
.tm-nav-label {
    padding: 6px 12px;
    font-size: 11px;
    color: var(--tm-text-subtle);
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 600;
}
.tm-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    margin: 2px 0;
    border-radius: 8px;
    color: var(--tm-text);
    font-size: 13.5px;
    font-weight: 500;
    transition: background .15s var(--tm-ease), color .15s var(--tm-ease);
    white-space: nowrap;
}
.tm-nav-link:hover { background: var(--tm-surface-2); color: var(--tm-text); }
.tm-nav-link.is-active {
    background: var(--tm-primary-soft);
    color: var(--tm-primary-700);
}
.tm-nav-link.is-active .tm-nav-icon { color: var(--tm-primary); }
.tm-nav-icon {
    width: 18px; height: 18px; flex: 0 0 18px;
    color: var(--tm-text-subtle);
    transition: color .15s var(--tm-ease);
}
.tm-nav-link:hover .tm-nav-icon { color: var(--tm-text); }

.tm-sidebar__footer {
    border-top: 1px solid var(--tm-divider);
    padding: 12px 14px;
    background: var(--tm-surface);
}
.tm-user {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.tm-user__avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--tm-primary-soft);
    color: var(--tm-primary-700);
    font-weight: 600; font-size: 13px;
    display: grid; place-items: center;
    flex: 0 0 34px;
}
.tm-user__meta { min-width: 0; line-height: 1.2; }
.tm-user__meta strong { display: block; font-size: 13px; color: var(--tm-text); font-weight: 600; }
.tm-user__meta small { font-size: 11px; color: var(--tm-text-subtle); }

.tm-logout {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 10px;
    border-radius: 6px;
    color: var(--tm-text-muted) !important;
    font-size: 12px; font-weight: 500;
    text-decoration: none;
    transition: background .15s var(--tm-ease), color .15s var(--tm-ease);
    margin-top: 10px;
    width: 100%;
    justify-content: center;
    border: 1px solid var(--tm-border);
    background: var(--tm-surface);
}
.tm-logout:hover { background: var(--tm-danger-soft); color: var(--tm-danger) !important; border-color: var(--tm-danger-soft); }
.tm-logout svg { width: 14px; height: 14px; }

/* -------------------- Topbar -------------------- */
.tm-topbar {
    position: sticky; top: 0; z-index: 20;
    height: var(--tm-topbar-h);
    background: rgba(255,255,255,.85);
    backdrop-filter: saturate(180%) blur(8px);
    -webkit-backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--tm-border);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 var(--tm-content-pad);
}
.tm-topbar__toggle {
    display: none;
    width: 36px; height: 36px;
    border: 1px solid var(--tm-border);
    background: var(--tm-surface);
    border-radius: 8px;
    align-items: center; justify-content: center;
    color: var(--tm-text-muted);
    cursor: pointer;
    transition: background .15s var(--tm-ease);
}
.tm-topbar__toggle:hover { background: var(--tm-surface-2); }
.tm-topbar__toggle svg { width: 18px; height: 18px; }

.tm-topbar__crumbs {
    display: flex; align-items: center; gap: 6px;
    color: var(--tm-text-muted); font-size: 13px;
}
.tm-topbar__crumbs strong { color: var(--tm-text); font-weight: 600; }

/* -------------------- Notifications (bell + dropdown) -------------------- */
.tm-notify { position: relative; margin-left: auto; }
.tm-notify__btn {
    position: relative;
    width: 36px; height: 36px;
    border: 1px solid var(--tm-border);
    background: var(--tm-surface);
    border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--tm-text-muted);
    cursor: pointer;
    transition: background .15s var(--tm-ease), color .15s var(--tm-ease);
}
.tm-notify__btn:hover { background: var(--tm-surface-2); color: var(--tm-text); }
.tm-notify__btn svg { width: 18px; height: 18px; }
.tm-notify__badge {
    position: absolute; top: -4px; right: -4px;
    min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 9px;
    background: #ef4444; color: #fff;
    font-size: 10px; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
    border: 2px solid var(--tm-surface);
    line-height: 1;
}
.tm-notify__panel {
    position: absolute; top: calc(100% + 8px); right: 0;
    width: 360px; max-width: calc(100vw - 32px);
    background: var(--tm-surface);
    border: 1px solid var(--tm-border);
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(15,23,42,.18);
    overflow: hidden;
    display: none;
    z-index: 50;
}
.tm-notify.is-open .tm-notify__panel { display: block; }
.tm-notify__head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--tm-border);
    font-size: 13px; font-weight: 600; color: var(--tm-text);
}
.tm-notify__action {
    font-size: 12px; color: var(--tm-primary, #4f46e5);
    text-decoration: none; font-weight: 500;
}
.tm-notify__action:hover { text-decoration: underline; }
.tm-notify__list { max-height: 380px; overflow-y: auto; }
.tm-notify__item {
    display: block; padding: 12px 16px;
    border-bottom: 1px solid var(--tm-border);
    color: var(--tm-text); text-decoration: none;
    transition: background .12s var(--tm-ease);
}
.tm-notify__item:last-child { border-bottom: none; }
.tm-notify__item:hover { background: var(--tm-surface-2); }
.tm-notify__item.is-unread { background: rgba(79,70,229,.04); }
.tm-notify__item.is-unread .tm-notify__title::before {
    content: ""; display: inline-block;
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--tm-primary, #4f46e5);
    margin-right: 8px; vertical-align: middle;
}
.tm-notify__title {
    font-size: 13px; font-weight: 600;
    margin-bottom: 4px; color: var(--tm-text);
}
.tm-notify__msg {
    font-size: 12px; color: var(--tm-text-muted);
    line-height: 1.45;
    overflow: hidden; text-overflow: ellipsis;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.tm-notify__time {
    font-size: 11px; color: var(--tm-text-muted);
    margin-top: 6px; opacity: .8;
}
.tm-notify__empty {
    padding: 32px 16px; text-align: center;
    color: var(--tm-text-muted); font-size: 13px;
}
.tm-notify__foot {
    padding: 10px 16px;
    border-top: 1px solid var(--tm-border);
    text-align: center;
}
.tm-notify__foot a {
    font-size: 12px; color: var(--tm-primary, #4f46e5);
    text-decoration: none; font-weight: 500;
}
.tm-notify__foot a:hover { text-decoration: underline; }

/* -------------------- Page header -------------------- */
.tm-page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--tm-divider);
}
.tm-page-title { font-size: 22px; font-weight: 700; letter-spacing: -.015em; margin: 0; color: var(--tm-text); }
.tm-page-subtitle { font-size: 13px; color: var(--tm-text-muted); margin-top: 4px; }
.tm-page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* -------------------- Cards -------------------- */
.tm-card,
.card {
    background: var(--tm-surface);
    border: 1px solid var(--tm-border);
    border-radius: var(--tm-radius-lg);
    box-shadow: var(--tm-shadow-sm);
    overflow: hidden;
}
.tm-card + .tm-card,
.card + .card,
.tm-card + .card,
.card + .tm-card { margin-top: 20px; }

.tm-card__header,
.card .card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--tm-divider);
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px;
    background: var(--tm-surface);
}
.tm-card__title { font-size: 14px; font-weight: 600; color: var(--tm-text); }
.tm-card__sub   { font-size: 12px; color: var(--tm-text-muted); margin-top: 2px; }

.tm-card__body,
.card .card-body { padding: 20px; }

/* -------------------- Activity timeline (Phase 11) -------------------- */
.tm-timeline {
    list-style: none;
    margin: 0;
    padding: 0;
    border-left: 2px solid var(--tm-divider);
}
.tm-timeline__item {
    position: relative;
    padding: 6px 0 12px 16px;
    margin-left: -1px;
}
.tm-timeline__item:before {
    content: "";
    position: absolute;
    left: -7px;
    top: 12px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--tm-primary, #0d6efd);
    border: 2px solid var(--tm-surface, #fff);
}
.tm-timeline__item--reassigned:before    { background: #f59e0b; }
.tm-timeline__item--statuschanged:before { background: #10b981; }
.tm-timeline__item--reminderset:before   { background: #8b5cf6; }
.tm-timeline__when {
    font-size: 11.5px;
    color: var(--tm-text-muted);
    margin-bottom: 2px;
}
.tm-timeline__row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 13px;
}
.tm-timeline__row .badge { font-weight: 500; }

/* -------------------- Collapsible sidebar (Phase 10e) -------------------- */
.tm-section-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 14px;
    background: transparent;
    border: 0;
    color: var(--tm-text-muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .12em;
    cursor: pointer;
    border-radius: 6px;
}
.tm-section-toggle:hover {
    background: var(--tm-surface-2);
    color: var(--tm-text);
}
.tm-section-toggle .tm-nav-label {
    margin: 0;
    padding: 0;
}
.tm-section-chevron {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    transition: transform .18s ease;
}
.tm-section-toggle.collapsed .tm-section-chevron {
    transform: rotate(-90deg);
}
.tm-section-collapse {
    padding: 4px 0 8px;
}

/* -------------------- Scope tabs (Phase 10d) — outer "My / Team" -------------------- */
.tm-scope-tabs {
    border-bottom: none;
    margin: 0;
    padding: 0;
    gap: 4px;
}
.tm-scope-tabs .nav-link {
    color: var(--tm-text-muted);
    font-weight: 600;
    font-size: 13px;
    padding: 8px 18px;
    border: 1px solid transparent;
    border-radius: 8px 8px 0 0;
    background: transparent;
}
.tm-scope-tabs .nav-link:hover {
    color: var(--tm-text);
    background: var(--tm-surface-2);
    text-decoration: none;
}
.tm-scope-tabs .nav-link.active {
    color: var(--tm-primary, #0d6efd);
    background: var(--tm-surface);
    border-color: var(--tm-divider);
    border-bottom-color: var(--tm-surface);
}

/* -------------------- Status tabs (Phase 9) -------------------- */
/* Pill-style tab strip on Dashboard / Reporting. Built on .nav-pills. */
.tm-status-tabs {
    flex-wrap: wrap;
    gap: 4px;
    margin: 0;
    padding: 2px 0;
}
.tm-status-tabs .nav-link {
    color: var(--tm-text-muted);
    font-size: 13px;
    font-weight: 500;
    padding: 6px 14px;
    border-radius: 999px;
    transition: background-color .12s, color .12s;
}
.tm-status-tabs .nav-link:hover {
    color: var(--tm-text);
    background: var(--tm-surface-2);
    text-decoration: none;
}
.tm-status-tabs .nav-link.active {
    color: #fff;
    background: var(--tm-primary, #0d6efd);
}

.tm-card__footer,
.card .card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--tm-divider);
    background: var(--tm-surface-2);
    display: flex; justify-content: flex-end; gap: 8px;
}

/* -------------------- Forms -------------------- */
.form-label,
.tm-label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--tm-text);
    margin-bottom: 6px;
    letter-spacing: .005em;
}
.required::after { content: " *"; color: var(--tm-danger); font-weight: 700; }

.form-control,
.form-select,
.tm-input {
    display: block;
    width: 100%;
    padding: 9px 12px;
    font-size: 13.5px;
    line-height: 1.4;
    color: var(--tm-text);
    background: var(--tm-surface);
    border: 1px solid var(--tm-border-strong);
    border-radius: var(--tm-radius-sm);
    transition: border-color .15s var(--tm-ease), box-shadow .15s var(--tm-ease), background .15s var(--tm-ease);
    appearance: none;
    -webkit-appearance: none;
}
.form-control::placeholder { color: var(--tm-text-subtle); }
.form-control:hover,
.form-select:hover { border-color: #b9bdc6; }
.form-control:focus,
.form-select:focus {
    outline: none;
    border-color: var(--tm-primary);
    box-shadow: var(--tm-ring);
    background: var(--tm-surface);
}
.form-control:disabled,
.form-select:disabled { background: var(--tm-surface-2); color: var(--tm-text-muted); }

textarea.form-control { min-height: 88px; resize: vertical; }

.form-control-sm,
.form-select-sm { padding: 6px 10px; font-size: 12.5px; border-radius: 6px; }

/* Checkbox & radio */
.form-check { padding-left: 0; display: inline-flex; align-items: center; gap: 8px; min-height: 22px; }
.form-check-input {
    width: 16px !important; height: 16px !important;
    margin: 0 !important;
    border: 1.5px solid var(--tm-border-strong) !important;
    border-radius: 4px !important;
    cursor: pointer;
    transition: background .15s var(--tm-ease), border-color .15s var(--tm-ease);
    background-color: var(--tm-surface) !important;
}
.form-check-input:focus {
    box-shadow: var(--tm-ring) !important;
    border-color: var(--tm-primary) !important;
}
.form-check-input:checked {
    background-color: var(--tm-primary) !important;
    border-color: var(--tm-primary) !important;
}
.form-check-label { font-size: 13.5px; color: var(--tm-text); cursor: pointer; }

/* ASP.NET CheckBox renders <span><input/><label/></span>. Make it look like .form-check */
.form-check-inline,
input[type="checkbox"] + label {
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px;
    margin-right: 12px;
    font-size: 13.5px;
    color: var(--tm-text);
    cursor: pointer;
}

input[type="checkbox"] {
    accent-color: var(--tm-primary);
    width: 16px; height: 16px; margin: 0;
}

/* Validators */
.field-error,
.tm-field-error {
    display: inline-block;
    margin-top: 6px;
    color: var(--tm-danger);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.3;
}

/* -------------------- Buttons -------------------- */
.btn,
.tm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: .005em;
    border: 1px solid transparent;
    border-radius: var(--tm-radius-sm);
    cursor: pointer;
    transition: background .15s var(--tm-ease), border-color .15s var(--tm-ease),
                color .15s var(--tm-ease), box-shadow .15s var(--tm-ease), transform .05s var(--tm-ease);
    text-decoration: none;
    white-space: nowrap;
    user-select: none;
}
.btn:focus-visible { outline: none; box-shadow: var(--tm-ring); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; }

.btn-sm  { padding: 6px 10px; font-size: 12px; border-radius: 6px; }
.btn-lg  { padding: 11px 18px; font-size: 14px; border-radius: var(--tm-radius); }

.btn-primary {
    background: var(--tm-primary);
    border-color: var(--tm-primary);
    color: #fff;
    box-shadow: 0 1px 2px rgba(67,56,202,.18);
}
.btn-primary:hover { background: var(--tm-primary-600); border-color: var(--tm-primary-600); color: #fff; }

.btn-secondary,
.btn-outline-secondary {
    background: var(--tm-surface);
    border-color: var(--tm-border-strong);
    color: var(--tm-text);
}
.btn-secondary:hover,
.btn-outline-secondary:hover { background: var(--tm-surface-2); color: var(--tm-text); border-color: var(--tm-border-strong); }

.btn-outline-primary {
    background: var(--tm-surface);
    border-color: var(--tm-border-strong);
    color: var(--tm-primary-700);
}
.btn-outline-primary:hover {
    background: var(--tm-primary-soft);
    border-color: var(--tm-primary);
    color: var(--tm-primary-700);
}

.btn-outline-danger {
    background: var(--tm-surface);
    border-color: var(--tm-border-strong);
    color: var(--tm-danger);
}
.btn-outline-danger:hover { background: var(--tm-danger-soft); border-color: var(--tm-danger); color: var(--tm-danger); }

.btn-light { background: var(--tm-surface); color: var(--tm-text); border-color: var(--tm-border-strong); }
.btn-light:hover { background: var(--tm-surface-2); }

.btn-ghost {
    background: transparent;
    color: var(--tm-text-muted);
    border-color: transparent;
}
.btn-ghost:hover { background: var(--tm-surface-2); color: var(--tm-text); }

/* -------------------- Tables / GridView -------------------- */
.table,
.gv-grid,
.tm-table {
    width: 100%;
    background: var(--tm-surface);
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}
.table thead th,
.gv-grid th,
.tm-table thead th {
    background: var(--tm-surface-2) !important;
    color: var(--tm-text-muted) !important;
    font-size: 11.5px !important;
    font-weight: 600 !important;
    letter-spacing: .06em;
    text-transform: uppercase;
    padding: 12px 16px !important;
    border-bottom: 1px solid var(--tm-border) !important;
    text-align: left;
    white-space: nowrap;
}
.table tbody td,
.gv-grid td,
.tm-table tbody td {
    padding: 12px 16px !important;
    border-bottom: 1px solid var(--tm-divider) !important;
    background: var(--tm-surface) !important;
    color: var(--tm-text);
    vertical-align: middle;
}
.table tbody tr:last-child td,
.gv-grid tr:last-child td { border-bottom: none !important; }
.gv-grid tr:nth-child(even) td { background: var(--tm-surface) !important; }  /* remove zebra */
.table tbody tr:hover td,
.gv-grid tr:hover td {
    background: var(--tm-surface-2) !important;
}

/* GridView empty data row */
.gv-grid tr.no-data td,
.gv-grid tr td:only-child {
    /* nothing required; default ok */
}

.tm-table-wrap {
    border: 1px solid var(--tm-border);
    border-radius: var(--tm-radius-lg);
    background: var(--tm-surface);
    overflow: hidden;
}
.tm-table-wrap .table,
.tm-table-wrap .gv-grid { margin: 0; }

.tm-table-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--tm-divider);
    background: var(--tm-surface);
}
.tm-table-toolbar .tm-search {
    position: relative; flex: 0 1 320px;
}
.tm-table-toolbar .tm-search input { padding-left: 34px; }
.tm-table-toolbar .tm-search svg {
    position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
    width: 14px; height: 14px; color: var(--tm-text-subtle);
}
.tm-table-toolbar .tm-toolbar-right {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}

/* Action cell */
.tm-actions { display: inline-flex; gap: 6px; }
.tm-actions .btn { padding: 5px 10px; font-size: 12px; }

/* -------------------- Pagination -------------------- */
.tm-pager-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--tm-surface);
    border-top: 1px solid var(--tm-divider);
    gap: 12px;
    flex-wrap: wrap;
}
.tm-pager-bar__size {
    display: flex; align-items: center; gap: 8px;
    color: var(--tm-text-muted); font-size: 12.5px;
}
.tm-pager-bar__size .form-select {
    width: auto;
    min-width: 76px;
    padding: 4px 28px 4px 10px;
    font-size: 12.5px;
}
.tm-pager-bar__info {
    color: var(--tm-text-subtle);
    font-size: 12px;
}

/* GridView built-in pager row — restyle to look like .tm-pager-bar */
.gv-grid > tbody > tr.tm-pager-row > td {
    background: var(--tm-surface) !important;
    padding: 10px 16px !important;
    border-top: 1px solid var(--tm-divider) !important;
}
.gv-grid .tm-pager-row table { margin: 0; }
.gv-grid .tm-pager-row td td { padding: 0 !important; border: 0 !important; }
.gv-grid .tm-pager-row a,
.gv-grid .tm-pager-row span {
    display: inline-block;
    padding: 5px 11px;
    margin: 0 2px;
    border-radius: 6px;
    border: 1px solid var(--tm-border);
    background: var(--tm-surface);
    color: var(--tm-text) !important;
    font-size: 12.5px;
    font-weight: 500;
    text-decoration: none;
    line-height: 1.3;
    transition: background .15s var(--tm-ease), border-color .15s var(--tm-ease);
}
.gv-grid .tm-pager-row a:hover {
    background: var(--tm-surface-2);
    border-color: var(--tm-border-strong);
}
.gv-grid .tm-pager-row span {
    background: var(--tm-primary);
    color: #fff !important;
    border-color: var(--tm-primary);
    font-weight: 600;
}

/* -------------------- Badges -------------------- */
.badge,
.tm-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.4;
    border-radius: 999px;
    border: 1px solid transparent;
    letter-spacing: .01em;
}
.badge::before,
.tm-badge::before {
    content: "";
    width: 6px; height: 6px; border-radius: 50%;
    background: currentColor; opacity: .9;
}
.badge.bg-success, .tm-badge--success {
    background: var(--tm-success-soft) !important;
    color: var(--tm-success) !important;
    border-color: rgba(5,150,105,.18);
}
.badge.bg-secondary, .tm-badge--neutral {
    background: var(--tm-surface-2) !important;
    color: var(--tm-text-muted) !important;
    border-color: var(--tm-border);
}
.badge.bg-warning, .tm-badge--warning {
    background: var(--tm-warning-soft) !important;
    color: var(--tm-warning) !important;
    border-color: rgba(180,83,9,.18);
}
.badge.bg-danger, .tm-badge--danger {
    background: var(--tm-danger-soft) !important;
    color: var(--tm-danger) !important;
    border-color: rgba(185,28,28,.18);
}
.badge.bg-info, .tm-badge--info {
    background: var(--tm-info-soft) !important;
    color: var(--tm-info) !important;
    border-color: rgba(14,116,144,.18);
}
.badge.bg-primary, .tm-badge--primary {
    background: var(--tm-primary-soft) !important;
    color: var(--tm-primary-700) !important;
    border-color: rgba(79,70,229,.18);
}

/* -------------------- Alerts -------------------- */
.alert {
    border-radius: var(--tm-radius);
    padding: 12px 14px;
    border: 1px solid;
    font-size: 13px;
    line-height: 1.45;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.alert::before {
    content: "";
    width: 6px; min-width: 6px;
    align-self: stretch;
    border-radius: 4px;
    background: currentColor;
    opacity: .9;
    margin-right: 4px;
}
.alert-success { background: var(--tm-success-soft); border-color: rgba(5,150,105,.22); color: var(--tm-success); }
.alert-warning { background: var(--tm-warning-soft); border-color: rgba(180,83,9,.22); color: var(--tm-warning); }
.alert-danger  { background: var(--tm-danger-soft);  border-color: rgba(185,28,28,.22); color: var(--tm-danger);  }
.alert-info    { background: var(--tm-info-soft);    border-color: rgba(14,116,144,.22); color: var(--tm-info);    }
.alert-secondary { background: var(--tm-surface-2); border-color: var(--tm-border); color: var(--tm-text-muted); }
.alert > * { color: inherit !important; }

/* -------------------- Login (centered minimalist) -------------------- */
.tm-login {
    position: relative;
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 48px 20px;
    background: #fbfcfe;
    overflow: hidden;
    isolation: isolate;
}

/* Soft multi-blob mesh background */
.tm-login__bg {
    position: absolute; inset: 0; z-index: -2; pointer-events: none;
    background:
        radial-gradient(38% 42% at 12% 8%,  rgba(99, 102, 241, .22), transparent 70%),
        radial-gradient(34% 38% at 88% 14%, rgba(14, 165, 233, .14), transparent 70%),
        radial-gradient(40% 45% at 80% 92%, rgba(139, 92, 246, .14), transparent 70%),
        radial-gradient(32% 40% at 8% 88%,  rgba(244, 114, 182, .10), transparent 70%);
}
/* Faint dot grid for depth */
.tm-login::before {
    content: "";
    position: absolute; inset: 0; z-index: -1; pointer-events: none;
    background-image: radial-gradient(circle, rgba(15,23,42,.06) 1px, transparent 1px);
    background-size: 26px 26px;
    mask-image: radial-gradient(ellipse 80% 60% at 50% 40%, #000 30%, transparent 80%);
    -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 40%, #000 30%, transparent 80%);
    opacity: .55;
}

.tm-login__inner {
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.tm-login__brand {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 24px;
}
.tm-login__brand .tm-sidebar__brand-mark {
    width: 36px; height: 36px; flex: 0 0 36px;
    font-size: 14px;
    box-shadow: 0 8px 22px rgba(67, 56, 202, .35);
}
.tm-login__wordmark {
    font-weight: 700; font-size: 16px;
    letter-spacing: -.015em; color: var(--tm-text);
}

.tm-login__card {
    width: 100%;
    background: #ffffff;
    border-radius: 18px;
    padding: 36px 32px 28px;
    box-shadow:
        0 1px 0 rgba(15, 23, 42, .04),
        0 0 0 1px rgba(15, 23, 42, .02),
        0 24px 48px -16px rgba(15, 23, 42, .14),
        0 8px 16px -8px rgba(15, 23, 42, .06);
    animation: tmLoginUp .4s var(--tm-ease) both;
}

@keyframes tmLoginUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.tm-login__title {
    font-size: 22px; font-weight: 700;
    letter-spacing: -.015em; margin: 0 0 6px;
    color: var(--tm-text);
}
.tm-login__sub {
    color: var(--tm-text-muted);
    font-size: 13.5px;
    margin: 0 0 22px;
}

.tm-login__field { margin-bottom: 16px; }
.tm-login__field-head {
    display: flex; justify-content: space-between; align-items: baseline;
    margin-bottom: 6px;
}

/* Input with leading icon */
.tm-input-icon {
    position: relative;
    display: block;
}
.tm-input-icon > svg {
    position: absolute;
    left: 12px; top: 50%;
    transform: translateY(-50%);
    width: 16px; height: 16px;
    color: var(--tm-text-subtle);
    pointer-events: none;
    transition: color .15s var(--tm-ease);
}
.tm-input-icon .form-control { padding-left: 38px; padding-right: 14px; height: 42px; font-size: 14px; }
.tm-input-icon .form-control:focus + .__bg,
.tm-input-icon .form-control:focus ~ svg { color: var(--tm-primary); }

/* Show / hide password toggle */
.tm-pwd-toggle {
    background: none;
    border: 0;
    padding: 0;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--tm-text-muted);
    letter-spacing: .03em;
    text-transform: uppercase;
    cursor: pointer;
    transition: color .15s var(--tm-ease);
}
.tm-pwd-toggle:hover { color: var(--tm-primary); }

.tm-login__submit { margin-top: 8px; }
.tm-login__submit .btn-primary {
    width: 100%;
    padding: 11px 18px;
    height: 44px;
    font-size: 14px;
    border-radius: 10px;
}

.tm-login__divider {
    display: flex; align-items: center; gap: 12px;
    margin: 22px 0 18px;
    color: var(--tm-text-subtle);
    font-size: 11px; font-weight: 500;
    text-transform: uppercase; letter-spacing: .12em;
}
.tm-login__divider::before,
.tm-login__divider::after {
    content: ""; flex: 1; height: 1px; background: var(--tm-divider);
}

.tm-login__hint-row {
    text-align: center;
    color: var(--tm-text-subtle);
    font-size: 12.5px;
    line-height: 1.5;
}
.tm-login__hint-row a { color: var(--tm-primary); font-weight: 500; }

.tm-login__foot {
    margin-top: 24px;
    text-align: center;
    color: var(--tm-text-subtle);
    font-size: 11.5px;
    letter-spacing: .02em;
}
.tm-login__foot strong { color: var(--tm-text-muted); font-weight: 600; }

@media (max-width: 480px) {
    .tm-login { padding: 24px 14px; }
    .tm-login__card { padding: 26px 20px 22px; border-radius: 14px; }
    .tm-login__title { font-size: 20px; }
}

/* -------------------- Empty / error state -------------------- */
.tm-empty {
    text-align: center;
    padding: 64px 24px;
    background: var(--tm-surface);
    border: 1px solid var(--tm-border);
    border-radius: var(--tm-radius-lg);
    color: var(--tm-text-muted);
}
.tm-empty__icon {
    width: 56px; height: 56px;
    margin: 0 auto 14px;
    background: var(--tm-primary-soft);
    color: var(--tm-primary);
    border-radius: 14px;
    display: grid; place-items: center;
}
.tm-empty__icon svg { width: 26px; height: 26px; }
.tm-empty h3 { color: var(--tm-text); font-size: 18px; margin-bottom: 6px; }
.tm-empty p  { font-size: 13.5px; max-width: 420px; margin: 0 auto; }

/* -------------------- Utilities -------------------- */
.tm-divider { height: 1px; background: var(--tm-divider); margin: 16px 0; border: 0; }
.tm-stack-sm > * + * { margin-top: 8px; }
.tm-stack    > * + * { margin-top: 16px; }
.tm-row { display: flex; gap: 12px; flex-wrap: wrap; }
.tm-row > * { flex: 1 1 220px; min-width: 0; }

.tm-muted { color: var(--tm-text-muted) !important; }
.tm-subtle { color: var(--tm-text-subtle) !important; }

/* -------------------- Responsive -------------------- */
@media (max-width: 1024px) {
    :root { --tm-content-pad: 22px; }
    .tm-shell { grid-template-columns: 1fr; }
    .tm-sidebar {
        position: fixed; top: 0; left: 0; bottom: 0;
        width: var(--tm-sidebar-w);
        transform: translateX(-100%);
        transition: transform .25s var(--tm-ease);
        box-shadow: var(--tm-shadow-lg);
    }
    .tm-shell.is-mobile-open .tm-sidebar { transform: translateX(0); }
    .tm-shell.is-mobile-open::after {
        content: "";
        position: fixed; inset: 0;
        background: rgba(15,23,42,.4);
        z-index: 25;
    }
    .tm-topbar__toggle { display: inline-flex; }
}

@media (max-width: 640px) {
    :root { --tm-content-pad: 16px; }
    .tm-page-header { flex-direction: column; align-items: flex-start; }
    .tm-auth__form { padding: 24px 18px; border-radius: var(--tm-radius-lg); }
}
