:root {
    --primary: #2563eb;
    --success: #16a34a;
    --warning: #f59e0b;
    --danger: #dc2626;
    --bg: #f4f6fb;
    --text: #0f172a;
    --muted: #64748b;
    --card-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
    --radius: 16px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
    color: var(--text);
    background: linear-gradient(180deg, #f8faff 0%, var(--bg) 100%);
}

a {
    color: var(--primary);
    text-decoration: none;
}

.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 16px;
}

.auth-card {
    width: 100%;
    max-width: 430px;
    background: #fff;
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--card-shadow);
}

.app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 250px;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    background: #ffffff;
    border-right: 1px solid #e2e8f0;
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.brand {
    font-weight: 700;
    font-size: 20px;
    margin-bottom: 16px;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav a {
    padding: 10px 12px;
    border-radius: 12px;
    color: var(--text);
}

.nav a.active,
.nav a:hover {
    background: #e8efff;
    color: var(--primary);
}

.content {
    margin-left: 250px;
    width: calc(100% - 250px);
    padding: 24px;
}

.header h1 {
    margin: 0;
}

.grid {
    display: grid;
    gap: 20px;
}

.cards-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.cards-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.card {
    background: #fff;
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--card-shadow);
}

.kpi {
    margin: 8px 0;
    font-size: 30px;
    font-weight: 700;
}

.muted {
    color: var(--muted);
}

.small {
    font-size: 13px;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

label {
    display: flex;
    flex-direction: column;
    gap: 7px;
    font-weight: 500;
}

input,
select,
textarea {
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 15px;
    outline: none;
    width: 100%;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
}

.btn {
    border: none;
    border-radius: 12px;
    padding: 10px 14px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    display: inline-block;
    text-align: center;
}

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

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

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

.btn-ghost {
    background: #e2e8f0;
    color: #0f172a;
}

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

.alert {
    padding: 12px;
    border-radius: 12px;
    margin: 10px 0 16px;
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
}

.mt {
    margin-top: 20px;
}

.mt-sm {
    margin-top: 14px;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 10px;
    border-bottom: 1px solid #e2e8f0;
    text-align: left;
    font-size: 14px;
}

.habit-item {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px;
}

.habit-calendar {
    display: grid;
    grid-template-rows: repeat(7, 18px);
    grid-auto-flow: column;
    gap: 0;
    margin-bottom: 12px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.day-cell {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    margin: 2px;
    transition: 0.15s ease;
    cursor: pointer;
}

.day-cell:hover {
    transform: scale(1.2);
}

.null-day {
    background: #e5e7eb;
}

.success-day {
    background: #16a34a;
}

.fail-day {
    background: #dc2626;
}

.habit-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.badge {
    background: #ecfeff;
    color: #155e75;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
}

.progress {
    height: 10px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress span {
    display: block;
    height: 100%;
    background: var(--success);
}

.habit-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    font-size: 13px;
    color: #334155;
}

.note {
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 8px;
}

@media (max-width: 1024px) {
    .sidebar {
        position: static;
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
    }

    .app {
        flex-direction: column;
    }

    .content {
        margin-left: 0;
        width: 100%;
    }

    .cards-2,
    .cards-3 {
        grid-template-columns: 1fr;
    }
}
