/* CSS Variables */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #22c55e;
    --success-light: #dcfce7;
    --warning: #f59e0b;
    --danger: #ef4444;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 6px rgba(0,0,0,0.1);
    --nav-height: 64px;
}

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.5;
    min-height: 100vh;
    padding-bottom: var(--nav-height);
}

/* App Container */
#app {
    max-width: 600px;
    margin: 0 auto;
    padding: 16px;
    padding-bottom: calc(var(--nav-height) + 16px);
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: white;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 100;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-decoration: none;
    color: var(--gray-400);
    font-size: 11px;
    padding: 8px 16px;
    transition: color 0.2s;
}

.nav-item svg {
    width: 24px;
    height: 24px;
}

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

.nav-item:active {
    opacity: 0.7;
}

/* Hide nav on login page */
body.login-page .bottom-nav {
    display: none;
}

body.login-page {
    padding-bottom: 0;
}

/* Typography */
h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 16px;
}

h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 12px;
}

h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 8px;
}

/* Header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.page-subtitle {
    font-size: 10px;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 600;
}

/* Week Navigation */
.season-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: white;
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.week-nav-btn:disabled {
    opacity: 0.15;
    cursor: default;
}

.season-nav-center {
    text-align: center;
    flex: 1;
}

.season-nav-center.clickable {
    cursor: pointer;
}

.season-nav-center.clickable:active {
    opacity: 0.7;
}

.season-nav-name {
    font-weight: 600;
    font-size: 16px;
    display: block;
}

.season-nav-dates {
    font-size: 13px;
    color: var(--gray-500);
    display: block;
    margin-top: 2px;
}

.week-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: white;
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.week-nav-btn {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--gray-600);
    border-radius: var(--radius);
    transition: background 0.2s;
}

.week-nav-btn:hover {
    background: var(--gray-100);
}

.week-nav-btn:active {
    background: var(--gray-200);
}

.week-nav-btn svg {
    width: 20px;
    height: 20px;
}

.week-team-info {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--gray-400);
    margin-bottom: 2px;
}

.week-team-info:empty {
    display: none;
}

.week-range {
    font-weight: 500;
    color: var(--gray-700);
}

.week-current {
    font-size: 12px;
    color: var(--primary);
    margin-top: 2px;
}

/* Week Notes */
.week-notes-container {
    margin-bottom: 16px;
}

.week-notes-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    color: var(--gray-700);
    background: white;
    resize: none;
    overflow: hidden;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.week-notes-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.week-notes-input::placeholder {
    color: var(--gray-400);
}

.week-notes-input.has-content {
    background: var(--gray-50);
}

.member-card {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    margin-bottom: 12px;
}

.member-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.member-card-goals {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--gray-100);
}

.season-goals-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
    margin: 0 0 6px 0;
}

.season-goal-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 14px;
    color: var(--gray-700);
}

.season-goal-icon {
    cursor: pointer;
    transition: transform 0.2s ease, color 0.2s ease;
    color: var(--gray-400);
}

.season-goal-icon:hover {
    transform: scale(1.3);
    color: var(--primary);
}

.week-controls-card {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 0;
    margin-bottom: 16px;
}

.week-controls-card .week-nav {
    margin-bottom: 0;
    border-bottom: none;
}

.week-controls-card .week-notes-container {
    margin: 0;
    padding: 0 12px 12px;
}

.week-controls-card .week-filter-bar {
    border-top: 1px solid var(--gray-100);
    padding: 8px 12px;
    margin: 0;
}

.week-notes-readonly {
    padding: 12px 16px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    font-size: 14px;
    line-height: 1.5;
    color: var(--gray-600);
    background: var(--gray-50);
    white-space: pre-wrap;
}

/* Cards */
.card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}

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

.card-title {
    font-weight: 500;
    color: var(--gray-800);
}

.card-subtitle {
    font-size: 13px;
    color: var(--gray-500);
}

/* Action Progress Row */
.action-row {
    background: white;
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}

.action-row.week-completed {
    background: var(--gray-100);
    opacity: 0.7;
}

.action-row.dragging {
    opacity: 0.15;
}

.drag-placeholder {
    border: 2px dashed var(--primary);
    border-radius: var(--radius-lg);
    margin-bottom: 12px;
    background: rgba(37, 99, 235, 0.05);
    pointer-events: none;
}

.action-edit-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-400);
    cursor: grab;
    padding: 4px;
    margin-right: 4px;
    flex-shrink: 0;
    touch-action: none;
}

.action-edit-handle:active {
    cursor: grabbing;
    color: var(--gray-600);
}

.action-delete-btn {
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    padding: 4px;
    margin-left: 8px;
    flex-shrink: 0;
}

.action-delete-btn:hover {
    color: var(--danger, #ef4444);
}

.fab-menu {
    position: fixed;
    bottom: 80px;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 100;
}

.fab-menu:not(.show) {
    display: none;
}

.fab-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
    cursor: pointer;
    box-shadow: var(--shadow);
    white-space: nowrap;
}

.fab-menu-item:hover {
    background: var(--gray-50);
}

.action-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 12px;
}

.action-name {
    font-weight: 500;
    color: var(--gray-800);
    flex: 1;
}

.action-name .goal-chip {
    vertical-align: middle;
    position: relative;
    top: -1px;
    margin-left: 4px;
    max-width: 50%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    display: inline-block;
}

.action-target {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Progress Circle */
.action-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.progress-circle-container {
    flex-shrink: 0;
}

.progress-circle {
    display: block;
}

/* Day Grid */
.days-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.day-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 4px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.day-cell:active {
    background: var(--gray-100);
}

.day-label {
    font-size: 10px;
    color: var(--gray-500);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.day-cell.is-today .day-label {
    color: var(--primary);
    font-weight: 600;
}

.day-check {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid var(--gray-300);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.day-cell.completed .day-check {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.day-check svg {
    width: 16px;
    height: 16px;
    opacity: 0;
    transition: opacity 0.2s;
}

.day-cell.completed .day-check svg {
    opacity: 1;
}

.day-cell.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.day-cell.disabled:active {
    background: transparent;
}

.day-value {
    font-size: 11px;
    color: var(--gray-600);
    margin-top: 4px;
    min-height: 16px;
}

/* Day notes button */
.day-notes-btn {
    background: none;
    border: none;
    padding: 2px;
    margin-top: 2px;
    cursor: pointer;
    color: var(--gray-300);
    transition: color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.day-notes-btn:hover {
    color: var(--primary);
}

.day-notes-btn.has-notes {
    color: var(--primary);
}

.day-notes-btn.has-notes:hover {
    color: var(--primary-dark, #4338ca);
}

/* Day value notes indicator */
.day-value-notes {
    color: var(--primary);
    font-weight: 600;
    margin-left: 1px;
}

/* Overlap day styling (for week time cutoff) */
.day-cell.is-overlap {
    position: relative;
    border: 1px dashed var(--gray-300);
    background: var(--gray-50);
}

.day-cell.is-next-week-overlap {
    border: 1px dashed var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.day-cell.is-next-week-overlap .day-label {
    color: var(--primary);
}

.cutoff-hint {
    display: block;
    font-size: 8px;
    font-weight: 400;
    color: var(--gray-400);
    text-transform: none;
    margin-top: 2px;
}

.day-cell.is-next-week-overlap .cutoff-hint {
    color: var(--primary);
    opacity: 0.7;
}

/* 8-column grid for overlap day display */
.days-grid.has-overlap {
    grid-template-columns: repeat(8, 1fr);
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

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

select.form-input {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-input::placeholder {
    color: var(--gray-400);
}

select.form-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

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

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

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

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-200);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-ghost {
    background: transparent;
    color: var(--gray-600);
}

.btn-ghost:hover {
    background: var(--gray-100);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 8px 12px;
    font-size: 13px;
}

.btn-icon {
    padding: 8px;
    border-radius: 50%;
}

.btn svg {
    width: 18px;
    height: 18px;
}

/* FAB */
.fab {
    position: fixed;
    bottom: calc(var(--nav-height) + 16px);
    right: 16px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    z-index: 50;
}

.fab:active {
    transform: scale(0.95);
}

.fab svg {
    width: 24px;
    height: 24px;
    transition: transform 0.2s;
}

.fab.fab-open svg {
    transform: rotate(45deg);
}

.fab-menu {
    position: fixed;
    bottom: calc(var(--nav-height) + 16px);
    right: 16px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.fab-menu .fab {
    position: static;
}

.fab-options {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.fab-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}

.fab-option:active {
    background: var(--gray-50);
}

/* Modal */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

.modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: white;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.3s ease-out;
    padding-bottom: env(safe-area-inset-bottom);
}

.modal-backdrop.active .modal {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    background: white;
    z-index: 1;
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--gray-500);
    border-radius: 50%;
}

.modal-close:hover {
    background: var(--gray-100);
}

.modal-body {
    padding: 16px;
}

.modal-footer {
    padding: 16px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: 12px;
}

/* Toast */
.toast {
    position: fixed;
    bottom: calc(var(--nav-height) + 16px);
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--gray-800);
    color: white;
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    opacity: 0;
    transition: transform 0.3s, opacity 0.3s;
    z-index: 300;
    max-width: calc(100% - 32px);
    text-align: center;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

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

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

/* Login Page */
.login-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-logo {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
}

.login-tagline {
    color: var(--gray-500);
    margin-bottom: 32px;
}

.login-form {
    width: 100%;
    max-width: 360px;
}

.login-tabs {
    display: flex;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--gray-200);
}

.login-tab {
    flex: 1;
    padding: 12px;
    text-align: center;
    background: none;
    border: none;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-500);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.2s, border-color 0.2s;
}

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

.forgot-password-link {
    text-align: center;
    margin-top: 12px;
}

.forgot-password-link a {
    font-size: 13px;
    color: var(--gray-500);
    text-decoration: none;
}

.forgot-password-link a:hover {
    color: var(--primary);
}

.form-help-text {
    font-size: 14px;
    color: var(--gray-500);
    margin-bottom: 16px;
    line-height: 1.4;
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--gray-500);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    color: var(--gray-700);
    margin-bottom: 8px;
}

/* List Items */
.list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: white;
    border-radius: var(--radius-lg);
    margin-bottom: 8px;
    box-shadow: var(--shadow);
}

.list-item-content {
    flex: 1;
}

.list-item-title {
    font-weight: 500;
    color: var(--gray-800);
}

.list-item-subtitle {
    font-size: 13px;
    color: var(--gray-500);
    margin-top: 2px;
}

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

/* Chips/Tags */
.chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    background: var(--gray-100);
    border-radius: 100px;
    font-size: 12px;
    color: var(--gray-600);
}

.chip.active {
    background: var(--primary);
    color: white;
}

.chip.goal-chip {
    background: var(--gray-200);
    color: var(--gray-600);
    font-size: 11px;
    padding: 1px 8px;
}

/* Target Config */
.target-config {
    background: var(--gray-50);
    border-radius: var(--radius);
    padding: 12px;
    margin-top: 12px;
}

.target-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.target-row:last-child {
    margin-bottom: 0;
}

.target-label {
    font-size: 13px;
    color: var(--gray-600);
    min-width: 80px;
}

.target-input {
    width: 80px;
    padding: 8px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
    text-align: center;
}

/* Days Selector */
.days-selector {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.day-toggle {
    padding: 6px 10px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    background: white;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.day-toggle.selected {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.day-toggle:disabled {
    background: var(--gray-100);
    border-color: var(--gray-200);
    color: var(--gray-400);
    cursor: not-allowed;
}

.day-toggle:disabled.selected {
    background: var(--gray-300);
    border-color: var(--gray-300);
    color: var(--gray-500);
}

/* Progress Indicator */
.progress-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--gray-600);
}

.progress-indicator strong {
    color: var(--gray-800);
}

/* Settings */
.settings-section {
    background: white;
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
    overflow: hidden;
}

.settings-header {
    padding: 12px 16px;
    background: var(--gray-50);
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--gray-100);
}

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

.settings-item-label {
    font-weight: 500;
}

.settings-item-value {
    color: var(--gray-500);
}

/* Loading Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Goal Card */
.goal-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--gray-300);
}

.goal-card.current {
    border-left-color: var(--primary);
}

.goal-name {
    font-weight: 500;
    color: var(--gray-800);
    margin-bottom: 4px;
}

.goal-dates {
    font-size: 13px;
    color: var(--gray-500);
}

.goal-actions-list {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--gray-100);
}

.goal-action-item {
    font-size: 13px;
    color: var(--gray-600);
    padding: 4px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.goal-action-item::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--gray-400);
    border-radius: 50%;
}

/* Responsive */
@media (min-width: 600px) {
    .modal {
        border-radius: var(--radius-lg);
        margin: 24px;
        max-height: calc(100vh - 48px);
    }

    .modal-backdrop {
        align-items: center;
    }
}

/* Utilities */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

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

.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }

/* Settings Link */
.settings-link {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.settings-link:hover {
    background: var(--gray-50);
}

/* Help Page */
.help-section {
    background: white;
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
    overflow: hidden;
}

.help-header {
    padding: 12px 16px;
    background: var(--gray-50);
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.help-content {
    padding: 16px;
}

.help-content p {
    margin-bottom: 12px;
    color: var(--gray-700);
    line-height: 1.6;
}

.help-content h3 {
    color: var(--gray-800);
    margin-top: 16px;
    margin-bottom: 8px;
}

.help-content h3:first-child {
    margin-top: 0;
}

.help-content ul {
    margin-left: 20px;
    margin-bottom: 12px;
    color: var(--gray-700);
}

.help-content li {
    margin-bottom: 6px;
    line-height: 1.5;
}

.action-types {
    margin: 12px 0;
}

.action-type {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    background: var(--gray-50);
    border-radius: var(--radius);
    margin-bottom: 8px;
}

.action-type-name {
    font-weight: 600;
    color: var(--primary);
    min-width: 100px;
}

.action-type-desc {
    color: var(--gray-600);
    font-size: 14px;
}

/* Help Page Navigation */
.help-nav {
    display: flex;
    gap: 6px;
    padding: 0 0 16px 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.help-nav::-webkit-scrollbar {
    display: none;
}

.help-nav-btn {
    flex-shrink: 0;
    padding: 6px 14px;
    border: 1px solid var(--gray-200);
    border-radius: 20px;
    background: white;
    color: var(--gray-500);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.help-nav-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.help-nav-btn:active {
    opacity: 0.7;
}

.help-page {
    display: none;
}

.help-page.active {
    display: block;
}

.help-content code {
    background: var(--gray-100);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

/* Week Target Modal */
.week-target-action-name {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-800);
}

.week-target-week-range {
    font-size: 14px;
    color: var(--gray-500);
    margin-top: 4px;
}

.target-mode-selector {
    display: flex;
    gap: 8px;
}

.target-mode-btn {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    background: white;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.target-mode-btn:hover {
    background: var(--gray-50);
}

.target-mode-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* Week target config disabled state */
#weekTargetConfig.disabled {
    opacity: 0.6;
}

#weekTargetConfig.disabled .form-label {
    color: var(--gray-400);
}

.form-input:disabled {
    background: var(--gray-100);
    border-color: var(--gray-200);
    color: var(--gray-500);
    cursor: not-allowed;
}

/* Progress indicator group */
.progress-indicator-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-edit-target {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--gray-400);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-edit-target:hover {
    color: var(--primary);
    background: var(--gray-100);
}


/* Inline note text on action cards */
.action-note-text {
    color: var(--gray-400);
    font-style: italic;
}

.action-note-text.week-note-text {
    display: block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* Teams */
.team-card {
    display: block;
    background: white;
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--gray-300);
    text-decoration: none;
    color: inherit;
    transition: transform 0.1s, box-shadow 0.1s;
}

.team-card:active {
    transform: scale(0.98);
}

.team-card.is-captain {
    border-left-color: var(--primary);
}

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

.team-name {
    font-weight: 600;
    color: var(--gray-800);
}

.team-description {
    font-size: 14px;
    color: var(--gray-500);
    margin-bottom: 8px;
}

.team-description-header {
    font-size: 14px;
    color: var(--gray-500);
    margin-bottom: 16px;
}

.team-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--gray-500);
}

/* Team Links */
.team-links {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.team-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    color: var(--gray-700);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.15s;
}

.team-link:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--gray-50);
}

.team-link svg {
    flex-shrink: 0;
}

/* Form section divider */
.form-divider {
    border: none;
    border-top: 1px solid var(--gray-200);
    margin: 20px 0;
}

.form-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 12px;
}

/* Invitations */
.invitation-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--warning);
}

.invitation-info {
    margin-bottom: 12px;
}

.invitation-team {
    font-weight: 600;
    color: var(--gray-800);
}

.invitation-from {
    font-size: 13px;
    color: var(--gray-500);
}

.invitation-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* Members */
.member-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--gray-100);
}

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

.member-item.clickable {
    cursor: pointer;
    border-radius: 8px;
    padding: 12px 8px;
    margin: 0 -8px;
}

.member-item.clickable:active {
    background: var(--gray-50);
}

.member-meta {
    font-size: 13px;
    margin-top: 2px;
}

.member-info {
    flex: 1;
    min-width: 0;
}

.member-name {
    font-weight: 500;
    color: var(--gray-800);
}

.member-email {
    font-size: 13px;
    color: var(--gray-500);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.member-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chip.pending {
    background: var(--warning);
    color: white;
}

/* Shared Goals */
.team-user-section {
    background: white;
    border-radius: var(--radius-lg);
    margin-bottom: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.team-user-header {
    padding: 14px 16px;
    background: var(--gray-50);
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: background 0.2s;
}

.team-user-header:active {
    background: var(--gray-100);
}

.team-user-name {
    font-weight: 500;
    color: var(--gray-800);
}

.team-user-goals {
    padding: 12px 16px;
    border-top: 1px solid var(--gray-200);
}

.team-goal-item {
    font-size: 14px;
    color: var(--gray-600);
    padding: 6px 0;
}

.team-goal-item + .team-goal-item {
    border-top: 1px solid var(--gray-100);
}

/* Team sharing in goal modal */
.team-share-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--gray-200);
}

.team-share-list {
    margin-top: 8px;
}

.team-share-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--gray-50);
    border-radius: var(--radius);
    margin-bottom: 6px;
}

.team-share-item label {
    flex: 1;
    font-size: 14px;
    color: var(--gray-700);
    cursor: pointer;
}

.team-share-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* Section header with button */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.section-header .section-title {
    margin-bottom: 0;
}

/* Back link */
.page-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.back-link {
    color: var(--gray-500);
    display: flex;
    align-items: center;
    padding: 4px;
    margin-left: -4px;
}

.back-link:active {
    opacity: 0.5;
}

/* Action row readonly */
.action-row.readonly {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 12px;
    margin-bottom: 12px;
}

.action-row.readonly .action-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.action-row.readonly .action-name {
    font-weight: 500;
    color: var(--gray-800);
}

.action-type-badge {
    font-size: 11px;
    padding: 2px 8px;
    background: var(--gray-200);
    color: var(--gray-600);
    border-radius: 100px;
    text-transform: uppercase;
}

/* Modal large */
.modal.modal-lg {
    max-width: 500px;
    max-height: 80vh;
}

.modal.modal-lg .modal-body {
    max-height: 60vh;
    overflow-y: auto;
}

/* Loading and error states */
.loading {
    text-align: center;
    padding: 24px;
    color: var(--gray-500);
}

.error {
    text-align: center;
    padding: 24px;
    color: var(--danger);
}

/* Button full width */
.btn-full {
    width: 100%;
}

/* Small buttons */
.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

/* Checkbox label */
.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    color: var(--gray-700);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    accent-color: var(--primary);
    cursor: pointer;
    flex-shrink: 0;
}

.checkbox-label span {
    line-height: 1.4;
}

/* Form hint text */
.form-hint {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 6px;
    margin-left: 28px;
    line-height: 1.4;
}

/* Member week banner */
.member-week-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    margin-bottom: 16px;
}

.member-week-banner .back-link {
    color: var(--gray-500);
    display: flex;
    align-items: center;
    padding: 4px;
    margin: -4px;
}

.member-week-banner .back-link:active {
    opacity: 0.5;
}

.member-week-banner-content {
    flex: 1;
    min-width: 0;
}

.member-week-banner-name {
    font-weight: 600;
    font-size: 16px;
    color: var(--gray-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.member-week-banner-label {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 2px;
}

.member-week-banner .share-link-btn {
    background: none;
    border: none;
    color: var(--gray-500);
    padding: 8px;
    margin: -8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    transition: color 0.15s, background 0.15s;
}

.member-week-banner .share-link-btn:hover {
    color: var(--primary);
    background: var(--gray-200);
}

.member-week-banner .share-link-btn:active {
    opacity: 0.7;
}

/* Readonly day cells */
.action-row.readonly .day-cell {
    cursor: default;
}

.action-row.readonly .day-cell:hover {
    background: transparent;
}

.action-row.readonly .day-cell.completed:hover {
    background: var(--primary-light);
}

/* Search box */
.search-box {
    position: relative;
    margin-bottom: 16px;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--gray-400);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 12px 48px 12px 40px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 16px;
    background: white;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-add-btn {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border: none;
    background: var(--primary);
    color: white;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, opacity 0.2s;
}

.search-add-btn:hover {
    background: var(--primary-dark);
}

.search-add-btn:active {
    transform: translateY(-50%) scale(0.95);
}

.search-add-btn svg {
    width: 18px;
    height: 18px;
}

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

.search-input::placeholder {
    color: var(--gray-400);
}

/* Goal filter dropdown */
.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 50;
    margin-top: 4px;
    max-height: 200px;
    overflow-y: auto;
    display: none;
}

.search-dropdown.show {
    display: block;
}

.search-dropdown-item {
    padding: 10px 12px;
    font-size: 14px;
    color: var(--gray-700);
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid var(--gray-100);
}

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

.search-dropdown-item:hover {
    background: var(--gray-50);
}

.search-dropdown-item:active {
    background: var(--gray-100);
}

.search-dropdown-item.highlighted {
    background: var(--gray-100);
}

/* Active filter pills container */
.active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.active-filters:empty {
    display: none;
}

.filter-pill-active {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--primary);
    color: white;
    border-radius: 100px;
    font-size: 13px;
    font-weight: 500;
}

.filter-pill-active .filter-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.15s;
}

.filter-pill-active .filter-remove:hover {
    background: rgba(255, 255, 255, 0.4);
}

.filter-pill-active .filter-remove svg {
    width: 10px;
    height: 10px;
}

/* Action selection UI */
.action-section {
    margin-bottom: 16px;
}

.action-section.one-time-section {
    margin-top: 24px;
}

.section-divider {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    gap: 12px;
}

.section-divider::before,
.section-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--gray-300);
}

.section-divider span {
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-400);
    letter-spacing: 0.5px;
}

.action-select-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: white;
    border-radius: var(--radius-lg);
    margin-bottom: 8px;
    box-shadow: var(--shadow);
    transition: transform 0.1s, box-shadow 0.1s;
}

.action-select-item.one-time {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    box-shadow: none;
}

.action-select-item.one-time .action-select-name {
    color: var(--gray-600);
}

.action-select-item.one-time .action-select-meta {
    color: var(--gray-400);
}

/* Custom checkbox */
.action-select-checkbox {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    cursor: pointer;
    flex-shrink: 0;
}

.action-select-checkbox input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

.action-select-checkbox .checkmark {
    width: 22px;
    height: 22px;
    border: 2px solid var(--gray-300);
    border-radius: 6px;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.action-select-checkbox input:checked + .checkmark {
    background: var(--primary);
    border-color: var(--primary);
}

.action-select-checkbox .checkmark::after {
    content: '';
    display: none;
    width: 6px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) translate(-1px, -1px);
}

.action-select-checkbox input:checked + .checkmark::after {
    display: block;
}

.action-select-content {
    flex: 1;
    min-width: 0;
    cursor: pointer;
}

.action-select-name {
    font-weight: 500;
    color: var(--gray-800);
    margin-bottom: 2px;
}

.action-select-meta {
    font-size: 13px;
    color: var(--gray-500);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
}

/* Week Filter Bar */
.week-filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    padding: 8px 12px;
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.filter-search {
    flex: 1;
    position: relative;
    min-width: 0;
}

.filter-search-icon {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--gray-400);
    pointer-events: none;
}

.filter-search-input {
    width: 100%;
    padding: 6px 8px 6px 30px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 14px;
    background: var(--gray-50);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.filter-search-input:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.filter-search-input::placeholder {
    color: var(--gray-400);
}

.filter-sort-select {
    padding: 6px 10px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--gray-50);
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-600);
    cursor: pointer;
    white-space: nowrap;
    appearance: auto;
    flex-shrink: 0;
}

.filter-status-pills {
    display: flex;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
    flex-shrink: 0;
}

.filter-pill {
    padding: 6px 10px;
    border: none;
    background: var(--gray-50);
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-500);
    cursor: pointer;
    transition: all 0.2s;
    border-right: 1px solid var(--gray-200);
}

.filter-pill:last-child {
    border-right: none;
}

.filter-pill:hover {
    background: var(--gray-100);
}

.filter-pill.active {
    background: var(--primary);
    color: white;
}

/* Mobile: stack filter bar */
@media (max-width: 480px) {
    .week-filter-bar {
        flex-wrap: wrap;
    }

    .filter-search {
        flex-basis: 100%;
    }

    .filter-sort-select {
        flex: 1;
    }

    .filter-status-pills {
        flex: 1;
    }

    .filter-pill {
        flex: 1;
        text-align: center;
    }
}

/* Overall Caveat */
.overall-caveat {
    margin-top: 24px;
    padding: 12px 16px;
    font-size: 14px;
    color: var(--gray-500);
    font-style: italic;
    text-align: center;
}
