/* =========================================================================
   SDR Tracker — Design System
   ========================================================================= */

/* ---------- 1. Tokens ---------- */
:root {
    /* Brand */
    --brand-primary: #1E2A78;
    --brand-primary-hover: #2A3795;
    --brand-primary-light: #E8EBF7;
    --brand-accent: #3B4ECC;

    /* Neutrals */
    --color-bg: #F7F8FB;
    --color-surface: #FFFFFF;
    --color-sidebar: #FFFFFF;
    --color-sidebar-hover: #F4F5FA;
    --color-sidebar-active: #E8EBF7;
    --color-border: #E5E7EB;
    --color-border-strong: #D1D5DB;
    --color-text: #0F172A;
    --color-text-muted: #6B7280;
    --color-text-subtle: #9CA3AF;

    /* Semantic */
    --color-success: #16A34A;
    --color-success-bg: #DCFCE7;
    --color-error: #DC2626;
    --color-error-bg: #FEE2E2;
    --color-info: #2563EB;
    --color-info-bg: #DBEAFE;
    --color-warning: #D97706;
    --color-warning-bg: #FEF3C7;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 6px rgba(15, 23, 42, 0.05), 0 2px 4px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 10px 15px rgba(15, 23, 42, 0.08), 0 4px 6px rgba(15, 23, 42, 0.04);

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

    /* Spacing */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-size-xs: 12px;
    --font-size-sm: 13px;
    --font-size-base: 14px;
    --font-size-md: 15px;
    --font-size-lg: 17px;
    --font-size-xl: 20px;
    --font-size-2xl: 24px;
    --font-size-3xl: 32px;

    /* Layout */
    --sidebar-width: 240px;
    --sidebar-width-collapsed: 64px;
    --topbar-height: 56px;

    /* SDR palette (used by Module 7 funnel stacked bars) */
    --sdr-color-1: #1E2A78;
    --sdr-color-2: #DC2626;
    --sdr-color-3: #16A34A;
    --sdr-color-4: #D97706;
    --sdr-color-5: #7C3AED;
    --sdr-color-6: #0891B2;
    --sdr-color-7: #BE185D;
    --sdr-color-8: #4D7C0F;
}

/* ---------- 2. Reset / base ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; height: 100%; }

body {
    font-family: var(--font-sans);
    font-size: var(--font-size-base);
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--brand-primary);
    text-decoration: none;
}
a:hover { text-decoration: underline; }

button { font-family: inherit; }
img, svg { display: block; max-width: 100%; }
h1, h2, h3, h4, h5 { margin: 0; line-height: 1.3; color: var(--color-text); }

/* ---------- 3. App shell ---------- */
body.app-shell {
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--color-sidebar);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    z-index: 30;
    transition: width 0.18s ease, transform 0.18s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-5) var(--space-5);
    height: var(--topbar-height);
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text);
    font-weight: 600;
    font-size: var(--font-size-md);
    overflow: hidden;
    white-space: nowrap;
}

.sidebar-brand img {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    object-fit: contain;
    flex: 0 0 28px;
}

.sidebar-brand-text { color: var(--color-text); }

.brand-role-badge {
    font-size: var(--font-size-xs);
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--brand-primary-light);
    color: var(--brand-primary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-left: 4px;
    line-height: 1.4;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4) var(--space-3);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 9px var(--space-3);
    border-radius: var(--radius-md);
    color: var(--color-text-muted);
    font-size: var(--font-size-base);
    font-weight: 500;
    border-left: 3px solid transparent;
    margin-left: -3px;
    white-space: nowrap;
    overflow: hidden;
    text-decoration: none;
}

.sidebar-nav a:hover {
    background: var(--color-sidebar-hover);
    color: var(--color-text);
    text-decoration: none;
}

.sidebar-nav a.active {
    background: var(--color-sidebar-active);
    color: var(--brand-primary);
    border-left-color: var(--brand-primary);
    font-weight: 600;
}

.sidebar-nav a svg { flex: 0 0 18px; }
.sidebar-nav .nav-label { flex: 1; }

.sidebar-footer {
    border-top: 1px solid var(--color-border);
    padding: var(--space-3) var(--space-4);
}

.user-card {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) 0;
    overflow: hidden;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--brand-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: var(--font-size-sm);
    flex: 0 0 36px;
}

.user-info { overflow: hidden; }
.user-name {
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-role {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

.sidebar-collapse-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-muted);
    cursor: pointer;
    margin-left: auto;
}
.sidebar-collapse-btn:hover { color: var(--color-text); background: var(--color-bg); }

/* Collapsed state */
body.sidebar-collapsed .sidebar { width: var(--sidebar-width-collapsed); }
body.sidebar-collapsed .sidebar-brand-text,
body.sidebar-collapsed .brand-role-badge,
body.sidebar-collapsed .sidebar-nav .nav-label,
body.sidebar-collapsed .user-info,
body.sidebar-collapsed .sidebar-collapse-btn { display: none; }
body.sidebar-collapsed .sidebar-nav a { justify-content: center; padding-left: 0; padding-right: 0; }
body.sidebar-collapsed .sidebar-brand { justify-content: center; padding-left: 0; padding-right: 0; }
body.sidebar-collapsed .user-card { justify-content: center; }
body.sidebar-collapsed .main-area { margin-left: var(--sidebar-width-collapsed); }

.main-area {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.18s ease;
}

/* Topbar */
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: 0 var(--space-6);
    transition: box-shadow 0.15s ease;
}

.topbar.scrolled { box-shadow: var(--shadow-sm); }

.topbar-toggle {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.topbar-toggle:hover { color: var(--color-text); background: var(--color-bg); }

.topbar-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--color-text);
}

.topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.logout-form { margin: 0; }

/* Sidebar backdrop (mobile) */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    z-index: 25;
}
body.sidebar-open .sidebar-backdrop { display: block; }

/* Content */
.content {
    flex: 1;
    padding: var(--space-6) var(--space-6) var(--space-10);
    max-width: 1280px;
    width: 100%;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-5);
    flex-wrap: wrap;
}
.page-header h1 {
    font-size: var(--font-size-2xl);
    font-weight: 600;
}

/* ---------- 4. Cards ---------- */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: var(--space-5); }

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
    flex-wrap: wrap;
}
.card-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin: 0;
}
.card-subtitle {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin: var(--space-1) 0 0;
}

.card.table-card { padding: 0; }
.card.table-card > .card-header { padding: var(--space-5) var(--space-6); margin-bottom: 0; border-bottom: 1px solid var(--color-border); }
.card.table-card > .card-footer { padding: var(--space-4) var(--space-6); border-top: 1px solid var(--color-border); color: var(--color-text-muted); font-size: var(--font-size-sm); }

/* ---------- 5. Stat cards ---------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-5);
    margin-bottom: var(--space-6);
}

.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.stat-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-2);
}

.stat-card-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--brand-primary-light);
    color: var(--brand-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-card-icon.bg-info    { background: var(--color-info-bg);    color: var(--color-info); }
.stat-card-icon.bg-success { background: var(--color-success-bg); color: var(--color-success); }
.stat-card-icon.bg-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.stat-card-icon.bg-error   { background: var(--color-error-bg);   color: var(--color-error); }

.stat-card-trend {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: var(--font-size-xs);
    font-weight: 600;
}
.trend-up   { background: var(--color-success-bg); color: var(--color-success); }
.trend-down { background: var(--color-error-bg);   color: var(--color-error); }
.trend-flat { background: var(--color-bg);         color: var(--color-text-muted); }

.stat-card-value {
    font-size: var(--font-size-3xl);
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.1;
}

.stat-card-label {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.stat-card-meta {
    font-size: var(--font-size-xs);
    color: var(--color-text-subtle);
    margin-top: var(--space-1);
}

/* ---------- 6. Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    white-space: nowrap;
    line-height: 1;
}
.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--brand-primary); outline-offset: 2px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary { background: var(--brand-primary); color: #fff; border-color: var(--brand-primary); }
.btn-primary:hover { background: var(--brand-primary-hover); border-color: var(--brand-primary-hover); color: #fff; }

.btn-secondary { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border-strong); }
.btn-secondary:hover { background: var(--color-bg); color: var(--color-text); }

.btn-danger { background: var(--color-error); color: #fff; border-color: var(--color-error); }
.btn-danger:hover { filter: brightness(0.9); color: #fff; }

.btn-danger-outline { background: var(--color-surface); color: var(--color-error); border-color: var(--color-error); }
.btn-danger-outline:hover { background: var(--color-error); color: #fff; }

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

.btn-link { background: none; border: none; color: var(--brand-primary); padding: 0; text-decoration: underline; cursor: pointer; }

.btn-sm { padding: 6px 12px; font-size: var(--font-size-sm); border-radius: var(--radius-sm); }
.btn-lg { padding: 12px 20px; font-size: var(--font-size-md); }
.btn-block { width: 100%; }

/* ---------- 7. Forms ---------- */
.form-group { margin-bottom: var(--space-5); }

.form-label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 500;
    margin-bottom: var(--space-2);
    color: var(--color-text);
}

.form-hint {
    display: block;
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    margin-top: var(--space-1);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 12px;
    font-size: var(--font-size-base);
    font-family: inherit;
    color: var(--color-text);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    transition: border-color 0.15s, box-shadow 0.15s;
    line-height: 1.4;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--brand-primary-light);
}

.form-input.is-invalid,
.form-select.is-invalid,
.form-textarea.is-invalid {
    border-color: var(--color-error);
}

.form-error {
    display: block;
    font-size: var(--font-size-xs);
    color: var(--color-error);
    margin-top: var(--space-1);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-5);
}

.form-actions {
    display: flex;
    gap: var(--space-3);
    margin-top: var(--space-6);
    flex-wrap: wrap;
}

.form-card { max-width: 720px; }

.input-with-icon {
    position: relative;
    display: block;
}
.input-with-icon svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-subtle);
    pointer-events: none;
}
.input-with-icon .form-input { padding-left: 38px; }

/* Monospace textarea (for template body, copy-pasteable outreach copy) */
.form-textarea-mono {
    font-family: 'Menlo', 'Monaco', 'Consolas', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.55;
    white-space: pre-wrap;
}

/* Char counter under textarea */
.char-counter {
    display: block;
    text-align: right;
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    margin-top: var(--space-1);
    font-variant-numeric: tabular-nums;
}
.char-counter.char-warning { color: var(--color-warning); }
.char-counter.char-error   { color: var(--color-error); font-weight: 600; }

/* Filter bar (used on templates list) */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
}
.filter-bar .form-select { min-width: 160px; }

/* Pill platform label */
.platform-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: var(--font-size-sm);
    color: var(--color-text);
}
.platform-tag svg { color: var(--color-text-muted); }

/* Lead detail two-column layout */
.lead-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--space-5);
    align-items: start;
}
@media (max-width: 1023px) {
    .lead-grid { grid-template-columns: 1fr; }
}

/* Definition-list style for lead info */
.info-list {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: var(--space-3) var(--space-4);
    font-size: var(--font-size-sm);
}
.info-list dt {
    color: var(--color-text-muted);
    font-weight: 500;
}
.info-list dd { margin: 0; color: var(--color-text); word-break: break-word; }
.info-list dd a { color: var(--brand-primary); }
.info-list .mono { font-family: 'Menlo', 'Monaco', 'Consolas', 'Courier New', monospace; font-size: 13px; }
@media (max-width: 640px) {
    .info-list { grid-template-columns: 1fr; gap: var(--space-1) 0; }
    .info-list dt { margin-top: var(--space-2); }
}

/* Notes feed */
.note-item {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    background: var(--color-bg);
    margin-bottom: var(--space-3);
}
.note-item:last-child { margin-bottom: 0; }
.note-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    margin-bottom: var(--space-2);
}
.note-body {
    white-space: pre-wrap;
    color: var(--color-text);
    font-size: var(--font-size-sm);
}

/* Activity log list */
.activity-list { list-style: none; padding: 0; margin: 0; }
.activity-list li {
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--color-border);
    font-size: var(--font-size-sm);
}
.activity-list li:last-child { border-bottom: none; }
.activity-action { font-weight: 500; }
.activity-meta { color: var(--color-text-muted); font-size: var(--font-size-xs); margin-top: 2px; }

/* Pagination */
.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-top: var(--space-5);
    flex-wrap: wrap;
}
.pager .pager-info {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
}
.pager .pager-controls {
    display: inline-flex;
    gap: var(--space-2);
}

/* Hidden helper (used by JS-controlled fields) */
.is-hidden { display: none !important; }

/* Task list (Module 5: minimal task view; Module 6 will refine) */
.task-group { margin-top: var(--space-6); }
.task-group:first-child { margin-top: 0; }
.task-group-title {
    font-size: var(--font-size-sm);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    margin: 0 0 var(--space-3);
}

.task-card {
    position: relative;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-4) var(--space-5);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--space-3);
}
.task-card.is-replied {
    border-color: var(--color-error);
    box-shadow: 0 0 0 1px var(--color-error-bg) inset;
}
.task-card.is-overdue {
    border-left: 3px solid var(--color-warning);
}

.task-card-ribbon {
    position: absolute;
    top: 0;
    right: 0;
    padding: 4px 10px;
    background: var(--color-error);
    color: #fff;
    font-size: var(--font-size-xs);
    font-weight: 700;
    letter-spacing: 0.05em;
    border-bottom-left-radius: var(--radius-md);
}

.task-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
    flex-wrap: wrap;
}
.task-card-lead {
    font-size: var(--font-size-md);
    font-weight: 600;
}
.task-card-lead a { color: var(--color-text); }
.task-card-type { font-size: var(--font-size-sm); color: var(--color-text-muted); }
.task-card-when { font-size: var(--font-size-sm); color: var(--color-text-muted); }
.task-card-when .overdue {
    color: var(--color-warning);
    font-weight: 600;
}

.task-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}
.task-card-actions form { display: inline; margin: 0; }

.task-card-note-toggle {
    background: none;
    border: none;
    color: var(--color-info);
    cursor: pointer;
    padding: 0;
    font-size: var(--font-size-sm);
    text-decoration: underline;
}
.task-card-note { margin-top: var(--space-3); }
.task-card-note textarea { min-height: 70px; }

/* ===== Module 6: Dashboard styles ===== */

/* Vertical-rhythm container for dashboard sections.
   Direct children are spaced uniformly via flex gap; any sibling margins
   that exist outside this context (e.g., .stat-grid margin-bottom) are
   neutralized inside the stack so spacing stays consistent. */
.dashboard-stack {
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
}
.dashboard-stack > .stat-grid { margin-bottom: 0; }
.dashboard-stack > .card + .card { margin-top: 0; }

.stat-progress {
    margin-top: var(--space-3);
    height: 6px;
    background: var(--color-bg);
    border-radius: 999px;
    overflow: hidden;
}
.stat-progress-bar {
    height: 100%;
    border-radius: 999px;
    transition: width 0.3s ease;
}
.stat-progress-primary { background: var(--brand-primary); }
.stat-progress-success { background: var(--color-success); }
.stat-progress-warning { background: var(--color-warning); }

/* Period summary card */
.period-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-4);
}
.period-summary-cell {
    background: var(--color-bg);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    text-align: left;
}
.period-summary-cell .num {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.1;
}
.period-summary-cell .lab {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    margin-top: var(--space-1);
}
.period-summary-grid-row2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-4);
    margin-top: var(--space-4);
    max-width: 50%;
}
.period-toggle {
    display: inline-flex;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    padding: 3px;
}
.period-toggle a {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    text-decoration: none;
    font-weight: 500;
}
.period-toggle a.active {
    background: var(--brand-primary);
    color: #fff;
}

/* Hot leads list */
.hot-leads-list { display: flex; flex-direction: column; }
.hot-leads-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--color-border);
}
.hot-leads-row:last-child { border-bottom: none; }
.hot-leads-row a { color: var(--color-text); font-weight: 500; }

/* Quick actions row */
.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
}

/* Tasks page: tabs + chip */
.task-tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    padding: 4px;
    background: var(--color-bg);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-5);
    align-items: center;
}
.task-tab {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text-muted);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s;
    white-space: nowrap;
}
.task-tab:hover { background: var(--color-surface); color: var(--color-text); text-decoration: none; }
.task-tab.active { background: var(--brand-primary); color: #fff; }
.task-tab .tab-count {
    background: rgba(255,255,255,0.2);
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}
.task-tab:not(.active) .tab-count {
    background: var(--color-border);
    color: var(--color-text-muted);
}
.overdue-chip {
    margin-left: auto;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: var(--color-error-bg);
    color: var(--color-error);
    font-size: var(--font-size-sm);
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    border: 1px solid transparent;
}
.overdue-chip.active {
    background: var(--color-error);
    color: #fff;
}
.overdue-chip:hover { text-decoration: none; }
.overdue-chip .dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: currentColor; display: inline-block;
}

/* Task row card (Module 6 polished version) */
.task-row {
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-border-strong);
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: var(--space-4) var(--space-5);
    margin-bottom: var(--space-3);
    box-shadow: var(--shadow-sm);
}
.task-row.is-overdue { border-left-color: var(--color-warning); }
.task-row.is-replied { border-left-color: var(--color-error); background: var(--color-error-bg); }

.task-row-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-3);
    margin-bottom: var(--space-2);
    flex-wrap: wrap;
}
.task-row-leadname a { color: var(--color-text); font-weight: 600; }
.task-row-leadname { display: flex; align-items: center; gap: 6px; }
.task-row-title { font-weight: 600; margin-bottom: 2px; }
.task-row-meta {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}
.task-row-meta .overdue {
    color: var(--color-warning);
    font-weight: 600;
}
.task-row-url {
    font-family: 'Menlo', 'Monaco', 'Consolas', monospace;
    font-size: var(--font-size-xs);
    color: var(--color-info);
    word-break: break-all;
    margin-top: var(--space-2);
}
.task-row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-top: var(--space-3);
    align-items: center;
}
.task-row-pinned-section {
    margin-bottom: var(--space-5);
}
.task-row-pinned-title {
    color: var(--color-error);
    font-size: var(--font-size-sm);
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin: 0 0 var(--space-3);
    display: flex; align-items: center; gap: 6px;
}

/* Admin leaderboard */
.leaderboard-table { width: 100%; }
.leaderboard-row {
    display: grid;
    grid-template-columns: 40px 1fr auto auto auto;
    gap: var(--space-4);
    align-items: center;
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--color-border);
}
.leaderboard-row:last-child { border-bottom: none; }
.leaderboard-row .lb-name a { color: var(--color-text); font-weight: 600; }
.leaderboard-row .lb-num {
    font-variant-numeric: tabular-nums;
    color: var(--color-text);
    font-weight: 500;
}
.leaderboard-row .lb-target {
    font-variant-numeric: tabular-nums;
}
.leaderboard-row .lb-target.below-half { color: var(--color-error); }
.leaderboard-row .lb-target.at-target  { color: var(--color-success); }
.avatar-initials {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--brand-primary-light); color: var(--brand-primary);
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: var(--font-size-sm);
}
.lb-label { font-size: var(--font-size-xs); color: var(--color-text-muted); }

/* Pipeline snapshot */
.pipeline-bar-row {
    display: grid;
    grid-template-columns: 130px 1fr 50px;
    gap: var(--space-3);
    align-items: center;
    margin-bottom: var(--space-3);
    font-size: var(--font-size-sm);
}
.pipeline-bar-row:last-child { margin-bottom: 0; }
.pipeline-bar-row .label { color: var(--color-text); }
.pipeline-bar-row .count {
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--color-text);
    font-weight: 500;
}
.pipeline-bar-track {
    height: 10px;
    background: var(--color-bg);
    border-radius: 999px;
    overflow: hidden;
}
.pipeline-bar-fill {
    height: 100%;
    background: var(--brand-primary);
    border-radius: 999px;
    transition: width 0.3s;
}

/* Activity feed */
.activity-feed-row {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--color-border);
    font-size: var(--font-size-sm);
}
.activity-feed-row:last-child { border-bottom: none; }
.activity-feed-icon {
    flex-shrink: 0;
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--color-bg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
}
.activity-feed-icon.bg-success { background: var(--color-success-bg); color: var(--color-success); }
.activity-feed-icon.bg-error   { background: var(--color-error-bg);   color: var(--color-error); }
.activity-feed-icon.bg-info    { background: var(--color-info-bg);    color: var(--color-info); }
.activity-feed-icon.bg-warning { background: var(--color-warning-bg); color: var(--color-warning); }

.activity-feed-body { flex: 1; }
.activity-feed-body a { color: var(--color-text); }
.activity-feed-meta { color: var(--color-text-muted); font-size: var(--font-size-xs); margin-top: 2px; }

/* Two-column admin dashboard layout */
.admin-feed-grid {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: var(--space-5);
    align-items: start;
}
.admin-feed-grid > .card { margin-top: 0; }
@media (max-width: 1023px) {
    .admin-feed-grid { grid-template-columns: 1fr; }
}

/* Empty state large */
.empty-state-large {
    text-align: center;
    padding: var(--space-10) var(--space-5);
}
.empty-state-large .empty-icon {
    margin: 0 auto var(--space-4);
    width: 56px; height: 56px;
    border-radius: 50%;
    background: var(--color-success-bg);
    color: var(--color-success);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.empty-state-large h3 { font-size: var(--font-size-xl); margin-bottom: var(--space-2); }
.empty-state-large p { color: var(--color-text-muted); margin-bottom: var(--space-5); }

/* Period summary grid responsive */
@media (max-width: 768px) {
    .period-summary-grid { grid-template-columns: repeat(2, 1fr); }
    .period-summary-grid-row2 { max-width: 100%; }
    .leaderboard-row {
        grid-template-columns: 36px 1fr;
        row-gap: var(--space-2);
    }
    .leaderboard-row .lb-num,
    .leaderboard-row .lb-target,
    .leaderboard-row .lb-replies {
        grid-column: 2 / -1;
        display: flex;
        justify-content: space-between;
    }
}

/* Pill toggle (working-days) */
.pill-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.pill-toggle {
    --pill-bg: var(--color-surface);
    --pill-color: var(--color-text-muted);
    --pill-border: var(--color-border-strong);
    display: inline-flex;
    align-items: center;
    padding: 7px 14px;
    border-radius: 999px;
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--pill-color);
    background: var(--pill-bg);
    border: 1px solid var(--pill-border);
    cursor: pointer;
    user-select: none;
    transition: all 0.12s ease;
}
.pill-toggle:hover { color: var(--color-text); border-color: var(--brand-primary); }
.pill-toggle.active {
    --pill-bg: var(--brand-primary);
    --pill-color: #fff;
    --pill-border: var(--brand-primary);
}
.pill-toggle input { display: none; }

/* ---------- 8. Tables ---------- */
.table-wrapper { overflow-x: auto; }

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-surface);
}

.table th {
    text-align: left;
    padding: 12px 16px;
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg);
}

.table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--color-border);
    font-size: var(--font-size-base);
    color: var(--color-text);
    vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--color-bg); }

.row-actions {
    display: inline-flex;
    gap: var(--space-2);
    flex-wrap: wrap;
}
.row-actions form { display: inline; margin: 0; }

/* ---------- 9. Badges ---------- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: var(--font-size-xs);
    font-weight: 500;
    line-height: 1.5;
}
.badge-success { background: var(--color-success-bg); color: var(--color-success); }
.badge-error   { background: var(--color-error-bg);   color: var(--color-error); }
.badge-info    { background: var(--color-info-bg);    color: var(--color-info); }
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-neutral { background: var(--color-bg);         color: var(--color-text-muted); border: 1px solid var(--color-border); }

/* ---------- 10. Flash ---------- */
.flash {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: var(--space-5);
    border: 1px solid;
    font-size: var(--font-size-base);
    animation: flash-slide-in 0.25s ease;
}
.flash-icon { display: inline-flex; flex: 0 0 auto; }
.flash-content { flex: 1; }
.flash-dismiss {
    margin-left: auto;
    background: transparent;
    border: none;
    cursor: pointer;
    opacity: 0.55;
    color: inherit;
    padding: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.flash-dismiss:hover { opacity: 1; }

.flash-success { background: var(--color-success-bg); color: #166534; border-color: #BBF7D0; }
.flash-error   { background: var(--color-error-bg);   color: #991B1B; border-color: #FECACA; }
.flash-info    { background: var(--color-info-bg);    color: #1E40AF; border-color: #BFDBFE; }
.flash-warning { background: var(--color-warning-bg); color: #92400E; border-color: #FDE68A; }

@keyframes flash-slide-in {
    from { transform: translateY(-6px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

.banner-info {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 12px 16px;
    background: var(--color-info-bg);
    color: #1E40AF;
    border: 1px solid #BFDBFE;
    border-radius: var(--radius-md);
    margin-bottom: var(--space-5);
    font-size: var(--font-size-sm);
}

/* ---------- 11. Auth split-screen ---------- */
body.auth-shell {
    display: grid;
    grid-template-columns: 45% 55%;
    height: 100vh;
    width: 100%;
    overflow: hidden;
}

.auth-brand-panel {
    background: linear-gradient(160deg, var(--brand-primary) 0%, #141d5c 100%);
    color: #fff;
    padding: var(--space-10);
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    overflow: hidden;
    height: 100%;
}

.auth-brand-content { position: relative; z-index: 2; max-width: 420px; }

.auth-logo {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.12);
    padding: 8px;
    margin-bottom: var(--space-5);
}

.auth-brand-content h1 {
    font-size: 28px;
    font-weight: 700;
    color: #fff;
    margin-bottom: var(--space-3);
}

.auth-tagline {
    font-size: var(--font-size-md);
    color: rgba(255, 255, 255, 0.78);
    margin: 0;
    line-height: 1.55;
}

.auth-brand-decoration {
    position: absolute;
    width: 520px;
    height: 520px;
    right: -180px;
    bottom: -180px;
    border-radius: 50%;
    background: radial-gradient(circle at center, rgba(255,255,255,0.10) 0%, rgba(255,255,255,0) 60%);
    z-index: 1;
}
.auth-brand-decoration::before,
.auth-brand-decoration::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.08);
}
.auth-brand-decoration::before {
    inset: 80px;
}
.auth-brand-decoration::after {
    inset: 160px;
    border-color: rgba(255, 255, 255, 0.05);
}

.auth-form-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-8);
    background: var(--color-bg);
    height: 100%;
    overflow-y: auto;
}

.auth-form-card {
    width: 100%;
    max-width: 420px;
    background: var(--color-surface);
    padding: var(--space-8);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--color-border);
}

.auth-form-card h2 {
    font-size: var(--font-size-2xl);
    font-weight: 600;
    margin-bottom: var(--space-1);
}

.auth-form-card .subtitle {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    margin: 0 0 var(--space-6);
}

.auth-form-footer {
    margin-top: var(--space-5);
    text-align: center;
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

/* ---------- 12. Minimal (centered) shell ---------- */
body.minimal-shell {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: var(--space-6);
}

.minimal-card {
    width: 100%;
    max-width: 440px;
    background: var(--color-surface);
    padding: var(--space-8);
    border-radius: var(--radius-xl);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-md);
    text-align: center;
}
.minimal-code {
    font-size: 56px;
    font-weight: 700;
    color: var(--brand-primary);
    margin-bottom: var(--space-2);
    line-height: 1;
}

/* ---------- 13. Utility ---------- */
.muted          { color: var(--color-text-muted); }
.text-subtle    { color: var(--color-text-subtle); }
.text-error     { color: var(--color-error); }
.text-success   { color: var(--color-success); }
.mt-3 { margin-top: var(--space-3); }
.mt-5 { margin-top: var(--space-5); }
.mt-6 { margin-top: var(--space-6); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-5 { margin-bottom: var(--space-5); }
.gap-3 { gap: var(--space-3); }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.skeleton-block {
    background: linear-gradient(90deg, var(--color-bg), #f1f5f9, var(--color-bg));
    background-size: 200% 100%;
    animation: skel-shimmer 1.6s linear infinite;
    border-radius: var(--radius-md);
}
.skeleton-line { height: 12px; margin-bottom: 10px; }
.skeleton-line.short { width: 40%; }
.skeleton-line.medium { width: 70%; }
.skeleton-line.long { width: 100%; }
@keyframes skel-shimmer {
    from { background-position: 200% 0; }
    to   { background-position: -200% 0; }
}

/* ---------- 14. Responsive ---------- */
@media (max-width: 1023px) {
    body.app-shell .sidebar {
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }
    body.app-shell.sidebar-open .sidebar {
        transform: translateX(0);
    }
    .main-area,
    body.sidebar-collapsed .main-area { margin-left: 0; }
    .topbar-toggle { display: inline-flex; }
}

@media (min-width: 1024px) {
    .sidebar-backdrop { display: none !important; }
    .topbar-toggle.mobile-only { display: none; }
}

@media (max-width: 900px) {
    body.auth-shell {
        grid-template-columns: 1fr;
        grid-template-rows: 200px 1fr;
        height: auto;
        min-height: 100vh;
        overflow: visible;
    }
    .auth-brand-panel,
    .auth-form-panel {
        height: auto;
        overflow: visible;
    }
    .auth-brand-panel {
        padding: var(--space-6);
        justify-content: center;
        text-align: center;
    }
    .auth-brand-content { margin: 0 auto; }
    .auth-brand-content h1 { font-size: var(--font-size-2xl); }
    .auth-logo { margin: 0 auto var(--space-3); }
    .auth-brand-decoration { right: -200px; bottom: -300px; }
    .auth-form-panel { padding: var(--space-5); }
    .auth-form-card { padding: var(--space-6); }
}

@media (max-width: 768px) {
    .content { padding: var(--space-4) var(--space-4) var(--space-8); }
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-row { grid-template-columns: 1fr; }

    .table-card .table,
    .table-card .table thead,
    .table-card .table tbody,
    .table-card .table tr,
    .table-card .table th,
    .table-card .table td { display: block; width: 100%; }
    .table-card .table thead { display: none; }
    .table-card .table tr {
        border-bottom: 1px solid var(--color-border);
        padding: var(--space-2) 0;
    }
    .table-card .table tr:last-child { border-bottom: none; }
    .table-card .table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: var(--space-3);
        border-bottom: 1px dashed var(--color-border);
        padding: 10px 16px;
    }
    .table-card .table td:last-child { border-bottom: none; }
    .table-card .table td::before {
        content: attr(data-label);
        font-size: var(--font-size-xs);
        font-weight: 600;
        color: var(--color-text-muted);
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }

    .topbar { padding: 0 var(--space-4); }
}

@media (max-width: 480px) {
    .stat-grid { grid-template-columns: 1fr; }
    .auth-form-card { padding: var(--space-5); }
}

/* ===== Module 7: Reports & Per-SDR Detail ===== */

.filter-bar-reports {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    margin-bottom: var(--space-5);
}
.filter-row {
    display: flex;
    gap: var(--space-3);
    flex-wrap: wrap;
    align-items: flex-end;
}
.filter-row + .filter-row { margin-top: var(--space-4); }
.filter-field {
    display: flex;
    flex-direction: column;
    min-width: 140px;
}
.filter-field label {
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    margin-bottom: 4px;
    font-weight: 600;
}
.filter-actions {
    display: flex;
    gap: var(--space-2);
    align-items: flex-end;
}

.funnel-stage { margin-bottom: var(--space-5); }
.funnel-stage-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: var(--space-2);
    gap: var(--space-3);
}
.funnel-stage-label {
    font-weight: 600;
    font-size: var(--font-size-md);
    color: var(--color-text);
}
.funnel-stage-count {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    font-variant-numeric: tabular-nums;
}
.funnel-bar-track {
    display: flex;
    height: 36px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
}
.funnel-bar-segment {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: var(--font-size-xs);
    font-weight: 600;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    cursor: default;
    transition: filter 0.15s;
}
.funnel-bar-segment:hover { filter: brightness(1.12); }
.funnel-bar-empty {
    color: var(--color-text-muted);
    font-size: var(--font-size-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}
.funnel-bar-full {
    background: var(--brand-primary);
    height: 100%;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    padding-left: 12px;
    color: #fff;
    font-weight: 600;
    font-size: var(--font-size-xs);
    transition: width 0.3s ease;
}

.funnel-conversion {
    margin: var(--space-2) 0 var(--space-4) 0;
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    display: flex;
    align-items: center;
    gap: 6px;
}

.funnel-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3) var(--space-4);
    margin-top: var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--color-border);
}
.funnel-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}
.funnel-legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex: 0 0 12px;
}

/* SDR palette swatch helpers */
.sdr-color-1 { background: var(--sdr-color-1); }
.sdr-color-2 { background: var(--sdr-color-2); }
.sdr-color-3 { background: var(--sdr-color-3); }
.sdr-color-4 { background: var(--sdr-color-4); }
.sdr-color-5 { background: var(--sdr-color-5); }
.sdr-color-6 { background: var(--sdr-color-6); }
.sdr-color-7 { background: var(--sdr-color-7); }
.sdr-color-8 { background: var(--sdr-color-8); }

/* Per-SDR detail header */
.sdr-detail-header {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    margin-bottom: var(--space-5);
    display: flex;
    align-items: center;
    gap: var(--space-5);
    box-shadow: var(--shadow-sm);
}
.sdr-detail-header .avatar-initials {
    width: 64px;
    height: 64px;
    font-size: 20px;
    flex: 0 0 64px;
}
.sdr-detail-info { flex: 1; min-width: 0; }
.sdr-detail-info h1 { font-size: var(--font-size-2xl); margin: 0; }
.sdr-detail-info .email {
    color: var(--color-text-muted);
    margin: 4px 0 8px;
    font-size: var(--font-size-sm);
}
.sdr-detail-meta {
    display: flex;
    gap: var(--space-3);
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    flex-wrap: wrap;
    align-items: center;
}
.sdr-detail-actions {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .sdr-detail-header { flex-direction: column; align-items: flex-start; }
    .funnel-bar-segment { font-size: 10px; }
    .filter-field { min-width: 120px; }
}

/* ===== Module 9: Settings, Activity Log, Templates, Profile ===== */

/* Settings page sections */
.settings-section + .settings-section { margin-top: var(--space-6); }
.settings-info-banner {
    margin-top: var(--space-4);
    padding: 12px 16px;
    background: var(--color-info-bg);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    color: var(--color-info);
}

/* System info read-only grid */
.system-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3) var(--space-4);
    font-size: var(--font-size-sm);
    margin: 0;
}
.system-info-grid dt { color: var(--color-text-muted); }
.system-info-grid dd { margin: 0; font-weight: 500; }
@media (max-width: 640px) { .system-info-grid { grid-template-columns: 1fr; gap: var(--space-1) 0; } }

/* Activity log table */
.activity-table { width: 100%; border-collapse: collapse; }
.activity-table th, .activity-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    font-size: var(--font-size-sm);
}
.activity-table .col-details {
    max-width: 360px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: 'Menlo','Monaco','Consolas',monospace;
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}
.actor-role-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    margin-left: 4px;
    vertical-align: middle;
}
.actor-role-admin { background: var(--brand-primary-light); color: var(--brand-primary); }
.actor-role-sdr   { background: var(--color-bg);            color: var(--color-text-muted); }

/* Template cards grid */
.template-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-4);
}
@media (max-width: 1024px) { .template-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px)  { .template-grid { grid-template-columns: 1fr; } }

.template-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
}
.template-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-3);
}
.template-card-title {
    font-weight: 600;
    font-size: var(--font-size-md);
    margin-bottom: var(--space-2);
    color: var(--color-text);
}
.template-card-body {
    font-family: 'Menlo','Monaco','Consolas',monospace;
    font-size: var(--font-size-sm);
    background: var(--color-bg);
    padding: var(--space-3);
    border-radius: var(--radius-sm);
    white-space: pre-wrap;
    flex: 1;
    margin-bottom: var(--space-3);
    max-height: 150px;
    overflow: hidden;
}
.template-card-body.expanded { max-height: none; }
.template-card-actions { display: flex; gap: 8px; justify-content: space-between; align-items: center; }

/* Toast notification */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--color-text);
    color: white;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: var(--font-size-sm);
    z-index: 1000;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }


/* ───────── Module 9.8: Platform tabs (Tasks page) ───────── */
.platform-tabs {
    display: flex;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: var(--space-5);
    gap: var(--space-2);
}
.platform-tab {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 16px 24px;
    text-decoration: none;
    color: var(--color-text-muted);
    font-weight: 500;
    font-size: var(--font-size-md);
    border-bottom: 3px solid transparent;
    margin-bottom: -1px;
    transition: color 0.15s, border-color 0.15s;
}
.platform-tab:hover { color: var(--color-text); text-decoration: none; }
.platform-tab.active {
    color: var(--brand-primary);
    border-bottom-color: var(--brand-primary);
}
.platform-tab svg { flex-shrink: 0; }
.platform-tab-label { font-weight: 600; }
.platform-tab-count {
    background: var(--color-bg);
    color: var(--color-text-muted);
    padding: 2px 10px;
    border-radius: 999px;
    font-size: var(--font-size-xs);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.platform-tab.active .platform-tab-count {
    background: var(--brand-primary-light);
    color: var(--brand-primary);
}

@media (max-width: 640px) {
    .platform-tabs { gap: 0; }
    .platform-tab {
        padding: 12px 16px;
        font-size: var(--font-size-sm);
    }
    .platform-tab-label { display: none; }
}

.empty-state-hint a { color: var(--brand-primary); text-decoration: underline; }
.empty-state-hint a:hover { color: var(--brand-primary-hover); }
