/* === CSS Variables === */
:root {
    --primary: #C8102E;
    --primary-dark: #9b0d23;
    --secondary: #f0a500;
    --success: #22c55e;
    --info: #3b82f6;
    --warning: #f59e0b;
    --bg: #f4f4f4;
    --card-bg: #ffffff;
    --text: #1a1a1a;
    --text-secondary: #666666;
    --border: #e5e5e5;
    --header-height: 56px;
    --nav-height: 64px;
    --radius: 12px;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* === Reset === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'PingFang TC', 'Noto Sans TC', 'Microsoft JhengHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; }
input, select { font-family: inherit; }

/* === Header === */
.app-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--header-height);
    background: var(--primary);
    z-index: 100;
    box-shadow: 0 2px 8px rgba(200,16,46,0.35);
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 16px;
    max-width: 600px;
    margin: 0 auto;
}
.header-title { display: flex; align-items: center; gap: 8px; }
.brand { color: #fff; font-size: 22px; font-weight: 900; letter-spacing: 2px; }
.chapter {
    color: rgba(255,255,255,0.9);
    font-size: 13px;
    font-weight: 600;
    padding: 3px 10px;
    background: rgba(255,255,255,0.18);
    border-radius: 20px;
}
.admin-icon-btn {
    background: rgba(255,255,255,0.15);
    border: none;
    width: 38px; height: 38px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.2s;
}
.admin-icon-btn:hover { background: rgba(255,255,255,0.28); }

/* === Main === */
.app-main {
    margin-top: var(--header-height);
    margin-bottom: var(--nav-height);
    padding: 12px;
    min-height: calc(100vh - var(--header-height) - var(--nav-height));
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

/* === Tab Content === */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* === Section Header === */
.section-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 12px; padding: 0 2px;
}
.section-header h2 { font-size: 18px; font-weight: 700; }
.period-badge {
    font-size: 12px; color: var(--primary);
    background: rgba(200,16,46,0.08);
    padding: 3px 10px; border-radius: 20px; font-weight: 600;
}

/* === Stats Grid === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px; margin-bottom: 14px;
}
.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px 12px;
    text-align: center;
    box-shadow: var(--shadow);
    position: relative; overflow: hidden;
}
.stat-card::before {
    content: ''; position: absolute;
    top: 0; left: 0; right: 0; height: 3px;
}
.stat-card.primary::before  { background: var(--primary); }
.stat-card.secondary::before { background: var(--secondary); }
.stat-card.success::before  { background: var(--success); }
.stat-card.info::before     { background: var(--info); }
.stat-card.warning::before  { background: var(--warning); }
.stat-value { font-size: 26px; font-weight: 800; line-height: 1.1; }
.stat-card.primary  .stat-value { color: var(--primary); }
.stat-card.secondary .stat-value { color: var(--secondary); }
.stat-card.success  .stat-value { color: var(--success); }
.stat-card.info     .stat-value { color: var(--info); }
.stat-card.warning  .stat-value { color: var(--warning); }
.stat-span-2 { grid-column: span 2; }
.stat-label { font-size: 12px; color: var(--text-secondary); margin-top: 4px; font-weight: 500; }

/* === Card === */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px;
}
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 14px; }

/* === Progress === */
.progress-item { margin-bottom: 14px; }
.progress-item:last-child { margin-bottom: 0; }
.progress-header { display: flex; justify-content: space-between; margin-bottom: 5px; }
.progress-label { font-size: 13px; font-weight: 600; }
.progress-value { font-size: 12px; color: var(--text-secondary); }
.progress-track { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; transition: width 0.7s ease; background: var(--primary); }
.progress-fill.success { background: var(--success); }
.progress-fill.warning { background: var(--warning); }
.progress-pct { font-size: 11px; color: var(--text-secondary); text-align: right; margin-top: 3px; }

/* === Top 3 === */
.top3-list { display: flex; flex-direction: column; gap: 10px; }
.top3-item { display: flex; align-items: center; gap: 12px; padding: 10px; background: var(--bg); border-radius: 10px; }
.rank-badge { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.rank-1 { background: #fff3cd; }
.rank-2 { background: #f0f0f0; }
.rank-3 { background: #fde8d8; }
.rank-4 { background: var(--bg); color: var(--text-secondary); font-size: 13px; font-weight: 700; }
.top3-name { font-size: 14px; font-weight: 700; flex: 1; }
.top3-value { font-size: 15px; font-weight: 800; color: var(--primary); text-align: right; }
.top3-label { font-size: 11px; color: var(--text-secondary); text-align: right; }

/* === Performance Table === */
.performance-table-wrap {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    border-radius: var(--radius); box-shadow: var(--shadow);
}
.perf-table {
    width: 100%; border-collapse: collapse;
    background: var(--card-bg); font-size: 13px; min-width: 400px;
}
.perf-table thead tr { background: var(--primary); color: #fff; }
.perf-table th { padding: 10px 8px; text-align: center; font-weight: 600; font-size: 12px; white-space: nowrap; }
.perf-table th:first-child { text-align: left; padding-left: 14px; }
.perf-table td { padding: 10px 8px; text-align: center; border-bottom: 1px solid var(--border); }
.perf-table td:first-child { text-align: left; padding-left: 14px; }
.perf-table tbody tr:last-child td { border-bottom: none; }
.perf-table tbody tr:hover { background: rgba(200,16,46,0.03); }
.member-name-cell { font-weight: 700; }
.industry-cell { font-size: 11px; color: var(--text-secondary); }
.num-cell { font-weight: 700; color: var(--text); }
.tyfcb-cell { font-size: 12px; font-weight: 700; color: var(--secondary); }

/* === Goals === */
.goal-metric-card {
    background: var(--card-bg); border-radius: var(--radius);
    padding: 16px; box-shadow: var(--shadow); margin-bottom: 12px;
}
.goal-metric-header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.goal-metric-icon { font-size: 22px; }
.goal-metric-name { font-size: 15px; font-weight: 700; }
.goal-numbers { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 10px; }
.goal-actual { font-size: 26px; font-weight: 800; }
.goal-target-num { font-size: 16px; font-weight: 700; color: var(--text-secondary); text-align: right; }
.goal-target-text { font-size: 11px; color: var(--text-secondary); text-align: right; }

/* === Leaderboard === */
.metric-tabs {
    display: flex; gap: 6px; margin-bottom: 14px;
    overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px;
}
.metric-tab {
    padding: 7px 16px; border: none; border-radius: 20px;
    font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
    background: var(--card-bg); color: var(--text-secondary);
    box-shadow: var(--shadow); transition: all 0.2s;
}
.metric-tab.active { background: var(--primary); color: #fff; }
.leaderboard-list { display: flex; flex-direction: column; gap: 8px; }
.leaderboard-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px; background: var(--card-bg);
    border-radius: 12px; box-shadow: var(--shadow);
}
.lb-rank { width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; border-radius: 50%; font-size: 13px; font-weight: 800; flex-shrink: 0; }
.lb-rank-1 { background: #ffd700; color: #5c4300; font-size: 18px; }
.lb-rank-2 { background: #d4d4d4; color: #444; }
.lb-rank-3 { background: #cd7f32; color: #fff; }
.lb-rank-other { background: var(--bg); color: var(--text-secondary); font-size: 12px; }
.lb-info { flex: 1; }
.lb-name { font-size: 14px; font-weight: 700; }
.lb-industry { font-size: 11px; color: var(--text-secondary); }
.lb-value { font-size: 20px; font-weight: 800; color: var(--primary); text-align: right; }
.lb-unit { font-size: 11px; color: var(--text-secondary); text-align: right; }

/* === Attendance === */
.attendance-overview { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.att-stat { background: var(--card-bg); border-radius: 10px; padding: 12px 8px; text-align: center; box-shadow: var(--shadow); }
.att-stat-num { font-size: 24px; font-weight: 800; }
.att-stat-num.present { color: var(--success); }
.att-stat-num.absent  { color: var(--primary); }
.att-stat-num.rate    { color: var(--info); }
.att-stat-label { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
.attendance-list { display: flex; flex-direction: column; gap: 6px; }
.att-item { display: flex; align-items: center; justify-content: space-between; padding: 11px 14px; background: var(--card-bg); border-radius: 10px; box-shadow: var(--shadow); }
.att-member-name { font-size: 14px; font-weight: 600; }
.att-status { padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.att-present    { background: #d1fae5; color: #065f46; }
.att-absent     { background: #fee2e2; color: #991b1b; }
.att-substitute { background: #fef3c7; color: #92400e; }
.att-leave      { background: #e0e7ff; color: #3730a3; }
.att-late       { background: #fff7ed; color: #c2410c; }

/* === Bottom Nav === */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    height: var(--nav-height);
    background: var(--card-bg);
    display: flex; border-top: 1px solid var(--border);
    z-index: 100; box-shadow: 0 -2px 10px rgba(0,0,0,0.07);
    max-width: 600px; margin: 0 auto;
}
.nav-btn {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 2px;
    border: none; background: none; cursor: pointer; padding: 6px 0;
    transition: all 0.15s;
}
.nav-icon { font-size: 20px; line-height: 1; }
.nav-label { font-size: 9px; color: var(--text-secondary); font-weight: 500; }
.nav-btn.active .nav-label { color: var(--primary); font-weight: 700; }
.nav-btn.active .nav-icon { transform: scale(1.12); }

/* === Modal === */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    display: none;
    align-items: flex-end; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--card-bg);
    width: 100%; max-width: 600px;
    max-height: 90vh; border-radius: 20px 20px 0 0;
    overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.modal-small { border-radius: 16px; max-height: 80vh; width: calc(100% - 32px); margin: auto; }
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid var(--border);
    position: sticky; top: 0; background: var(--card-bg); z-index: 10;
}
.modal-header h2, .modal-header h3 { font-size: 17px; font-weight: 700; }
.modal-close { background: var(--bg); border: none; width: 32px; height: 32px; border-radius: 50%; font-size: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center; }

/* === Admin Panel === */
.admin-login-form { padding: 24px 20px; display: flex; flex-direction: column; gap: 12px; }
.admin-hint { font-size: 14px; color: var(--text-secondary); text-align: center; }
.admin-tabs {
    display: flex; border-bottom: 2px solid var(--border);
    overflow-x: auto; padding: 0 16px;
}
.admin-tab {
    padding: 10px 12px; border: none; background: none;
    font-size: 13px; font-weight: 600; cursor: pointer;
    color: var(--text-secondary); white-space: nowrap;
    border-bottom: 2px solid transparent; margin-bottom: -2px;
    transition: all 0.2s;
}
.admin-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.admin-tab-content { display: none; padding: 16px 20px; }
.admin-tab-content.active { display: block; }
.admin-actions { margin-bottom: 12px; }
.admin-form { background: var(--bg); border-radius: 12px; padding: 16px; margin-top: 12px; }
.admin-form h4 { font-size: 15px; margin-bottom: 12px; }
.admin-settings { display: flex; gap: 16px; padding: 12px 20px; border-top: 1px solid var(--border); }
.goals-admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }

/* === Form === */
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }
.input-field {
    width: 100%; padding: 10px 12px;
    border: 1.5px solid var(--border); border-radius: 10px;
    font-size: 14px; outline: none; transition: border-color 0.2s;
    background: var(--card-bg); color: var(--text);
}
.input-field:focus { border-color: var(--primary); }
.select-mini {
    padding: 5px 10px; border: 1.5px solid var(--border);
    border-radius: 8px; font-size: 12px; outline: none;
    background: var(--card-bg); color: var(--text); cursor: pointer;
}
.form-actions { display: flex; gap: 8px; margin-top: 12px; }

/* === Buttons === */
.btn-primary {
    background: var(--primary); color: #fff; border: none;
    padding: 12px 20px; border-radius: 10px;
    font-size: 14px; font-weight: 700; cursor: pointer; width: 100%;
    transition: background 0.2s;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-secondary {
    background: var(--bg); color: var(--text);
    border: 1.5px solid var(--border); padding: 10px 16px;
    border-radius: 10px; font-size: 14px; font-weight: 600;
    cursor: pointer; flex: 1;
}
.btn-text { background: none; border: none; font-size: 13px; color: var(--text-secondary); cursor: pointer; padding: 6px 0; }
.btn-logout { color: var(--primary); }
.btn-sm { font-size: 13px; padding: 8px 16px; width: auto; }

/* === Member Admin List === */
.member-admin-item { display: flex; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); gap: 10px; }
.member-admin-item:last-child { border-bottom: none; }
.member-admin-info { flex: 1; }
.member-admin-name { font-size: 14px; font-weight: 700; }
.member-admin-sub { font-size: 12px; color: var(--text-secondary); }
.member-edit-btn, .member-delete-btn { background: none; border: none; cursor: pointer; font-size: 16px; padding: 4px 6px; border-radius: 6px; }
.member-edit-btn:hover   { background: var(--bg); }
.member-delete-btn:hover { background: #fee2e2; }

/* === Performance Input === */
.perf-input-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; }
.perf-input-table th { background: var(--bg); padding: 8px 6px; text-align: center; font-size: 11px; font-weight: 600; color: var(--text-secondary); }
.perf-input-table td { padding: 6px 4px; border-bottom: 1px solid var(--border); }
.perf-input-table .name-col { font-size: 13px; font-weight: 600; padding-left: 2px; }
.perf-num-input { width: 58px; padding: 6px 4px; border: 1.5px solid var(--border); border-radius: 6px; font-size: 13px; text-align: center; outline: none; }
.perf-num-input:focus { border-color: var(--primary); }
.tyfcb-input { width: 80px; }

/* === Attendance Input === */
.att-input-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.att-input-item:last-child { border-bottom: none; }
.att-input-name { font-size: 14px; font-weight: 600; }
.att-status-select { padding: 6px 8px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 12px; outline: none; background: var(--card-bg); cursor: pointer; }

/* === Misc === */
.loading-text { text-align: center; color: var(--text-secondary); padding: 24px; font-size: 14px; }
.hint-text { text-align: center; color: var(--text-secondary); font-size: 13px; padding: 16px 0; }
.error-text { color: #dc2626; font-size: 13px; text-align: center; }
.empty-state { text-align: center; padding: 40px 16px; color: var(--text-secondary); }
.empty-state p:first-child { font-size: 40px; margin-bottom: 8px; }

/* === Toast === */
.toast {
    position: fixed; bottom: calc(var(--nav-height) + 14px);
    left: 50%; transform: translateX(-50%);
    background: #1a1a1a; color: #fff;
    padding: 10px 22px; border-radius: 24px;
    font-size: 14px; z-index: 300;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    white-space: nowrap; pointer-events: none;
}

/* === Monthly Report === */
.report-infobar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.report-info-chip { font-size: 12px; font-weight: 600; padding: 4px 10px; background: var(--card-bg); border-radius: 20px; box-shadow: var(--shadow); color: var(--text); }
.light-chip { background: #fff3cd; color: #856404; }

.report-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 12px; }
.report-table { border-collapse: collapse; background: var(--card-bg); font-size: 12px; white-space: nowrap; }
.report-table thead tr { background: var(--primary); color: #fff; }
.report-table th { padding: 8px 10px; text-align: center; font-weight: 600; font-size: 11px; line-height: 1.3; }
.report-table td { padding: 8px 10px; text-align: center; border-bottom: 1px solid var(--border); font-size: 12px; }
.report-sticky { position: sticky; left: 0; z-index: 2; background: inherit; }
.report-table thead .report-sticky { background: var(--primary); }
.row-label { font-weight: 700; font-size: 12px; min-width: 64px; }
.row-target  { background: #dbeafe; } .row-target  .report-sticky { background: #dbeafe; }
.row-actual  { background: #fff;    } .row-actual  .report-sticky { background: #fff;    }
.row-rate    { background: #fce7f3; } .row-rate    .report-sticky { background: #fce7f3; }
.row-last    { background: #f9fafb; } .row-last    .report-sticky { background: #f9fafb; }
.row-diff    { background: #f0fdf4; } .row-diff    .report-sticky { background: #f0fdf4; }
.rate-high   { color: var(--success); font-weight: 800; }
.rate-mid    { color: var(--info); font-weight: 700; }
.rate-low    { color: var(--primary); font-weight: 700; }
.diff-up     { color: var(--info);    font-weight: 700; }
.diff-down   { color: var(--primary); font-weight: 700; }

.report-note { margin-top: 4px; }
.report-note-content { background: var(--card-bg); border-radius: 10px; padding: 12px 16px; font-size: 13px; color: var(--text); box-shadow: var(--shadow); border-left: 3px solid var(--primary); }

/* Report Admin Input */
.report-admin-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 12px; }
.report-input-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 8px 0; border-radius: 8px; border: 1.5px solid var(--border); }
.report-input-table { border-collapse: collapse; font-size: 12px; white-space: nowrap; background: var(--card-bg); }
.report-input-table thead tr { background: var(--primary); color: #fff; }
.report-input-table th { padding: 7px 8px; text-align: center; font-size: 11px; line-height: 1.3; font-weight: 600; }
.report-input-table td { padding: 5px 4px; border-bottom: 1px solid var(--border); text-align: center; }
.report-input-table .report-sticky { background: var(--bg); }
.report-input-table thead .report-sticky { background: var(--primary); }
.report-cell-input { width: 62px; padding: 5px 3px; border: 1.5px solid var(--border); border-radius: 5px; font-size: 12px; text-align: center; outline: none; background: var(--card-bg); }
.report-cell-input:focus { border-color: var(--primary); }

/* === Visitor Awards === */
.va-strip {
    display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap;
}
.va-item {
    display: flex; align-items: center; gap: 5px;
    background: linear-gradient(135deg, #ecfdf5, #d1fae5);
    border: 1px solid #6ee7b7; border-radius: 20px;
    padding: 5px 12px; font-size: 13px;
}
.va-medal { font-size: 16px; }
.va-name  { font-weight: 600; color: #065f46; }
.va-count { font-size: 12px; color: #059669; font-weight: 700; }

/* === Visitor Invitation Table === */
.visitor-legend {
    display: flex; align-items: center; gap: 6px;
    margin-bottom: 10px; flex-wrap: wrap;
}
.vl-label { font-size: 11px; color: var(--text-secondary); font-weight: 500; }
.vl-item {
    padding: 3px 11px; border-radius: 20px;
    font-size: 11px; font-weight: 700;
}
.vl-0 { background: var(--bg); color: #aaa; border: 1px solid var(--border); }
.vl-1 { background: #d1fae5; color: #065f46; }
.vl-2 { background: #34d399; color: #064e3b; }
.vl-4 { background: #059669; color: #fff; }

.visitor-table-wrap {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    border-radius: var(--radius); box-shadow: var(--shadow);
}
.visitor-table {
    border-collapse: collapse; background: var(--card-bg);
    font-size: 12px; white-space: nowrap; width: 100%;
}
.visitor-table thead tr { background: var(--primary); color: #fff; }
.visitor-table th {
    padding: 9px 6px; text-align: center;
    font-weight: 600; font-size: 11px;
}
.visitor-table th.vt-sticky {
    position: sticky; left: 0;
    background: var(--primary); z-index: 2;
    text-align: left; padding-left: 12px; min-width: 72px;
}
.visitor-table td {
    padding: 8px 6px; text-align: center;
    border-bottom: 1px solid var(--border);
}
.visitor-table td.vt-sticky {
    position: sticky; left: 0;
    background: var(--card-bg); z-index: 1;
    font-weight: 700; font-size: 13px;
    text-align: left; padding-left: 12px;
    border-right: 1px solid var(--border);
}
.visitor-table tbody tr:hover td { background: rgba(200,16,46,0.03); }
.visitor-table tbody tr:hover td.vt-sticky { background: rgba(200,16,46,0.03); }

.vc-0 { color: #d1d5db; }
.vc-1 { background: #d1fae5; color: #065f46; font-weight: 700; }
.vc-2 { background: #34d399; color: #064e3b; font-weight: 800; }
.vc-4 { background: #059669; color: #fff;    font-weight: 800; }

.vt-total-col {
    font-weight: 800; color: var(--primary);
    background: rgba(200,16,46,0.05);
    border-left: 2px solid rgba(200,16,46,0.15);
}
.visitor-table thead .vt-total-col { background: var(--primary-dark); color: #fff; }

.vt-total-row td {
    background: #f8fafc; font-weight: 800;
    border-top: 2px solid var(--border); border-bottom: none;
}
.vt-total-row .vt-sticky { background: #f8fafc; }
.vt-total-label { font-size: 11px; color: var(--text-secondary); font-weight: 600; }
.vt-month-total { color: var(--info); font-weight: 700; }
.vt-grand-total { color: var(--primary); font-weight: 800; }
.vt-star { text-align: center; color: #cbd5e1; font-size: 13px; }

/* === PALMS === */
.palms-legend { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.pl-item { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px; }
.pl-P { background: #dcfce7; color: #166534; }
.pl-A { background: #fee2e2; color: #991b1b; }
.pl-L { background: #fef9c3; color: #854d0e; }
.pl-M { background: #dbeafe; color: #1e40af; }
.pl-S { background: #ede9fe; color: #5b21b6; }

.palms-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); box-shadow: var(--shadow); }
.palms-table { border-collapse: collapse; background: var(--card-bg); font-size: 12px; white-space: nowrap; width: 100%; min-width: 560px; }
.palms-table thead tr { background: var(--primary); color: #fff; }
.palms-table th { padding: 8px 6px; text-align: center; font-weight: 600; font-size: 11px; line-height: 1.3; }
.palms-table th:first-child { text-align: left; padding-left: 12px; }
.palms-table td { padding: 8px 6px; text-align: center; border-bottom: 1px solid var(--border); }
.palms-table tbody tr:last-child td { border-bottom: none; }
.pt-sticky { position: sticky; left: 0; background: var(--card-bg); z-index: 1; }
.palms-table thead th:first-child { position: sticky; left: 0; z-index: 2; background: var(--primary); }
.pt-name { font-weight: 700; text-align: left !important; padding-left: 12px !important; min-width: 68px; }
.pt-num { font-size: 12px; }
.pt-nonzero { font-weight: 700; color: var(--text); }
.pt-special td { color: var(--text-secondary); }
.pt-special .pt-sticky { background: var(--card-bg); }
.pt-total td { font-weight: 800; background: rgba(200,16,46,0.06); border-top: 2px solid var(--primary); }
.pt-total .pt-sticky { background: rgba(200,16,46,0.06); }
.pt-not-yet td { color: #cbd5e1; background: #f8fafc; }
.pt-not-yet .pt-sticky { background: #f8fafc; }
.pt-star { text-align: center !important; color: #94a3b8; }

.palms-badge { display: inline-block; font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 20px; }
.pb-P { background: #dcfce7; color: #166534; }
.pb-A { background: #fee2e2; color: #991b1b; }
.pb-L { background: #fef9c3; color: #854d0e; }
.pb-M { background: #dbeafe; color: #1e40af; }
.pb-S { background: #ede9fe; color: #5b21b6; }

.palms-sel { padding: 4px 2px; border: 1.5px solid var(--border); border-radius: 6px; font-size: 12px; outline: none; background: var(--card-bg); width: 52px; }
.palms-sel:focus { border-color: var(--primary); }

/* === Traffic Light === */
.tl-summary {
    display: flex; gap: 10px; margin-bottom: 16px;
}
.tl-sum {
    flex: 1; text-align: center; padding: 12px 8px;
    border-radius: 12px; background: var(--card-bg);
    box-shadow: var(--shadow);
}
.tl-sum.green  { border-top: 4px solid #22c55e; }
.tl-sum.yellow { border-top: 4px solid #f59e0b; }
.tl-sum.red    { border-top: 4px solid var(--primary); }
.tl-cnt { font-size: 28px; font-weight: 800; line-height: 1.1; }
.tl-sum.green  .tl-cnt { color: #22c55e; }
.tl-sum.yellow .tl-cnt { color: #f59e0b; }
.tl-sum.red    .tl-cnt { color: var(--primary); }
.tl-lbl { font-size: 11px; color: var(--text-secondary); margin-top: 3px; }

.tl-card {
    background: var(--card-bg); border-radius: 12px;
    padding: 14px 14px 10px; margin-bottom: 10px;
    border-left: 5px solid #e5e7eb; box-shadow: var(--shadow);
}
.tl-card.tl-green   { border-left-color: #22c55e; }
.tl-card.tl-yellow  { border-left-color: #f59e0b; }
.tl-card.tl-red     { border-left-color: var(--primary); }
.tl-card.tl-pending { border-left-color: #ccc; opacity: 0.7; }

.tl-card-top {
    display: flex; justify-content: space-between;
    align-items: flex-start; margin-bottom: 10px;
}
.tl-name     { font-size: 16px; font-weight: 700; }
.tl-industry { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.tl-right    { text-align: center; min-width: 52px; }
.tl-total    { font-size: 22px; font-weight: 800; line-height: 1.1; }
.tl-llabel   { font-size: 11px; color: var(--text-secondary); }

.tl-scores { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.tls {
    padding: 3px 9px; border-radius: 20px; font-size: 12px;
    background: var(--bg); color: var(--text-secondary);
}
.tls.tlm {
    background: rgba(34,197,94,0.15); color: #15803d; font-weight: 700;
}
.tl-deficit {
    font-size: 12px; color: #92400e;
    padding: 6px 10px; background: #fef3c7;
    border-radius: 8px; line-height: 1.6;
}
.tl-deficit.tl-ok {
    background: #dcfce7; color: #166534;
}

/* === Desktop Centering === */
@media (min-width: 600px) {
    .bottom-nav { left: 50%; right: auto; width: 600px; transform: translateX(-50%); }
    .app-main { padding: 16px; }
    .stats-grid { grid-template-columns: repeat(5, 1fr); }
    .stat-span-2 { grid-column: span 1; }
}
