:root {
    --bg: #0b0d10;
    --surface: #13161b;
    --surface-hover: #191d24;
    --border: #272c35;

    --text: #f4f7fb;
    --muted: #8e98a8;

    --primary: #5b8cff;
    --primary-hover: #4779ee;

    --success: #36c78c;
    --danger: #f05d6b;
    --warning: #f6b84a;

    --radius: 18px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;

    background:
        radial-gradient(
            circle at top right,
            rgba(91, 140, 255, 0.1),
            transparent 30%
        ),
        var(--bg);

    color: var(--text);

    font-family: "Inter", sans-serif;
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

.app {
    width: min(1400px, calc(100% - 40px));
    margin: 0 auto;
    padding: 40px 0;
}

/* =========================
   HEADER
========================= */

.header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 30px;

    margin-bottom: 30px;
}

.eyebrow {
    margin: 0 0 8px;

    color: var(--primary);

    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.14em;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 10px;

    font-size: clamp(32px, 5vw, 48px);
    letter-spacing: -0.04em;
}

h2 {
    margin-bottom: 0;

    font-size: 21px;
    letter-spacing: -0.02em;
}

.subtitle {
    max-width: 650px;

    margin-bottom: 0;

    color: var(--muted);
    line-height: 1.6;
}

.privacy-badge {
    display: flex;
    align-items: center;
    gap: 9px;

    padding: 10px 14px;

    color: #b7c1d1;
    background: rgba(19, 22, 27, 0.8);

    border: 1px solid var(--border);
    border-radius: 999px;

    font-size: 13px;
    white-space: nowrap;
}

.privacy-dot {
    width: 8px;
    height: 8px;

    background: var(--success);
    border-radius: 50%;
}

/* =========================
   MESSAGE
========================= */

.message-box {
    display: none;

    margin-bottom: 20px;
    padding: 14px 18px;

    border-radius: 12px;
    font-size: 14px;
}

.message-box.show {
    display: block;
}

.message-box.success {
    color: #a7f1d0;
    background: rgba(54, 199, 140, 0.12);
    border: 1px solid rgba(54, 199, 140, 0.25);
}

.message-box.error {
    color: #ffb6be;
    background: rgba(240, 93, 107, 0.12);
    border: 1px solid rgba(240, 93, 107, 0.25);
}

/* =========================
   STATS
========================= */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;

    margin-bottom: 16px;
}

.stat-card,
.panel {
    background: rgba(19, 22, 27, 0.94);

    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.stat-card {
    min-height: 190px;
    padding: 22px;
}

.stat-card.main-stat {
    border-color: rgba(91, 140, 255, 0.35);

    background:
        linear-gradient(
            135deg,
            rgba(91, 140, 255, 0.12),
            transparent
        ),
        var(--surface);
}

.stat-top {
    display: flex;
    align-items: center;
    justify-content: space-between;

    margin-bottom: 20px;
}

.stat-label {
    color: var(--muted);

    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.12em;
}

.stat-icon {
    font-size: 18px;
}

.stat-value {
    display: flex;
    align-items: baseline;
    gap: 8px;

    margin-bottom: 10px;
}

.stat-value span {
    font-size: 52px;
    font-weight: 800;
    letter-spacing: -0.06em;
}

.stat-value small {
    color: var(--muted);
}

.medium-value {
    margin-bottom: 14px;

    font-size: 25px;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.stat-description {
    margin-bottom: 0;

    color: var(--muted);

    font-size: 13px;
    line-height: 1.5;
}

/* =========================
   DASHBOARD
========================= */

.dashboard-grid {
    display: grid;
    grid-template-columns: 0.85fr 1.15fr;
    gap: 16px;

    margin-bottom: 16px;
}

.bottom-grid {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 16px;

    margin-top: 16px;
}

.panel {
    padding: 25px;
}

.panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;

    margin-bottom: 24px;
}

.panel-description {
    color: var(--muted);

    line-height: 1.7;

    margin-bottom: 24px;
}

/* =========================
   BUTTONS
========================= */

.primary-btn,
.secondary-btn,
.danger-btn {
    border: 0;
    border-radius: 12px;

    padding: 13px 17px;

    font-size: 14px;
    font-weight: 700;

    transition: 0.2s ease;
}

.primary-btn {
    width: 100%;

    margin-bottom: 10px;

    color: white;
    background: var(--primary);
}

.primary-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.primary-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.secondary-btn {
    color: #c5cedc;
    background: #1a1f27;

    border: 1px solid var(--border);
}

.secondary-btn:hover {
    background: #202630;
}

.action-panel .secondary-btn {
    width: 100%;
}

.full-width {
    width: 100%;
}

.danger-btn {
    color: #ffc5cb;
    background: rgba(240, 93, 107, 0.1);

    border: 1px solid rgba(240, 93, 107, 0.25);
}

.danger-btn:hover {
    background: rgba(240, 93, 107, 0.18);
}

/* =========================
   WEEKLY
========================= */

.week-range {
    color: var(--muted);

    font-size: 12px;
}

.progress-wrapper {
    margin-bottom: 28px;
}

.progress-info {
    display: flex;
    justify-content: space-between;

    margin-bottom: 10px;

    color: var(--muted);
    font-size: 13px;
}

.progress-info strong {
    color: var(--text);
}

.progress-bar {
    overflow: hidden;

    height: 9px;

    background: #0d1014;
    border-radius: 999px;
}

.progress-fill {
    width: 0%;
    height: 100%;

    background: var(--success);
    border-radius: inherit;

    transition: width 0.3s ease;
}

.progress-fill.exceeded {
    background: var(--danger);
}

.week-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}

.week-day {
    min-height: 70px;

    padding: 10px 6px;

    background: #101318;

    border: 1px solid var(--border);
    border-radius: 12px;

    text-align: center;
}

.week-day-name {
    display: block;

    color: var(--muted);

    font-size: 10px;
    font-weight: 700;
}

.week-day-number {
    display: block;

    margin: 6px 0;

    font-size: 15px;
    font-weight: 700;
}

.day-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 18px;
    height: 18px;

    color: var(--muted);

    font-size: 11px;
}

.week-day.active {
    border-color: rgba(91, 140, 255, 0.5);
    background: rgba(91, 140, 255, 0.08);
}

.week-day.active .day-status {
    color: var(--success);
}

/* =========================
   CALENDAR
========================= */

.calendar-panel {
    margin-top: 0;
}

.calendar-header {
    align-items: center;
}

.calendar-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.calendar-controls strong {
    min-width: 145px;
    text-align: center;
}

.icon-btn {
    width: 34px;
    height: 34px;

    color: var(--text);
    background: #1a1f27;

    border: 1px solid var(--border);
    border-radius: 9px;

    font-size: 22px;
}

.calendar-weekdays,
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}

.calendar-weekdays {
    margin-bottom: 8px;
}

.calendar-weekdays span {
    padding: 8px;

    color: var(--muted);

    font-size: 11px;
    font-weight: 700;
    text-align: center;
}

.calendar-day {
    position: relative;

    min-height: 80px;

    padding: 10px;

    background: #101318;

    border: 1px solid var(--border);
    border-radius: 12px;
}

.calendar-day.empty {
    background: transparent;
    border-color: transparent;
}

.calendar-day.today {
    border-color: rgba(91, 140, 255, 0.8);
}

.calendar-day.recorded {
    background: rgba(54, 199, 140, 0.08);
    border-color: rgba(54, 199, 140, 0.35);
}

.calendar-day.recorded::after {
    content: "✓";

    position: absolute;
    right: 9px;
    bottom: 8px;

    color: var(--success);

    font-size: 13px;
    font-weight: 800;
}

/* =========================
   HISTORY
========================= */

.count-badge {
    padding: 7px 10px;

    color: #b6c1d0;
    background: #1a1f27;

    border: 1px solid var(--border);
    border-radius: 999px;

    font-size: 11px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;

    max-height: 350px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 14px;

    background: #101318;

    border: 1px solid var(--border);
    border-radius: 12px;
}

.history-date {
    font-size: 14px;
    font-weight: 600;
}

.history-meta {
    color: var(--muted);

    font-size: 11px;
}

.delete-entry {
    width: 30px;
    height: 30px;

    color: #ff9da8;
    background: transparent;

    border: 1px solid rgba(240, 93, 107, 0.2);
    border-radius: 8px;
}

.empty-state {
    padding: 35px 15px;

    color: var(--muted);

    text-align: center;
}

/* =========================
   SETTINGS
========================= */

.settings-group {
    margin-bottom: 20px;
}

.settings-group label {
    display: block;

    margin-bottom: 10px;

    font-size: 13px;
    font-weight: 600;
}

.input-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.input-row input {
    width: 90px;

    padding: 11px;

    color: var(--text);
    background: #101318;

    border: 1px solid var(--border);
    border-radius: 10px;

    outline: none;
}

.input-row input:focus {
    border-color: var(--primary);
}

.input-row span {
    color: var(--muted);
    font-size: 12px;
}

/* =========================
   DATA
========================= */

.data-panel {
    margin-top: 16px;
}

.data-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.data-actions > div {
    padding: 18px;

    background: #101318;

    border: 1px solid var(--border);
    border-radius: 14px;
}

.data-actions h3 {
    margin-bottom: 8px;

    font-size: 14px;
}

.data-actions p {
    min-height: 38px;

    color: var(--muted);

    font-size: 12px;
    line-height: 1.5;
}

.import-label {
    display: inline-block;
}

.danger-zone {
    border-color: rgba(240, 93, 107, 0.2) !important;
}

footer {
    padding: 35px 0 5px;

    color: #667080;

    font-size: 12px;
    text-align: center;
}

/* =========================
   RESPONSIVE
========================= */

@media (max-width: 1050px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .dashboard-grid,
    .bottom-grid {
        grid-template-columns: 1fr;
    }

    .data-actions {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 650px) {
    .app {
        width: min(100% - 24px, 1400px);
        padding: 22px 0;
    }

    .header {
        flex-direction: column;
    }

    .privacy-badge {
        white-space: normal;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .panel,
    .stat-card {
        padding: 18px;
    }

    .week-days {
        gap: 4px;
    }

    .week-day {
        min-height: 60px;
        padding: 8px 2px;
    }

    .week-day-name {
        font-size: 8px;
    }

    .calendar-day {
        min-height: 48px;
        padding: 7px;
    }

    .calendar-day.recorded::after {
        right: 5px;
        bottom: 3px;
    }

    .calendar-weekdays,
    .calendar-grid {
        gap: 4px;
    }

    .calendar-weekdays span {
        padding: 5px 0;
        font-size: 9px;
    }

    .calendar-controls strong {
        min-width: 110px;
        font-size: 12px;
    }
}




/* =========================
   CUSTOM MODAL
========================= */

.custom-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 20px;

    opacity: 0;
    visibility: hidden;

    transition:
        opacity 0.2s ease,
        visibility 0.2s ease;
}

.custom-modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-overlay {
    position: absolute;
    inset: 0;

    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

.modal-box {
    position: relative;
    z-index: 2;

    width: min(100%, 430px);

    padding: 26px;

    background: #171b21;

    border: 1px solid #303846;
    border-radius: 20px;

    box-shadow:
        0 25px 80px rgba(0, 0, 0, 0.55);

    transform: translateY(10px) scale(0.97);

    transition:
        transform 0.2s ease;
}

.custom-modal.show .modal-box {
    transform: translateY(0) scale(1);
}

.modal-icon {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 46px;
    height: 46px;

    margin-bottom: 18px;

    color: #9abfff;
    background: rgba(91, 140, 255, 0.12);

    border: 1px solid rgba(91, 140, 255, 0.3);
    border-radius: 14px;

    font-size: 20px;
    font-weight: 800;
}

.modal-content h3 {
    margin: 0 0 10px;

    color: #f4f7fb;

    font-size: 20px;
}

.modal-content p {
    margin: 0;

    color: #98a2b3;

    font-size: 14px;
    line-height: 1.65;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;

    margin-top: 26px;
}

.modal-btn {
    min-width: 100px;

    padding: 11px 17px;

    border-radius: 10px;

    font-size: 14px;
    font-weight: 700;

    transition: 0.2s ease;
}

.modal-cancel {
    color: #c1cad7;
    background: #222832;

    border: 1px solid #343d4b;
}

.modal-cancel:hover {
    background: #2a313d;
}

.modal-confirm {
    color: #ffffff;
    background: #5b8cff;

    border: 1px solid #5b8cff;
}

.modal-confirm:hover {
    background: #4779ee;
    transform: translateY(-1px);
}

/* Danger modal */

.custom-modal.danger .modal-icon {
    color: #ff9daa;
    background: rgba(240, 93, 107, 0.12);
    border-color: rgba(240, 93, 107, 0.3);
}

.custom-modal.danger .modal-confirm {
    background: #e84f60;
    border-color: #e84f60;
}

.custom-modal.danger .modal-confirm:hover {
    background: #d94152;
}

/* Success modal */

.custom-modal.success .modal-icon {
    color: #7de0b5;
    background: rgba(54, 199, 140, 0.12);
    border-color: rgba(54, 199, 140, 0.3);
}

@media (max-width: 500px) {
    .modal-box {
        padding: 22px;
    }

    .modal-actions {
        flex-direction: column-reverse;
    }

    .modal-btn {
        width: 100%;
    }
}