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

:root {
    --app-bg: #e8edf3;
    --surface: #ffffff;
    --surface-muted: #f4f7fa;
    --surface-chip: #f1f4f8;
    --border: #dbe3eb;
    --border-strong: #cfd8dc;
    --text: #1e293b;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --accent: #43a047;
    --accent-soft: #e8f5e9;
    --radius-panel: 14px;
    --radius-control: 10px;
    --shadow-soft: 0 4px 24px rgba(15, 23, 42, 0.06);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--app-bg);
    color: var(--text);
    padding: 12px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 100%;
    margin: 0 auto;
    background: var(--surface);
    border-radius: var(--radius-panel);
    padding: 16px 14px 18px;
    box-shadow: var(--shadow-soft);
    border: 1px solid rgba(255, 255, 255, 0.8);
}

.top-tabs {
    display: flex;
    gap: 6px;
    margin: 0 -2px 4px;
    padding: 0 2px 0;
    border-bottom: 1px solid var(--border);
}

.top-tab {
    border: 1px solid transparent;
    border-bottom: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 10px 10px 0 0;
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    margin-bottom: -1px;
    transition: background 0.15s ease, color 0.15s ease;
}

.top-tab:hover {
    background: rgba(241, 245, 249, 0.9);
    color: var(--text);
}

.top-tab--active {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
    border-bottom-color: var(--surface);
    font-weight: 600;
    box-shadow: 0 -1px 0 var(--surface);
}

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

h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.btn-add {
    background-color: var(--accent);
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    box-shadow: 0 1px 3px rgba(67, 160, 71, 0.35);
}

.btn-add:hover {
    background-color: #388e3c;
}

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

.table-wrapper {
    overflow-x: auto;
    margin-bottom: 30px;
    border-radius: var(--radius-control);
    border: 1px solid var(--border);
    background: var(--surface);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    background: var(--surface);
    border: none;
}

th, td {
    padding: 10px;
    text-align: left;
    border: 1px solid var(--border);
    min-width: 80px;
}

.habit-header {
    background-color: #f8f9fa;
    font-weight: 600;
    position: sticky;
    left: 0;
    z-index: 10;
    min-width: 220px;
    max-width: 280px;
}

thead th:not(.habit-header) {
    background-color: #f8f9fa;
    font-weight: 600;
    text-align: center;
    font-size: 12px;
    padding: 8px 5px;
    min-width: 60px;
}

.month-nav-th {
    min-width: 44px;
    max-width: 52px;
    padding: 6px 4px !important;
    vertical-align: middle;
}

.month-nav-cell {
    min-width: 44px;
    max-width: 52px;
    background-color: #f8f9fa;
}

.month-nav-btn {
    width: 36px;
    height: 34px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    color: #2c3e50;
    padding: 0;
}

.month-nav-btn:hover {
    background: #eef1f4;
}

.month-nav-btn:active {
    transform: scale(0.96);
}

tbody td:first-child {
    background-color: #f8f9fa;
    font-weight: 500;
    position: sticky;
    left: 0;
    z-index: 5;
    min-width: 220px;
    max-width: 280px;
}

.habit-cell {
    cursor: pointer;
    text-align: center;
    background-color: white;
    transition: background-color 0.2s;
    position: relative;
}

.habit-cell:hover {
    background-color: #f0f0f0;
}

.habit-cell.completed {
    background-color: #4CAF50;
}

.habit-cell.completed.completed-gold {
    background-color: #d4af37;
}

.habit-cell.completed::after {
    content: '✓';
    color: white;
    font-weight: bold;
    font-size: 16px;
}

.habit-cell.completed.completed-gold:hover {
    background-color: #bf9a2f;
}

.habit-cell.missed {
    background-color: #c62828;
}

.habit-cell.missed::after {
    content: '✗';
    color: white;
    font-weight: bold;
    font-size: 16px;
}

.habit-cell.missed:hover {
    background-color: #b71c1c;
}

.habit-cell.neutral {
    background-color: #9e9e9e;
}

.habit-cell.neutral::after {
    content: '—';
    color: white;
    font-weight: 600;
    font-size: 14px;
}

.habit-cell.neutral:hover {
    background-color: #757575;
}

.habit-name-cell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
}

.habit-name {
    min-width: 0;
    display: block;
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
    hyphens: auto;
}

.habit-name--editable {
    cursor: pointer;
    text-decoration: underline;
    text-decoration-color: rgba(44, 62, 80, 0.35);
    text-underline-offset: 2px;
}

.habit-name--editable:hover {
    text-decoration-color: rgba(44, 62, 80, 0.65);
}

/* Two buttons (Restore + Delete) did not fit in first-column max-width: 200px */
tbody td.habit-name-cell--archive-actions {
    max-width: 320px;
    min-width: 220px;
    overflow: visible;
    /* Sticky column above date cells so actions stay clickable when table scrolls */
    z-index: 7;
}

tbody td.habit-name-cell--archive-actions .habit-row-actions {
    position: relative;
    z-index: 2;
    /* Always show — do not rely on row hover (fragile in Telegram WebView / after reflow) */
    opacity: 1 !important;
}

.habits-toolbar,
.goals-toolbar {
    margin-bottom: 12px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

/* ——— Tab control stack: actions + filter sections in one card ——— */
.tab-control-stack {
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    padding: 12px 12px 10px;
    margin-bottom: 14px;
}

.tab-control-stack .tab-actions-row.habits-toolbar,
.tab-control-stack .tab-actions-row.goals-toolbar {
    margin-bottom: 0;
    gap: 8px;
}

/* Goals / Tasks: divider under Archive+Tags sits on the row, not under filter chips */
.tab-control-stack .tab-actions-row.goals-toolbar {
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.tab-control-stack .btn-archive,
.tab-control-stack .btn-back-archive,
.tab-control-stack .btn-goal-tags,
.tab-control-stack .btn-habits-stats {
    min-width: 0;
    flex: 1 1 auto;
    max-width: 11rem;
    text-align: center;
    border-radius: 9px;
    font-size: 13px;
    font-weight: 600;
    padding: 9px 12px;
    box-shadow: none;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.tab-control-stack .btn-archive,
.tab-control-stack .btn-back-archive {
    background: var(--surface);
    color: var(--text-secondary);
    border: 1px solid var(--border-strong);
}

.tab-control-stack .btn-archive:hover,
.tab-control-stack .btn-back-archive:hover {
    background: #f8fafc;
    border-color: #b0bec5;
    color: var(--text);
}

.tab-control-stack .btn-habits-stats {
    color: #2e7d32;
    background: var(--surface);
    border: 1px solid #c8e6c9;
    cursor: pointer;
}

.tab-control-stack .btn-habits-stats:hover {
    background: #e8f5e9;
    border-color: #81c784;
    color: #1b5e20;
}

.tab-control-stack .btn-goal-tags {
    color: #3949ab;
    background: var(--surface);
    border: 1px solid #c5cae9;
}

.tab-control-stack .btn-goal-tags:hover {
    background: #e8eaf6;
    border-color: #9fa8da;
    color: #283593;
}

.tab-control-stack > .filter-block {
    margin: 0 -12px;
    padding: 12px 12px 12px;
    border-top: none;
}

/* Tasks: line between tag filters and status only when tag row is shown */
#tasksTabContent .filter-block--task-tags:not(:has(#taskTagFilterRow[hidden])) + .filter-block--status {
    border-top: 1px solid var(--border);
    margin-top: 4px;
    padding-top: 14px;
}

.filter-block__label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.filter-block--goal-tags:has(#goalTagFilterRow[hidden]),
.filter-block--task-tags:has(#taskTagFilterRow[hidden]) {
    display: none;
}

.btn-goal-tags {
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    background: #5c6bc0;
    box-sizing: border-box;
}

.btn-goal-tags:hover {
    background: #3f51b5;
}

/* Match Archive and Tags footprint when toolbar is not inside tab-control-stack */
.goals-toolbar .btn-archive,
.goals-toolbar .btn-goal-tags {
    min-width: 7.25rem;
    text-align: center;
}

.goal-tag-filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin: 0;
}

.tab-control-stack .goal-tag-filter-row {
    margin: 0;
}

.goal-tag-filter-chip {
    border: none;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.15s ease;
}

.goal-tag-filter-chip:hover {
    transform: translateY(-1px);
}

/* Colored tag chips keep inline background from JS; only add a light edge */
.tab-control-stack .goal-tag-filter-chip:not(.goal-tag-filter-chip--all):not(.goal-tag-filter-chip--completion) {
    border: 1px solid rgba(0, 0, 0, 0.12);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.tab-control-stack .goal-tag-filter-chip--all {
    background: var(--surface-chip);
    color: var(--text);
    border: 1px solid var(--border-strong);
}

.tab-control-stack .goal-tag-filter-chip--all.is-active {
    background: #334155;
    color: #fff;
    border-color: #334155;
    box-shadow: 0 0 0 2px rgba(51, 65, 85, 0.25);
}

.goal-tag-filter-chip--all {
    background: #eceff1;
    color: #37474f;
}

.goal-tag-filter-chip--all.is-active {
    background: #37474f;
    color: #fff;
    box-shadow: 0 0 0 2px rgba(55, 71, 79, 0.35);
}

.goal-tag-filter-chip--completion {
    background: #eceff1;
    color: #37474f;
}

.tab-control-stack .goal-tag-filter-chip--completion {
    background: var(--surface);
    color: var(--text-secondary);
    border: 1px solid var(--border-strong);
}

.goal-tag-filter-chip--completion.is-active {
    background: #37474f;
    color: #fff;
    box-shadow: 0 0 0 2px rgba(55, 71, 79, 0.35);
}

.tab-control-stack .goal-tag-filter-chip--completion.is-active {
    background: #1e293b;
    color: #fff;
    border-color: #1e293b;
    box-shadow: 0 0 0 2px rgba(30, 41, 59, 0.2);
}

.goal-tag-filter-chip:not(.goal-tag-filter-chip--all):not(.goal-tag-filter-chip--completion).is-active {
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35);
}

.task-completion-filter-row {
    margin-top: 0;
    margin-bottom: 0;
}

.goals-add-form {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

#goalNameModalInput,
#editGoalNameInput,
#taskNameModalInput,
#editTaskNameInput {
    width: 100%;
    flex: 1;
    min-width: 0;
    box-sizing: border-box;
    border: 1px solid #e3e8ec;
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 16px;
    line-height: 1.35;
    background: #fff;
    color: #2c3e50;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#goalNameModalInput,
#editGoalNameInput {
    margin-bottom: 16px;
}

#taskNameModalInput,
#editTaskNameInput {
    margin-bottom: 12px;
}

#goalNameModalInput:focus,
#editGoalNameInput:focus,
#taskNameModalInput:focus,
#editTaskNameInput:focus {
    outline: none;
    border-color: #4caf50;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
}

.goal-description-input:focus {
    outline: none;
    border-color: #4caf50;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
}

.goal-description-label {
    display: block;
    margin: 14px 0 6px;
    font-size: 13px;
    font-weight: 600;
    color: #455a64;
}

.goal-description-label .optional-hint {
    font-weight: 400;
    color: #78909c;
}

.goal-description-input {
    width: 100%;
    min-height: 72px;
    padding: 10px 12px;
    border: 1px solid #e3e8ec;
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.45;
    color: #2c3e50;
    background: #fafcfd;
    resize: vertical;
    box-sizing: border-box;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

/* Task modals: name label above title field (matches Description block rhythm) */
.modal-content--task .goal-description-label--task-name {
    margin-top: 8px;
    margin-bottom: 8px;
}

.modal-content--goal {
    max-width: min(440px, 96vw);
}

.goal-habit-links-block {
    margin-bottom: 18px;
    padding: 0;
    border: none;
    background: transparent;
}

.goal-habit-links-title {
    font-size: 12px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #6b7785;
    margin-bottom: 6px;
    font-weight: 600;
}

.goal-habit-links-hint {
    font-size: 13px;
    color: #6b7785;
    margin-bottom: 14px;
    line-height: 1.45;
}

.goal-habit-links-rows {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 12px;
}

.goal-habit-link-row,
.goal-task-link-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    padding: 14px;
    background: #fff;
    border: 1px solid #e3e8ec;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(15, 34, 58, 0.07);
}

.goal-habit-link-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.goal-habit-link-field--habit {
    flex: 1 1 200px;
}

.goal-habit-link-field--task-pick {
    flex: 1 1 auto;
    min-width: 0;
}

.goal-habit-link-field--months {
    flex: 0 0 104px;
}

.goal-habit-link-field-label {
    font-size: 11px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    font-weight: 600;
    color: #7a8796;
}

.goal-habit-link-select,
.goal-task-link-select {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid #e3e8ec;
    border-radius: 10px;
    font-size: 15px;
    background: #fafcfd;
    color: #2c3e50;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.goal-habit-link-select:focus,
.goal-task-link-select:focus {
    outline: none;
    border-color: #4caf50;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.18);
}

.goal-habit-link-months,
.goal-task-link-months {
    width: 100%;
    min-height: 44px;
    padding: 10px 8px;
    border: 1px solid #e3e8ec;
    border-radius: 10px;
    font-size: 15px;
    text-align: center;
    background: #fafcfd;
    color: #2c3e50;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.goal-habit-link-months:focus,
.goal-task-link-months:focus {
    outline: none;
    border-color: #4caf50;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.18);
}

.goal-habit-link-remove,
.goal-task-link-remove {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid #e0e6eb;
    border-radius: 10px;
    background: #f5f7f9;
    color: #78909c;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.goal-habit-link-remove:hover,
.goal-task-link-remove:hover {
    background: #ffebee;
    border-color: #ef9a9a;
    color: #c62828;
}

.btn-add-habit-link {
    width: 100%;
    padding: 12px 14px;
    border: 2px dashed #b0bec5;
    border-radius: 12px;
    background: linear-gradient(180deg, #fbfcfd 0%, #f4f7f9 100%);
    color: #37474f;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.btn-add-habit-link:hover {
    border-color: #66bb6a;
    color: #1b5e20;
    background: linear-gradient(180deg, #f1f8f4 0%, #e8f5e9 100%);
}

.btn-add-goal {
    background-color: var(--accent);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 11px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    width: 100%;
    max-width: 100%;
    box-shadow: 0 1px 3px rgba(67, 160, 71, 0.3);
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.btn-add-goal:hover {
    background-color: #388e3c;
}

#addGoalBtn,
#addTaskBtn {
    margin-bottom: 12px;
}

.goals-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.goal-item {
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    padding: 14px 12px;
    margin-bottom: 10px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.goal-item:hover {
    border-color: #c5d0dc;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.goal-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.goal-item-header .goal-name--editable {
    flex: 1;
    min-width: 0;
}

.task-item-header-main {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.task-done-checkbox {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: #43a047;
}

.task-done-checkbox:disabled {
    cursor: default;
    opacity: 0.7;
}

.goal-item.task--completed .goal-name--editable {
    text-decoration: line-through;
    color: #78909c;
}

.goal-item.task--completed .goal-description-preview {
    color: #90a4ae;
}

.task-completed-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 10px 0 14px;
    font-size: 15px;
    font-weight: 500;
    color: #37474f;
    cursor: pointer;
    user-select: none;
}

.task-completed-label input {
    width: 18px;
    height: 18px;
    accent-color: #43a047;
}

.goal-description-preview {
    margin: 8px 0 0;
    font-size: 13px;
    line-height: 1.45;
    color: #607d8b;
    white-space: pre-wrap;
    word-break: break-word;
}

.goal-progress-modal-desc {
    margin: -6px 0 10px;
    font-size: 14px;
    line-height: 1.45;
    color: #546e7a;
    white-space: pre-wrap;
    word-break: break-word;
}

.goal-progress-modal-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 10px;
}

.goal-tags-picker-block {
    margin-bottom: 16px;
}

.task-tags-picker-block {
    margin-bottom: 16px;
}

.goal-tag-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    margin-top: 4px;
}

.goal-tag-pick-item {
    position: relative;
    cursor: pointer;
    display: inline-flex;
    margin: 0 8px 8px 0;
}

.goal-tag-pick-item input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.goal-tag-pick-chip {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    border: 2px solid transparent;
    transition: box-shadow 0.15s ease, transform 0.1s ease;
}

.goal-tag-pick-item input:focus-visible + .goal-tag-pick-chip {
    outline: 2px solid #5c6bc0;
    outline-offset: 2px;
}

.goal-tag-pick-item input:checked + .goal-tag-pick-chip {
    box-shadow: 0 0 0 2px #2c3e50;
    transform: scale(1.02);
}

.modal-content--goal-tags {
    max-width: min(440px, 96vw);
}

.goal-tags-manage-intro {
    font-size: 14px;
    color: #607d8b;
    line-height: 1.45;
    margin: 0 0 16px;
}

.goal-tags-manage-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
    max-height: min(280px, 45vh);
    overflow-y: auto;
    padding-right: 4px;
}

.goal-tags-empty {
    margin: 0;
    font-size: 14px;
    color: #90a4ae;
}

.goal-tags-manage-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    background: #f5f7fa;
    border: 1px solid #e3e8ec;
    border-radius: 10px;
}

.goal-tags-manage-name {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1px solid #e3e8ec;
    border-radius: 8px;
    font-size: 15px;
}

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

.goal-tag-color-swatches--compact {
    gap: 6px;
}

.goal-tag-swatch {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 3px solid #fff;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    transition: transform 0.1s ease, box-shadow 0.15s ease;
}

.goal-tag-swatch--sm {
    width: 26px;
    height: 26px;
    border-width: 2px;
}

.goal-tag-swatch:hover {
    transform: scale(1.08);
}

.goal-tag-swatch.is-selected {
    box-shadow: 0 0 0 2px #2c3e50, 0 2px 8px rgba(0, 0, 0, 0.2);
}

.goal-tags-manage-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.goal-tags-manage-actions--single {
    justify-content: flex-end;
}

.btn-goal-tag-save {
    background: #4caf50;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.btn-goal-tag-save:hover {
    background: #43a047;
}

.btn-goal-tag-delete {
    background: transparent;
    color: #c62828;
    border: 1px solid #ffcdd2;
    border-radius: 6px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.btn-goal-tag-delete:hover {
    background: #ffebee;
}

.goal-tags-limit-note {
    margin: 0 0 12px;
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.45;
    color: #5d4037;
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 8px;
}

.goal-tags-manage-create {
    border-top: 1px solid #e3e8ec;
    padding-top: 16px;
}

/* Space before "Create label" — swatch ring/shadow/hover scale was touching the button */
.goal-tags-manage-create .goal-tag-color-swatches {
    margin-bottom: 18px;
    padding-bottom: 6px;
}

.goal-tags-new-name {
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 10px;
    padding: 10px 12px;
    border: 1px solid #e3e8ec;
    border-radius: 8px;
    font-size: 15px;
}

.goal-tags-swatch-label {
    font-size: 11px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    font-weight: 600;
    color: #7a8796;
    margin: 0 0 8px;
}

.goal-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 8px 0 0;
}

.goal-tag-chip {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.goal-tag-chip--card {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.goal-tag-chip--modal {
    font-size: 12px;
    padding: 5px 10px;
    border-radius: 6px;
}

.goal-row-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    position: relative;
    z-index: 2;
}

.archive-goal,
.restore-goal,
.delete-archived-goal {
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 11px;
    cursor: pointer;
    white-space: nowrap;
}

.archive-goal {
    background: #ff9800;
}

.archive-goal:hover {
    background: #f57c00;
}

.restore-goal {
    background: #4caf50;
}

.restore-goal:hover {
    background: #45a049;
}

.delete-archived-goal {
    background: #f44336;
}

.delete-archived-goal:hover {
    background: #da190b;
}

.goal-name {
    font-size: 15px;
    white-space: normal;
    word-break: normal;
    overflow-wrap: normal;
}

.goal-name--editable {
    cursor: pointer;
    text-decoration: underline;
    text-decoration-color: rgba(44, 62, 80, 0.35);
    text-underline-offset: 2px;
    font-weight: 600;
    color: #2c3e50;
}

.goal-name--editable:hover {
    text-decoration-color: rgba(44, 62, 80, 0.65);
}

.goal-links-meta {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    line-height: 1.35;
}

.goal-link-chip {
    display: inline-block;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 500;
    color: #2e7d32;
    background: #e8f5e9;
    border: 1px solid #c8e6c9;
    border-radius: 999px;
}

.goal-link-chip--task {
    color: #1565c0;
    background: #e3f2fd;
    border-color: #90caf9;
}

.goal-progress-hint {
    margin-top: 10px;
    font-size: 13px;
    color: #7a8796;
    line-height: 1.4;
}

.goal-progress-teaser {
    width: 100%;
    margin-top: 12px;
    padding: 14px 16px 12px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    border: 1px solid #e3e8ec;
    border-radius: 12px;
    background: linear-gradient(180deg, #fafcfd 0%, #fff 48%);
    box-shadow: 0 1px 2px rgba(55, 71, 79, 0.06);
    cursor: pointer;
    font: inherit;
    text-align: left;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.goal-progress-teaser:hover {
    border-color: #81c784;
    background: linear-gradient(180deg, #f4fbf5 0%, #f8fdf9 100%);
    box-shadow: 0 2px 8px rgba(46, 125, 50, 0.1);
}

.goal-progress-teaser-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.goal-progress-teaser-copy {
    flex: 1;
    min-width: 0;
}

.goal-progress-teaser-title {
    font-size: 15px;
    font-weight: 700;
    color: #263238;
    letter-spacing: -0.02em;
    line-height: 1.25;
}

.goal-progress-teaser-right {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.goal-progress-teaser-pct {
    font-size: 17px;
    font-weight: 700;
    color: #2e7d32;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.03em;
}

.goal-progress-teaser-chevron {
    font-size: 22px;
    color: #b0bec5;
    line-height: 1;
    flex-shrink: 0;
    transition: color 0.15s ease, transform 0.15s ease;
}

.goal-progress-teaser:hover .goal-progress-teaser-chevron {
    color: #66bb6a;
    transform: translateX(2px);
}

.goal-progress-teaser-track {
    height: 5px;
    border-radius: 999px;
    background: #eceff1;
    overflow: hidden;
}

.goal-progress-teaser-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #81c784, #43a047);
    transition: width 0.35s ease;
}

.goal-progress-track {
    height: 10px;
    border-radius: 999px;
    background: #e8edf2;
    overflow: hidden;
}

.goal-progress-track--modal {
    height: 16px;
    margin-bottom: 16px;
}

.goal-progress-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #66bb6a, #43a047);
    transition: width 0.35s ease;
}

.goal-progress-fill--complete {
    background: linear-gradient(90deg, #2e7d32, #1b5e20);
}

.modal-content--goal-progress {
    max-width: min(420px, 96vw);
}

.goal-progress-modal-subtitle {
    margin: -4px 0 14px;
    font-size: 14px;
    color: #666;
}

.goal-progress-modal-summary {
    line-height: 1.1;
    margin: 0 0 12px;
}

.goal-progress-modal-summary--pct {
    font-size: 34px;
    font-weight: 700;
    text-align: center;
    color: #37474f;
    letter-spacing: -0.03em;
}

.goal-progress-modal-summary--pct.goal-progress-modal-summary--complete {
    color: #2e7d32;
    font-size: 40px;
}

.goal-progress-modal-calc-hint {
    margin: 0 0 16px;
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.45;
    color: #455a64;
    background: #f4f7f9;
    border-radius: 10px;
    border: 1px solid #e3e8ec;
}

.goal-habit-progress-contrib {
    margin: 0 0 10px;
    font-size: 12px;
    line-height: 1.4;
    color: #546e7a;
}

.goal-progress-modal-habits {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.goal-progress-modal-tasks-section {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid #e8ecef;
}

.goal-progress-modal-section-title {
    margin: 0 0 10px;
    font-size: 12px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-weight: 600;
    color: #6b7785;
}

.goal-progress-modal-tasks {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.goal-progress-task-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid #e3e8ec;
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    line-height: 1.35;
}

.goal-progress-task-row--archived {
    opacity: 0.75;
    cursor: default;
}

.goal-progress-task-checkbox {
    margin-top: 2px;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    accent-color: #43a047;
    cursor: pointer;
}

.goal-progress-task-row--archived .goal-progress-task-checkbox {
    cursor: not-allowed;
}

.goal-progress-task-textcol {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.goal-progress-task-name {
    font-size: 15px;
    font-weight: 500;
    color: #2c3e50;
}

.goal-progress-task-contrib {
    font-size: 12px;
    line-height: 1.35;
    color: #546e7a;
}

.goal-habit-progress-card {
    border: 1px solid #e3e8ec;
    border-radius: 10px;
    padding: 12px 12px 10px;
    background: #fafbfc;
}

.goal-habit-progress-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.goal-habit-progress-name {
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50;
}

.goal-habit-progress-pct {
    font-size: 15px;
    font-weight: 700;
    color: #2e7d32;
    flex-shrink: 0;
}

.goal-month-slots {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.goal-month-slot {
    flex: 1;
    min-width: 0;
    height: 22px;
    border-radius: 6px;
    border: 1px solid #cfd8dc;
    overflow: hidden;
    box-sizing: border-box;
}

.goal-month-slot--done {
    background: linear-gradient(180deg, #81c784, #43a047);
    border-color: #388e3c;
}

.goal-month-slot--empty {
    background: #eceff1;
    border-color: #cfd8dc;
}

.goal-month-slot--upcoming {
    background: #f5f5f5;
    border: 1px dashed #b0bec5;
}

.goal-month-slot--active {
    background: repeating-linear-gradient(
        -45deg,
        #e8f5e9,
        #e8f5e9 4px,
        #c8e6c9 4px,
        #c8e6c9 8px
    );
    border-color: #81c784;
    position: relative;
}

.goal-month-slot-stack {
    display: flex;
    flex-direction: row;
    height: 100%;
    width: 100%;
    align-items: stretch;
}

.goal-month-slot-seg {
    flex-shrink: 0;
    height: 100%;
    min-width: 0;
    transition: width 0.35s ease;
}

.goal-month-slot-seg--done {
    background: linear-gradient(90deg, #66bb6a, #43a047);
}

.goal-month-slot-seg--missed {
    background: linear-gradient(90deg, #e57373, #c62828);
}

.goal-month-slot-fill {
    height: 100%;
    border-radius: 0 5px 5px 0;
    background: linear-gradient(90deg, #66bb6a, #43a047);
    transition: width 0.35s ease;
    min-width: 0;
}

.goal-habit-mini-track {
    display: flex;
    flex-direction: row;
    height: 6px;
    border-radius: 999px;
    background: #e0e7ec;
    overflow: hidden;
    margin-bottom: 8px;
}

.goal-habit-mini-fill {
    flex-shrink: 0;
    height: 100%;
    border-radius: 0;
    background: linear-gradient(90deg, #81c784, #43a047);
    transition: width 0.35s ease;
}

.goal-habit-mini-miss {
    flex-shrink: 0;
    height: 100%;
    background: linear-gradient(90deg, #e57373, #c62828);
    transition: width 0.35s ease;
}

.goals-empty {
    text-align: center;
    color: #777;
    font-style: italic;
    padding: 18px;
    border: 1px dashed #c9c9c9;
    border-radius: 8px;
    background: #fafafa;
}

.btn-archive,
.btn-back-archive {
    background: #607d8b;
    color: white;
    border: none;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.btn-archive:hover,
.btn-back-archive:hover {
    background: #546e7a;
}

.btn-back-archive {
    background: #455a64;
}

.habit-row-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 8px;
    flex-shrink: 0;
    opacity: 1;
}

.archive-habit,
.restore-habit,
.delete-archived-habit {
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 11px;
    cursor: pointer;
    white-space: nowrap;
}

.archive-habit {
    margin-left: 0;
    opacity: 1;
    transition: opacity 0.2s;
    background: #ff9800;
}

.archive-habit:hover {
    background: #f57c00;
}

.restore-habit {
    background: #4CAF50;
}

.restore-habit:hover {
    background: #45a049;
}

.delete-archived-habit {
    background: #f44336;
}

.delete-archived-habit:hover {
    background: #da190b;
}

/* Telegram/touch: there is no hover, so buttons stay visible above.
   On desktop, hide single Archive until row hover (active habits only). */
@media (hover: hover) and (pointer: fine) {
    .archive-habit {
        opacity: 0;
    }

    .habit-name-cell:hover .archive-habit {
        opacity: 1;
    }
}

.empty-row td {
    text-align: center;
    color: #999;
    font-style: italic;
    padding: 30px;
}

.habits-stats-panel {
    margin-top: 4px;
}

.habits-stats-period-row {
    margin-bottom: 12px;
}

.habits-stats-period-chips {
    margin-top: 0;
}

.habits-stats-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.habits-stats-period {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.btn-send-stats-json {
    border: 1px solid #90caf9;
    background: #e3f2fd;
    color: #1565c0;
    border-radius: 9px;
    padding: 9px 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.btn-send-stats-json:hover {
    background: #bbdefb;
}

.btn-send-stats-json:disabled {
    opacity: 0.65;
    cursor: default;
}

.habits-stats-summary {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 18px;
}

.habits-stats-score-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
}

.habits-stats-grade {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 800;
    color: #fff;
    flex-shrink: 0;
    background: #78909c;
}

.habits-stats-grade--sm {
    width: 34px;
    height: 34px;
    font-size: 16px;
    border-radius: 9px;
}

.habits-stats-grade--A { background: #2e7d32; }
.habits-stats-grade--B { background: #558b2f; }
.habits-stats-grade--C { background: #f9a825; color: #263238; }
.habits-stats-grade--D { background: #ef6c00; }
.habits-stats-grade--F { background: #c62828; }

.habits-stats-score-meta {
    min-width: 0;
}

.habits-stats-score-pct {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.1;
}

.habits-stats-score-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
}

.habits-stats-score-sub {
    margin-top: 2px;
    font-size: 12px;
    color: var(--text-muted);
}

.habits-stats-counters {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.habits-stats-counters--scored {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.habits-stats-exclude-note {
    margin: 0;
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-muted);
}

.habits-stats-counter {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 8px;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.habits-stats-counter span {
    display: block;
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 2px;
    text-transform: none;
    letter-spacing: 0;
}

.habits-stats-counter--done span { color: #2e7d32; }
.habits-stats-counter--missed span { color: #c62828; }
.habits-stats-counter--empty span { color: #78909c; }
.habits-stats-counter--skip span { color: #546e7a; }

.habits-stats-block {
    margin-bottom: 18px;
}

.habits-stats-heading {
    margin: 0 0 10px;
    font-size: 16px;
    color: var(--text);
}

.habits-stats-chart-card {
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    padding: 12px;
}

.habits-stats-chart-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.habits-line-chart {
    display: block;
    width: 100%;
    height: auto;
    min-height: 110px;
}

.habits-stats-by-habit {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.habits-stats-habit-card {
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-control);
    padding: 12px;
}

.habits-stats-habit-head {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: flex-start;
    margin-bottom: 8px;
}

.habits-stats-habit-title {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.habits-stats-habit-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    overflow-wrap: anywhere;
}

.habits-stats-habit-meta {
    font-size: 12px;
    color: var(--text-muted);
}

.habits-stats-habit-score {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.habits-stats-habit-pct {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    min-width: 3.2rem;
    text-align: right;
}

.habits-stats-habit-counters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.habits-stats-habit-counters .pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 600;
}

.pill--done { background: #e8f5e9; color: #2e7d32; }
.pill--missed { background: #ffebee; color: #c62828; }
.pill--empty { background: #eceff1; color: #607d8b; }
.pill--skip { background: #e3f2fd; color: #1565c0; }

.habits-stats-habit-chart {
    margin-top: 4px;
}

.stats-section {
    margin-top: 28px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.stats-section h2 {
    font-size: 18px;
    margin-bottom: 15px;
    color: #2c3e50;
}

.stat-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 14px;
    padding: 12px;
    margin-bottom: 10px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 4px solid #4CAF50;
}

.stat-item--interactive {
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.1s ease;
}

.stat-item--interactive:active {
    background-color: #eef1f4;
    transform: scale(0.99);
}

.stat-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat-name {
    font-weight: 500;
    display: block;
    min-width: 0;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: normal;
    hyphens: auto;
}

.stat-info {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 13px;
    color: #666;
    margin-right: 0;
}

.stat-streak {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.stat-streak--green {
    color: #1b5e20;
    background: #e8f5e9;
    border: 1px solid #a5d6a7;
}

.stat-streak--gold {
    color: #7a5a00;
    background: #fff4cc;
    border: 1px solid #e0b94f;
}

.stat-percentage {
    font-weight: 600;
    color: #4CAF50;
    min-width: 60px;
    text-align: right;
    white-space: nowrap;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(2px);
}

.modal-content {
    background-color: white;
    margin: 24px auto 40px;
    padding: 25px;
    border-radius: 10px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    position: relative;
    /* Taller than viewport: scroll inside panel; overlay also scrolls */
    max-height: calc(100vh - 48px);
    max-height: calc(100dvh - 48px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.modal-content--chart {
    margin: 24px auto 40px;
    max-width: min(420px, 96vw);
    padding-top: 32px;
}

.stats-chart-subtitle {
    margin: -8px 0 14px;
    font-size: 14px;
    color: #666;
}

.stats-chart-counts {
    margin: 14px 0 0;
    font-size: 13px;
    color: #555;
    text-align: center;
}

.stats-chart-svg-wrap {
    width: 100%;
    overflow: hidden;
}

.stats-chart-svg-wrap--donut {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stats-donut-svg {
    display: block;
    width: min(240px, 85vw);
    height: auto;
    max-height: 240px;
}

.stats-chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 14px;
    justify-content: center;
    margin-top: 16px;
    font-size: 12px;
    color: #555;
}

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

.stats-leg {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 2px;
    flex-shrink: 0;
}

.stats-leg.done {
    background: #4caf50;
}

.stats-leg.missed {
    background: #c62828;
}

.stats-leg.neutral {
    background: #9e9e9e;
}

.stats-leg.empty {
    background: #e8e8e8;
    border: 1px solid #ccc;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    right: 15px;
    top: 10px;
    cursor: pointer;
}

.close:hover {
    color: #000;
}

.modal-content h2 {
    margin-bottom: 20px;
    color: #2c3e50;
}

/* Habit modals: full-width name field (matches weekday-picker below) */
#habitNameInput,
#editHabitNameInput {
    width: 100%;
    max-width: 100%;
    display: block;
    box-sizing: border-box;
    padding: 12px 14px;
    border: 1px solid #e3e8ec;
    border-radius: 10px;
    font-size: 16px;
    line-height: 1.35;
    margin-bottom: 16px;
    background: #fff;
    color: #2c3e50;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#habitNameInput::placeholder,
#editHabitNameInput::placeholder {
    color: #9aa5b1;
}

#habitNameInput:focus,
#editHabitNameInput:focus {
    outline: none;
    border-color: #4caf50;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
}

.weekday-picker {
    margin-bottom: 18px;
    padding: 10px;
    border: 1px solid #e3e8ec;
    border-radius: 10px;
    background: #f9fbfc;
}

.weekday-picker-title {
    font-size: 12px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #6b7785;
    margin-bottom: 10px;
    font-weight: 600;
}

.weekday-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.weekday-chip {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.weekday-chip input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.weekday-chip input[type="checkbox"]:checked + span {
    background: #e8f5e9;
    border-color: #4caf50;
    color: #2e7d32;
}

.weekday-chip span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 50px;
    padding: 7px 10px;
    border: 1px solid #cfd8dc;
    border-radius: 999px;
    background: #fff;
    font-size: 12px;
    font-weight: 600;
    color: #2c3e50;
    transition: all 0.15s ease;
}

.weekday-chip:hover span {
    background: #f0f5f7;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.btn-primary {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}

.btn-primary:hover {
    background-color: #45a049;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

.btn-link-skip {
    background: none;
    border: none;
    padding: 8px 4px;
    font-size: 14px;
    font-weight: 500;
    color: #546e7a;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.btn-link-skip:hover {
    color: #37474f;
}

.onboarding-modal {
    z-index: 1100;
}

.app-confirm-modal {
    z-index: 1200;
}

.modal-content--app-confirm {
    max-width: min(360px, 92vw);
    padding: 22px 20px 18px;
}

.app-confirm-message {
    margin: 0 0 18px;
    font-size: 15px;
    line-height: 1.45;
    color: #263238;
    white-space: pre-wrap;
}

.app-confirm-buttons {
    justify-content: flex-end;
}

.btn-danger {
    background: #e53935;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.btn-danger:hover {
    background: #c62828;
}

.modal-content--onboarding {
    max-width: min(420px, 94vw);
    padding: 28px 22px 22px;
}

.onboarding-modal .onboarding-close {
    position: absolute;
    top: 12px;
    right: 14px;
    z-index: 1;
}

.onboarding-step-label {
    margin: 0 0 6px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #78909c;
}

.onboarding-title {
    margin: 0 0 14px;
    padding-right: 28px;
    font-size: 22px;
    line-height: 1.25;
    color: #263238;
}

.onboarding-body {
    margin: 0;
    font-size: 15px;
    line-height: 1.55;
    color: #455a64;
}

.onboarding-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 22px 0 8px;
}

.onboarding-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #cfd8dc;
    transition: transform 0.15s ease, background 0.15s ease;
}

.onboarding-dot.is-active {
    background: #43a047;
    transform: scale(1.15);
}

.onboarding-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 18px;
    flex-wrap: wrap;
}

.onboarding-actions-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* Loading state */
.loading {
    text-align: center;
    padding: 20px;
    color: #999;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .btn-add {
        width: 100%;
    }

    .goals-add-form {
        flex-direction: column;
    }

    .btn-add-goal {
        width: 100%;
    }

    .weekday-grid {
        gap: 6px;
    }

    .weekday-chip {
        min-width: auto;
        padding: 0;
    }

    .weekday-chip span {
        min-width: 46px;
        padding: 6px 9px;
    }

    th, td {
        padding: 8px 5px;
        font-size: 12px;
    }

    .habit-header,
    tbody td:first-child {
        min-width: 170px;
        max-width: 220px;
    }

    tbody td.habit-name-cell--archive-actions {
        max-width: 300px;
        min-width: 200px;
    }
}

