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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #f5f6fa;
    color: #2d3436;
}

/* ── Shell layout ── */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 220px;
    background: #2d3436;
    color: #dfe6e9;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.main-content { flex: 1; padding: 2rem; max-width: 960px; }

/* ── Nav ── */
.nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1rem;
    border-bottom: 1px solid #3d4246;
}
.nav-brand { font-size: 1.1rem; font-weight: 700; color: #fff; }
.nav-toggle { background: none; border: none; color: #dfe6e9; font-size: 1.3rem; cursor: pointer; }

.nav-body { padding: 1rem 0; }
.nav-body.collapsed { display: none; }

.nav-link {
    display: block;
    padding: 0.75rem 1.25rem;
    color: #b2bec3;
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: all 0.15s;
}
.nav-link:hover { color: #fff; background: #3d4246; }
.nav-link.active { color: #fff; border-left-color: #74b9ff; background: #3d4246; }

/* ── Page header ── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.page-header h2 { font-size: 1.5rem; font-weight: 700; }

/* ── Date picker ── */
.date-picker {
    padding: 0.4rem 0.75rem;
    border: 1px solid #dfe6e9;
    border-radius: 6px;
    font-size: 0.95rem;
}

/* ── Add goal row ── */
.add-goal-row { display: flex; gap: 0.75rem; margin-bottom: 1.5rem; }

.goal-input {
    flex: 1;
    padding: 0.6rem 1rem;
    border: 1px solid #dfe6e9;
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.15s;
}
.goal-input:focus { border-color: #74b9ff; }

.btn-add {
    padding: 0.6rem 1.25rem;
    background: #0984e3;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-add:hover { background: #0770c4; }
.btn-add:disabled { background: #b2bec3; cursor: not-allowed; }

/* ── Goal list ── */
.goal-list { display: flex; flex-direction: column; gap: 0.75rem; }

.goal-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: #fff;
    border-radius: 10px;
    padding: 0.85rem 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.goal-title { flex: 1; font-size: 1rem; }

.status-buttons { display: flex; gap: 0.4rem; }

.btn-status {
    padding: 0.35rem 0.75rem;
    border: 1px solid #dfe6e9;
    border-radius: 6px;
    background: #f5f6fa;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.15s;
}
.btn-status:hover { background: #dfe6e9; }

.btn-status.active-green  { background: #00b894; color: #fff; border-color: #00b894; }
.btn-status.active-yellow { background: #fdcb6e; color: #2d3436; border-color: #fdcb6e; }
.btn-status.active-red    { background: #d63031; color: #fff; border-color: #d63031; }

.btn-delete {
    background: none;
    border: none;
    color: #b2bec3;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0.25rem;
    border-radius: 4px;
    transition: color 0.15s;
}
.btn-delete:hover { color: #d63031; }

/* ── Filter bar ── */
.filter-bar { display: flex; gap: 0.5rem; }

.filter-btn {
    padding: 0.4rem 1rem;
    border: 1px solid #dfe6e9;
    border-radius: 20px;
    background: #fff;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.15s;
}
.filter-btn.active { background: #0984e3; color: #fff; border-color: #0984e3; }
.filter-btn:hover:not(.active) { background: #dfe6e9; }

/* ── Calendar nav ── */
.calendar-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.25rem 0;
}
.nav-btn {
    padding: 0.35rem 0.85rem;
    border: 1px solid #dfe6e9;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    font-size: 1rem;
}
.nav-btn:hover { background: #dfe6e9; }
.period-label { font-weight: 600; font-size: 1.1rem; }

/* ── Legend ── */
.legend { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.25rem; font-size: 0.85rem; }
.legend-dot {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    margin-right: 4px;
}

/* ── Calendar grid ── */
.calendar-month { margin-bottom: 2rem; }
.month-label { font-weight: 700; font-size: 1rem; margin-bottom: 0.5rem; }

.calendar-day-headers {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-bottom: 2px;
}
.day-header { text-align: center; font-size: 0.75rem; color: #636e72; padding: 0.25rem 0; font-weight: 600; }

.calendar-grid { display: flex; flex-direction: column; gap: 2px; }
.calendar-week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }

.calendar-day {
    aspect-ratio: 1;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s, transform 0.1s;
    min-height: 42px;
    position: relative;
}
.calendar-day:hover { opacity: 0.8; transform: scale(1.05); }
.calendar-day.empty { background: transparent; cursor: default; pointer-events: none; }

.calendar-day.gray   { background: #dfe6e9; }
.calendar-day.green  { background: #00b894; }
.calendar-day.yellow { background: #fdcb6e; }
.calendar-day.red    { background: #d63031; }

.calendar-day.today { outline: 2px solid #0984e3; outline-offset: 1px; }

.day-number { font-size: 0.8rem; font-weight: 600; color: #2d3436; }
.calendar-day.green .day-number,
.calendar-day.red   .day-number { color: #fff; }

.goal-count {
    font-size: 0.65rem;
    background: rgba(0,0,0,0.18);
    border-radius: 10px;
    padding: 0 4px;
    color: #fff;
    margin-top: 2px;
}

/* ── Yearly grid ── */
.yearly-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}
.yearly-month { background: #fff; border-radius: 10px; padding: 1rem; box-shadow: 0 1px 4px rgba(0,0,0,.06); }

/* ── Auth pages ── */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 70vh;
}

.auth-card {
    background: #fff;
    border-radius: 12px;
    padding: 2rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 16px rgba(0,0,0,.08);
}

.auth-title { font-size: 1.5rem; font-weight: 700; margin-bottom: 1.5rem; }

.auth-field { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1rem; }
.auth-field label { font-size: 0.85rem; font-weight: 600; color: #636e72; }
.auth-hint { font-weight: 400; color: #b2bec3; }

.auth-btn { width: 100%; margin-top: 0.5rem; padding: 0.7rem; font-size: 1rem; }

.auth-error {
    background: #ffeaea;
    color: #d63031;
    border-radius: 6px;
    padding: 0.6rem 0.85rem;
    font-size: 0.88rem;
    margin-bottom: 1rem;
}

.auth-switch { margin-top: 1.25rem; text-align: center; font-size: 0.88rem; color: #636e72; }
.auth-switch a { color: #0984e3; text-decoration: none; font-weight: 600; }

/* ── Alert ── */
.alert-error {
    background: #ffeaea;
    color: #d63031;
    border-radius: 6px;
    padding: 0.6rem 0.85rem;
    font-size: 0.88rem;
    margin-bottom: 1rem;
}

/* ── Nav footer ── */
.nav-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid #3d4246;
    margin-top: auto;
}
.nav-user { display: block; font-size: 0.8rem; color: #b2bec3; margin-bottom: 0.5rem; }
.nav-logout {
    background: none;
    border: 1px solid #636e72;
    color: #b2bec3;
    border-radius: 6px;
    padding: 0.3rem 0.75rem;
    font-size: 0.82rem;
    cursor: pointer;
    width: 100%;
    transition: all 0.15s;
}
.nav-logout:hover { border-color: #d63031; color: #d63031; }

/* ── View toggle ── */
.view-toggle { display: flex; gap: 0.4rem; }

/* ── Weekly tracker ── */
.date-label { font-size: 0.85rem; color: #636e72; align-self: center; white-space: nowrap; }

.weekly-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.25rem 0;
}

.weekly-table-wrapper {
    overflow-x: auto;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.weekly-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    min-width: 640px;
}

.weekly-table thead th {
    padding: 0.6rem 0.75rem;
    text-align: center;
    font-size: 0.82rem;
    font-weight: 700;
    color: #636e72;
    background: #f5f6fa;
    border-bottom: 2px solid #dfe6e9;
}

.weekly-table thead th.goal-col { text-align: left; }

.weekly-table thead th.today-col {
    background: #e8f4fd;
    color: #0984e3;
}

.day-date { font-size: 0.75rem; font-weight: 400; color: #b2bec3; }
.today-col .day-date { color: #74b9ff; }

.weekly-table tbody tr:not(:last-child) td {
    border-bottom: 1px solid #f0f2f5;
}

.goal-row-header {
    padding: 0.6rem 0.75rem;
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    background: #f5f6fa;
    border-right: 2px solid #dfe6e9;
    min-width: 140px;
}

.status-cell {
    padding: 0.35rem 0.5rem;
    text-align: center;
    transition: background 0.15s;
}

.status-cell select {
    width: 100%;
    padding: 0.3rem 0.4rem;
    border: none;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    background: transparent;
    font-weight: 600;
    appearance: none;
    text-align: center;
}

.cell-green  { background: #00b894; }
.cell-yellow { background: #fdcb6e; }
.cell-red    { background: #d63031; }
.cell-gray   { background: #f5f6fa; }

.cell-green  select { color: #fff; }
.cell-yellow select { color: #2d3436; }
.cell-red    select { color: #fff; }
.cell-gray   select { color: #636e72; }

.cell-green  select option,
.cell-yellow select option,
.cell-red    select option,
.cell-gray   select option { color: #2d3436; background: #fff; }

/* ── States ── */
.loading, .empty-state { color: #636e72; font-size: 0.95rem; margin-top: 1rem; }

/* ── Blazor error UI ── */
#blazor-error-ui {
    background: #fff3cd;
    border-top: 1px solid #ffc107;
    bottom: 0; position: fixed; width: 100%;
    padding: 0.6rem 1rem;
    display: none;
    z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; float: right; }

@media (max-width: 640px) {
    .app-shell { flex-direction: column; }
    .sidebar { width: 100%; }
    .yearly-grid { grid-template-columns: repeat(2, 1fr); }
}
