/* ================================
   CSS VARIABLES (Light Mode)
   ================================ */
:root {
    --bg-app: #f0f2f5;
    --bg-card: #fff;
    --bg-card-hover: #f8f9fa;
    --bg-stat: #f8f9fa;
    --bg-track: #f0f2f5;
    --bg-input: #fff;
    --text-primary: #1a1a2e;
    --text-secondary: #555;
    --text-muted: #888;
    --text-body: #333;
    --text-disabled: #aaa;
    --border-color: #e8e8e8;
    --border-light: #f0f0f0;
    --border-tabs: #eee;
    --color-primary: #667eea;
    --color-danger: #e74c3c;
    --color-success: #27ae60;
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --shadow-nav: 0 2px 12px rgba(0, 0, 0, 0.08);
    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.06);
    --shadow-auth: 0 20px 60px rgba(0, 0, 0, 0.2);
    --chart-grid: #e8e8e8;
    --tooltip-bg: #1a1a2e;
    --tooltip-text: #fff;
    --spinner-bg: rgba(255, 255, 255, 0.8);
    --overlay-bg: rgba(0, 0, 0, 0.5);
    --toggle-bg: #ddd;
}

/* ================================
   DARK MODE OVERRIDES
   ================================ */
body.dark {
    --bg-app: #121212;
    --bg-card: #1e1e1e;
    --bg-card-hover: #2a2a2a;
    --bg-stat: #2a2a2a;
    --bg-track: #2a2a2a;
    --bg-input: #2a2a2a;
    --text-primary: #e0e0e0;
    --text-secondary: #bbb;
    --text-muted: #888;
    --text-body: #d0d0d0;
    --text-disabled: #666;
    --border-color: #333;
    --border-light: #2a2a2a;
    --border-tabs: #333;
    --color-primary: #7b93f5;
    --gradient-primary: linear-gradient(135deg, #7b93f5 0%, #9b6fd4 100%);
    --shadow-nav: 0 2px 12px rgba(0, 0, 0, 0.3);
    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.2);
    --shadow-auth: 0 20px 60px rgba(0, 0, 0, 0.5);
    --chart-grid: #333;
    --tooltip-bg: #333;
    --tooltip-text: #e0e0e0;
    --spinner-bg: rgba(30, 30, 30, 0.8);
    --overlay-bg: rgba(0, 0, 0, 0.7);
    --toggle-bg: #444;
}

/* ================================
   BASE
   ================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    min-height: 100vh;
    background: var(--gradient-primary);
}

/* ================================
   AUTH VIEW
   ================================ */
#auth-view {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.auth-container {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-auth);
    margin: 20px;
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-header h1 {
    font-size: 28px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.auth-header p {
    color: var(--text-muted);
    font-size: 14px;
}

.tabs {
    display: flex;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--border-tabs);
}

.tab {
    flex: 1;
    text-align: center;
    padding: 12px;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-disabled);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.3s, border-color 0.3s;
}

.tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 15px;
    transition: border-color 0.3s;
    outline: none;
    background: var(--bg-input);
    color: var(--text-body);
}

.form-group input:focus {
    border-color: var(--color-primary);
}

.submit-btn {
    width: 100%;
    padding: 14px;
    background: var(--gradient-primary);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.3s, transform 0.1s;
    margin-top: 8px;
}

.submit-btn:hover {
    opacity: 0.9;
}

.submit-btn:active {
    transform: scale(0.98);
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.auth-error {
    color: var(--color-danger);
    font-size: 13px;
    margin-top: 12px;
    text-align: center;
    display: none;
}

/* ================================
   DASHBOARD VIEW
   ================================ */
#dashboard-view {
    display: none;
    min-height: 100vh;
    background: var(--bg-app);
    padding-bottom: 80px;
}

.dashboard-nav {
    background: var(--bg-card);
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-nav);
    position: sticky;
    top: 0;
    z-index: 100;
}

.dashboard-nav h1 {
    font-size: 22px;
    color: var(--text-primary);
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

#user-name {
    font-weight: 600;
    color: var(--text-secondary);
}

#logout-btn {
    padding: 8px 16px;
    background: none;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: border-color 0.3s, color 0.3s;
}

#logout-btn:hover {
    border-color: var(--color-danger);
    color: var(--color-danger);
}

.dashboard-main {
    max-width: 800px;
    margin: 24px auto;
    padding: 0 20px;
}

/* Screens */
.screen {
    display: none;
    flex-direction: column;
    gap: 20px;
}

.screen.active {
    display: flex;
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow-card);
}

.card h2 {
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 16px;
}

/* Weight input */
.weight-input-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.weight-input-row input[type="number"] {
    flex: 1;
    min-width: 100px;
    padding: 12px 14px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 18px;
    outline: none;
    transition: border-color 0.3s;
    background: var(--bg-input);
    color: var(--text-body);
}

.weight-input-row input[type="number"]:focus {
    border-color: var(--color-primary);
}

.weight-input-row input[type="date"] {
    padding: 11px 14px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s;
    color: var(--text-secondary);
    background: var(--bg-input);
}

.weight-input-row input[type="date"]:focus {
    border-color: var(--color-primary);
}

.unit-label {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-muted);
}

.weight-submit-btn {
    padding: 12px 24px;
    background: var(--gradient-primary);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.3s, transform 0.1s;
    white-space: nowrap;
    min-height: 44px;
}

.weight-submit-btn:hover {
    opacity: 0.9;
}

.weight-submit-btn:active {
    transform: scale(0.98);
}

#last-entry {
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-muted);
}

.weight-feedback {
    margin-top: 8px;
    font-size: 13px;
    font-weight: 500;
    display: none;
}

.weight-feedback.success {
    color: var(--color-success);
    display: block;
}

.weight-feedback.error {
    color: var(--color-danger);
    display: block;
}

/* Chart controls */
.chart-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.chart-controls button {
    padding: 6px 14px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-card);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    min-height: 44px;
}

.chart-controls button.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

.chart-controls button:hover:not(.active) {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

#chart-container {
    width: 100%;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#chart-container svg {
    width: 100%;
    height: auto;
}

.empty-chart {
    color: var(--text-disabled);
    font-size: 15px;
    text-align: center;
    padding: 60px 0;
}

/* D3 chart styles */
.grid line {
    stroke: var(--chart-grid);
    stroke-dasharray: 2,2;
}

.grid .domain {
    display: none;
}

.axis text {
    font-size: 12px;
    fill: var(--text-muted);
}

.axis .domain {
    stroke: var(--chart-grid);
}

.axis line {
    stroke: var(--chart-grid);
}

.chart-dot {
    fill: var(--color-primary);
    cursor: pointer;
    transition: r 0.2s;
}

.chart-dot:hover {
    r: 6;
}

.chart-tooltip {
    position: absolute;
    background: var(--tooltip-bg);
    color: var(--tooltip-text);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    white-space: nowrap;
    z-index: 1000;
}

/* Stats */
.stats-row {
    display: flex;
    gap: 16px;
}

.stat {
    flex: 1;
    text-align: center;
    padding: 16px;
    background: var(--bg-stat);
    border-radius: 12px;
}

.stat-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.stat-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-value.positive {
    color: var(--color-danger);
}

.stat-value.negative {
    color: var(--color-success);
}

/* ================================
   ENTRIES TABLE
   ================================ */
.entries-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.entries-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border-tabs);
}

.entries-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-body);
}

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

.entry-actions {
    display: flex;
    gap: 8px;
}

.entry-btn {
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: opacity 0.2s;
    min-height: 32px;
}

.entry-edit {
    background: #e8efff;
    color: var(--color-primary);
}

body.dark .entry-edit {
    background: rgba(123, 147, 245, 0.15);
}

.entry-delete {
    background: #fde8e8;
    color: var(--color-danger);
}

body.dark .entry-delete {
    background: rgba(231, 76, 60, 0.15);
}

.entry-btn:hover {
    opacity: 0.8;
}

.empty-state {
    color: var(--text-disabled);
    font-size: 14px;
    text-align: center;
    padding: 32px 0;
}

/* ================================
   TOAST NOTIFICATIONS
   ================================ */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    transform: translateX(120%);
    transition: transform 0.3s ease;
    pointer-events: auto;
    max-width: 320px;
}

.toast-visible {
    transform: translateX(0);
}

.toast-success {
    background: var(--color-success);
}

.toast-error {
    background: var(--color-danger);
}

.toast-info {
    background: var(--color-primary);
}

/* ================================
   SPINNER
   ================================ */
.spinner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--spinner-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    z-index: 10;
}

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

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

/* ================================
   CONFIRM DIALOG
   ================================ */
.confirm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--overlay-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.confirm-dialog {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 28px;
    max-width: 340px;
    width: 90%;
    box-shadow: var(--shadow-auth);
}

.confirm-dialog p {
    font-size: 16px;
    color: var(--text-body);
    margin-bottom: 20px;
    text-align: center;
}

.confirm-actions {
    display: flex;
    gap: 12px;
}

.confirm-btn {
    flex: 1;
    padding: 12px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: opacity 0.2s;
    min-height: 44px;
}

.confirm-cancel {
    background: var(--bg-track);
    color: var(--text-secondary);
}

.confirm-ok {
    background: var(--color-danger);
    color: #fff;
}

.confirm-btn:hover {
    opacity: 0.85;
}

/* ================================
   BOTTOM NAVIGATION
   ================================ */
#bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-card);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 8px 0;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
    z-index: 200;
}

.nav-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 12px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-disabled);
    font-size: 11px;
    font-weight: 600;
    transition: color 0.2s;
    min-width: 64px;
    min-height: 44px;
}

.nav-tab svg {
    width: 22px;
    height: 22px;
}

.nav-tab.active {
    color: var(--color-primary);
}

.nav-tab:hover:not(.active) {
    color: var(--text-muted);
}

/* ================================
   HABITS SCREEN
   ================================ */
.habits-sub-nav {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.habits-sub-nav button {
    padding: 8px 18px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-card);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    min-height: 44px;
}

.habits-sub-nav button.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

.habit-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-light);
}

.habit-item:last-child {
    border-bottom: none;
}

.habit-checkbox {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 3px solid var(--border-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.habit-checkbox.checked {
    border-color: currentColor;
    background: currentColor;
}

.habit-checkbox.checked::after {
    content: '';
    width: 10px;
    height: 6px;
    border-left: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(-45deg);
    margin-top: -2px;
}

.habit-info {
    flex: 1;
}

.habit-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-body);
}

.habit-progress {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.habit-add-btn {
    padding: 12px 24px;
    background: var(--gradient-primary);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 12px;
    min-height: 44px;
}

/* Calendar */
.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.calendar-header h3 {
    font-size: 16px;
    color: var(--text-body);
}

.calendar-nav-btn {
    padding: 8px 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-card);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-primary);
    min-height: 44px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.calendar-day-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-disabled);
    text-align: center;
    padding: 4px;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-body);
    position: relative;
    cursor: pointer;
    transition: box-shadow 0.15s;
}

.calendar-day.selected {
    box-shadow: inset 0 0 0 2px var(--color-primary);
}

.calendar-day.future {
    opacity: 0.3;
    cursor: default;
    pointer-events: none;
}

.calendar-day.today {
    font-weight: 700;
    background: var(--bg-track);
}

.calendar-day.empty {
    color: transparent;
    cursor: default;
    pointer-events: none;
}

.calendar-dots {
    display: flex;
    gap: 2px;
    margin-top: 2px;
}

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

/* Calendar day detail panel */
#calendar-day-detail,
#week-day-detail {
    border-top: 1px solid var(--border-light);
    margin-top: 16px;
    padding-top: 16px;
}

#calendar-day-detail:empty,
#week-day-detail:empty {
    display: none;
}

.day-detail-header {
    font-size: 15px;
    color: var(--text-body);
    margin-bottom: 8px;
}

/* Habit modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--overlay-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.modal {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 28px;
    max-width: 400px;
    width: 90%;
    box-shadow: var(--shadow-auth);
}

.modal h3 {
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 20px;
}

.modal .form-group {
    margin-bottom: 16px;
}

.modal .form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.modal .form-group input,
.modal .form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 14px;
    outline: none;
    background: var(--bg-input);
    color: var(--text-body);
}

.modal .form-group input:focus,
.modal .form-group select:focus {
    border-color: var(--color-primary);
}

.color-swatches {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.color-swatch {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: border-color 0.2s;
}

.color-swatch.selected {
    border-color: var(--text-body);
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.modal-actions button {
    flex: 1;
    padding: 12px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    min-height: 44px;
}

.modal-cancel {
    background: var(--bg-track);
    color: var(--text-secondary);
}

.modal-save {
    background: var(--gradient-primary);
    color: #fff;
}

/* Habit stats */
.habit-stat-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.habit-stat-label {
    width: 100px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.habit-stat-track {
    flex: 1;
    height: 24px;
    background: var(--bg-track);
    border-radius: 12px;
    overflow: hidden;
}

.habit-stat-fill {
    height: 100%;
    border-radius: 12px;
    transition: width 0.5s ease;
}

.habit-stat-pct {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    width: 40px;
    text-align: right;
}

/* ================================
   FRIENDS SCREEN
   ================================ */
.friend-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-light);
}

.friend-item:last-child {
    border-bottom: none;
}

.friend-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
}

.friend-info {
    flex: 1;
}

.friend-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-body);
}

.friend-email {
    font-size: 12px;
    color: var(--text-muted);
}

.friend-actions {
    display: flex;
    gap: 8px;
}

.friend-btn {
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    min-height: 36px;
    transition: opacity 0.2s;
}

.friend-btn:hover {
    opacity: 0.85;
}

.friend-btn-primary {
    background: var(--color-primary);
    color: #fff;
}

.friend-btn-danger {
    background: #fde8e8;
    color: var(--color-danger);
}

body.dark .friend-btn-danger {
    background: rgba(231, 76, 60, 0.15);
}

.friend-btn-accept {
    background: #e8f5e9;
    color: var(--color-success);
}

body.dark .friend-btn-accept {
    background: rgba(39, 174, 96, 0.15);
}

.pending-badge {
    display: inline-block;
    background: var(--color-danger);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    border-radius: 10px;
    padding: 0 6px;
    margin-left: 6px;
}

/* Compare chart legend */
.chart-legend {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-top: 12px;
    font-size: 13px;
    font-weight: 600;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-color {
    width: 12px;
    height: 3px;
    border-radius: 2px;
}

/* ================================
   SETTINGS SCREEN
   ================================ */
.settings-group {
    margin-bottom: 20px;
}

.settings-group h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-light);
}

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

.settings-label {
    font-size: 15px;
    color: var(--text-body);
}

.settings-value {
    font-size: 14px;
    color: var(--text-muted);
}

/* Toggle switch */
.toggle {
    position: relative;
    width: 50px;
    height: 28px;
    cursor: pointer;
}

.toggle input {
    display: none;
}

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--toggle-bg);
    border-radius: 14px;
    transition: background 0.3s;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.3s;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.toggle input:checked + .toggle-slider {
    background: var(--color-primary);
}

.toggle input:checked + .toggle-slider::after {
    transform: translateX(22px);
}

/* ================================
   WEEK VIEW
   ================================ */
.week-strip {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
}

.week-day {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 4px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
    min-width: 0;
}

.week-day:hover {
    background: var(--bg-card-hover);
}

.week-day.selected {
    box-shadow: inset 0 0 0 2px var(--color-primary);
    background: var(--bg-card-hover);
}

.week-day.today {
    font-weight: 700;
    background: var(--bg-track);
}

.week-day.future {
    opacity: 0.3;
    cursor: default;
    pointer-events: none;
}

.week-day-name {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.week-day-num {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-body);
    margin-bottom: 6px;
}

.week-day-dots {
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
    justify-content: center;
}

.week-day-dots .calendar-dot {
    width: 6px;
    height: 6px;
}

/* ================================
   CREATIVE STATS
   ================================ */
.stats-period-toggle {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.stats-period-toggle button {
    padding: 8px 18px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-card);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    min-height: 44px;
}

.stats-period-toggle button.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

#stats-donut-container {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

#stats-donut-container svg {
    overflow: visible;
}

.donut-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    margin-bottom: 24px;
}

.donut-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-body);
}

.donut-legend-color {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.streak-row {
    margin-bottom: 16px;
}

.streak-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.streak-habit-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-body);
}

.streak-info {
    font-size: 12px;
    color: var(--text-muted);
}

.streak-cells {
    display: flex;
    gap: 3px;
}

.streak-cell {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    background: var(--bg-track);
}

.streak-cell.filled {
    opacity: 1;
}

.streak-cell.empty {
    opacity: 1;
}

/* ================================
   RESPONSIVE
   ================================ */
@media (max-width: 600px) {
    .dashboard-nav {
        padding: 12px 16px;
    }

    .dashboard-main {
        margin: 16px auto;
    }

    .card {
        padding: 20px;
    }

    .weight-input-row {
        flex-wrap: wrap;
    }

    .weight-input-row input[type="date"] {
        flex: 1;
        min-width: 120px;
    }

    .weight-submit-btn {
        width: 100%;
    }

    .stats-row {
        flex-wrap: wrap;
    }

    .stat {
        min-width: calc(50% - 8px);
    }

    .entries-table th:last-child,
    .entries-table td:last-child {
        text-align: right;
    }

    .entry-actions {
        flex-direction: column;
        gap: 4px;
    }

    .week-strip {
        gap: 3px;
    }

    .week-day {
        padding: 8px 2px;
    }
}

/* Desktop: bottom nav becomes left sidebar */
@media (min-width: 768px) {
    #dashboard-view {
        padding-bottom: 0;
        padding-left: 80px;
    }

    #bottom-nav {
        top: 0;
        bottom: 0;
        right: auto;
        width: 80px;
        flex-direction: column;
        justify-content: flex-start;
        padding: 20px 0;
        padding-bottom: 0;
        box-shadow: 2px 0 12px rgba(0, 0, 0, 0.08);
    }

    .nav-tab {
        padding: 16px 12px;
    }

    .dashboard-nav {
        margin-left: 0;
    }
}

/* Screen reader only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
