:root {
    --background: #050a11;
    --background-soft: #07111f;
    --surface: #0b1625;
    --surface-hover: #102238;
    --surface-light: #132942;

    --primary: #1687ff;
    --primary-dark: #0869d4;
    --primary-soft: rgba(22, 135, 255, 0.14);

    --text: #f5f9ff;
    --text-soft: #b4c4d8;
    --muted: #73869d;

    --border: rgba(151, 181, 214, 0.14);
    --border-strong: rgba(22, 135, 255, 0.35);

    --success: #28d17c;
    --warning: #ffb020;
    --danger: #ff5263;

    --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
    --sidebar-width: 250px;
    --radius-large: 22px;
    --radius-medium: 15px;
    --radius-small: 10px;

    color-scheme: dark;
}

body.light-theme {
    --background: #edf4fc;
    --background-soft: #f6faff;
    --surface: #ffffff;
    --surface-hover: #edf6ff;
    --surface-light: #e5f1ff;

    --text: #07111f;
    --text-soft: #40536a;
    --muted: #718197;

    --border: rgba(13, 55, 97, 0.12);
    --border-strong: rgba(22, 135, 255, 0.35);

    --shadow: 0 18px 45px rgba(28, 70, 112, 0.12);

    color-scheme: light;
}

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

html {
    min-height: 100%;
    background: var(--background);
    scroll-behavior: smooth;
}

body {
    min-width: 320px;
    min-height: 100vh;
    overflow-x: hidden;
    background:
        radial-gradient(
            circle at 80% -10%,
            rgba(22, 135, 255, 0.14),
            transparent 30%
        ),
        var(--background);
    color: var(--text);
    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    line-height: 1.5;
    transition:
        background-color 0.25s ease,
        color 0.25s ease;
}

button,
input,
select {
    font: inherit;
}

button {
    color: inherit;
}

button,
label,
select,
input[type="date"],
input[type="month"],
input[type="color"] {
    -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 3px solid rgba(22, 135, 255, 0.28);
    outline-offset: 2px;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

input,
select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-small);
    background: var(--background-soft);
    color: var(--text);
    padding: 12px 14px;
    transition:
        border-color 0.2s ease,
        background-color 0.2s ease;
}

input:hover,
select:hover {
    border-color: var(--border-strong);
}

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

input[type="color"] {
    height: 48px;
    cursor: pointer;
    padding: 5px;
}

input[type="date"],
input[type="month"] {
    cursor: pointer;
}

body.light-theme input,
body.light-theme select {
    background: #f7faff;
}

body.light-theme input[type="date"],
body.light-theme input[type="month"] {
    color-scheme: light;
}

h1,
h2,
h3,
h4,
strong {
    letter-spacing: -0.02em;
}

p {
    color: var(--text-soft);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

.is-hidden {
    display: none !important;
}

.eyebrow {
    margin-bottom: 5px;
    color: var(--primary);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.14em;
}

/* SECURITY */

.security-screen {
    position: fixed;
    z-index: 5000;
    inset: 0;
    display: grid;
    place-items: center;
    min-height: 100dvh;
    padding:
        max(24px, env(safe-area-inset-top))
        20px
        max(24px, env(safe-area-inset-bottom));
    background:
        radial-gradient(
            circle at 50% 15%,
            rgba(22, 135, 255, 0.24),
            transparent 30%
        ),
        linear-gradient(145deg, #03070c, #071321 60%, #03070c);
}

.security-card {
    width: min(100%, 410px);
    padding: 38px;
    border: 1px solid rgba(92, 174, 255, 0.2);
    border-radius: 26px;
    background: rgba(7, 17, 31, 0.9);
    box-shadow:
        0 28px 80px rgba(0, 0, 0, 0.5),
        inset 0 1px rgba(255, 255, 255, 0.04);
    text-align: center;
    backdrop-filter: blur(20px);
}

.security-logo,
.brand-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    border: 1px solid rgba(0, 107, 255, 0.3);
    background: #000000;
    box-shadow: 0 10px 24px rgba(0, 107, 255, 0.16);
    font-family: "Arial Black", Arial, sans-serif;
    font-weight: 900;
}

.security-logo span,
.brand-logo span {
    display: block;
    color: #f7faff;
    line-height: 1;
}

.security-logo span:last-child,
.brand-logo span:last-child {
    margin-left: -0.13em;
    color: #006bff;
}

.security-logo {
    width: 72px;
    height: 72px;
    margin: 0 auto 25px;
    border-radius: 21px;
    font-size: 1.45rem;
}

.security-card h1 {
    margin-bottom: 9px;
    font-size: clamp(1.8rem, 6vw, 2.3rem);
}

.security-description {
    max-width: 320px;
    margin: 0 auto 27px;
    color: #93a7bf;
    font-size: 0.94rem;
}

#pinForm {
    display: grid;
    gap: 13px;
}

.pin-input {
    height: 57px;
    border-color: rgba(120, 177, 233, 0.2);
    background: rgba(2, 8, 14, 0.72);
    color: #ffffff;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 0.48em;
}

.pin-input::placeholder {
    color: #56718d;
    letter-spacing: 0.25em;
}

.form-message {
    display: none;
    min-height: 20px;
    color: var(--danger);
    font-size: 0.84rem;
    font-weight: 650;
}

.form-message.is-visible {
    display: block;
}

/* BUTTONS */

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 43px;
    border: 1px solid transparent;
    border-radius: 11px;
    padding: 10px 16px;
    cursor: pointer;
    font-size: 0.86rem;
    font-weight: 750;
    text-decoration: none;
    transition:
        transform 0.18s ease,
        border-color 0.18s ease,
        background-color 0.18s ease,
        opacity 0.18s ease;
}

.button:hover {
    transform: translateY(-1px);
}

.button:active {
    transform: scale(0.98);
}

.button-full {
    width: 100%;
}

.button-primary {
    background: linear-gradient(135deg, var(--primary), #0871df);
    color: #ffffff;
    box-shadow: 0 9px 22px rgba(22, 135, 255, 0.2);
}

.button-primary:hover {
    background: linear-gradient(135deg, #3198ff, var(--primary-dark));
}

.button-secondary {
    border-color: var(--border-strong);
    background: var(--primary-soft);
    color: var(--primary);
}

.button-secondary:hover {
    background: rgba(22, 135, 255, 0.2);
}

.button-ghost {
    border-color: var(--border);
    background: transparent;
    color: var(--text-soft);
}

.button-ghost:hover {
    border-color: var(--border-strong);
    color: var(--text);
}

.button-danger {
    background: rgba(255, 82, 99, 0.13);
    color: var(--danger);
}

.button-danger:hover {
    background: rgba(255, 82, 99, 0.22);
}

.icon-button {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    cursor: pointer;
    color: var(--text);
    font-size: 1rem;
    transition:
        border-color 0.2s ease,
        background-color 0.2s ease,
        transform 0.2s ease;
}

.icon-button:hover {
    border-color: var(--border-strong);
    background: var(--surface-hover);
    transform: translateY(-1px);
}

/* APP LAYOUT */

.app-shell {
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    z-index: 100;
    inset: 0 auto 0 0;
    display: flex;
    width: var(--sidebar-width);
    flex-direction: column;
    border-right: 1px solid var(--border);
    background: rgba(6, 14, 24, 0.94);
    padding: 25px 17px;
    backdrop-filter: blur(20px);
}

body.light-theme .sidebar {
    background: rgba(255, 255, 255, 0.93);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 8px 25px;
}

.brand-logo {
    width: 43px;
    height: 43px;
    border-radius: 13px;
    font-size: 0.92rem;
}

.brand div:last-child {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.brand strong {
    font-size: 1rem;
}

.brand span {
    color: var(--muted);
    font-size: 0.73rem;
}

.sidebar-navigation {
    display: grid;
    gap: 7px;
}

.nav-button {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 48px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: transparent;
    padding: 10px 13px;
    cursor: pointer;
    color: var(--muted);
    text-align: left;
    font-size: 0.86rem;
    font-weight: 700;
    transition:
        color 0.2s ease,
        background-color 0.2s ease,
        border-color 0.2s ease;
}

.nav-button:hover {
    border-color: var(--border);
    background: var(--surface);
    color: var(--text);
}

.nav-button.is-active {
    border-color: rgba(22, 135, 255, 0.16);
    background: var(--primary-soft);
    color: var(--primary);
}

.nav-icon {
    display: grid;
    place-items: center;
    width: 24px;
    font-size: 1.15rem;
}

.sidebar-footer {
    display: flex;
    margin-top: auto;
    flex-direction: column;
    border-top: 1px solid var(--border);
    padding: 19px 8px 0;
}

.sidebar-footer span {
    color: var(--muted);
    font-size: 0.7rem;
}

.sidebar-footer strong {
    margin-top: 2px;
    color: var(--success);
    font-size: 0.78rem;
}

.app-content {
    min-height: 100vh;
    margin-left: var(--sidebar-width);
}

.topbar {
    position: sticky;
    z-index: 80;
    top: 0;
    display: flex;
    min-height: 84px;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    border-bottom: 1px solid var(--border);
    background: rgba(5, 10, 17, 0.82);
    padding: 15px clamp(20px, 4vw, 45px);
    backdrop-filter: blur(20px);
}

body.light-theme .topbar {
    background: rgba(237, 244, 252, 0.82);
}

.topbar h2 {
    font-size: clamp(1.25rem, 3vw, 1.55rem);
}

.topbar-actions {
    display: flex;
    gap: 9px;
}

main {
    width: min(100%, 1500px);
    margin: 0 auto;
    padding: clamp(20px, 3.2vw, 40px);
}

.page {
    display: none;
    animation: pageFade 0.25s ease;
}

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

@keyframes pageFade {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* DASHBOARD */

.welcome-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 28px;
    overflow: hidden;
    border: 1px solid rgba(22, 135, 255, 0.24);
    border-radius: var(--radius-large);
    background:
        radial-gradient(
            circle at 88% 25%,
            rgba(60, 162, 255, 0.22),
            transparent 28%
        ),
        linear-gradient(135deg, #0a1b2e, #081321);
    padding: clamp(22px, 4vw, 34px);
    box-shadow: var(--shadow);
}

body.light-theme .welcome-panel {
    background:
        radial-gradient(
            circle at 88% 25%,
            rgba(22, 135, 255, 0.15),
            transparent 28%
        ),
        linear-gradient(135deg, #ffffff, #edf6ff);
}

.welcome-panel h3 {
    margin-bottom: 6px;
    font-size: clamp(1.3rem, 3vw, 1.85rem);
}

.welcome-panel > div:first-child {
    max-width: 700px;
}

.welcome-panel > div:first-child p:last-child {
    font-size: 0.92rem;
}

.date-control {
    display: grid;
    flex: 0 0 190px;
    gap: 7px;
}

.date-control label,
.filter-group label,
.form-group label {
    color: var(--text-soft);
    font-size: 0.77rem;
    font-weight: 750;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 15px;
    margin-top: 18px;
}

.stat-card {
    position: relative;
    overflow: hidden;
    min-height: 132px;
    border: 1px solid var(--border);
    border-radius: var(--radius-medium);
    background: var(--surface);
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

.stat-card::after {
    position: absolute;
    right: -24px;
    bottom: -24px;
    width: 75px;
    height: 75px;
    border-radius: 50%;
    background: rgba(22, 135, 255, 0.08);
    content: "";
}

.stat-card span {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 0.77rem;
    font-weight: 700;
}

.stat-card strong {
    display: block;
    color: var(--text);
    font-size: clamp(1.7rem, 4vw, 2.15rem);
}

.stat-card small {
    color: var(--text-soft);
    font-size: 0.72rem;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(300px, 0.8fr);
    gap: 18px;
    margin-top: 18px;
}

.panel {
    border: 1px solid var(--border);
    border-radius: var(--radius-large);
    background: var(--surface);
    padding: clamp(19px, 3vw, 25px);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.09);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.panel-header h3 {
    font-size: 1.05rem;
}

.daily-habit-list {
    display: grid;
    gap: 10px;
}

.habit-check-item {
    display: flex;
    align-items: center;
    gap: 13px;
    min-height: 67px;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: var(--background-soft);
    padding: 11px 14px;
    transition:
        border-color 0.2s ease,
        transform 0.2s ease,
        background-color 0.2s ease;
}

.habit-check-item:hover {
    border-color: var(--border-strong);
    transform: translateY(-1px);
}

.habit-check-item.is-completed {
    border-color: rgba(40, 209, 124, 0.2);
    background: rgba(40, 209, 124, 0.055);
}

.habit-checkbox {
    position: relative;
    display: grid;
    width: 29px;
    height: 29px;
    flex: 0 0 29px;
    place-items: center;
    border: 2px solid var(--habit-color, var(--primary));
    border-radius: 9px;
    background: transparent;
    cursor: pointer;
    transition:
        transform 0.17s ease,
        background-color 0.17s ease;
}

.habit-checkbox:hover {
    transform: scale(1.06);
}

.habit-checkbox.is-checked {
    background: var(--habit-color, var(--primary));
}

.habit-checkbox.is-checked::after {
    color: #ffffff;
    content: "✓";
    font-size: 0.91rem;
    font-weight: 900;
}

.habit-info {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
}

.habit-name {
    overflow: hidden;
    color: var(--text);
    font-size: 0.88rem;
    font-weight: 750;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.is-completed .habit-name {
    color: var(--text-soft);
    text-decoration: line-through;
}

.habit-category {
    color: var(--muted);
    font-size: 0.7rem;
}

.habit-color-dot {
    width: 9px;
    height: 9px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--habit-color, var(--primary));
    box-shadow: 0 0 9px var(--habit-color, var(--primary));
}

.empty-state {
    display: grid;
    min-height: 280px;
    place-items: center;
    align-content: center;
    text-align: center;
}

.empty-state.is-hidden {
    display: none;
}

.empty-state h4 {
    margin: 11px 0 3px;
}

.empty-state p {
    max-width: 320px;
    margin-bottom: 17px;
    color: var(--muted);
    font-size: 0.82rem;
}

.empty-icon {
    display: grid;
    width: 57px;
    height: 57px;
    place-items: center;
    border: 1px solid var(--border-strong);
    border-radius: 17px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 1.45rem;
    font-weight: 900;
}

.chart-container {
    position: relative;
    width: 100%;
    height: 220px;
}

#weeklyChart {
    width: 100%;
    height: 100%;
}

.progress-summary {
    display: flex;
    align-items: center;
    gap: 15px;
    border-top: 1px solid var(--border);
    margin-top: 19px;
    padding-top: 19px;
}

.progress-ring {
    --progress: 0deg;

    position: relative;
    display: grid;
    width: 67px;
    height: 67px;
    flex-shrink: 0;
    place-items: center;
    border-radius: 50%;
    background:
        radial-gradient(
            circle,
            var(--surface) 57%,
            transparent 59%
        ),
        conic-gradient(
            var(--primary) var(--progress),
            var(--surface-light) 0
        );
}

.progress-ring span {
    font-size: 0.78rem;
    font-weight: 850;
}

.progress-summary strong {
    font-size: 0.87rem;
}

.progress-summary p {
    margin-top: 2px;
    color: var(--muted);
    font-size: 0.72rem;
}

/* SECTION HEADING */

.section-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 23px;
}

.section-heading h3 {
    font-size: clamp(1.35rem, 3vw, 1.75rem);
}

.section-heading > div:first-child > p:last-child {
    margin-top: 4px;
    font-size: 0.84rem;
}

/* HABIT MANAGEMENT */

.management-list {
    display: grid;
    gap: 11px;
}

.management-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-medium);
    background: var(--surface);
    padding: 15px 17px;
    transition:
        border-color 0.2s ease,
        background-color 0.2s ease;
}

.management-item:hover {
    border-color: var(--border-strong);
}

.management-item.is-inactive {
    opacity: 0.58;
}

.management-color {
    width: 13px;
    height: 42px;
    border-radius: 10px;
    background: var(--habit-color, var(--primary));
}

.management-info {
    min-width: 0;
}

.management-info strong {
    display: block;
    overflow: hidden;
    font-size: 0.9rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.management-info span {
    color: var(--muted);
    font-size: 0.72rem;
}

.status-badge {
    border-radius: 999px;
    background: rgba(40, 209, 124, 0.11);
    color: var(--success);
    padding: 5px 10px;
    font-size: 0.68rem;
    font-weight: 800;
}

.status-badge.is-inactive {
    background: rgba(115, 134, 157, 0.12);
    color: var(--muted);
}

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

.action-button {
    display: grid;
    width: 35px;
    height: 35px;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--background-soft);
    cursor: pointer;
    color: var(--text-soft);
    font-size: 0.75rem;
    font-weight: 800;
    transition:
        border-color 0.18s ease,
        color 0.18s ease,
        background-color 0.18s ease;
}

.action-button:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.action-button.is-danger:hover {
    border-color: var(--danger);
    background: rgba(255, 82, 99, 0.08);
    color: var(--danger);
}

.management-empty {
    display: grid;
    min-height: 350px;
    place-items: center;
    align-content: center;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-large);
    text-align: center;
}

.management-empty p {
    margin: 5px 0 17px;
    color: var(--muted);
    font-size: 0.84rem;
}

/* HISTORY */

.history-heading {
    align-items: flex-end;
}

.filter-group {
    display: grid;
    width: 190px;
    flex-shrink: 0;
    gap: 6px;
}

.history-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 13px;
    margin-bottom: 17px;
}

.history-summary article {
    border: 1px solid var(--border);
    border-radius: var(--radius-medium);
    background: var(--surface);
    padding: 17px;
}

.history-summary span {
    display: block;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
}

.history-summary strong {
    display: block;
    margin-top: 3px;
    font-size: 1.45rem;
}

.history-table-wrapper {
    width: 100%;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-medium);
    background: var(--surface);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.08);
    scrollbar-color: var(--primary) var(--background-soft);
    scrollbar-width: thin;
}

.history-table {
    width: max-content;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.75rem;
}

.history-table th,
.history-table td {
    min-width: 42px;
    height: 45px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 6px;
    text-align: center;
}

.history-table th {
    position: sticky;
    z-index: 2;
    top: 0;
    background: var(--surface-light);
    color: var(--text-soft);
    font-weight: 800;
}

.history-table th:first-child,
.history-table td:first-child {
    position: sticky;
    z-index: 3;
    left: 0;
    min-width: 185px;
    max-width: 185px;
    background: var(--surface);
    text-align: left;
}

.history-table th:first-child {
    z-index: 4;
    background: var(--surface-light);
}

.history-table tr:last-child td {
    border-bottom: 0;
}

.history-table th:last-child,
.history-table td:last-child {
    border-right: 0;
}

.history-habit-name {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-dot {
    width: 7px;
    height: 7px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--habit-color, var(--primary));
}

.history-check {
    display: grid;
    width: 23px;
    height: 23px;
    margin: auto;
    place-items: center;
    border-radius: 7px;
    background: var(--background-soft);
    color: transparent;
    font-size: 0.7rem;
    font-weight: 900;
}

.history-check.is-completed {
    background: rgba(40, 209, 124, 0.15);
    color: var(--success);
}

.history-check.is-future {
    opacity: 0.35;
}

.history-check.is-off {
    background: rgba(115, 134, 157, 0.08);
    color: var(--muted);
    opacity: 0.7;
    font-size: 0.52rem;
    font-weight: 850;
}

.habit-check-item.is-weekly-target-complete {
    border-color: rgba(40, 209, 124, 0.32);
    background: rgba(40, 209, 124, 0.06);
}

.habit-check-item.is-weekly-target-complete
.habit-category {
    color: var(--success);
}

.management-info span {
    line-height: 1.4;
    white-space: normal;
}

/* SETTINGS */

.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 15px;
}

.setting-card {
    display: flex;
    min-height: 190px;
    align-items: flex-start;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: var(--radius-large);
    background: var(--surface);
    padding: 23px;
}

.setting-card h4 {
    margin-bottom: 6px;
    font-size: 1rem;
}

.setting-card p {
    max-width: 520px;
    margin-bottom: 22px;
    color: var(--muted);
    font-size: 0.81rem;
}

.setting-card .button {
    margin-top: auto;
}

.danger-card {
    border-color: rgba(255, 82, 99, 0.2);
}

.file-button {
    cursor: pointer;
}

.privacy-note {
    margin-top: 16px;
    border: 1px solid rgba(40, 209, 124, 0.18);
    border-radius: var(--radius-medium);
    background: rgba(40, 209, 124, 0.055);
    padding: 18px 20px;
}

.privacy-note strong {
    color: var(--success);
    font-size: 0.87rem;
}

.privacy-note p {
    margin-top: 3px;
    font-size: 0.78rem;
}

/* HABIT SCHEDULE */

.form-help {
    display: block;
    color: var(--muted);
    font-size: 0.7rem;
    line-height: 1.45;
}

.schedule-group {
    border: 1px solid var(--border);
    border-radius: 13px;
    background: var(--background-soft);
    padding: 14px;
}

.weekday-selector {
    display: grid;
    grid-template-columns: repeat(7, minmax(35px, 1fr));
    gap: 6px;
}

.weekday-option {
    position: relative;
    cursor: pointer;
}

.weekday-option input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.weekday-option span {
    display: grid;
    min-height: 38px;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface);
    color: var(--muted);
    font-size: 0.66rem;
    font-weight: 800;
    transition:
        border-color 0.18s ease,
        background-color 0.18s ease,
        color 0.18s ease,
        transform 0.18s ease;
}

.weekday-option:hover span {
    border-color: var(--border-strong);
    color: var(--text);
}

.weekday-option input:checked + span {
    border-color: var(--primary);
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 6px 15px rgba(22, 135, 255, 0.2);
}

.weekday-option input:focus-visible + span {
    outline: 3px solid rgba(22, 135, 255, 0.28);
    outline-offset: 2px;
}

.weekday-option:active span {
    transform: scale(0.95);
}

.weekly-target-input {
    display: grid;
    grid-template-columns: 90px minmax(0, 1fr);
    align-items: center;
    gap: 11px;
}

.weekly-target-input input {
    text-align: center;
    font-weight: 800;
}

.weekly-target-input span {
    color: var(--text-soft);
    font-size: 0.78rem;
    font-weight: 700;
}

/* MODAL */

.modal {
    position: fixed;
    z-index: 3000;
    inset: 0;
    display: grid;
    visibility: hidden;
    place-items: center;
    padding: 20px;
    opacity: 0;
    transition:
        visibility 0.2s ease,
        opacity 0.2s ease;
}

.modal.is-open {
    visibility: visible;
    opacity: 1;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 4, 10, 0.76);
    backdrop-filter: blur(7px);
}

.modal-card {
    position: relative;
    z-index: 1;
    width: min(100%, 475px);
    max-height: calc(100dvh - 40px);
    overflow-y: auto;
    border: 1px solid var(--border-strong);
    border-radius: 22px;
    background: var(--surface);
    padding: 25px;
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.5);
    transform: translateY(12px) scale(0.98);
    transition: transform 0.2s ease;
}

.modal.is-open .modal-card {
    transform: translateY(0) scale(1);
}

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}

.modal-close {
    display: grid;
    width: 35px;
    height: 35px;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--background-soft);
    cursor: pointer;
    color: var(--text-soft);
    font-size: 1.25rem;
}

#habitForm {
    display: grid;
    gap: 17px;
}

.form-group {
    display: grid;
    gap: 7px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 9px;
    margin-top: 8px;
}

.confirm-card {
    max-width: 390px;
    text-align: center;
}

.confirm-card h3 {
    margin: 13px 0 5px;
}

.confirm-card p {
    color: var(--muted);
    font-size: 0.85rem;
}

.confirm-card .modal-actions {
    justify-content: center;
    margin-top: 22px;
}

.confirm-icon {
    display: grid;
    width: 54px;
    height: 54px;
    margin: 0 auto;
    place-items: center;
    border-radius: 16px;
    background: rgba(255, 82, 99, 0.13);
    color: var(--danger);
    font-size: 1.4rem;
    font-weight: 900;
}

/* TOAST */

.toast {
    position: fixed;
    z-index: 6000;
    right: 22px;
    bottom: 22px;
    max-width: min(360px, calc(100% - 40px));
    visibility: hidden;
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    background: var(--surface-light);
    color: var(--text);
    box-shadow: var(--shadow);
    padding: 13px 17px;
    opacity: 0;
    font-size: 0.8rem;
    font-weight: 700;
    transform: translateY(12px);
    transition:
        visibility 0.25s ease,
        opacity 0.25s ease,
        transform 0.25s ease;
}

.toast.is-visible {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
}

.toast.is-error {
    border-color: rgba(255, 82, 99, 0.35);
    color: var(--danger);
}

/* MOBILE NAVIGATION */

.mobile-navigation {
    display: none;
}

/* TABLET */

@media (max-width: 1050px) {
    :root {
        --sidebar-width: 215px;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .chart-panel {
        min-height: 370px;
    }

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

/* MOBILE */

@media (max-width: 760px) {
    body {
        padding-bottom: calc(76px + env(safe-area-inset-bottom));
    }

    .sidebar {
        display: none;
    }

    .app-content {
        margin-left: 0;
    }

    .topbar {
        min-height: 73px;
        padding:
            max(11px, env(safe-area-inset-top))
            16px
            11px;
    }

    .topbar .eyebrow {
        font-size: 0.62rem;
    }

    .topbar h2 {
        font-size: 1.22rem;
    }

    .icon-button {
        width: 38px;
        height: 38px;
        border-radius: 10px;
    }

    main {
        padding: 17px 14px;
    }

    .welcome-panel {
        align-items: stretch;
        flex-direction: column;
        gap: 20px;
        border-radius: 18px;
        padding: 22px 18px;
    }

    .date-control {
        width: 100%;
        flex-basis: auto;
    }

    .stats-grid {
        gap: 10px;
        margin-top: 12px;
    }

    .stat-card {
        min-height: 112px;
        padding: 16px;
    }

    .stat-card strong {
        font-size: 1.65rem;
    }

    .dashboard-grid {
        gap: 12px;
        margin-top: 12px;
    }

    .panel {
        border-radius: 18px;
        padding: 17px;
    }

    .panel-header {
        align-items: flex-start;
        margin-bottom: 16px;
    }

    .panel-header .button {
        min-height: 38px;
        padding: 8px 11px;
        font-size: 0.73rem;
    }

    .habit-check-item {
        min-height: 64px;
        padding: 10px 12px;
    }

    .chart-container {
        height: 210px;
    }

    .section-heading,
    .history-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .section-heading > .button {
        width: 100%;
    }

    .filter-group {
        width: 100%;
    }

    .management-item {
        grid-template-columns: auto minmax(0, 1fr) auto;
        gap: 10px;
        padding: 13px;
    }

    .management-color {
        height: 39px;
    }

    .status-badge {
        display: none;
    }

    .item-actions {
        gap: 4px;
    }

    .action-button {
        width: 32px;
        height: 32px;
    }

    .history-summary {
        gap: 8px;
    }

    .history-summary article {
        padding: 13px 10px;
    }

    .history-summary span {
        font-size: 0.61rem;
    }

    .history-summary strong {
        font-size: 1.15rem;
    }

    .history-table th:first-child,
    .history-table td:first-child {
        min-width: 145px;
        max-width: 145px;
    }

    .settings-grid {
        grid-template-columns: 1fr;
        gap: 11px;
    }

    .setting-card {
        min-height: 170px;
        padding: 19px;
    }

    .mobile-navigation {
        position: fixed;
        z-index: 1000;
        right: 10px;
        bottom: max(9px, env(safe-area-inset-bottom));
        left: 10px;
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        border: 1px solid var(--border);
        border-radius: 17px;
        background: rgba(7, 17, 31, 0.94);
        padding: 6px;
        box-shadow: 0 18px 45px rgba(0, 0, 0, 0.34);
        backdrop-filter: blur(20px);
    }

    body.light-theme .mobile-navigation {
        background: rgba(255, 255, 255, 0.94);
    }

    .mobile-nav-button {
        display: grid;
        min-height: 51px;
        place-items: center;
        border: 0;
        border-radius: 12px;
        background: transparent;
        cursor: pointer;
        color: var(--muted);
    }

    .mobile-nav-button span {
        font-size: 1.04rem;
        line-height: 1;
    }

    .mobile-nav-button small {
        margin-top: 3px;
        font-size: 0.59rem;
        font-weight: 750;
    }

    .mobile-nav-button.is-active {
        background: var(--primary-soft);
        color: var(--primary);
    }

    .toast {
        right: 14px;
        bottom: calc(82px + env(safe-area-inset-bottom));
        left: 14px;
        max-width: none;
        text-align: center;
    }

    .security-card {
        padding: 31px 22px;
    }
}

@media (max-width: 420px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .stat-card {
        min-height: 105px;
        padding: 14px;
    }

    .stat-card span {
        font-size: 0.68rem;
    }

    .stat-card strong {
        font-size: 1.48rem;
    }

    .stat-card small {
        font-size: 0.62rem;
    }

    .panel-header {
        gap: 8px;
    }

    .history-summary {
        grid-template-columns: 1fr;
    }

    .history-summary article {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .history-summary strong {
        margin-top: 0;
    }

    .modal {
        align-items: end;
        padding: 10px;
    }

    .modal-card {
        width: 100%;
        max-height: calc(100dvh - 20px);
        border-radius: 22px 22px 15px 15px;
        padding: 21px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}