/* ============================================================
   Lighthouse V2 - Light Theme Design System
   Professional, Clean, Production-Ready
   ============================================================ */

:root {
    --bg-page: #f5f6f8;
    --bg-white: #ffffff;
    --bg-hover: #f0f2f5;
    --bg-active: #e8eaed;
    --bg-input: #f5f6f8;

    --text-primary: #1a1a1a;
    --text-secondary: #5f6368;
    --text-muted: #9aa0a6;
    --text-accent: #e67c34;

    --accent: #e67c34;
    --accent-hover: #d06a28;
    --accent-light: rgba(230, 124, 52, 0.08);

    --blue: #1a73e8;
    --blue-light: rgba(26, 115, 232, 0.08);
    --green: #137333;
    --green-light: rgba(19, 115, 51, 0.08);
    --yellow: #e37400;
    --yellow-light: rgba(227, 116, 0, 0.08);
    --red: #c5221f;
    --red-light: rgba(197, 34, 31, 0.08);
    --purple: #7b1fa2;
    --purple-light: rgba(123, 31, 162, 0.08);

    --border: #e0e0e0;
    --border-light: #f0f0f0;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);

    --radius: 6px;
    --radius-lg: 10px;

    --font: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --transition: 0.15s ease;
}

/* Reset */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 14px;
}

body {
    font-family: var(--font);
    background: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
    height: 100vh;
}

a {
    color: var(--blue);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

button {
    font-family: var(--font);
    cursor: pointer;
    border: none;
    outline: none;
}

/* ============================================================
   APP SHELL
   ============================================================ */
.app-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* --- Top Bar --- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: 48px;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 100;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 6px;
}

.brand-icon {
    font-size: 20px;
    color: var(--accent);
}

.brand-name {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

.brand-tag {
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--accent);
    background: var(--accent-light);
    padding: 1px 5px;
    border-radius: 3px;
}

.topbar-tabs {
    display: flex;
    gap: 2px;
}

.nav-tab {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 500;
    transition: all var(--transition);
}

.nav-tab:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-tab.active {
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 600;
}

.nav-tab .material-icons-round {
    font-size: 17px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-secondary);
    transition: all var(--transition);
}

.icon-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* ============================================================
   MAIN SECTIONS
   ============================================================ */
.main-section {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

.main-section.active {
    display: flex;
}

/* --- Controls Bar (compact) --- */
.controls-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 16px;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    gap: 12px;
    min-height: 40px;
}

.controls-left,
.controls-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* --- Date Controls --- */
.date-controls {
    display: flex;
    gap: 3px;
    align-items: center;
}

.range-btn {
    padding: 4px 10px;
    font-size: 0.78rem;
    font-weight: 500;
    border-radius: 4px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 3px;
}

.range-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.range-btn.active {
    background: var(--accent);
    color: white;
}

.custom-date-wrapper {
    position: relative;
}

.date-display {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-left: 6px;
}

/* --- Action Buttons --- */
.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 0.78rem;
    font-weight: 500;
    border-radius: 4px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    transition: all var(--transition);
}

.action-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.action-btn.primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.action-btn.primary:hover {
    background: var(--accent-hover);
}

.action-btn .material-icons-round {
    font-size: 15px;
}

/* --- Meta Label --- */
.meta-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* --- PDF Export Center --- */
.export-center {
    padding: 24px;
    display: grid;
    grid-template-columns: minmax(320px, 1.2fr) minmax(260px, 0.8fr);
    gap: 24px;
    background: var(--bg);
    min-height: calc(100vh - 160px);
}

.export-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.04);
}

.export-header h2,
.export-header h3 {
    margin: 0 0 6px 0;
    font-size: 1.1rem;
    color: var(--text);
}

.export-header p {
    margin: 0 0 16px 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.export-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.export-section {
    border: 1px solid #edf2f7;
    border-radius: 10px;
    padding: 16px;
    background: #fff;
}

.export-section h4 {
    margin: 0 0 12px 0;
    font-size: 0.95rem;
    color: var(--text);
}

.export-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.export-field-full {
    grid-column: 1 / -1;
}

.export-advanced {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed #e2e8f0;
}

.export-advanced summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--text);
    font-size: 0.85rem;
}

.export-advanced-grid {
    margin-top: 12px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.export-checklist {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 180px;
    overflow-y: auto;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
}

.export-checklist label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    color: var(--text);
}

.export-checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 18px;
    font-size: 0.85rem;
}

.export-field label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.export-field select,
.export-field input[type="text"],
.export-field input[type="date"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.85rem;
    background: #fff;
}

.export-radio-group {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 0.85rem;
    color: var(--text);
}

.export-radio-group label,
.export-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.export-hint {
    margin-top: 6px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.export-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.export-preview {
    border-top: 1px solid #e5e7eb;
    padding-top: 12px;
}

.export-preview-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.export-preview-table {
    max-height: 240px;
    overflow-y: auto;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fafafa;
}

.export-preview-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
}

.export-preview-table th,
.export-preview-table td {
    padding: 8px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
}

.export-preview-table th {
    position: sticky;
    top: 0;
    background: #f1f5f9;
    font-weight: 600;
}

.export-status {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.export-progress {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.export-progress-bar {
    width: 100%;
    height: 10px;
    border-radius: 999px;
    background: #e5e7eb;
    overflow: hidden;
}

.export-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #e67c34, #ffb347);
    transition: width 0.3s ease;
}

.export-progress-text {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.export-log-card {
    grid-column: 1 / -1;
}

.export-log {
    max-height: 320px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 4px;
}

.export-log-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: #fafafa;
    font-size: 0.82rem;
    color: var(--text);
}

.export-log-icon {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    background: #e5e7eb;
    color: #64748b;
}

.export-log-item.success .export-log-icon {
    background: #dcfce7;
    color: #16a34a;
}

.export-log-item.partial .export-log-icon {
    background: #fef3c7;
    color: #d97706;
}

.export-log-item.failed .export-log-icon {
    background: #fee2e2;
    color: #dc2626;
}

.export-log-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.export-log-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

@media (max-width: 1024px) {
    .export-center {
        grid-template-columns: 1fr;
    }
}

/* --- Project Selector --- */
.project-selector {
    display: flex;
    gap: 3px;
}

.project-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    font-size: 0.78rem;
    font-weight: 500;
    border-radius: 4px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    transition: all var(--transition);
}

.project-btn:hover {
    background: var(--bg-hover);
}

.project-btn.active {
    background: var(--bg-active);
    color: var(--text-primary);
    border-color: var(--text-muted);
    font-weight: 600;
}

.project-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
}

/* --- Inline Filters (Modernized) --- */
.inline-filters {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-page);
    padding: 6px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.modern-select {
    appearance: none;
    background: var(--bg-white) url('data:image/svg+xml;charset=US-ASCII,<svg width="12" height="12" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%2364748b"><path d="M7 10l5 5 5-5z"/></svg>') no-repeat right 10px center;
    padding: 6px 30px 6px 14px;
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.modern-select:hover {
    border-color: var(--blue);
}

.modern-select:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-inline {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 0 10px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
    transition: all 0.2s;
}

.search-inline:focus-within {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-inline .material-icons-round {
    font-size: 16px;
    color: var(--text-muted);
}

.search-inline input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 0.82rem;
    padding: 7px 0;
    font-weight: 500;
    font-family: var(--font);
    width: 130px;
}

.search-inline input::placeholder {
    color: var(--text-muted);
    font-weight: 500;
}

.filter-reset-btn {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--text-muted);
    border-radius: 6px;
    transition: all var(--transition);
}

.filter-reset-btn:hover {
    background: var(--bg-white);
    color: var(--red);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.filter-reset-btn .material-icons-round {
    font-size: 18px;
}

/* --- Project Pulse Dashboard --- */
.pulse-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.pulse-card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.pulse-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: transparent;
    transition: all 0.3s;
}

.pulse-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-light);
}

.pulse-card.active-filter {
    background: #f8fafc;
    border-color: var(--blue);
}

.pulse-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pulse-data {
    display: flex;
    flex-direction: column;
}

.pulse-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

.pulse-val {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}

/* Specific pulse colors */
.pulse-card.stagnant::before {
    background: var(--red);
}

.pulse-card.stagnant .pulse-icon {
    background: #fee2e2;
    color: var(--red);
}

.pulse-card.review::before {
    background: var(--yellow);
}

.pulse-card.review .pulse-icon {
    background: #fef3c7;
    color: var(--yellow);
}

.pulse-card.closed::before {
    background: var(--green);
}

.pulse-card.closed .pulse-icon {
    background: #d1fae5;
    color: var(--green);
}

.pulse-card.hot::before {
    background: var(--blue);
}

.pulse-card.hot .pulse-icon {
    background: #dbeafe;
    color: var(--blue);
}

/* --- Stat Chips (APC compact summary) --- */
.stat-chips {
    display: flex;
    gap: 6px;
    align-items: center;
}

.stat-chip {
    font-size: 0.72rem;
    color: var(--text-secondary);
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--bg-hover);
    font-weight: 500;
}

.stat-chip b {
    font-weight: 700;
    margin-right: 2px;
}

.stat-chip.open b {
    color: var(--blue);
}

.stat-chip.checked b {
    color: var(--yellow);
}

.stat-chip.closed b {
    color: var(--green);
}

/* --- View Toggle (PCR3 Group) --- */
.view-toggle-group {
    display: flex;
    gap: 2px;
    background: var(--bg-input);
    border-radius: 4px;
    padding: 2px;
}

.view-toggle-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 3px;
    background: transparent;
    color: var(--text-muted);
    transition: all var(--transition);
}

.view-toggle-btn:hover {
    color: var(--text-primary);
}

.view-toggle-btn.active {
    background: var(--bg-white);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.view-toggle-btn .material-icons-round {
    font-size: 15px;
}

/* --- Sub Tabs (PCR3 Reports) --- */
.sub-tabs {
    display: flex;
    gap: 1px;
    padding: 4px 16px;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.sub-tabs::-webkit-scrollbar {
    display: none;
}

.sub-tab {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 4px;
    background: transparent;
    color: var(--text-muted);
    white-space: nowrap;
    transition: all var(--transition);
}

.sub-tab:hover {
    color: var(--text-secondary);
    background: var(--bg-hover);
}

.sub-tab.active {
    color: var(--accent);
    background: var(--accent-light);
    font-weight: 600;
}

.sub-tab .material-icons-round {
    font-size: 15px;
}

/* ============================================================
   CONTENT AREA (scrollable)
   ============================================================ */
.content-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    min-height: 0;
    /* critical for flex scrolling */
}

.content-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    gap: 10px;
    color: var(--text-muted);
    font-size: 0.88rem;
}

.content-placeholder.error {
    color: var(--red);
}

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.spin {
    animation: spin 1s linear infinite;
}

/* Also support classes from pcr3_report.js */
.report-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    gap: 10px;
    color: var(--text-muted);
}

.report-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    gap: 10px;
    color: var(--red);
}

.report-error button {
    margin-top: 6px;
    padding: 6px 16px;
    background: var(--accent);
    color: white;
    border-radius: 4px;
    border: none;
    cursor: pointer;
}

/* ============================================================
   DATA TABLE (APC)
   ============================================================ */
.data-table-wrap {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
}

.table-info-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    font-size: 0.75rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-light);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    padding: 8px 12px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    text-align: left;
    background: var(--bg-page);
    border-bottom: 1px solid var(--border);
    user-select: none;
}

.data-table th.sortable {
    cursor: pointer;
}

.data-table th.sortable:hover {
    color: var(--text-primary);
}

.data-table td {
    padding: 8px 12px;
    font-size: 0.82rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

.data-table tbody tr:hover {
    background: var(--bg-hover);
}

.issue-link {
    font-weight: 600;
    color: var(--blue);
    font-size: 0.8rem;
}

.cell-subject {
    max-width: 380px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.text-muted {
    color: var(--text-muted);
}

.table-empty {
    text-align: center;
    padding: 32px 20px !important;
    color: var(--text-muted);
    font-size: 0.88rem;
}

.table-error {
    color: var(--red);
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    padding: 2px 7px;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 3px;
    white-space: nowrap;
}

.status-open {
    background: var(--blue-light);
    color: var(--blue);
}

.status-checked {
    background: var(--yellow-light);
    color: var(--yellow);
}

.status-closed {
    background: var(--green-light);
    color: var(--green);
}

.status-feedback {
    background: var(--purple-light);
    color: var(--purple);
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
}

.page-btn {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    background: var(--bg-white);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    transition: all var(--transition);
}

.page-btn:hover:not(:disabled) {
    background: var(--bg-hover);
}

.page-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.page-btn .material-icons-round {
    font-size: 16px;
}

.page-info {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ============================================================
   PCR3 GROUP CARDS
   ============================================================ */
.group-card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 10px;
    overflow: hidden;
}

.group-card-header {
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-page);
}

.group-id {
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--accent);
    min-width: 80px;
}

.group-desc {
    flex: 1;
    font-size: 0.82rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.group-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.75rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.group-stat {
    font-weight: 500;
}

.group-stale {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 400;
    font-style: italic;
}

.group-alert {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--yellow);
    padding: 1px 5px;
    border-radius: 3px;
    background: var(--yellow-light);
}

.group-progress {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    color: var(--green);
}

.progress-bar {
    width: 50px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
    display: inline-block;
}

.progress-fill {
    display: block;
    height: 100%;
    background: var(--green);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.group-issues {
    padding: 4px 0;
}

.group-issue-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 14px;
    font-size: 0.78rem;
    border-bottom: 1px solid var(--border-light);
}

.group-issue-row:last-child {
    border-bottom: none;
}

.group-issue-row:hover {
    background: var(--bg-hover);
}

.issue-id {
    font-weight: 600;
    color: var(--blue);
    min-width: 50px;
}

.issue-tag {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-input);
    padding: 1px 5px;
    border-radius: 3px;
    min-width: 40px;
    text-align: center;
}

.issue-subject-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
}

.issue-done-ratio {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    min-width: 30px;
    text-align: center;
}

.issue-assignee {
    font-size: 0.75rem;
    color: var(--text-muted);
    min-width: 100px;
    text-align: right;
}

/* --- Team Overview Grid --- */
.team-overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.team-card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.team-card-header {
    padding: 10px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-page);
}

.team-name {
    font-weight: 700;
    font-size: 0.9rem;
}

.team-total {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.team-card-body {
    padding: 12px 14px;
}

.team-stat {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    margin-bottom: 4px;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.dot.open {
    background: var(--blue);
}

.dot.checked {
    background: var(--yellow);
}

.dot.closed {
    background: var(--green);
}

.team-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* ============================================================
   APC DAILY ACTIVITY
   ============================================================ */
.apc-view-toggle {
    display: flex;
    gap: 3px;
    background: var(--bg-input);
    border-radius: 6px;
    padding: 3px;
    margin-left: 10px;
    border: 1px solid var(--border);
}

.apc-view-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: 4px;
    background: transparent;
    color: var(--text-muted);
    border: none;
    cursor: pointer;
    transition: all var(--transition);
}

.apc-view-btn:hover {
    color: var(--text-primary);
}

.apc-view-btn.active {
    background: var(--bg-white);
    color: var(--accent);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    font-weight: 600;
}

.apc-view-btn .material-icons-round {
    font-size: 16px;
}

/* Daily Navigation Bar */
.daily-nav-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
}

.daily-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--bg-page);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.daily-nav-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.daily-nav-btn.today-btn {
    width: auto;
    padding: 0 12px;
    font-size: 0.82rem;
    font-weight: 600;
}

.daily-date-display {
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    padding: 0 8px;
}

.daily-date-text {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}

.daily-date-display:hover .daily-date-text {
    color: var(--accent);
}

/* Daily Summary Chips */
.daily-summary-chips {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.daily-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-page);
    border: 1px solid var(--border);
    border-radius: 100px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.daily-chip .material-icons-round {
    font-size: 14px;
}

.daily-chip b {
    font-weight: 700;
    color: var(--text-primary);
}

.daily-chip.closed {
    background: var(--green-light);
    border-color: transparent;
}

.daily-chip.closed .material-icons-round,
.daily-chip.closed b {
    color: var(--green);
}

.daily-chip.new {
    background: var(--blue-light);
    border-color: transparent;
}

.daily-chip.new .material-icons-round,
.daily-chip.new b {
    color: var(--blue);
}

.daily-chip.status {
    background: var(--accent-light);
    border-color: transparent;
}

.daily-chip.status .material-icons-round,
.daily-chip.status b {
    color: var(--accent);
}

/* Daily Timeline */
.daily-activity-body {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px 32px;
    min-height: 400px;
}

.daily-timeline {
    display: flex;
    flex-direction: column;
}

.daily-event {
    display: flex;
    gap: 20px;
    position: relative;
    padding-bottom: 24px;
}

.daily-event:last-child {
    padding-bottom: 0;
}

.daily-event::before {
    content: '';
    position: absolute;
    left: 17px;
    top: 35px;
    bottom: 0;
    width: 2px;
    background: var(--border-light);
}

.daily-event:last-child::before {
    display: none;
}

.daily-event-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-white);
    z-index: 1;
}

.daily-event-icon .material-icons-round {
    font-size: 18px;
}

.daily-event-content {
    flex: 1;
    background: var(--bg-page);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    transition: all var(--transition);
}

.daily-event-content:hover {
    border-color: var(--border-light);
    box-shadow: var(--shadow-sm);
    background: var(--bg-white);
}

.daily-event-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.daily-event-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    font-family: monospace;
}

.daily-event-id {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--blue);
}

.daily-event-subject {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.daily-event-body {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.daily-event-author {
    font-weight: 600;
    color: var(--text-primary);
}

.daily-change-arrow {
    display: inline-flex;
    align-items: center;
    font-family: inherit;
}

.daily-extra-changes {
    font-size: 0.7rem;
    background: var(--bg-input);
    padding: 2px 6px;
    border-radius: 100px;
}

.daily-event-batch {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--border-light);
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: auto;
}

.daily-event-note {
    margin-top: 12px;
    padding: 12px 16px;
    background: var(--bg-white);
    border-left: 3px solid var(--border);
    border-radius: 4px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ============================================================
   TOAST
   ============================================================ */
.toast-container {
    position: fixed;
    bottom: 16px;
    right: 16px;
    z-index: 99999;
    display: flex;
    flex-direction: column-reverse;
    gap: 6px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    font-size: 0.82rem;
    color: var(--text-primary);
    transform: translateX(120%);
    transition: transform 0.3s ease;
}

.toast.show {
    transform: translateX(0);
}

.toast-success .material-icons-round {
    color: var(--green);
}

.toast-error .material-icons-round {
    color: var(--red);
}

.toast-info .material-icons-round {
    color: var(--blue);
}

.toast-warning .material-icons-round {
    color: var(--yellow);
}

/* ============================================================
   COMPATIBILITY: PCR3 Report engine & Auth module
   ============================================================ */

#pcr3ReportBody {
    /* CRITICAL: pcr3_report.js replaces className to 'report-modal-body ...'
       which removes .content-area. This ID rule re-applies scrolling. */
    flex: 1;
    overflow-y: auto !important;
    overflow-x: hidden;
    padding: 16px;
    min-height: 0;
    /* Override report-modal-body fixed max-height from V1 CSS */
    max-height: none !important;
}

/* Hide modal overlay from pcr3_report.js */
.report-modal-overlay {
    display: none !important;
}

#pcr3ReportBody {
    min-height: 200px;
}

/* User profile badge from auth.js */
.user-profile-badge:hover {
    background: var(--bg-hover) !important;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal-overlay.show,
.modal-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

.modal {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 640px;
    max-height: 85vh;
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
    transform: scale(0.98);
    transition: transform 0.2s ease;
}

.modal-overlay.show .modal,
.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text);
}

.modal-body {
    padding: 16px 20px;
    max-height: 70vh;
    overflow-y: auto;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
}

.lh-profile-modal {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    width: 380px;
    max-width: 90vw;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.lh-profile-header {
    padding: 28px 24px 18px;
    text-align: center;
    background: linear-gradient(135deg, #1e3a5f, #2d3250);
    position: relative;
    color: white;
}

.lh-profile-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.2);
}

.lh-profile-name {
    font-size: 1rem;
    font-weight: 700;
    color: white;
    margin-top: 8px;
}

.lh-profile-login {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
}

.lh-profile-body {
    padding: 18px 24px;
}

.lh-profile-info-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.lh-profile-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.lh-profile-icon {
    color: var(--text-muted);
}

.lh-profile-label {
    font-size: 0.68rem;
    color: var(--text-muted);
}

.lh-profile-value {
    font-size: 0.82rem;
    font-weight: 500;
}

.lh-profile-footer {
    padding: 14px 24px;
    border-top: 1px solid var(--border-light);
}

.lh-btn-full {
    width: 100%;
    padding: 8px;
    border-radius: 4px;
    font-size: 0.82rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all var(--transition);
}

.lh-btn-logout {
    background: var(--red-light);
    color: var(--red);
    border: 1px solid rgba(197, 34, 31, 0.15);
}

.lh-btn-logout:hover {
    background: var(--red);
    color: white;
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {

    .topbar,
    .controls-bar,
    .sub-tabs,
    .toast-container {
        display: none !important;
    }

    body {
        background: white;
        overflow: visible;
        height: auto;
    }

    .app-shell {
        overflow: visible;
        height: auto;
    }

    .main-section {
        overflow: visible;
    }

    .content-area {
        overflow: visible;
        padding: 0;
    }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
    .controls-bar {
        flex-direction: column;
        align-items: flex-start;
        padding: 8px 12px;
    }

    .inline-filters {
        flex-wrap: wrap;
    }

    .stat-chips {
        flex-wrap: wrap;
    }

    .nav-tab-label {
        display: none;
    }

    .team-overview-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   SIT6 外圍測試追蹤
   ============================================================ */
.controls-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
}

.sit6-live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    animation: sit6-pulse 2s infinite;
    margin-left: 4px;
}

@keyframes sit6-pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(34,197,94,0.4); }
    50% { opacity: 0.7; box-shadow: 0 0 0 4px rgba(34,197,94,0); }
}

.sit6-data-info {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    margin-left: 6px;
}

/* Report Card */
.sit6-report-card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: 20px;
}

.sit6-report-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.sit6-report-card-header h3 {
    margin: 0;
    font-size: 15px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.sit6-report-card-header h3 .material-icons-round {
    font-size: 20px;
    color: var(--accent);
}

/* Table */
.sit6-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.sit6-table thead th {
    background: #1a3a5c;
    color: #fff;
    font-weight: 600;
    padding: 10px 16px;
    text-align: center;
    font-size: 13px;
    white-space: nowrap;
}

.sit6-th-label {
    text-align: left !important;
    width: 80px;
}

.sit6-th-total {
    min-width: 60px;
}

.sit6-table tbody td {
    padding: 10px 16px;
    border: 1px solid #e5e7eb;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.sit6-td-label {
    text-align: left !important;
    background: #f8fafc;
}

.sit6-td-total {
    background: #f0f4f8;
    font-weight: 600;
}

.sit6-row-total td {
    background: #e8edf2;
    border-top: 2px solid #cbd5e1;
}

.sit6-table tbody tr:hover td {
    background: #f0f7ff;
}

.sit6-row-total:hover td {
    background: #dce4ee;
}

/* Notes Card */
.sit6-notes-card {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-left: 4px solid #d4a017;
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 14px 18px;
    margin-top: 20px;
}

.sit6-notes-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}

.sit6-notes-card ol {
    margin: 0;
    padding-left: 20px;
    font-size: 13px;
    line-height: 1.7;
    color: #4a4a2e;
}

.sit6-notes-card ol li {
    margin-bottom: 3px;
}

.sit6-notes-editor {
    width: 100%;
    min-height: 100px;
    border: 1px solid #e5d9a8;
    border-radius: 6px;
    padding: 10px;
    font-size: 13px;
    font-family: inherit;
    line-height: 1.7;
    resize: vertical;
    background: #fffef5;
    box-sizing: border-box;
}

.sit6-notes-editor:focus {
    outline: none;
    border-color: #d4a017;
    box-shadow: 0 0 0 2px rgba(212,160,23,0.2);
}

/* Issue Groups */
.sit6-group {
    margin-bottom: 16px;
}

.sit6-group-header {
    padding: 8px 14px;
    border-left: 4px solid #628DB6;
    background: #f8fafc;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    border-radius: 0 var(--radius) var(--radius) 0;
}

.clickable-row {
    cursor: pointer;
    transition: background 0.12s;
}

.clickable-row:hover {
    background: #f0f7ff !important;
}
