:root {
    --primary: #ff5500;
    --bg: #f8f7f5;
    --text-main: #1a1a1a;
    --text-muted: #8a8a8a;
    --border: #e8e4e0;
    --success: #22c55e;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', sans-serif; background-color: var(--bg); color: var(--text-main); }

/* User Security Layouts */
.auth-overlay { position: fixed; inset: 0; background: #0f172a; display: flex; align-items: center; justify-content: center; z-index: 2000; padding: 20px; }
.auth-card { background: white; width: 100%; max-width: 420px; padding: 40px; border-radius: 28px; box-shadow: 0 20px 40px rgba(0,0,0,0.2); }
.auth-card h2 { font-weight: 900; font-size: 1.5rem; margin-bottom: 8px; text-align: center; }
.auth-card h2 span { color: var(--primary); }
.auth-card p { font-size: 0.85rem; color: var(--text-muted); text-align: center; margin-bottom: 30px; }
.auth-buttons { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.auth-error { font-size: 0.75rem; color: #ef4444; text-align: center; margin-top: 15px; font-weight: 600; }
.btn-link { background: none; border: none; color: var(--text-muted); font-size: 0.8rem; cursor: pointer; text-decoration: underline; margin-top: 5px; font-weight: 600; }
.btn-link:hover { color: var(--primary); }
.btn-google { width: 100%; padding: 13px; background: white; border: 1.5px solid var(--border); border-radius: 14px; font-family: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer; color: var(--text-main); display: flex; align-items: center; justify-content: center; transition: background 0.15s, border-color 0.15s, box-shadow 0.15s; }
.btn-google:hover { background: #f8f9fa; border-color: #ccc; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.auth-divider { display: flex; align-items: center; gap: 12px; color: var(--text-muted); font-size: 0.75rem; font-weight: 600; margin: 4px 0; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.auth-buttons #btnMainAuth { width: 100%; padding: 14px; border-radius: 14px; font-family: inherit; font-size: 0.95rem; font-weight: 700; cursor: pointer; border: none; background: var(--primary); color: white; letter-spacing: 0.3px; box-shadow: 0 4px 14px rgba(255,85,0,0.35); transition: background 0.15s, box-shadow 0.15s, transform 0.1s; }
.auth-buttons #btnMainAuth:hover { background: #e64d00; box-shadow: 0 6px 18px rgba(255,85,0,0.45); transform: translateY(-1px); }
.auth-buttons #btnSubAuth { width: 100%; padding: 13px; border-radius: 14px; font-family: inherit; font-size: 0.9rem; font-weight: 700; cursor: pointer; background: white; border: 2px solid var(--primary); color: var(--primary); transition: background 0.15s, box-shadow 0.15s, transform 0.1s; }
.auth-buttons #btnSubAuth:hover { background: #fff3ee; box-shadow: 0 4px 12px rgba(255,85,0,0.15); transform: translateY(-1px); }

.app-header { background: rgba(255, 255, 255, 0.9); backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 100; padding: 15px 40px; border-bottom: 1px solid var(--border); }
.header-main { max-width: 1600px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; }
.logo-lockup { display: flex; align-items: center; gap: 10px; }
.logo-img { height: 36px; width: auto; }
.logo-text { font-size: 1.3rem; font-weight: 900; }
.logo-text span { color: var(--primary); }

.tab-nav { display: flex; background: #f1f5f9; padding: 4px; border-radius: 12px; margin: 0 20px; }
.tab-btn { border: none; padding: 8px 20px; border-radius: 9px; font-weight: 700; font-size: 0.8rem; cursor: pointer; background: transparent; color: var(--text-muted); }
.tab-btn.active { background: white; color: var(--text-main); box-shadow: 0 2px 8px rgba(0,0,0,0.05); }

.action-bar { display: flex; gap: 10px; align-items: center; }
.settings-dropdown { position: relative; }
.settings-menu { display: none; position: absolute; right: 0; top: calc(100% + 8px); background: white; border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 8px 24px rgba(0,0,0,0.1); min-width: 180px; overflow: hidden; z-index: 200; }
.settings-menu.open { display: block; }
.settings-menu button { display: block; width: 100%; text-align: left; padding: 12px 18px; border: none; background: none; font-family: inherit; font-size: 0.82rem; font-weight: 700; color: var(--text-main); cursor: pointer; }
.settings-menu button:hover { background: #f8f9fa; }
.settings-divider { height: 1px; background: var(--border); margin: 4px 0; }
.nav-btn { padding: 10px 18px; border-radius: 12px; font-weight: 700; font-size: 0.75rem; cursor: pointer; border: none; }
.btn-primary { background: var(--primary); color: white; }
.btn-secondary { background: #f1f5f9; color: var(--text-muted); }

.content-area { padding: 30px; width: 100%; max-width: 1600px; margin: 0 auto; }
.view-pane { display: none !important; }
.view-pane.active { display: block !important; }

/* Grid Structural Containers */
.matrix-container { background: white; border-radius: 20px; box-shadow: 0 4px 20px rgba(0,0,0,0.05); border: 1px solid var(--border); width: 100%; overflow-x: auto; }
.modern-table { width: 100%; border-collapse: collapse; }
th, td { padding: 16px 20px; border-bottom: 1px solid #f1f5f9; border-right: 1px solid #f1f5f9; vertical-align: middle; text-align: center; }

/* Base header layout settings */
th { background: #fcfdfe; font-size: 0.65rem; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; min-width: 115px; box-shadow: 0 2px 0 #e2e8f0; }

/* Font Color for Metrics Headings */
.col-stat, th:not(.dynamic-type-th) { color: var(--text-muted); }
.col-date { width: 150px; min-width: 150px; background: #fafbfc; color: var(--primary); font-weight: 800; }

/* Distinct Font Color for Exercise Type Headings */
.dynamic-type-th { color: var(--primary); }
.dynamic-type-th.cat-cardio,  .tick-cell.cat-cardio  { color: #ff5500; }
.dynamic-type-th.cat-gym,     .tick-cell.cat-gym     { color: #6366f1; }
.dynamic-type-th.cat-bodyweight, .tick-cell.cat-bodyweight { color: #10b981; }
.dynamic-type-th.cat-time,    .tick-cell.cat-time    { color: #3b82f6; }
.dynamic-type-th.cat-other,   .tick-cell.cat-other   { color: #8a8a8a; }

/* Interactive Cells */
.tick-cell { font-size: 1.4rem; font-weight: 900; cursor: pointer; transition: transform 0.1s ease; margin: 0 auto; width: max-content; }
.tick-cell.done { color: var(--primary); }
.tick-cell.plan { color: var(--text-muted); background: white; border: 2.5px dashed var(--text-muted); border-radius: 6px; width: 28px; height: 28px; font-size: 0.8rem; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.happy-pill { background: #f1f5f9; width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; border-radius: 50%; font-weight: 800; margin: 0 auto; font-size: 0.9rem; }

/* Insights Section Titles */
.insights-section-title { font-size: 0.7rem; font-weight: 800; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-muted); margin: 30px 0 12px 0; }
.insights-container > .insights-section-title:first-child { margin-top: 0; }

/* Stat card icon */
.stat-icon { font-size: 1.4rem; margin-bottom: 8px; }
.stat-val--sm { font-size: 1.4rem; }

/* Advanced Insights Styling */
.advanced-story-banner { background: #fff7ed; border: 1px solid #ffedd5; border-radius: 24px; padding: 30px; margin-bottom: 30px; }
.advanced-story-banner h3 { font-size: 1rem; color: #c2410c; margin-bottom: 15px; text-transform: uppercase; letter-spacing: 0.5px; }
.story-stack { display: flex; flex-direction: column; gap: 12px; }
.story-item { background: white; padding: 15px 20px; border-radius: 14px; border-left: 5px solid var(--primary); font-size: 0.9rem; font-weight: 600; color: var(--text-main); line-height: 1.5; box-shadow: 0 4px 6px rgba(0,0,0,0.01); }
.neutral-msg { font-size: 0.85rem; color: var(--text-muted); font-style: italic; }

.insights-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 30px; }
.stat-card { background: white; padding: 30px; border-radius: 24px; border: 1px solid var(--border); text-align: center; }
.stat-card label { font-size: 0.7rem; font-weight: 800; text-transform: uppercase; color: var(--text-muted); display: block; margin-bottom: 10px; }
.stat-val { font-size: 2.2rem; font-weight: 900; color: var(--primary); }

.chart-container { background: white; padding: 30px; border-radius: 24px; border: 1px solid var(--border); margin-bottom: 20px; }
.chart-container canvas { max-height: 260px; }
.chart-container h3 { font-size: 0.9rem; margin-bottom: 25px; color: var(--text-muted); text-transform: uppercase; }
.week-compare-grid { background: white; border-radius: 20px; border: 1px solid var(--border); overflow: hidden; margin-bottom: 30px; }
.compare-header { display: grid; grid-template-columns: 1fr 1fr 1fr; padding: 10px 24px; background: #f8f9fa; border-bottom: 1px solid var(--border); font-size: 0.65rem; font-weight: 800; letter-spacing: 0.5px; color: var(--text-muted); }
.compare-header span:not(:first-child) { text-align: center; }
.compare-row { display: grid; grid-template-columns: 1fr 1fr 1fr; padding: 16px 24px; border-bottom: 1px solid #f1f5f9; align-items: center; }
.compare-row:last-child { border-bottom: none; }
.compare-label { font-size: 0.8rem; font-weight: 700; color: var(--text-muted); }
.compare-this { font-size: 1.3rem; font-weight: 900; color: var(--text-main); text-align: center; }
.compare-last { font-size: 1.3rem; font-weight: 900; color: #c0c0c0; text-align: center; }
.compare-arrow { font-size: 0.9rem; margin-left: 4px; }
.compare-arrow.up { color: var(--success); }
.compare-arrow.down { color: #ef4444; }
.compare-unit { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; }
.activity-bars { display: flex; flex-direction: column; gap: 15px; }
.bar-row { display: flex; align-items: center; gap: 15px; }
.bar-label { width: 100px; font-size: 0.75rem; font-weight: 800; text-align: right; }
.bar-outer { flex: 1; height: 12px; background: #f1f5f9; border-radius: 6px; overflow: hidden; }
.bar-inner { height: 100%; background: var(--primary); border-radius: 6px; }

/* Modal Inputs and Strips */
.toggle-container { display: flex; gap: 15px; margin-bottom: 20px; }
.binary-strip { display: flex; gap: 4px; background: #f1f5f9; padding: 4px; border-radius: 10px; flex: 1; }
.bin-btn { flex: 1; border: none; padding: 10px; border-radius: 7px; font-weight: 800; font-size: 0.65rem; cursor: pointer; color: var(--text-muted); background: transparent; }
.bin-btn.active { background: white; color: var(--text-main); box-shadow: 0 2px 5px rgba(0,0,0,0.05); }
.bin-btn.active[id*="Yes"] { color: var(--success); }
.highlight-box { background: #f8fafc; padding: 15px; border-radius: 15px; border: 1px solid var(--border); margin-bottom: 20px; }
.slider-row { display: flex; align-items: center; gap: 15px; margin-top: 5px; }
.slider-row input { flex: 1; accent-color: var(--primary); }
.score-display { font-weight: 900; color: var(--primary); font-size: 1.2rem; width: 25px; text-align: right; }

.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); backdrop-filter: blur(8px); align-items: center; justify-content: center; z-index: 1000; }
.modal-card { background: white; width: 95%; max-width: 480px; border-radius: 24px; padding: 30px; }
.input-row label { display: block; font-weight: 700; font-size: 0.75rem; color: var(--text-muted); margin-bottom: 5px; }
.input-row input[type="date"], .input-row textarea, .input-row select, .input-row input[type="email"], .input-row input[type="password"], .input-row input[type="text"] { width: 100%; padding: 12px; border: 1.5px solid var(--border); border-radius: 10px; font-family: inherit; font-size: 0.9rem; outline: none; }

.rating-strip { display: flex; gap: 8px; }
.rate-btn { flex: 1; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: white; font-weight: 800; font-size: 0.7rem; cursor: pointer; }
.rate-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.btn-submit { width: 100%; padding: 14px; background: var(--primary); color: white; border: none; border-radius: 12px; font-weight: 800; cursor: pointer; margin-top: 15px; }
.btn-delete { width: 100%; padding: 10px; background: #fee2e2; color: #ef4444; border: none; border-radius: 10px; font-weight: 700; font-size: 0.8rem; margin-bottom: 10px; cursor: pointer; }
.add-type-footer { display: flex; gap: 10px; margin-top: 15px; }
.type-editor-list { display: flex; flex-direction: column; gap: 8px; max-height: 200px; overflow-y: auto; }

.dist-label { font-size: 0.7rem; font-weight: 700; color: var(--text-muted); margin-top: 3px; }
.type-category-badge { display: inline-block; background: #fff4ee; color: var(--primary); font-size: 0.7rem; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; padding: 4px 12px; border-radius: 20px; margin: 8px 0 12px 0; border: 1px solid #ffd5c0; }
.distance-input-row { display: flex; gap: 8px; }
.distance-input-row input { flex: 1; }
.distance-input-row select { width: 70px; }

.week-summary-row td { background: #fef6f2; border-top: 3px solid var(--primary); border-bottom: 2px solid #fde8df; cursor: pointer; }
.week-summary-row td:first-child { border-left: 4px solid var(--primary); }
.week-summary-row:hover td { background: #fdeee7; }
.week-summary-label { color: var(--primary) !important; font-weight: 800; }
.week-summary-row td:not(.week-summary-label) { color: var(--text-muted); font-weight: 700; }
.week-toggle-icon { font-size: 0.6rem; margin-right: 6px; }
.alt-row td { background: #fafcff; }

.btn-strava { background: #242428; color: white; }
.btn-strava:hover { background: #3a3a3f; }

.strava-activity-card { background: #fff7f5; border: 1px solid #ffd5c0; border-radius: 16px; padding: 20px 24px; margin-bottom: 20px; }
.strava-type { font-size: 0.65rem; font-weight: 800; text-transform: uppercase; letter-spacing: 1.5px; color: #ff5500; margin-bottom: 6px; }
.strava-name { font-size: 1.1rem; font-weight: 900; color: #1a1a1a; margin-bottom: 4px; }
.strava-date { font-size: 0.8rem; color: #8a8a8a; margin-bottom: 10px; }
.strava-details { font-size: 0.9rem; font-weight: 700; color: #1a1a1a; }

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.close-btn { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--text-muted); }

.help-container { max-width: 960px; margin: 0 auto; }
.help-hero { text-align: center; padding: 40px 20px 50px; }
.help-logo { height: 52px; margin-bottom: 16px; }
.help-hero h2 { font-size: 1.8rem; font-weight: 900; margin-bottom: 10px; }
.help-hero p { color: var(--text-muted); font-size: 0.95rem; }
.help-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; }
.help-card { background: white; border-radius: 20px; border: 1px solid var(--border); padding: 28px; }
.help-icon { font-size: 1.6rem; margin-bottom: 12px; }
.help-card h3 { font-size: 0.9rem; font-weight: 900; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; color: var(--text-main); }
.help-card p { font-size: 0.85rem; color: var(--text-muted); line-height: 1.6; }
.help-card p b { color: var(--text-main); }

.editable-cell { cursor: pointer; }
.editable-cell:hover { background: #fdf4f0 !important; }
.cell-empty { color: #d0d0d0; font-size: 1rem; font-weight: 700; }
.editable-cell:hover .cell-empty { color: var(--primary); }
.empty-type-cell { cursor: pointer; }
.empty-type-cell:hover { background: #fdf4f0 !important; }
.empty-type-cell:hover::after { content: '+'; color: #e0c8bf; font-size: 1rem; font-weight: 700; }

.cell-popover { position: fixed; background: white; border: 1px solid var(--border); border-radius: 16px; padding: 14px 16px; box-shadow: 0 8px 24px rgba(0,0,0,0.12); z-index: 500; min-width: 240px; }
.pop-label { font-size: 0.65rem; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); margin-bottom: 10px; }
.pop-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.pop-btn { width: 34px; height: 34px; border: 1.5px solid var(--border); border-radius: 8px; background: white; font-weight: 800; font-size: 0.8rem; cursor: pointer; color: var(--text-main); }
.pop-btn:hover { border-color: var(--primary); color: var(--primary); }
.pop-btn-active { background: var(--primary); color: white; border-color: var(--primary); }

.chart-empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.chart-empty-state .chart-empty-icon { font-size: 2.5rem; margin-bottom: 12px; }
.chart-empty-state p { font-size: 0.85rem; font-weight: 600; }

@media (max-width: 768px) {
    .app-header { padding: 12px 16px; }
    .header-main { flex-wrap: wrap; gap: 8px; }
    .logo-lockup { flex: 1; min-width: 0; }
    .logo-text { font-size: 1rem; }
    .logo-img { height: 28px; }
    .header-main > div:nth-child(2) { order: 3; width: 100%; justify-content: center; }
    .tab-nav { margin: 0; }
    .action-bar { order: 2; }
    .content-area { padding: 16px; }
}

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