/* ==========================================================================
   デザイントークン（全画面共通）
   色・角丸・影はここで一元管理し、各画面のCSSでは直接カラーコードを書かず
   var(--xxx) を参照すること。
   ========================================================================== */
:root {
    /* アクセント（藍。Bootstrap primary もこの色に上書きする） */
    --color-primary: #33518e;
    --color-primary-dark: #2a4376;
    --color-primary-soft: #eceff6;

    /* テキスト・サーフェス（寒色系ニュートラル） */
    --color-text: #191c21;
    --color-text-muted: #676e79;
    --color-bg: #f5f6f8;
    --color-surface: #ffffff;
    --color-surface-alt: #f5f6f8;
    --color-border: #e3e6ea;

    /* セマンティックカラー（Bootstrap準拠） */
    --color-success: #28a745;
    --color-danger: #dc3545;
    --color-warning: #ffc107;
    --color-info: #17a2b8;

    /* 形状 */
    --radius: 10px;
    --shadow-sm: 0 1px 2px rgba(20, 24, 33, 0.05);
    --shadow: 0 4px 6px rgba(20, 24, 33, 0.08);

    /* レイアウト */
    --topbar-height: 56px;
    --sidebar-width: 216px;
    --bottomnav-height: 62px;
    /* ヘッダー帯は従来のダークカラーを維持する */
    --color-topbar: #343a40;
}

.m-5 {
    margin: 5%;
}

html, body {
    height: 100%;
    background-color: var(--color-bg);
    color: var(--color-text);
}

/* ==========================================================================
   アクセントカラーの Bootstrap 上書き
   （--color-primary を変えたらここも自動で追従する）
   ========================================================================== */
a {
    color: var(--color-primary);
}

a:hover {
    color: var(--color-primary-dark);
}

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

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active,
.btn-primary:not(:disabled):not(.disabled):active {
    background-color: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
}

.btn-outline-primary {
    color: var(--color-primary);
    border-color: var(--color-primary);
}

.btn-outline-primary:hover,
.btn-outline-primary:not(:disabled):not(.disabled):active {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

.text-primary {
    color: var(--color-primary) !important;
}

.bg-primary,
.badge-primary {
    background-color: var(--color-primary) !important;
}

/* ==========================================================================
   アプリシェル（トップバー / サイドバー / ボトムタブ）
   ========================================================================== */

/* トップバー（帯は従来のダークカラー） */
.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    height: var(--topbar-height);
    background-color: var(--color-topbar);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 16px;
}

.app-topbar .topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 0.95rem;
    color: #ffffff;
    text-decoration: none;
}

.app-topbar .topbar-brand:hover {
    color: #ffffff;
    text-decoration: none;
}

.app-topbar .topbar-brand img {
    width: 34px;
    height: 34px;
}

.app-topbar .topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
}

.app-topbar .navbar-nav {
    flex-direction: row;
    list-style: none;
    margin: 0;
    padding: 0;
}

/* シェル本体 */
.app-shell {
    display: flex;
    align-items: stretch;
    min-height: calc(100vh - var(--topbar-height));
}

.app-main {
    flex: 1;
    min-width: 0;
}

/* サイドバー（デスクトップのみ） */
.app-sidebar {
    width: var(--sidebar-width);
    flex: none;
    background-color: var(--color-surface);
    border-right: 1px solid var(--color-border);
    padding: 14px 0;
    position: sticky;
    top: var(--topbar-height);
    align-self: flex-start;
    height: calc(100vh - var(--topbar-height));
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.app-sidebar .side-link {
    display: block;
    padding: 9px 20px;
    font-size: 0.9rem;
    color: var(--color-text-muted);
    border-left: 3px solid transparent;
    text-decoration: none;
}

.app-sidebar .side-link:hover {
    color: var(--color-text);
    background-color: var(--color-surface-alt);
    text-decoration: none;
}

.app-sidebar .side-link:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: -2px;
}

.app-sidebar .side-link.active {
    color: var(--color-primary);
    font-weight: 700;
    border-left-color: var(--color-primary);
    background-color: var(--color-primary-soft);
}

.app-sidebar .side-divider {
    border-top: 1px solid var(--color-border);
    margin: 10px 20px;
}

@media (max-width: 767.98px) {
    .app-sidebar {
        display: none;
    }
}

/* ボトムタブ（モバイルのみ） */
.app-bottomnav {
    display: none;
}

@media (max-width: 767.98px) {
    .app-bottomnav {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1030;
        background-color: var(--color-surface);
        border-top: 1px solid var(--color-border);
        padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    }

    body.has-bottomnav {
        padding-bottom: calc(var(--bottomnav-height) + 24px);
    }

    /* ボトムタブとフッターは同居できないためモバイルでは隠す */
    body.has-bottomnav .site-footer {
        display: none;
    }
}

.app-bottomnav .bottomnav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 10px;
    color: var(--color-text-muted);
    padding: 4px 0 2px;
    text-decoration: none;
    background: transparent;
    border: 0;
    width: 100%;
}

.app-bottomnav .bottomnav-item:hover {
    text-decoration: none;
    color: var(--color-text);
}

.app-bottomnav .bottomnav-item:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: -2px;
}

.app-bottomnav .bottomnav-item.active {
    color: var(--color-primary);
    font-weight: 700;
}

.app-bottomnav .bottomnav-item svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* その他メニュー（ドロップアップ） */
.app-bottomnav .dropup .dropdown-menu {
    margin-bottom: 8px;
}

/* ==========================================================================
   スケルトンスクリーン（画面遷移時に skeleton.js が表示する）
   ========================================================================== */
.skeleton-overlay {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    /* トップバー/ボトムタブ（z-index:1030）より下、コンテンツより上 */
    z-index: 1029;
    background-color: var(--color-bg);
    display: none;
    padding: 24px 16px;
    overflow: hidden;
}

.skeleton-overlay.show {
    display: block;
}

/* アプリシェル内ではトップバー・サイドバー・ボトムタブを覆わない */
body.has-bottomnav .skeleton-overlay {
    top: var(--topbar-height);
}

@media (min-width: 768px) {
    body.has-bottomnav .skeleton-overlay {
        left: var(--sidebar-width);
    }
}

/* モバイルのボトムタブは z-index:1030 でオーバーレイより上に残るため bottom:0 のままでよい */

.skeleton-page {
    max-width: 800px;
    margin: 0 auto;
}

.sk {
    position: relative;
    overflow: hidden;
    background-color: var(--color-border);
    border-radius: 8px;
}

.sk::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
    animation: skeleton-shimmer 1.2s ease-in-out infinite;
}

@keyframes skeleton-shimmer {
    100% { transform: translateX(100%); }
}

@media (prefers-reduced-motion: reduce) {
    .sk::after {
        animation: none;
    }
}

.sk-title {
    height: 28px;
    width: 40%;
    max-width: 220px;
    margin-bottom: 16px;
}

.sk-block {
    height: 96px;
    margin-bottom: 16px;
}

.sk-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.sk-card {
    height: 180px;
}

@media (max-width: 767.98px) {
    .sk-grid {
        grid-template-columns: 1fr;
    }

    .sk-card {
        height: 140px;
    }
}

/* ==========================================================================
   共通コンポーネント（Bootstrap の上書き。base.html で Bootstrap より後に
   読み込むこと）
   ========================================================================== */

/* カード：角丸と控えめな影で統一。ヘッダーはニュートラルな背景に統一し、
   画面ごとの色付きヘッダーは使わない */
.card {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.card-header {
    background-color: var(--color-surface-alt);
    color: var(--color-text);
    font-weight: 600;
}

/* あいさつバー（ヘッダー直下） */
.page-greeting {
    background-color: var(--color-surface-alt);
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text-muted);
}

/* アカウントメニュー（ヘッダー共通） */
.account-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--color-text-muted);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.account-avatar-sm {
    width: 30px;
    height: 30px;
    font-size: 0.85rem;
}

.account-avatar img {
    object-fit: cover;
}

.account-menu-button {
    border: 0;
    background: transparent;
    color: rgba(255, 255, 255, 0.75);
}

.account-menu-button:hover,
.account-menu-button:focus {
    color: #fff;
}

.account-dropdown {
    min-width: 18rem;
}

.account-switch-item {
    white-space: normal;
}

/* グラフエリア */
.chart-canvas {
    width: 100% !important;
    height: auto !important;
    max-height: 300px;  /* グラフの最大高さを指定 */
}

.money-value {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

@media (max-width: 575.98px) {
    .money-value-long {
        font-size: 0.72rem !important;
        letter-spacing: -0.02em;
    }
}

.dashboard-brief-icon {
    align-items: center;
    background: var(--color-primary-soft);
    border-radius: 50%;
    color: var(--color-primary);
    display: flex;
    flex: 0 0 2.5rem;
    height: 2.5rem;
    justify-content: center;
}

.dashboard-weather-status {
    min-height: 2.5rem;
}

@media (max-width: 768px) {
    .chart-canvas {
        max-height: 200px;  /* モバイルサイズでの高さを調整 */
    }
}

/* コンテナ */
.container {
    max-width: 800px;
    margin: 20px auto;
    padding: 20px;
    background-color: #ffffff; /* 白背景 */
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* 見出し */
h1 {
    text-align: center;
    margin-bottom: 20px;
    color: #333333; /* 明るめの文字色 */
}

/* メッセージダイアログ */
.message-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;  /* 初期状態は非表示 */
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.message-dialog-overlay.show {
    display: flex;  /* 表示時はflexに変更 */
    opacity: 1;
}

.message-dialog {
    background: #ffffff;  /* 白背景を明示的に指定 */
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    min-width: 400px;
    max-width: 600px;
    animation: slideDown 0.3s ease;
    overflow: hidden;  /* 角丸を効かせる */
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.message-dialog-content {
    padding: 30px;
    display: flex;
    align-items: center;
    gap: 20px;
    position: relative;
    background-color: #ffffff;  /* 白背景を明示的に指定 */
}

.message-dialog-content.success {
    border-left: 5px solid var(--color-success);
    background-color: #f8fff9;  /* 薄い緑背景 */
}

.message-dialog-content.error {
    border-left: 5px solid var(--color-danger);
    background-color: #fff8f8;  /* 薄い赤背景 */
}

.message-dialog-content.warning {
    border-left: 5px solid var(--color-warning);
    background-color: #fffef8;  /* 薄い黄色背景 */
}

.message-dialog-content.info {
    border-left: 5px solid var(--color-info);
    background-color: #f8fcff;  /* 薄い青背景 */
}

.message-icon {
    font-size: 40px;
    flex-shrink: 0;
}

.message-dialog-content.success .message-icon {
    color: var(--color-success);
}

.message-dialog-content.error .message-icon {
    color: var(--color-danger);
}

.message-dialog-content.warning .message-icon {
    color: var(--color-warning);
}

.message-dialog-content.info .message-icon {
    color: var(--color-info);
}

.message-text {
    flex: 1;
    font-size: 16px;
    color: var(--color-text);
    line-height: 1.5;
}

.message-close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 20px;
    color: #999;
    cursor: pointer;
    padding: 5px;
    line-height: 1;
    transition: color 0.2s;
}

.message-close-btn:hover {
    color: var(--color-text);
}

/* 長押し削除オーバーレイ（全画面共通） */
.lp-delete-item {
    position: relative;
    overflow: hidden;
}

.lp-delete-overlay {
    display: none;
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(220, 53, 69, 0.88);
    border-radius: inherit;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    font-size: 1.1rem;
    z-index: 10;
    gap: 8px;
}

.lp-delete-item {
    -webkit-user-select: none;
    user-select: none;
}

.lp-delete-item.delete-pending .lp-delete-overlay,
.lp-delete-modal-item.delete-pending .lp-delete-overlay {
    display: flex;
    animation: lp-overlay-appear 0.15s ease;
}

@keyframes lp-overlay-appear {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}

/* 設定画面テーブル行の長押し削除（<tr>はposition:relativeが効かないため<td>に適用） */
.lp-delete-modal-item {
    cursor: pointer;
}

.lp-actions-cell {
    position: relative;
    overflow: hidden;
    min-width: 80px;
}

.lp-edit-btn {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1;
}

/* ==========================================================================
   トースト通知（toast.js が表示する。Undo付き削除・一括操作の通知に使う）
   ========================================================================== */
.toast-container {
    position: fixed;
    left: 50%;
    bottom: calc(16px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 1080;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: max-content;
    max-width: calc(100vw - 24px);
    pointer-events: none;
}

/* モバイルでボトムタブに被らないよう持ち上げる */
@media (max-width: 767.98px) {
    body.has-bottomnav .toast-container {
        bottom: calc(var(--bottomnav-height) + 16px + env(safe-area-inset-bottom));
    }
}

.app-toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    background-color: #2c333a;
    color: #fff;
    border-radius: var(--radius);
    padding: 10px 14px;
    box-shadow: 0 6px 20px rgba(20, 24, 33, 0.25);
    font-size: 0.9rem;
    max-width: 100%;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.app-toast.show {
    opacity: 1;
    transform: translateY(0);
}

@media (prefers-reduced-motion: reduce) {
    .app-toast {
        transition: none;
    }
}

.app-toast-success { background-color: #1c7a4c; }
.app-toast-error { background-color: #bb4638; }

.app-toast-text {
    flex: 1;
    min-width: 0;
}

.app-toast-undo {
    flex: none;
    border: 0;
    background: transparent;
    color: #9ec1ff;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 6px;
}

.app-toast-undo:hover,
.app-toast-undo:focus-visible {
    background-color: rgba(158, 193, 255, 0.15);
    color: #c3d8ff;
}

.app-toast-close {
    flex: none;
    border: 0;
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}

.app-toast-close:hover {
    color: #fff;
}

/* ==========================================================================
   選択モード＋一括削除（bulk_delete.js が制御する）
   ========================================================================== */
/* 選択用チェックボックスは選択モード中のみ表示 */
.bulk-check {
    display: none;
    flex: none;
    width: 20px;
    height: 20px;
    margin-right: 10px;
    cursor: pointer;
}

.bulk-mode .bulk-item .bulk-check {
    display: inline-block;
}

.bulk-mode .bulk-item {
    cursor: pointer;
}

.bulk-item.bulk-selected {
    background-color: var(--color-primary-soft) !important;
}

.bulk-item.bulk-hidden {
    display: none !important;
}

/* 選択モード中は行内の長押し削除オーバーレイを出さない */
.bulk-mode .lp-delete-overlay {
    display: none !important;
}

.bulk-toggle-btn[aria-pressed="true"] {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

/* 下部の一括操作バー */
.bulk-action-bar {
    position: fixed;
    left: 50%;
    bottom: calc(16px + env(safe-area-inset-bottom));
    transform: translate(-50%, 140%);
    z-index: 1075;
    display: flex;
    align-items: center;
    gap: 16px;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    box-shadow: 0 6px 20px rgba(20, 24, 33, 0.18);
    padding: 8px 10px 8px 18px;
    opacity: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
    pointer-events: none;
    max-width: calc(100vw - 24px);
}

.bulk-action-bar.show {
    transform: translate(-50%, 0);
    opacity: 1;
    pointer-events: auto;
}

@media (prefers-reduced-motion: reduce) {
    .bulk-action-bar {
        transition: none;
    }
}

/* モバイルでボトムタブに被らないよう持ち上げる */
@media (max-width: 767.98px) {
    body.has-bottomnav .bulk-action-bar {
        bottom: calc(var(--bottomnav-height) + 16px + env(safe-area-inset-bottom));
    }
}

.bulk-action-count {
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
}

.bulk-action-buttons {
    display: flex;
    gap: 8px;
}

/* ==========================================================================
   アプリ内確認ダイアログ（toast.js の showConfirm。window.confirm の代替）
   ========================================================================== */
.app-confirm-overlay {
    position: fixed;
    inset: 0;
    z-index: 1090;
    background: rgba(20, 24, 33, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.app-confirm-overlay.show {
    opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
    .app-confirm-overlay {
        transition: none;
    }
}

.app-confirm-dialog {
    background: var(--color-surface);
    color: var(--color-text);
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(20, 24, 33, 0.25);
    max-width: 380px;
    width: 100%;
    padding: 20px;
}

.app-confirm-message {
    margin: 0 0 18px;
    font-size: 0.95rem;
    line-height: 1.6;
    white-space: pre-line;
}

.app-confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ==========================================================================
   レスポンシブ共通レイアウト
   ========================================================================== */

.page-heading-row {
    align-items: center;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.page-heading-row > :first-child {
    min-width: 0;
}

.page-actions {
    align-items: center;
    display: flex;
    flex: none;
    gap: 8px;
}

.page-actions-menu > .dropdown-toggle {
    display: none;
}

.page-actions-menu .dropdown-menu {
    align-items: center;
    background: transparent;
    border: 0;
    box-shadow: none;
    display: flex !important;
    float: none;
    gap: 8px;
    margin: 0;
    min-width: 0;
    padding: 0;
    position: static;
}

.page-actions-menu .dropdown-divider {
    display: none;
}

.page-actions-menu .page-secondary-action {
    align-items: center;
    border: 1px solid var(--color-border);
    border-radius: 0.2rem;
    color: var(--color-text-muted);
    display: inline-flex;
    font-size: 0.875rem;
    gap: 0.3rem;
    justify-content: center;
    line-height: 1.5;
    padding: 0.25rem 0.5rem;
    white-space: nowrap;
    width: auto;
}

.page-actions-menu .page-secondary-action:hover,
.page-actions-menu .page-secondary-action:focus {
    background-color: var(--color-surface-alt);
    color: var(--color-text);
    text-decoration: none;
}

.page-actions-menu .page-secondary-action.btn-primary {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

.responsive-table-region {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.manage-chart-wrap {
    height: 300px;
    position: relative;
}

.demo-banner-track {
    overflow: hidden;
}

.demo-banner-inner {
    animation: demoBannerScroll 22s linear infinite;
    display: inline-block;
    font-size: 0.82rem;
    padding: 0.25rem 0;
    white-space: nowrap;
}

.demo-banner-mobile {
    display: none;
}

@keyframes demoBannerScroll {
    0% { transform: translateX(100vw); }
    100% { transform: translateX(-100%); }
}

@media (max-width: 767.98px) {
    :root {
        --topbar-height: 52px;
        --bottomnav-height: 62px;
        --mobile-gutter: 12px;
    }

    html,
    body {
        max-width: 100%;
        overflow-x: hidden;
    }

    body.has-bottomnav {
        padding-bottom: 0;
    }

    body.has-bottomnav .app-main {
        padding-bottom: calc(var(--bottomnav-height) + env(safe-area-inset-bottom) + 24px);
    }

    .app-topbar {
        gap: 6px;
        padding: 0 var(--mobile-gutter);
    }

    .app-topbar .topbar-brand {
        gap: 7px;
        min-width: 0;
    }

    .app-topbar .topbar-brand img {
        height: 30px;
        width: 30px;
    }

    .app-topbar .topbar-brand span {
        font-size: 0.88rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .app-topbar .topbar-right .btn {
        font-size: 0.75rem;
        min-height: 36px;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
        white-space: nowrap;
    }

    .app-shell {
        min-height: calc(100vh - var(--topbar-height));
    }

    .app-main > .container,
    .app-main .container {
        border-radius: 0;
        box-shadow: none;
        margin: 0 auto !important;
        max-width: 100%;
        padding: 14px var(--mobile-gutter) !important;
        width: 100%;
    }

    .app-main > [class$="-container"]:not(.toast-container),
    .app-main > [class*="-container "]:not(.toast-container) {
        max-width: 100%;
    }

    .app-main h1,
    .app-main .h1 {
        font-size: 1.5rem;
        line-height: 1.25;
        margin-bottom: 0.75rem;
    }

    .app-main h2,
    .app-main .h2 {
        font-size: 1.35rem;
        line-height: 1.3;
    }

    .app-main h3,
    .app-main .h3 {
        font-size: 1.2rem;
        line-height: 1.35;
    }

    .app-main h4,
    .app-main .h4,
    .app-main h5,
    .app-main .h5 {
        font-size: 1.05rem;
    }

    .card {
        border-radius: 8px;
    }

    .card-body {
        padding: 0.85rem;
    }

    .card-header,
    .list-group-item {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .row {
        margin-left: -6px;
        margin-right: -6px;
    }

    .row > [class^="col"],
    .row > [class*=" col"] {
        padding-left: 6px;
        padding-right: 6px;
    }

    .btn,
    button,
    input[type="button"],
    input[type="submit"] {
        min-height: 44px;
    }

    .btn-sm,
    .btn-group-sm > .btn,
    .input-group-sm > .input-group-append > .btn {
        align-items: center;
        display: inline-flex;
        justify-content: center;
        min-height: 40px;
    }

    .form-control,
    .custom-select {
        min-height: 44px;
    }

    .form-control-sm,
    .custom-select-sm,
    .input-group-sm > .form-control {
        min-height: 40px;
    }

    .form-inline {
        align-items: stretch;
    }

    .table-responsive,
    .responsive-table-region {
        border-radius: 6px;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .app-main table.table:not(.task-calendar) {
        display: block;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
        width: 100%;
    }

    .app-main table.table:not(.task-calendar) td,
    .app-main table.table:not(.task-calendar) th {
        vertical-align: middle;
    }

    .modal-dialog,
    .modal-dialog-centered,
    .day-tasks-modal .modal-dialog {
        margin: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom));
        max-width: calc(100% - 16px);
        min-height: calc(100% - 16px);
    }

    .modal-content {
        max-height: calc(100dvh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    }

    .modal-dialog-scrollable .modal-body,
    .modal-body {
        max-height: none;
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .message-dialog {
        max-width: calc(100vw - 24px);
        min-width: 0;
        width: 100%;
    }

    .message-dialog-content {
        gap: 12px;
        padding: 20px 16px;
    }

    .message-icon {
        font-size: 30px;
    }

    .page-heading-row {
        align-items: flex-start;
        gap: 8px;
        margin-bottom: 0.65rem;
    }

    .page-heading-row h1,
    .page-heading-row h2,
    .page-heading-row h3,
    .page-heading-row h4,
    .page-heading-row h5 {
        margin-bottom: 0;
    }

    .page-actions {
        gap: 6px;
    }

    .page-actions > .btn {
        white-space: nowrap;
    }

    .page-actions-menu > .dropdown-toggle {
        align-items: center;
        display: inline-flex;
        justify-content: center;
        min-width: 44px;
    }

    .page-actions-menu .dropdown-menu,
    .page-actions-menu .dropdown-menu:not(.show) {
        display: none !important;
    }

    .page-actions-menu .dropdown-menu.show {
        background: var(--color-surface);
        border: 1px solid var(--color-border);
        box-shadow: var(--shadow);
        display: block !important;
        min-width: 13rem;
        padding: 0.35rem 0;
        position: absolute;
    }

    .page-actions-menu .dropdown-divider {
        display: block;
    }

    .page-actions-menu .page-secondary-action {
        border: 0;
        border-radius: 0;
        display: flex;
        justify-content: flex-start;
        min-height: 44px;
        padding: 0.55rem 1rem;
        width: 100%;
    }

    .demo-banner-inner {
        animation: none;
        display: block;
        font-size: 0.75rem;
        line-height: 1.35;
        overflow: hidden;
        padding: 0.35rem var(--mobile-gutter);
        text-align: center;
        text-overflow: ellipsis;
        white-space: normal;
    }

    .demo-banner-desktop {
        display: none;
    }

    .demo-banner-mobile {
        display: inline;
    }

    .navbar.navbar-expand-md {
        min-height: var(--topbar-height);
        padding: 6px var(--mobile-gutter);
    }

    .navbar.navbar-expand-md img[alt="Menu"] {
        height: 40px !important;
        width: 40px !important;
    }

    .navbar.navbar-expand-md .navbar-collapse {
        max-height: calc(100dvh - var(--topbar-height));
        overflow-y: auto;
    }

    .navbar.navbar-expand-md .nav-item {
        margin: 0 !important;
    }

    .navbar.navbar-expand-md .nav-link {
        align-items: center;
        display: flex;
        min-height: 44px;
        padding: 0.55rem 0.75rem;
    }

    .habit-page,
    .habit-list-page,
    .contact-container {
        margin: 0 auto !important;
        max-width: 100% !important;
        padding: 14px var(--mobile-gutter) !important;
    }

    .habit-tabs {
        margin-bottom: 10px !important;
    }

    .habit-tab {
        align-items: center;
        display: flex;
        justify-content: center;
        min-height: 44px;
        padding: 5px 0 !important;
    }

    .date-nav {
        gap: 6px !important;
        margin-bottom: 8px !important;
    }

    .date-nav .date-picker-input {
        flex: 1;
        min-height: 40px;
        min-width: 0;
    }

    .habit-card {
        margin-bottom: 5px !important;
        padding: 6px 8px !important;
    }

    .dashboard-page > .row > [class^="col"],
    .dashboard-page > .row > [class*=" col"] {
        margin-bottom: 0.65rem !important;
    }

    .dashboard-page .card-body.py-3 {
        padding-bottom: 0.75rem !important;
        padding-top: 0.75rem !important;
    }

    .dashboard-page .dashboard-brief-icon {
        flex-basis: 2.1rem;
        height: 2.1rem;
        margin-right: 0.65rem !important;
    }

    .dashboard-page .dashboard-weather-status {
        font-size: 0.85rem;
        min-height: 0;
    }

    .dashboard-page .card-header {
        align-items: flex-start !important;
        gap: 8px;
    }

    .dashboard-page .card-header > :first-child {
        min-width: 0;
    }

    .dashboard-page .card-header a {
        flex: none;
        white-space: nowrap;
    }

    .manage-chart-wrap {
        height: 230px;
    }

    .manage-chart-header {
        align-items: stretch !important;
        flex-direction: column;
        gap: 8px;
    }

    #pageFilter,
    #daysBtns,
    #periodBtns,
    .filter-bar {
        flex-wrap: nowrap !important;
        max-width: 100%;
        overflow-x: auto;
        padding-bottom: 3px;
        -webkit-overflow-scrolling: touch;
    }

    #pageFilter .btn,
    #daysBtns .btn,
    #periodBtns .btn,
    .filter-bar .btn {
        flex: none;
    }

    .app-main .form-row > [class^="col"],
    .app-main .form-row > [class*=" col"] {
        margin-bottom: 0.65rem;
    }

    .year-nav {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        padding-bottom: 4px;
    }

    .pagination {
        flex-wrap: wrap;
        gap: 2px;
    }

    .pagination .page-link {
        min-height: 40px;
    }
}

@media (max-width: 359.98px) {
    .app-topbar .topbar-brand span {
        max-width: 8.5rem;
    }

    .app-main > .container,
    .app-main .container {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    .page-actions > .btn .mobile-action-label {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .demo-banner-inner {
        animation: none;
    }
}
