﻿html, body {
    height: 100%;
}

body {
    background: #f4f5f7;
    padding-bottom: 148px; /* leave room for fixed action bar + bottom nav */
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
}


.navbar-brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}



.brand-logo {
    display: inline-block;
    width: 78px;
    height: 28px;
    object-fit: contain;
}

.brand-logo-lg {
    width: 180px;
    height: auto;
}

.auth-brand {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 0;
}

.app-content {
    max-width: 520px;
    margin: 0 auto;
}

/* ---------- Bottom tab bar ---------- */

.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    background: #ffffff;
    border-top: 1px solid #dee2e6;
    padding-bottom: env(safe-area-inset-bottom, 0);
    z-index: 20;
}

.bottom-nav-item {
    flex: 1 1 0;
    text-align: center;
    padding: 8px 0 6px;
    font-size: 0.75rem;
    color: #6c757d;
    text-decoration: none;
}

.bottom-nav-item.active {
    color: #0d6efd;
    font-weight: 600;
}

.bottom-nav-icon {
    font-size: 1.4rem;
    line-height: 1.4rem;
}

/* ---------- Incremental mode: big number button ---------- */

.big-number-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 0;
}

.big-number-btn {
    width: 100%;
    max-width: 320px;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    font-size: 4rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    color: #fff;
    background: #0d6efd;
    box-shadow: 0 6px 18px rgba(13, 110, 253, 0.35);
}

.big-number-btn:active {
    background: #0b5ed7;
}

.big-number-btn:disabled {
    background: #adb5bd;
    box-shadow: none;
}

/* ---------- Random mode: keypad ---------- */

.number-display {
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: 0.4rem;
    text-align: center;
    padding: 16px 0;
    font-variant-numeric: tabular-nums;
}

.keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    max-width: 340px;
    margin: 0 auto;
}

.keypad-btn {
    aspect-ratio: 1 / 1;
    font-size: 1.8rem;
    font-weight: 600;
    border-radius: 16px;
    border: 1px solid #dee2e6;
    background: #fff;
}

.keypad-btn:active {
    background: #e9ecef;
}

.keypad-btn.keypad-clear {
    font-size: 1.3rem;
}

.register-btn-wrap {
    max-width: 340px;
    margin: 20px auto 0;
}

/* ---------- Numbers list ---------- */

.number-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.number-list-item .number {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 0.1rem;
}

.number-list-item .timestamp {
    color: #6c757d;
    font-size: 0.85rem;
}

/* ---------- Auth pages ---------- */

.auth-wrap {
    max-width: 380px;
    margin: 10vh auto 0;
    padding: 24px;
}

.otp-input {
    font-size: 2rem;
    letter-spacing: 0.6rem;
    text-align: center;
}

.number-list-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}

.map-btn {
    min-width: 64px;
}

.location-map {
    width: 100%;
    height: 360px;
    border: 0;
    border-radius: 8px;
}
.mode-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

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

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.stat-box {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 12px;
}

.stat-box span {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-box small {
    color: #6c757d;
}


.mode-bottom-actions {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(56px + env(safe-area-inset-bottom, 0) + 5px);
    z-index: 19;
    padding: 0 5px;
}

.mode-bottom-actions-inner {
    max-width: 520px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
}

.mode-bottom-actions .btn {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 42px;
    white-space: nowrap;
    background: #ffffff;
}

.btn-icon {
    line-height: 1;
    font-weight: 700;
}
.stats-btn-icon {
    display: inline-flex;
    width: 1.35rem;
    height: 1.35rem;
}

.stats-btn-icon svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.stats-icon-axis,
.stats-icon-bar {
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.stats-icon-axis {
    stroke-width: 2.2;
}

.stats-icon-bar {
    stroke-width: 2.8;
}

.graph-card {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 14px;
}

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

.graph-legend {
    display: flex;
    gap: 10px;
    font-size: 0.78rem;
    color: #6c757d;
}

.graph-legend span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.graph-legend i {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    display: inline-block;
}

.legend-user {
    background: #0d6efd;
}

.legend-average {
    background: #20c997;
}

.weekly-graph {
    height: 230px;
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 8px;
    align-items: end;
    border-left: 1px solid #dee2e6;
    border-bottom: 1px solid #dee2e6;
    padding: 10px 4px 0 8px;
}

.weekly-graph-day {
    min-width: 0;
    height: 100%;
    display: grid;
    grid-template-rows: 1fr auto auto;
    gap: 4px;
    text-align: center;
}

.weekly-bars {
    height: 100%;
    display: flex;
    align-items: end;
    justify-content: center;
    gap: 3px;
}

.weekly-bar {
    width: 12px;
    min-height: 0;
    border-radius: 4px 4px 0 0;
}

.user-bar {
    background: #0d6efd;
}

.average-bar {
    background: #20c997;
}

.weekly-value {
    font-size: 0.8rem;
    font-weight: 700;
}

.weekly-label {
    font-size: 0.68rem;
    color: #6c757d;
    white-space: nowrap;
}

.progress-graph-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    margin-bottom: 6px;
}

.progress-graph-track {
    height: 14px;
    border-radius: 999px;
    background: #e9ecef;
    overflow: hidden;
}

.progress-graph-fill {
    height: 100%;
    border-radius: 999px;
}

.primary-fill {
    background: #0d6efd;
}

.location-fill {
    background: #20c997;
}

.stats-list-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-top: 1px solid #edf0f2;
}

.stats-list-row:first-of-type {
    border-top: 0;
}
/* ---------- Sticky page headers ---------- */
.page-header {
    position: sticky;
    top: 56px;
    z-index: 18;
    margin: -16px -12px 18px;
    padding: 10px 12px;
    background: rgba(244, 245, 247, 0.96);
    border-bottom: 1px solid #dee2e6;
    backdrop-filter: blur(8px);
}

.page-header h1 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.25;
    display: flex;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
}

.page-header h1 span,
.page-header h1 small {
    color: #6c757d;
    font-size: 0.95rem;
    font-weight: 500;
}

/* ---------- Sticky bottom actions on pages that have them ---------- */
.mode-bottom-actions {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(56px + env(safe-area-inset-bottom, 0) + 5px);
    z-index: 19;
    padding: 0 5px;
}

.mode-bottom-actions-inner {
    max-width: 520px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
}

.mode-bottom-actions .btn {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 42px;
    white-space: nowrap;
    background: #ffffff;
}

.stats-extra-section {
    margin-bottom: 100px;
}
.numbers-list-section {
    margin-bottom: 100px;
}

.settings-toggle {
    width: 2.6rem;
    height: 1.3rem;
    flex: 0 0 auto;
}

/* ---------- Dark mode ---------- */
body.theme-dark {
    background: #111418;
    color: #f1f3f5;
}

body.theme-dark .page-header {
    background: rgba(17, 20, 24, 0.96);
    border-bottom-color: #2b3036;
}

body.theme-dark .page-header h1 small,
body.theme-dark .page-header h1 span,
body.theme-dark .text-muted,
body.theme-dark .timestamp,
body.theme-dark .chart-label,
body.theme-dark .chart-average,
body.theme-dark .weekly-label,
body.theme-dark .graph-legend,
body.theme-dark .stat-box small {
    color: #aeb6bf !important;
}

body.theme-dark .bottom-nav,
body.theme-dark .number-list-item,
body.theme-dark .stat-box,
body.theme-dark .graph-card,
body.theme-dark .list-group-item,
body.theme-dark .modal-content,
body.theme-dark .keypad-btn,
body.theme-dark .mode-bottom-actions .btn {
    background: #1b2026;
    color: #f1f3f5;
    border-color: #343a40;
}

body.theme-dark .bottom-nav {
    border-top-color: #343a40;
}

body.theme-dark .bottom-nav-item {
    color: #aeb6bf;
}

body.theme-dark .bottom-nav-item.active {
    color: #6ea8fe;
}

body.theme-dark .number-display,
body.theme-dark .weekly-value,
body.theme-dark .chart-value,
body.theme-dark .stat-box span,
body.theme-dark .stats-list-row strong {
    color: #f8f9fa;
}

body.theme-dark .keypad-btn:active {
    background: #2b3036;
}

body.theme-dark .big-number-btn,
body.theme-dark .chart-bar,
body.theme-dark .user-bar,
body.theme-dark .primary-fill {
    background: #4dabf7;
}

body.theme-dark .weekly-graph {
    border-left-color: #343a40;
    border-bottom-color: #343a40;
}

body.theme-dark .progress-graph-track,
body.theme-dark .chart-track {
    background: #2b3036;
}

body.theme-dark .stats-list-row {
    border-top-color: #343a40;
}

body.theme-dark .btn-outline-primary {
    color: #9ec5fe;
    border-color: #4778bf;
}

body.theme-dark .btn-outline-secondary {
    color: #ced4da;
    border-color: #6c757d;
}
body.theme-dark .settings-toggle-button {
    background: #2b3036;
    border-color: #495057;
    color: #ced4da;
}

body.theme-dark .settings-toggle-knob {
    background: #f8f9fa;
}

body.theme-dark .settings-toggle-input:checked + .settings-toggle-button {
    background: #4dabf7;
    border-color: #4dabf7;
    color: #111418;
}
/* ---------- Solid sticky surfaces ---------- */
.page-header {
    background: #f4f5f7;
    backdrop-filter: none;
}

.page-header::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 100%;
    height: 56px;
    background: #f4f5f7;
}

.mode-bottom-actions {
    background: #f4f5f7;
    padding-top: 5px;
}

.mode-bottom-actions::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    height: calc(56px + env(safe-area-inset-bottom, 0) + 5px);
    background: #f4f5f7;
}

.mode-bottom-actions.single-action .mode-bottom-actions-inner {
    grid-template-columns: 1fr;
}

.mode-bottom-actions.single-action .btn {
    width: 100%;
}

body.theme-dark .page-header,
body.theme-dark .page-header::before,
body.theme-dark .mode-bottom-actions,
body.theme-dark .mode-bottom-actions::after {
    background: #111418;
}








.settings-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    cursor: pointer;
}

.settings-toggle-control {
    position: relative;
    flex: 0 0 auto;
}

.settings-toggle-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.settings-toggle-button {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: center;
    width: 88px;
    height: 40px;
    padding: 4px;
    border: 1px solid #ced4da;
    border-radius: 999px;
    background: #e9ecef;
    color: #495057;
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1;
    transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.settings-toggle-label {
    position: relative;
    z-index: 2;
    text-align: center;
}

.settings-toggle-knob {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 40px;
    height: 30px;
    border-radius: 999px;
    background: #ffffff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.22);
    transition: transform 0.18s ease;
}

.settings-toggle-input:checked + .settings-toggle-button {
    background: #0d6efd;
    border-color: #0d6efd;
    color: #ffffff;
}

.settings-toggle-input:checked + .settings-toggle-button .settings-toggle-knob {
    transform: translateX(40px);
}

.settings-toggle-input:focus-visible + .settings-toggle-button {
    outline: 3px solid rgba(13, 110, 253, 0.28);
    outline-offset: 2px;
}

/* ---------- Application mode segmented switch ---------- */
.app-mode-setting {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
}

.app-mode-copy strong {
    display: block;
    font-size: 1.05rem;
    margin-bottom: 2px;
}

.app-mode-switch {
    display: block;
    width: 100%;
    margin: 0;
    cursor: pointer;
}

.app-mode-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.app-mode-track {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: center;
    width: 100%;
    max-width: 220px;
    height: 44px;
    padding: 4px;
    border-radius: 999px;
    background: #e5e7eb;
    color: #6c757d;
    font-size: 0.88rem;
    font-weight: 700;
    line-height: 1;
}

.app-mode-option {
    position: relative;
    z-index: 2;
    text-align: center;
    transition: color 0.18s ease;
}

.app-mode-thumb {
    position: absolute;
    top: 4px;
    left: 4px;
    width: calc(50% - 4px);
    height: 36px;
    border-radius: 999px;
    background: #ffffff;
    box-shadow: 0 6px 16px rgba(17, 20, 24, 0.14);
    transition: transform 0.18s ease;
}

.app-mode-input:not(:checked) + .app-mode-track .app-mode-light,
.app-mode-input:checked + .app-mode-track .app-mode-dark {
    color: #1f2328;
}

.app-mode-input:checked + .app-mode-track .app-mode-thumb {
    transform: translateX(100%);
}

.app-mode-input:focus-visible + .app-mode-track {
    outline: 3px solid rgba(13, 110, 253, 0.28);
    outline-offset: 2px;
}

body.theme-dark .app-mode-track {
    background: #2b3036;
    color: #aeb6bf;
}

body.theme-dark .app-mode-thumb {
    background: #f8f9fa;
}

body.theme-dark .app-mode-input:not(:checked) + .app-mode-track .app-mode-light,
body.theme-dark .app-mode-input:checked + .app-mode-track .app-mode-dark {
    color: #111418;
}

/* ---------- WCAG 2.x interaction contrast ---------- */
.mode-bottom-actions .btn,
.map-btn {
    transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.mode-bottom-actions .btn-outline-primary:hover,
.mode-bottom-actions .btn-outline-primary:active,
.map-btn:hover,
.map-btn:active {
    background-color: #084298;
    border-color: #084298;
    color: #ffffff;
}

.mode-bottom-actions .btn-outline-secondary:hover,
.mode-bottom-actions .btn-outline-secondary:active {
    background-color: #343a40;
    border-color: #343a40;
    color: #ffffff;
}

.mode-bottom-actions .btn:focus-visible,
.map-btn:focus-visible,
.bottom-nav-item:focus-visible,
.btn-close:focus-visible {
    outline: 3px solid #ffbf47;
    outline-offset: 3px;
    box-shadow: none;
}

body.theme-dark .mode-bottom-actions .btn-outline-primary:hover,
body.theme-dark .mode-bottom-actions .btn-outline-primary:active,
body.theme-dark .map-btn:hover,
body.theme-dark .map-btn:active {
    background-color: #9ec5fe;
    border-color: #9ec5fe;
    color: #111418;
}

body.theme-dark .mode-bottom-actions .btn-outline-secondary:hover,
body.theme-dark .mode-bottom-actions .btn-outline-secondary:active {
    background-color: #ced4da;
    border-color: #ced4da;
    color: #111418;
}

body.theme-dark .mode-bottom-actions .btn:focus-visible,
body.theme-dark .map-btn:focus-visible,
body.theme-dark .bottom-nav-item:focus-visible,
body.theme-dark .btn-close:focus-visible {
    outline-color: #ffd166;
}

.generated-history-setting {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.generated-history-open {
    align-self: flex-start;
    min-height: 44px;
}

.delete-number-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    min-width: 36px;
    height: 32px;
    padding: 0;
}

.delete-number-btn svg {
    width: 18px;
    height: 18px;
}

.delete-number-btn path {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.delete-number-btn:focus-visible {
    outline: 3px solid #ffbf47;
    outline-offset: 3px;
    box-shadow: none;
}

body.theme-dark .delete-number-btn {
    color: #ffb3b8;
    border-color: #b94a55;
}

body.theme-dark .delete-number-btn:hover,
body.theme-dark .delete-number-btn:active {
    background-color: #ffb3b8;
    border-color: #ffb3b8;
    color: #111418;
}

#fillHistoryModal .modal-body p:first-child {
    color: #842029;
}

body.theme-dark #fillHistoryModal .modal-body p:first-child {
    color: #ffb3b8;
}



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

.danger-setting-open {
    align-self: flex-start;
    min-height: 44px;
}

#deleteAccountModal .modal-body p:first-child {
    color: #842029;
}

body.theme-dark #deleteAccountModal .modal-body p:first-child {
    color: #ffb3b8;
}
