/* ============================================================
   1. デザインシステム変数
   ============================================================ */
:root {
    --legal-primary-dark: #001a17;
    --legal-primary: #00453e;
    --legal-accent: #00c2a8;
    --legal-interactive: #0d6efd;
    --legal-bg-light: #f8fafc;
    --legal-text-main: #1e293b;
    --legal-text-muted: #64748b;
    --font-family-soft: 'Inter', 'Noto Sans JP', 'Helvetica Neue', Arial, sans-serif;
    --sidebar-width: 280px;
    /* ハイライト用カラー定義 */
    --highlight-active: #f59e0b; /* Amber */
    --highlight-done: #10b981; /* Emerald */
    --text-scale-xxs: 0.65rem;
    --text-scale-xs: 0.7rem;
    --text-scale-sm: 0.75rem;
    --text-scale-md: 0.8rem;
    --text-scale-lg: 0.85rem;
    --text-scale-xl: 0.9rem;
    --text-scale-xxl: 0.95rem;
    --base-font-size: var(--text-scale-md);
    --bs-primary: #2c7be5;
    --bs-success: #00a870;
    --bs-warning: #f6c343;
    --bs-danger: #e63757;
}

/* ============================================================
   2. 基本設定 
   ============================================================ */
html, body {
    height: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    position: fixed; 
}

/* Blazorのルート要素も固定 */
#app {
    height: 100%;
    width: 100%;
    overflow: hidden;
}

.no-scrollbar::-webkit-scrollbar {
    display: none;
}

*, *::before, *::after {
    box-sizing: border-box;
}

a, .btn-link {
    color: var(--legal-interactive);
}

/* ============================================================
   2.5. 文字サイズ
   ============================================================ */
/* クラスによるルートのフォントサイズ変更 (Bootstrapのremを自動スケールさせる / MainLayout・OutlookLayout・LoginLayout共通) */
:root:has(.text-size-xxs) { font-size: 81.25%; }
:root:has(.text-size-xs) { font-size: 87.5%; }
:root:has(.text-size-sm) { font-size: 93.75%; }
:root:has(.text-size-md) { font-size: 100%; }
:root:has(.text-size-lg) { font-size: 106.25%; }
:root:has(.text-size-xl) { font-size: 112.5%; }
:root:has(.text-size-xxl) { font-size: 118.75%; }

/* Quill リッチテキストエディタのフォントサイズ・書体を個人設定(rem / font-family)に連動 */
.ql-container.ql-snow {
    font-size: 0.9rem !important;
    font-family: inherit !important;
}

.ql-container.ql-snow .ql-editor {
    font-size: 0.9rem;
    line-height: 1.6;
    font-family: inherit;
}

.ql-toolbar.ql-snow,
.ql-toolbar.ql-snow .ql-picker {
    font-size: 0.875rem;
    font-family: inherit !important;
}

/* システム全体のスムーズなスケールトランジション */
html, body, .page {
    transition: font-size 0.2s ease;
}

.extra-small {
    font-size: 0.75rem;
}


/* ============================================================
   タイポグラフィ・UI基礎
   ============================================================ */
.majestic-title {
    font-weight: 800;
    font-size: 1.5em;
    color: var(--legal-primary);
    letter-spacing: 0.05em;
    margin-bottom: 0.4em !important;
    display: flex;
    align-items: center; transform: translateY(2px); }

    .majestic-title .bi {
        line-height: 1;
        display: block;
        transform: translateY(-1.1px);
    }

/* ContextHeader 共通アイコン・ボタンスタイル */
.context-lead-icon {
    font-size: 1.75rem;
    display: inline-block;
    line-height: 1;
}

.context-back-btn {
    width: 44px;
    height: 44px;
}
.context-back-btn i {
    font-size: 1.25rem;
}

.context-circle-icon i {
    font-size: 1.5rem;
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6em 1.25em 0.7em 1.25em;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

/* ============================================================
   3. サイドバー 
   ============================================================ */
.sidebar {
    background-image: linear-gradient(180deg, var(--legal-primary-dark) 0%, var(--legal-primary) 100%) !important;
    letter-spacing: 0.05em;
    box-shadow: 4px 0 15px rgba(0,0,0,0.1);
    user-select: none;
    z-index: 1030;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

    .sidebar .top-row {
        background-color: transparent !important; border-bottom: 1px solid rgba(255,255,255,0.1);
        min-height: 3.5rem;
        height: auto;
        display: flex;
        align-items: center;
        padding: 0 1.5rem;
        border-bottom: 1px solid rgba(255,255,255,0.05);
        justify-content: space-between;
    }

    .sidebar .navbar-brand {
        font-weight: 800;
        color: #ffffff !important;
        letter-spacing: 0.1em;
        font-size: 1.1em;
        text-decoration: none;
    }

    .sidebar .navbar-toggler {
        background-color: transparent;
        border: none;
        padding: 0.25rem 0.5rem;
        font-size: 1em;
        cursor: pointer;
        outline: none;
        box-shadow: none !important;
    }

        .sidebar .navbar-toggler:focus, .sidebar .navbar-toggler:active {
            outline: none;
            box-shadow: none !important;
            transform: scale(0.95);
        }

.nav-item {
    padding: 0.2rem 0.8rem;
}

.sidebar .nav-link {
    display: flex !important;
    align-items: center !important;
    padding: 0.7rem 1.0rem !important;
    color: rgba(255, 255, 255, 0.75) !important;
    border-radius: 8px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.95em;
    text-decoration: none;
}

    .sidebar .nav-link .bi {
        font-size: 1.2em;
        width: 1.8em;
        margin-right: 0.5rem !important;
        display: inline-flex;
        justify-content: center;
        opacity: 0.8;
        transform: translateY(-2px); /* アイコンのベースラインを微調整 */
    }

    .sidebar .nav-link:hover {
        color: #ffffff !important;
        background-color: rgba(255, 255, 255, 0.1) !important;
        transform: translateX(3px);
    }

        .sidebar .nav-link:hover .bi {
            opacity: 1;
        }

    .sidebar .nav-link.active {
        color: #ffffff !important;
        background-color: rgba(0, 194, 168, 0.25) !important;
        font-weight: 700;
        box-shadow: 0 2px 8px rgba(0,0,0,0.2);
        border-left: 3px solid var(--legal-accent);
    }

/* 訴訟管理メニュー専用のスタイル */
.litigation-nav-link {
    color: #d8b4fe !important;
    border-left: 3px solid transparent;
}

    .litigation-nav-link.active {
        border-left: 3px solid #d8b4fe !important;
        background-color: rgba(111, 66, 193, 0.15) !important;
        color: #ffffff !important;
    }

.nav-scrollable {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
}

    .nav-scrollable::-webkit-scrollbar {
        width: 6px;
    }

    .nav-scrollable::-webkit-scrollbar-track {
        background: transparent;
    }

    .nav-scrollable::-webkit-scrollbar-thumb {
        background-color: rgba(255, 255, 255, 0.2);
        border-radius: 20px;
    }

#nav-toggle-checkbox {
    display: none !important;
}

/* Sidebar History Item */
.history-item {
    background-color: rgba(255, 255, 255, 0.05);
    transition: all 0.2s ease;
    border-left: 2px solid transparent;
}

    .history-item:hover {
        background-color: rgba(255, 255, 255, 0.15);
        border-left: 2px solid #ffc107; /* warning color */
        transform: translateX(3px);
    }

@media (min-width: 768px) {
    .sidebar {
        width: var(--sidebar-width);
        min-width: var(--sidebar-width);
        height: 100dvh;
        position: sticky;
        top: 0;
    }

        .sidebar .navbar-toggler {
            display: none;
        }

    .nav-content {
        display: block !important;
    }

    .nav-scrollable {
        height: calc(100vh - 3.5rem);
    }

    .page {
        height: 100dvh;
        overflow: hidden;
    }

    main {
        height: 100dvh;
        overflow-y: auto;
        overflow: hidden !important;
        flex: 1;
        scroll-behavior: smooth;
    }
}

/* ============================================================
   4. フォーム と ボタン 
   ============================================================ */
.form-control, .form-select, .input-group-text {
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    background-color: #ffffff;
}

.input-group-text {
    background-color: #f1f5f9;
    color: #64748b;
    font-weight: 700;
}

.form-control:focus, .form-select:focus {
    border-color: var(--legal-interactive) !important;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.15) !important;
    outline: none;
}

.btn-majestic {
    border-radius: 50px;
    padding: 0.7em 2.5em;
    font-weight: 700;
    letter-spacing: 0.03em;
    transition: all 0.2s;
    border: none;
}

.btn-save {
    background-color: var(--legal-interactive);
    color: white !important;
    box-shadow: 0 2px 4px rgba(13, 110, 253, 0.15);
}

    .btn-save:hover {
        background-color: #0b5ed7 !important;
        transform: translateY(-1px);
        box-shadow: 0 4px 8px rgba(13, 110, 253, 0.2);
    }

.btn-personal-task {
    background-color: #f0fdfa;
    color: #0f766e !important;
    border: 1.5px solid #14b8a6 !important;
    box-shadow: 0 2px 4px rgba(13, 148, 136, 0.1);
}

    .btn-personal-task:hover {
        background-color: #ccfbf1 !important;
        color: #115e59 !important;
        border-color: #0d9488 !important;
        transform: translateY(-1px);
        box-shadow: 0 4px 8px rgba(13, 148, 136, 0.18);
    }

.btn-cancel {
    background-color: #f1f5f9;
    color: #64748b !important;
    border: 1px solid #e2e8f0;
}

    .btn-cancel:hover {
        background-color: #e2e8f0 !important;
    }

/* bg-white と btn-outline-* を併用したボタンでホバー時に白背景＋白文字で文字が消える現象を防止 */
.btn.bg-white[class*="btn-outline-"]:hover:not(:disabled):not(.disabled),
.btn.bg-white[class*="btn-outline-"]:active:not(:disabled):not(.disabled),
.btn.bg-white[class*="btn-outline-"].active:not(:disabled):not(.disabled) {
    background-color: var(--bs-btn-hover-bg) !important;
    color: var(--bs-btn-hover-color) !important;
    border-color: var(--bs-btn-hover-border-color) !important;
}

.label-small {
    color: var(--legal-text-muted);
    font-size: 0.8em;
    font-weight: 700;
    margin-bottom: 0.4em;
    display: block;
}

.input-refined-sm {
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    padding: 0.4rem 0.8rem;
    font-size: 0.9rem;
    box-shadow: none;
    transition: all 0.2s;
}

    .input-refined-sm:focus {
        border-color: var(--legal-interactive);
        box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
        outline: none;
    }

/* ============================================================
   5. モーダル と ログイン
   ============================================================ */
.majestic-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100dvh;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.majestic-modal-dialog {
    width: 90%;
    max-width: 850px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.15);
    overflow: hidden;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalPopIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPopIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.login-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100dvh;
    z-index: 10000;
    background-color: var(--legal-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
}

.login-card {
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    width: 100%;
    max-width: 400px;
    padding: 2rem;
}

.input-refined-lg {
    height: 3.5rem;
    font-size: 1.1em;
    border-radius: 12px;
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    font-weight: 700;
}

.btn-login {
    background-color: var(--legal-accent) !important;
    color: #ffffff !important;
    font-size: 1.1em;
    box-shadow: 0 4px 15px rgba(0, 194, 168, 0.4);
    border: none;
    width: 100%;
    border-radius: 50px;
    padding: 0.8em;
    font-weight: bold;
}

    .btn-login:hover {
        background-color: #009688 !important;
        transform: translateY(-2px);
    }

/* ============================================================
   6. 共通グリッド と カレンダー 
   ============================================================ */
.day-view-scroll {
    scroll-behavior: smooth;
    overflow-x: auto;
    width: 100%;
    -webkit-overflow-scrolling: touch;
}

/* --- A. Day View Grid --- */
.calendar-grid {
    display: grid;
    grid-template-rows: 60px auto;
    position: relative;
    min-width: 800px;
}

.time-grid-container {
    position: relative;
    padding-left: 60px;
    min-height: 900px;
}

/* Common Grid Elements */
.time-row, .time-slot {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid #f1f5f9;
    position: relative;
    box-sizing: border-box;
}

.time-label {
    position: absolute;
    left: -60px;
    width: 60px;
    text-align: center;
    top: -10px;
    font-size: 0.75em;
    color: #94a3b8;
    font-weight: 600;
    background-color: transparent;
}

.time-axis .time-slot {
    font-size: 0.75em;
    color: #94a3b8;
    font-weight: 600;
    align-items: flex-start;
    padding-top: 8px;
}

.time-axis-header, .room-header, .task-header {
    background: #fff;
    z-index: 200;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    height: 60px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.click-slot {
    width: 100%;
    height: 100%;
    cursor: pointer;
}

    .click-slot:hover {
        background-color: rgba(13, 110, 253, 0.05);
    }

.room-column, .task-column, .time-axis {
    min-height: 900px;
    position: relative;
    background-image: linear-gradient(#f1f5f9 1px, transparent 1px);
    background-size: 100% 60px;
    background-position: 0 0;
    border-right: 1px solid #f1f5f9;
}

.time-axis {
    grid-column: 1;
    background-color: #fcfcfc;
    border-right: 1px solid #e2e8f0;
}

/* Entry Cards (Day View) */
.entry-card, .schedule-entry-card {
    position: absolute;
    width: 94%;
    left: 3%;
    border-radius: 4px;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    z-index: 20;
    overflow: visible !important;
    border-left-width: 4px !important;
    border-left-style: solid !important;
    padding: 2px 6px;
    background: #fff;
    transition: all 0.15s;
    font-size: 0.8em;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-top: 1px solid rgba(0,0,0,0.05);
    border-right: 1px solid rgba(0,0,0,0.05);
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

    .entry-card:hover, .schedule-entry-card:hover {
        z-index: 100;
        transform: translateY(-1px);
        box-shadow: 0 8px 16px rgba(0,0,0,0.15);
    }

    /* Day View ハイライト */
    .schedule-entry-card.target-highlight-active {
        border: 2px solid var(--highlight-active) !important;
        border-left: 6px solid var(--highlight-active) !important;
        box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4) !important;
        z-index: 50;
        transform: none;
    }

    .schedule-entry-card.target-highlight-done {
        border: 2px solid var(--highlight-done) !important;
        border-left: 6px solid var(--highlight-done) !important;
        box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3) !important;
        z-index: 49;
        opacity: 0.95;
    }

.entry-content, .entry-inner, .entry-subject, .entry-time {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    width: 100%;
}

.entry-subject {
    font-weight: 700;
}

.entry-time {
    font-size: 0.8em;
    color: #64748b;
}

/* Now Indicator */
.now-indicator {
    position: absolute;
    left: 0;
    right: 0;
    pointer-events: none;
    z-index: 1000;
    height: 1px;
}

.now-dot {
    position: absolute;
    left: -5px;
    top: -5px;
    width: 10px;
    height: 10px;
    background: #ef4444;
    border-radius: 50%;
    z-index: 1000;
}

.now-indicator-schedule .now-dot {
    left: 65px;
}

.now-line {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 2px;
    background: #ef4444;
}

.now-indicator-schedule .now-line {
    left: 70px;
}

/* --- C. Week/Month View Grid --- */
.week-grid, .month-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    height: auto;
    background-color: #cbd5e1;
    gap: 1px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    overflow: hidden;
}

.week-col, .month-cell, .grid-cell {
    background-color: #fff;
    min-height: 140px;
    padding: 4px;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: background-color 0.1s;
    border: none !important;
}

    .week-col:hover, .month-cell:hover, .grid-cell:hover {
        background-color: #f8fafc;
    }

.bg-today {
    background-color: #f0f9ff !important;
}

/* Mini Entries */
.mini-entry {
    font-size: 0.85em;
    padding: 3px 6px;
    margin-bottom: 3px;
    border-radius: 4px;
    overflow: visible !important;
    font-weight: 600;
    color: #334155;
    border-left-width: 3px !important;
    border-left-style: solid !important;
    cursor: pointer;
    background-color: #f1f5f9;
    position: relative;
    border: 1px solid transparent;
}

.mini-entry-text {
    display: block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.mini-entry:hover {
    z-index: 200;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.12);
}

/* Mini Entry ハイライト */
.mini-entry.target-highlight-mini-active {
    border: 2px solid var(--highlight-active) !important;
    box-shadow: 0 0 5px rgba(245, 158, 11, 0.3);
}

.mini-entry.target-highlight-mini-done {
    border: 2px solid var(--highlight-done) !important;
}

.completed-line {
    opacity: 0.6;
    text-decoration: line-through;
    background-color: #f1f5f9 !important;
    border-left-color: #94a3b8 !important;
    color: #94a3b8;
}

/* Headers */
.grid-header {
    background-color: #f8fafc;
    font-weight: 700;
    text-align: center;
    padding: 8px;
    font-size: 0.9em;
    border-bottom: none !important;
}

.day-number {
    font-weight: 700;
    font-size: 0.9em;
    margin-bottom: 4px;
    text-align: right;
    padding-right: 4px;
}

.fc-event-normal {
    opacity: 0.6;
    border: 1px solid #ddd !important;
    filter: grayscale(80%);
}

.fc-event-highlight {
    background-color: var(--legal-accent) !important;
    border: 2px solid #d63384 !important;
    color: #fff !important;
    opacity: 1;
    box-shadow: 0 4px 6px rgba(0,0,0,0.15);
    transform: scale(1.02);
    z-index: 10;
}

.task-card-fixed {
    border-left: 4px solid #0d6efd;
}

.task-card-free {
    border-left: 4px solid #198754;
}

/* List Card Highlight */
.task-card-item {
    transition: all 0.2s;
    border: 1px solid #e2e8f0;
}

.target-highlight-list-active {
    border: 2px solid var(--highlight-active) !important;
    border-left-width: 6px !important;
    background-color: #fff !important;
    transform: translateX(-2px);
}

.target-highlight-list-done {
    border: 2px solid var(--highlight-done) !important;
    border-left-width: 6px !important;
    background-color: #f0fdfa !important;
}

/* ============================================================
   7. トースト通知 (Toast)
   ============================================================ */
.toast-container-majestic {
    position: fixed;
    top: 5rem; /* 位置はremのままでOK */
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75em;
    pointer-events: none;
    white-space: pre-wrap;
}

.toast-majestic {
    justify-content: center;
    text-align: center;
    pointer-events: auto;
    display: flex;
    align-items: center;
    position: relative;
    overflow: hidden;
    gap: 0.75em;
    padding: 0.8em 1.5em;
    border-radius: 50px;
    font-weight: 700;
    color: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    min-width: 240px;
    max-width: 400px;
    transition: transform 0.2s ease;
    animation: popIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(-10px);
    }

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

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 4px;
    background-color: rgba(255, 255, 255, 0.7);
    width: 100%;
    animation: toast-countdown 3s linear forwards;
}

@keyframes toast-countdown {
    from { width: 100%; }
    to { width: 0%; }
}

.toast-success {
    background-color: #10b981;
}

.toast-danger {
    background-color: #ef4444;
}

.toast-warning {
    background-color: #f59e0b;
}

.toast-deleted {
    background-color: #495057;
}

.toast-info {
    background-color: #3b82f6;
}

/* ============================================================
   8. アニメーション と ユーティリティ 
   ============================================================ */
.animate-fade {
    animation: fadeIn 0.3s ease-in-out;
}

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

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

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

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

.card-refined {
    border-radius: 12px;
    border: 1px solid rgba(0,0,0,0.05);
}

.cursor-pointer {
    cursor: pointer;
}

.transition-all {
    transition: all 0.2s ease;
}

.opacity-60 {
    opacity: 0.6;
}

/* テーブルのホバー色を少し明るいグレー（#f8fafc）に統一 */
.table-hover-custom tbody tr:hover td {
    background-color: #f8fafc !important;
}

.status-badge {
    display: inline-block;
    min-width: 85px;
    text-align: center;
}

/* ツールチップ (Tooltip Fixed) */
.majestic-tooltip {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 250px;
    max-width: min(260px, 85vw);
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.28);
    visibility: hidden;
    opacity: 0;
    z-index: 99999;
    padding: 0;
    border: 1px solid #cbd5e1;
    overflow: hidden;
    margin-top: 5px;
    pointer-events: none;
    font-weight: 400;
    text-decoration: none !important;
}

.majestic-tooltip.tooltip-single-col {
    max-width: min(260px, calc(100% - 8px));
}

.majestic-tooltip.tooltip-align-left {
    left: 0 !important;
    right: auto !important;
    transform: none !important;
}

.majestic-tooltip.tooltip-align-right {
    right: 0 !important;
    left: auto !important;
    transform: none !important;
}

.majestic-tooltip.tooltip-flip-up {
    top: auto !important;
    bottom: 100% !important;
    margin-top: 0 !important;
    margin-bottom: 5px !important;
}

.tooltip-header {
    padding: 8px 12px;
    color: #fff;
    font-weight: 700;
    font-size: 0.82rem;
    word-break: break-word;
}

.tooltip-body {
    padding: 10px 12px;
    font-size: 0.8rem;
    color: #334155;
    white-space: normal;
    text-align: left;
    line-height: 1.45;
}

.tooltip-detail-block {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.78rem;
    color: #1e293b;
    background-color: #f8fafc;
    border-left: 3px solid #cbd5e1;
    padding: 4px 8px;
    border-radius: 0 6px 6px 0;
    max-height: 160px;
    overflow: hidden;
}

.task-card-item:hover {
    z-index: 120;
}

.entry-card:hover .majestic-tooltip,
.schedule-entry-card:hover .majestic-tooltip,
.mini-entry:hover .majestic-tooltip,
.task-card-item:hover .majestic-tooltip {
    display: block;
    visibility: visible;
    opacity: 1;
    animation: fadeIn 0.14s ease-out;
}

/* サジェストドロップダウン */
.suggest-container {
    position: relative;
    width: 100%;
}

.suggest-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 2000;
    width: 100%;
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid rgba(0,0,0,0.08);
    list-style: none;
    padding: 0.5em 0;
    margin-top: 5px;
    max-height: 300px;
    overflow-y: auto;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

    .suggest-dropdown li {
        padding: 0.7em 1.2em;
        cursor: pointer;
    }

        .suggest-dropdown li:hover {
            background-color: var(--legal-bg-light);
        }

/* ホバー時の浮き上がりエフェクト（汎用） */
.shadow-hover {
    transition: all 0.2s ease;
}

    .shadow-hover:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 20px rgba(0,0,0,0.08) !important;
    }

/* カラーピッカー (Color Picker) */
.color-picker-wrapper {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.color-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1);
}

    .color-circle.selected {
        transform: scale(1.1);
        box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--legal-accent);
    }

.hover-bg-light {
    transition: background-color 0.2s;
}

    .hover-bg-light:hover {
        background-color: #f1f5f9 !important;
    }

/* ============================================================
   9. レイアウト・ヘッダー用
   ============================================================ */
/* メインレイアウト用 */
.layout-sidebar-right {
    flex-direction: row-reverse !important;
}

    .layout-sidebar-right .sidebar {
        border-left: 1px solid rgba(255,255,255,0.1);
        box-shadow: -4px 0 15px rgba(0,0,0,0.1);
    }

.top-row {
    min-height: 3.5rem;
    height: auto !important;
    padding-top: 0.5rem;
    background-color: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.02);
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
}

/* 打刻ボタン専用スタイル */
.attendance-btn-mono {
    background-color: #ffffff;
    color: #475569;
    border: 1px solid #e2e8f0;
    padding: 0.35rem 1.2rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

    .attendance-btn-mono:disabled {
        opacity: 0.5;
        background-color: #f8fafc;
        cursor: not-allowed;
    }

.btn-hover-blue:not(:disabled):hover {
    background-color: #f0f9ff;
    color: #0284c7;
    border-color: #bae6fd;
}

.btn-hover-red:not(:disabled):hover {
    background-color: #fef2f2;
    color: #dc2626;
    border-color: #fecaca;
}

.btn-hover-yellow:not(:disabled):hover {
    background-color: #fffbeb;
    color: #d97706;
    border-color: #fde68a;
}

.btn-hover-cyan:not(:disabled):hover {
    background-color: #ecfeff;
    color: #0891b2;
    border-color: #a5f3fc;
}

.attendance-time {
    margin-left: 0.5rem;
    font-size: 0.85em;
    opacity: 0.8;
}

.memo-badge {
    font-size: 0.65rem !important;
    padding: 0 !important;
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translate(-35%, -25%) !important;
    border-width: 1.5px !important;
    font-weight: 800;
}

.memo-info-pill {
    font-size: 0.75rem;
    background-color: #f1f5f9;
    border-radius: 50px;
    padding: 2px 10px;
    color: #475569;
    display: flex;
    gap: 8px;
    border: 1px solid #e2e8f0;
}

.text-unread {
    color: #dc2626;
}

.text-undone {
    color: #0284c7;
}

/* 伝言メモアイコン用エフェクト */
.hover-primary-container:hover .memo-icon {
    color: var(--legal-primary) !important;
    transform: scale(1.1);
}

.hover-primary-container:hover .memo-text {
    color: var(--legal-primary) !important;
}

/* ============================================================
   10. サブナビゲーション・会計用
   ============================================================ */
.search-box-wide {
    min-width: 400px;
}

.sub-tab-link {
    border: none !important;
    border-bottom: 3px solid transparent !important;
}

.sub-tab-active {
    color: var(--legal-primary) !important; /* #00453e (または #0f766e) */
    background-color: transparent !important;
    border-bottom-color: var(--legal-primary) !important;
}

.sub-tab-inactive:hover {
    border-bottom-color: #cbd5e1 !important;
    color: var(--legal-primary) !important;
}

.sub-tab-divider {
    border-color: #e2e8f0 !important;
    margin-top: -2px;
}

/* ============================================================
   11. ユーザーUI用
   ============================================================ */
.avatar-circle-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: bold;
    flex-shrink: 0;
}

.icon-circle-md {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* メンテナンス・メニュー用共通スタイル */
.menu-icon-circle {
    width: 56px;
    height: 56px;
    min-width: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: transform 0.3s ease;
}

/* ホバー時にアイコンを少し浮かせる演出 */
.card-refined.shadow-hover:hover .menu-icon-circle {
    transform: scale(1.1);
}

/* カラーバリエーション */
.bg-soft-blue {
    background-color: rgba(13, 110, 253, 0.1) !important;
    color: #0d6efd !important;
}

.bg-soft-red {
    background-color: rgba(220, 53, 69, 0.1) !important;
    color: #dc3545 !important;
}

.bg-soft-purple {
    background-color: rgba(111, 66, 193, 0.1) !important;
    color: #6f42c1 !important;
}

.bg-soft-cyan {
    background-color: rgba(13, 202, 240, 0.1) !important;
    color: #0891b2 !important;
}

.bg-soft-amber {
    background-color: rgba(255, 193, 7, 0.1) !important;
    color: #b45309 !important;
}

.bg-soft-green {
    background-color: rgba(25, 135, 84, 0.1) !important;
    color: #198754 !important;
}

.bg-soft-gray {
    background-color: rgba(108, 117, 125, 0.1) !important;
    color: #6c757d !important;
}

.bg-soft-indigo {
    background-color: rgba(79, 70, 229, 0.1) !important;
    color: #4f46e5 !important;
}

.bg-soft-yellow {
    background-color: rgba(255, 235, 59, 0.2) !important;
    color: #fbc02d !important;
}

.bg-soft-gold {
    background-color: rgba(255, 160, 0, 0.15) !important;
    color: #ff8f00 !important;
}

.bg-soft-orange {
    background-color: rgba(253, 126, 20, 0.12) !important;
    color: #fd7e14 !important;
}

.bg-soft-winered {
    background-color: rgba(139, 0, 0, 0.1) !important;
    color: #8b0000 !important;
}

/* フォルダ＋人のアイコン重ね合わせ */
.icon-stack {
    position: relative;
    display: inline-block;
}

    .icon-stack .icon-overlay-person {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -20%) scale(0.5); /* フォルダの中央に人を小さく */
        color: inherit;
    }

    .icon-stack .icon-overlay {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%) scale(1.1);
        font-size: 0.8em;
        color: #b91c1c;
        text-shadow: 0 1px 2px rgba(0,0,0,0.3);
    }

/* ============================================================
   12. モバイル向けレスポンシブ (Mobile Overrides)
   ============================================================ */
@media (max-width: 768px) {
    /* 1. タイトルの改行防止 & スマホ版サイズバランス調整 (タイトルを少し小さく引き締め) */
    .majestic-title {
        font-size: 1.15rem !important;
        white-space: nowrap;
    }

    .context-lead-icon {
        font-size: 1.25rem !important;
    }

    .context-circle-icon {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
    }

    .context-circle-icon i {
        font-size: 1.15rem !important;
    }

    .context-back-btn {
        width: 36px !important;
        height: 36px !important;
    }

    .context-back-btn i {
        font-size: 1.1rem !important;
    }

    .context-header {
        margin-bottom: 0.5rem !important;
    }

    /* 2. ContextHeader内のアクションボタン・コントロールのスマホ最適化 (新規予約・登録ボタンのコンパクト化) */
    .context-header .btn-majestic,
    .context-header .btn:not(.context-back-btn) {
        font-size: 0.82rem !important;
        padding: 0.25rem 0.8rem !important;
        height: auto !important;
        min-height: 2rem !important;
        max-height: none !important;
        line-height: 1.2 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        border-radius: 50px !important;
        font-weight: 700 !important;
        letter-spacing: 0.02em !important;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
    }

    .context-header .btn:not(.context-back-btn) i {
        font-size: 0.85rem !important;
        line-height: 1 !important;
    }

    /* 拠点選択などのセレクトボックスの高さ・フォントサイズも 2rem 基準で連動 */
    .context-header .branch-selector {
        min-height: 2rem !important;
        height: auto !important;
        max-height: none !important;
        display: flex !important;
        align-items: center !important;
    }
    .context-header .branch-selector select {
        min-height: 2rem !important;
        height: auto !important;
        max-height: none !important;
        font-size: 0.82rem !important;
        padding-top: 0.2rem !important;
        padding-bottom: 0.2rem !important;
        padding-left: 0.6rem !important;
        padding-right: 1.5rem !important;
        line-height: 1.25 !important;
    }

    /* モバイル環境での全般的な btn-majestic のサイズ適正化 */
    .btn-majestic {
        font-size: 0.85rem !important;
        padding: 0.35rem 1.2rem !important;
    }

    /* 3. モバイルヘッダーとメイン領域の配置 (ヘッダーを少し大きくしてタップしやすく) */
    .mobile-top-header {
        flex-shrink: 0;
        height: 54px;
        padding: 0 1rem;
        background-color: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border-bottom: 1px solid #e2e8f0;
        z-index: 1000;
    }

    main {
        padding-top: 0 !important;
        padding-bottom: 0 !important;
    }

    .form-control, .form-select, input, select {
        max-width: 100% !important;
    }

    .card-refined, .card-body {
        overflow-x: hidden;
    }

    /* モバイル時は1ボタンなら1行横並びを維持し、検索ボックスや複数ボタン等で幅が足りない場合は2段目へ自然に折り返してタイトル潰れを防止 */
    .search-box-wide,
    .is-mobile-device .search-box-wide {
        min-width: 0 !important;
        width: 100% !important;
    }

    .context-header,
    .is-mobile-device .context-header {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 0.4rem 0.5rem !important;
        margin-bottom: 0.35rem !important;
    }

    .context-header > .d-flex:first-child,
    .is-mobile-device .context-header > .d-flex:first-child {
        min-width: 150px !important;
        flex: 1 1 auto !important;
        overflow: hidden !important;
    }

    .context-header-actions,
    .is-mobile-device .context-header-actions {
        flex: 0 1 auto !important;
        max-width: 100% !important;
        display: flex !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        justify-content: flex-end !important;
        gap: 0.35rem !important;
        margin-top: 0 !important;
        margin-left: auto !important;
    }

    .context-header-actions:has(.search-box-wide),
    .is-mobile-device .context-header-actions:has(.search-box-wide) {
        width: 100% !important;
    }

    .context-header-actions > *,
    .is-mobile-device .context-header-actions > * {
        max-width: 100% !important;
        margin-top: 0 !important;
        margin-bottom: 0 !important;
    }

    .context-header .page-description,
    .is-mobile-device .context-header .page-description {
        font-size: 0.72rem !important;
        line-height: 1.15 !important;
        margin-top: 2px !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
}

/* モバイルデバイス判定時 (.is-mobile-device) のスタイル保証 */
.is-mobile-device .majestic-title {
    font-size: 1.15rem !important;
    white-space: nowrap;
}

.is-mobile-device .context-lead-icon {
    font-size: 1.25rem !important;
}

.is-mobile-device .context-circle-icon {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
}

.is-mobile-device .context-circle-icon i {
    font-size: 1.15rem !important;
}

.is-mobile-device .context-back-btn {
    width: 36px !important;
    height: 36px !important;
}

.is-mobile-device .context-back-btn i {
    font-size: 1.1rem !important;
}

.is-mobile-device .context-header {
    flex-direction: row !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 0.4rem 0.5rem !important;
    margin-bottom: 0.35rem !important;
}

.is-mobile-device .context-header .btn-majestic,
.is-mobile-device .context-header .btn:not(.context-back-btn) {
    font-size: 0.82rem !important;
    padding: 0.25rem 0.8rem !important;
    height: auto !important;
    min-height: 2rem !important;
    max-height: none !important;
    line-height: 1.2 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 50px !important;
    font-weight: 700 !important;
    letter-spacing: 0.02em !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
}

.is-mobile-device .context-header .btn:not(.context-back-btn) i {
    font-size: 0.85rem !important;
    line-height: 1 !important;
}

.is-mobile-device .context-header .branch-selector {
    min-height: 2rem !important;
    height: auto !important;
    max-height: none !important;
    display: flex !important;
    align-items: center !important;
}

.is-mobile-device .context-header .branch-selector select {
    min-height: 2rem !important;
    height: auto !important;
    max-height: none !important;
    font-size: 0.82rem !important;
    padding-top: 0.2rem !important;
    padding-bottom: 0.2rem !important;
    padding-left: 0.6rem !important;
    padding-right: 1.5rem !important;
    line-height: 1.25 !important;
}

.is-mobile-device .btn-majestic {
    font-size: 0.85rem !important;
    padding: 0.35rem 1.2rem !important;
}

.is-mobile-device .mobile-top-header {
    height: 54px !important;
    padding: 0 1rem !important;
}

/* ============================================================
   13. 共通ペインレイアウト用
   ============================================================ */
.majestic-sidebar {
    width: 100%;
    height: auto;
    max-height: 180px; /* スマホでは高さを抑えてスクロール */
    flex-shrink: 0;
}

.majestic-main {
    width: 100%;
    min-width: 0;
    flex-grow: 1;
}

@media (min-width: 768px) {
    .majestic-sidebar {
        width: 250px !important; /* PCでは幅を固定 */
        max-height: 100% !important;
    }

    .majestic-main {
        width: calc(100% - 250px) !important;
    }

    .table-responsive {
        -webkit-overflow-scrolling: touch;
        overflow-x: auto !important;
    }

}

/* デバッグ用 */
/** {
    outline: 1px solid red !important;
}*/

/*.page {
    background-color: rgba(255, 0, 0, 0.1) !important;
}

main {
    background-color: rgba(0, 255, 0, 0.1) !important;
}

.content {
    background-color: rgba(0, 0, 255, 0.1) !important;
}*/

/* Sidebar Hidden State for LINE Inbox etc */
.page {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.sidebar {
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), min-width 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
}
.sidebar-hidden .sidebar {
    width: 0 !important;
    min-width: 0 !important;
    transform: translateX(-100%);
    opacity: 0;
    overflow: hidden;
}
.layout-sidebar-right.sidebar-hidden .sidebar {
    transform: translateX(100%);
}

/* --- Custom Utility Classes (Refactoring) --- */
.w-80px { width: 80px !important; }
.w-100px { width: 100px !important; }
.w-120px { width: 120px !important; }
.w-150px { width: 150px !important; }
.w-200px { width: 200px !important; }
.w-250px { width: 250px !important; }

.min-w-100px { min-width: 100px !important; }
.min-w-120px { min-width: 120px !important; }

.fs-xs { font-size: 0.75rem !important; }
.fs-sm { font-size: 0.85rem !important; }
.lh-sm { line-height: 1.2 !important; }

.icon-n1 { transform: translateY(-1px) !important; }
.w-24px { width: 24px !important; }
.w-28px { width: 28px !important; }
.w-30px { width: 30px !important; }
.w-40px { width: 40px !important; }
.w-45px { width: 45px !important; }
.w-50px { width: 50px !important; }
.w-60px { width: 60px !important; }
.w-75px { width: 75px !important; }
.w-85px { width: 85px !important; }
.w-90px { width: 90px !important; }
.w-95px { width: 95px !important; }
.w-105px { width: 105px !important; }
.w-110px { width: 110px !important; }
.w-115px { width: 115px !important; }
.w-125px { width: 125px !important; }
.w-130px { width: 130px !important; }
.w-135px { width: 135px !important; }
.w-140px { width: 140px !important; }
.w-155px { width: 155px !important; }
.w-160px { width: 160px !important; }
.w-170px { width: 170px !important; }
.w-180px { width: 180px !important; }
.w-260px { width: 260px !important; }
.w-300px { width: 300px !important; }

.col-w-50px { min-width: 50px !important; width: 50px !important; }
.col-w-80px { min-width: 80px !important; width: 80px !important; }
.col-w-100px { min-width: 100px !important; width: 100px !important; }
.col-w-120px { min-width: 120px !important; width: 120px !important; }
.col-w-140px { min-width: 140px !important; width: 140px !important; }
.col-w-150px { min-width: 150px !important; width: 150px !important; }
.col-w-200px { min-width: 200px !important; width: 200px !important; }
.col-w-250px { min-width: 250px !important; width: 250px !important; }

.min-w-0 { min-width: 0 !important; }
.min-w-60px { min-width: 60px !important; }
.min-w-110px { min-width: 110px !important; }
.min-w-115px { min-width: 115px !important; }
.min-w-125px { min-width: 125px !important; }
.min-w-160px { min-width: 160px !important; }
.min-w-170px { min-width: 170px !important; }
.min-w-180px { min-width: 180px !important; }
.min-w-200px { min-width: 200px !important; }
.min-w-220px { min-width: 220px !important; }
.min-w-max { min-width: max-content !important; }

.max-w-100px { max-width: 100px !important; }
.max-w-110px { max-width: 110px !important; }
.max-w-120px { max-width: 120px !important; }
.max-w-130px { max-width: 130px !important; }
.max-w-140px { max-width: 140px !important; }
.max-w-150px { max-width: 150px !important; }
.max-w-160px { max-width: 160px !important; }
.max-w-180px { max-width: 180px !important; }
.max-w-200px { max-width: 200px !important; }
.max-w-220px { max-width: 220px !important; }
.max-w-230px { max-width: 230px !important; }
.max-w-240px { max-width: 240px !important; }
.max-w-250px { max-width: 250px !important; }
.max-w-260px { max-width: 260px !important; }
.max-w-280px { max-width: 280px !important; }
.max-w-300px { max-width: 300px !important; }
.max-w-320px { max-width: 320px !important; }
.max-w-350px { max-width: 350px !important; }

.min-h-0 { min-height: 0 !important; }

.fs-3xs { font-size: 0.6rem !important; }
.fs-xxs { font-size: 0.65rem !important; }
.fs-68 { font-size: 0.68rem !important; }
.fs-2xs { font-size: 0.7rem !important; }
.fs-72 { font-size: 0.72rem !important; }
.fs-76 { font-size: 0.76rem !important; }
.fs-78 { font-size: 0.78rem !important; }
.fs-80, .fs-md { font-size: 0.8rem !important; }
.fs-90 { font-size: 0.9rem !important; }
.fs-92 { font-size: 0.92rem !important; }
.fs-95, .fs-lg { font-size: 0.95rem !important; }

.spinner-3rem { width: 3rem !important; height: 3rem !important; }
.z-5 { z-index: 5 !important; }
.z-10 { z-index: 10 !important; }
.z-20 { z-index: 20 !important; }
.pe-select-clear { padding-right: 2.25rem !important; }
.modal-footer-safe { z-index: 20 !important; padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px)) !important; }

/* Global Placeholder Style */
.form-control::placeholder,
.form-select::placeholder {
    color: #adb5bd !important;
    opacity: 0.8 !important;
}

/* ============================================================
   バリデーションサマリー・メッセージ (枠外の点を消去・すっきり配置)
   ============================================================ */
ul.validation-errors,
.validation-errors {
    list-style: none !important;
    list-style-type: none !important;
    padding-left: 0 !important;
    margin: 0 !important;
}

ul.validation-errors li,
.validation-errors li,
.validation-message {
    list-style: none !important;
    list-style-type: none !important;
}

/* ============================================================
   PC環境での「PCビュー固定」強制ルール (is-desktop-device)
   ウィンドウをいくら縮小してもスマホ用UIに切り替わらずPC表示を維持する
   ============================================================ */
.page.is-desktop-device .d-md-none,
.page.is-desktop-device .d-lg-none,
.page.is-desktop-device .d-sm-none {
    display: none !important;
}

.page.is-desktop-device .d-none.d-md-flex,
.page.is-desktop-device .d-none.d-lg-flex,
.page.is-desktop-device .d-none.d-sm-flex {
    display: flex !important;
}

.page.is-desktop-device .d-none.d-md-block,
.page.is-desktop-device .d-none.d-lg-block,
.page.is-desktop-device .d-none.d-sm-block {
    display: block !important;
}

.page.is-desktop-device .d-none.d-md-inline-flex,
.page.is-desktop-device .d-none.d-lg-inline-flex,
.page.is-desktop-device .d-none.d-sm-inline-flex {
    display: inline-flex !important;
}

.page.is-desktop-device .d-none.d-md-inline,
.page.is-desktop-device .d-none.d-lg-inline,
.page.is-desktop-device .d-none.d-sm-inline {
    display: inline !important;
}

.page.is-desktop-device .d-none.d-md-table-cell,
.page.is-desktop-device .d-none.d-lg-table-cell {
    display: table-cell !important;
}

/* スケジュール管理 (PCビュー強制) */
.page.is-desktop-device .schedule-wrapper {
    flex-direction: row !important;
    overflow: hidden !important;
    gap: 1rem !important;
}
.page.is-desktop-device .schedule-calendar-pane {
    width: calc(100% - 320px) !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: hidden !important;
    display: flex !important;
}
.page.is-desktop-device .schedule-task-pane {
    width: 320px !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: hidden !important;
    border-top: none !important;
    display: flex !important;
}
.page.is-desktop-device .schedule-mobile-tabs-container {
    display: none !important;
}

/* 会議室予約 (PCビュー強制) */
.page.is-desktop-device .room-wrapper {
    flex-direction: row !important;
    overflow: hidden !important;
    gap: 1rem !important;
}
.page.is-desktop-device .room-calendar-pane {
    width: calc(100% - 320px) !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: hidden !important;
    display: flex !important;
}
.page.is-desktop-device .room-task-pane {
    width: 320px !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: hidden !important;
    border-top: none !important;
    border-radius: 0 1rem 1rem 0 !important;
    display: flex !important;
}
.page.is-desktop-device .room-mobile-tabs-container {
    display: none !important;
}

/* 勤怠管理 (PCビュー強制) */
.page.is-desktop-device .attendance-wrapper {
    flex-direction: row !important;
    overflow: hidden !important;
    gap: 1rem !important;
}
.page.is-desktop-device .attendance-action-pane {
    width: 360px !important;
    flex: 0 0 360px !important;
    height: 100% !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    display: flex !important;
}
.page.is-desktop-device .attendance-list-pane {
    width: calc(100% - 360px - 1rem) !important;
    flex: 1 1 auto !important;
    height: 100% !important;
    min-height: 0 !important;
    overflow: hidden !important;
    display: flex !important;
}
.page.is-desktop-device .attendance-mobile-tabs-container {
    display: none !important;
}

/* 伝言メモ (PCビュー強制) */
.page.is-desktop-device .message-wrapper {
    flex-direction: row !important;
    overflow: hidden !important;
    gap: 1rem !important;
}
.page.is-desktop-device .message-list-pane {
    width: 380px !important;
    flex: 0 0 380px !important;
    max-height: none !important;
    height: 100% !important;
    display: flex !important;
}
.page.is-desktop-device .message-detail-pane {
    width: calc(100% - 380px - 1rem) !important;
    flex: 1 1 auto !important;
    max-height: none !important;
    height: 100% !important;
    display: flex !important;
}

/* モバイル時のWord / Excel / PDF プレビュー表示最適化 */
@media (max-width: 768px) {
    #docx-preview-container {
        padding: 0.5rem !important;
        overflow-x: hidden !important;
    }
    #docx-preview-container .docx-wrapper {
        padding: 0 !important;
        background: transparent !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    #docx-preview-container .docx-wrapper > section.docx {
        box-shadow: none !important;
        margin-bottom: 0.75rem !important;
        padding: 0.75rem !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }
    #docx-preview-container table {
        max-width: 100% !important;
        table-layout: auto !important;
    }
    #docx-preview-container img {
        max-width: 100% !important;
        height: auto !important;
    }
    #xlsx-preview-container table {
        font-size: 0.75rem !important;
    }
    .pdf-pages-wrapper {
        width: 100% !important;
        padding: 0.5rem !important;
    }
    .pdf-page-canvas {
        max-width: 100% !important;
        height: auto !important;
    }
}

/* スマホ端末における全般的なボタン縮尺・歪み防止 */
@media (max-width: 768px) {
    .is-mobile-device .btn,
    .btn {
        flex-shrink: 0;
    }
    .is-mobile-device .btn:not(.btn-lg):not(.nav-tab-item):not(.btn-link):not(.btn-close),
    .is-mobile-view .btn:not(.btn-lg):not(.nav-tab-item):not(.btn-link):not(.btn-close) {
        font-size: 0.82rem;
        min-height: 32px;
        line-height: 1.2;
    }
    .is-mobile-device .btn.btn-sm,
    .is-mobile-view .btn.btn-sm {
        min-height: 28px;
        font-size: 0.78rem;
        padding: 0.2rem 0.55rem;
    }
    .modal-footer,
    .dialog-footer {
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
    }
}

/* LINE受付・FAX受信画面の外部スクロール抑止 */
.content:has(.line-inbox-container) {
    overflow-y: hidden !important;
}

@media (min-width: 768px) {
    .content:has(.fax-inbox-container),
    .page.is-desktop-device .content:has(.fax-inbox-container) {
        overflow: hidden !important;
        height: 100% !important;
        max-height: 100% !important;
    }
}

/* ============================================================
   14. 小数点スペーシングユーティリティ (.5系 / remベースで文字サイズ設定に連動)
   ============================================================ */
.p-0\.5 { padding: 0.125rem !important; }
.p-1\.5 { padding: 0.375rem !important; }
.p-2\.5 { padding: 0.75rem !important; }
.p-3\.5 { padding: 1.25rem !important; }

.px-0\.5 { padding-left: 0.125rem !important; padding-right: 0.125rem !important; }
.px-1\.5 { padding-left: 0.375rem !important; padding-right: 0.375rem !important; }
.px-2\.5 { padding-left: 0.75rem !important; padding-right: 0.75rem !important; }
.px-3\.5 { padding-left: 1.25rem !important; padding-right: 1.25rem !important; }

.py-0\.5 { padding-top: 0.125rem !important; padding-bottom: 0.125rem !important; }
.py-1\.5 { padding-top: 0.375rem !important; padding-bottom: 0.375rem !important; }
.py-2\.5 { padding-top: 0.75rem !important; padding-bottom: 0.75rem !important; }
.py-3\.5 { padding-top: 1.25rem !important; padding-bottom: 1.25rem !important; }

.pt-0\.5 { padding-top: 0.125rem !important; }
.pt-1\.5 { padding-top: 0.375rem !important; }
.pt-2\.5 { padding-top: 0.75rem !important; }
.pt-3\.5 { padding-top: 1.25rem !important; }

.pb-0\.5 { padding-bottom: 0.125rem !important; }
.pb-1\.5 { padding-bottom: 0.375rem !important; }
.pb-2\.5 { padding-bottom: 0.75rem !important; }
.pb-3\.5 { padding-bottom: 1.25rem !important; }

.m-0\.5 { margin: 0.125rem !important; }
.m-1\.5 { margin: 0.375rem !important; }
.m-2\.5 { margin: 0.75rem !important; }
.m-3\.5 { margin: 1.25rem !important; }

.mt-0\.5 { margin-top: 0.125rem !important; }
.mt-1\.5 { margin-top: 0.375rem !important; }
.mt-2\.5 { margin-top: 0.75rem !important; }
.mt-3\.5 { margin-top: 1.25rem !important; }

.mb-0\.5 { margin-bottom: 0.125rem !important; }
.mb-1\.5 { margin-bottom: 0.375rem !important; }
.mb-2\.5 { margin-bottom: 0.75rem !important; }
.mb-3\.5 { margin-bottom: 1.25rem !important; }

.my-0\.5 { margin-top: 0.125rem !important; margin-bottom: 0.125rem !important; }
.my-1\.5 { margin-top: 0.375rem !important; margin-bottom: 0.375rem !important; }
.my-2\.5 { margin-top: 0.75rem !important; margin-bottom: 0.75rem !important; }
.my-3\.5 { margin-top: 1.25rem !important; margin-bottom: 1.25rem !important; }

.mx-0\.5 { margin-left: 0.125rem !important; margin-right: 0.125rem !important; }
.mx-1\.5 { margin-left: 0.375rem !important; margin-right: 0.375rem !important; }
.mx-2\.5 { margin-left: 0.75rem !important; margin-right: 0.75rem !important; }
.mx-3\.5 { margin-left: 1.25rem !important; margin-right: 1.25rem !important; }

.me-0\.5 { margin-right: 0.125rem !important; }
.me-1\.5 { margin-right: 0.375rem !important; }
.me-2\.5 { margin-right: 0.75rem !important; }
.me-3\.5 { margin-right: 1.25rem !important; }

.ms-0\.5 { margin-left: 0.125rem !important; }
.ms-1\.5 { margin-left: 0.375rem !important; }
.ms-2\.5 { margin-left: 0.75rem !important; }
.ms-3\.5 { margin-left: 1.25rem !important; }

.g-1\.5, .gx-1\.5 { --bs-gutter-x: 0.375rem; }
.g-1\.5, .gy-1\.5 { --bs-gutter-y: 0.375rem; }
.g-2\.5, .gx-2\.5 { --bs-gutter-x: 0.75rem; }
.g-2\.5, .gy-2\.5 { --bs-gutter-y: 0.75rem; }
.g-3\.5, .gx-3\.5 { --bs-gutter-x: 1.25rem; }
.g-3\.5, .gy-3\.5 { --bs-gutter-y: 1.25rem; }

.gap-0\.5 { gap: 0.125rem !important; }
.gap-1\.5 { gap: 0.375rem !important; }
.gap-2\.5 { gap: 0.75rem !important; }
.gap-3\.5 { gap: 1.25rem !important; }

/* ============================================================
   15. 動的フォントスケール & メンテナンス画面共通サイズ統一ルール
   （個人設定の文字サイズ text-size-xxs ～ text-size-xxl に完全連動）
   ============================================================ */
.theme-text-md,
.text-base-dynamic {
    font-size: 0.9rem;
}

.text-sm-dynamic {
    font-size: 0.85rem;
}

/* アイコンサークル等も rem 単位にして文字サイズ変更時に比率を維持 */
.avatar-circle-sm {
    width: 2rem;
    height: 2rem;
}

.icon-circle-md {
    width: 2.75rem;
    height: 2.75rem;
    min-width: 2.75rem;
}

.menu-icon-circle {
    width: 2.75rem;
    height: 2.75rem;
    min-width: 2.75rem;
}

/* メンテナンス画面共通コンテナ (.maint-page または .theme-text-md.text-base-dynamic) 内のカード・見出し・テーブル・フォーム統一 */
.maint-page .card-refined,
.maint-page .card:not(.bg-light) {
    border-radius: 0.75rem !important;
    border: 1px solid rgba(226, 232, 240, 0.9) !important;
}

.maint-page .card-refined h5,
.maint-page .card h5,
.maint-page .card-refined h6,
.maint-page .card h6,
.maint-page .section-title {
    font-size: 0.95rem !important;
    line-height: 1.35;
}

.maint-page .table {
    font-size: 0.875rem;
}

.maint-page .table > thead > tr > th {
    font-size: 0.78rem !important;
    font-weight: 700 !important;
    color: #64748b !important;
    background-color: #f8fafc !important;
    padding-top: 0.55rem !important;
    padding-bottom: 0.55rem !important;
    vertical-align: middle;
    border-bottom: 1px solid #e2e8f0 !important;
    white-space: nowrap;
}

.maint-page .table > tbody > tr > td {
    font-size: 0.875rem;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    vertical-align: middle;
}

/* テーブル内の操作アイコンサイズを適正化 */
.maint-page .table .btn-link i.fs-5,
.maint-page .table .btn i.fs-5 {
    font-size: 1.05rem !important;
}

/* メンテナンス内のフォームラベル・入力欄のサイズ統一 */
.maint-page .form-label,
.maint-page .label-small {
    font-size: 0.8rem !important;
    font-weight: 700 !important;
    color: #64748b;
    margin-bottom: 0.35rem;
}

.maint-page .form-control:not(.form-control-lg),
.maint-page .form-select:not(.form-select-lg) {
    font-size: 0.875rem;
    padding: 0.375rem 0.7rem;
    border-radius: 0.5rem;
}

.maint-page .input-group-text {
    font-size: 0.85rem;
    padding: 0.375rem 0.7rem;
}

/* カレンダー休業日・定休日セルの背景色 */
.bg-holiday-sun {
    background-color: #fff5f5 !important;
}

.bg-holiday-sat {
    background-color: #f5f9ff !important;
}

/* ============================================================
   16. スマホ用 検索結果テーブル「主要3〜4列コンパクト表示 / 全列表示切替」
   ============================================================ */
.page.is-desktop-device .mobile-col-toggle-pill {
    display: none !important;
}

@media (max-width: 767.98px) {
    .page:not(.is-desktop-device) .table-responsive:has(> .mobile-table-compact) {
        overflow-x: hidden !important;
    }

    .page:not(.is-desktop-device) .mobile-table-compact {
        width: 100% !important;
        max-width: 100% !important;
        table-layout: auto !important;
    }

    .page:not(.is-desktop-device) .mobile-table-compact > thead > tr > th {
        padding-left: 0.3rem !important;
        padding-right: 0.3rem !important;
        font-size: 0.72rem !important;
        white-space: nowrap !important;
        width: auto !important;
        min-width: 0 !important;
        vertical-align: middle !important;
    }

    .page:not(.is-desktop-device) .mobile-table-compact > tbody > tr > td {
        padding-left: 0.3rem !important;
        padding-right: 0.3rem !important;
        font-size: 0.76rem !important;
        white-space: normal !important;
        word-break: break-word;
        width: auto !important;
        min-width: 0 !important;
        vertical-align: middle !important;
    }

    /* td 自体は必ず table-cell を維持し、内部要素の .text-truncate のみ最大2行クランプにする */
    .page:not(.is-desktop-device) .mobile-table-compact > tbody > tr > td:not(.mobile-col-extra).text-truncate {
        display: table-cell !important;
        white-space: normal !important;
        max-width: none !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    .page:not(.is-desktop-device) .mobile-table-compact > tbody > tr > td .text-truncate {
        white-space: normal !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        max-width: 100% !important;
    }

    .page:not(.is-desktop-device) .mobile-table-compact > tbody > tr > td .badge,
    .page:not(.is-desktop-device) .mobile-table-compact > tbody > tr > td .btn:not(.badge-pill-soft),
    .page:not(.is-desktop-device) .mobile-table-compact > tbody > tr > td.mobile-col-nowrap,
    .page:not(.is-desktop-device) .mobile-table-compact > tbody > tr > td .mobile-col-nowrap {
        white-space: nowrap !important;
    }

    /* 案件管理：ステータスバッジの最小幅をスマホ用に縮小 */
    .page:not(.is-desktop-device) .mobile-table-compact .status-badge {
        min-width: 52px !important;
        font-size: 0.64rem !important;
        padding: 2px 5px !important;
    }

    .page:not(.is-desktop-device) .mobile-table-compact .badge-case-type {
        font-size: 0.68rem !important;
        padding: 3px 6px !important;
    }

    /* 受付管理：関与案件ピルボタンが横幅を押し広げないよう省略表示 */
    .page:not(.is-desktop-device) .mobile-table-compact .badge-pill-soft {
        max-width: 64px !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        display: inline-block !important;
        font-size: 0.62rem !important;
        padding: 1px 4px !important;
        min-height: 0 !important;
        line-height: 1.3 !important;
    }

    /* 受付管理 & 案件カルテ関係者：操作ボタンのサイズ・間隔を統一しつつ iPhone SE (375px) でも見切れないよう最適化 */
    .page:not(.is-desktop-device) .mobile-table-compact .col-name-cell {
        max-width: 72px !important;
        padding-left: 0.2rem !important;
        padding-right: 0.15rem !important;
    }

    .page:not(.is-desktop-device) .mobile-table-compact .reception-kana-text {
        max-width: 66px !important;
        font-size: 0.6rem !important;
    }

    .page:not(.is-desktop-device) .mobile-table-compact .reception-phone-cell,
    .page:not(.is-desktop-device) .mobile-table-compact .party-phone-cell {
        font-size: 0.66rem !important;
        letter-spacing: -0.04em !important;
        padding-left: 0.15rem !important;
        padding-right: 0.15rem !important;
    }

    .page:not(.is-desktop-device) .mobile-table-compact .col-matters-cell {
        max-width: 68px !important;
        padding-left: 0.15rem !important;
        padding-right: 0.15rem !important;
    }

    .page:not(.is-desktop-device) .mobile-table-compact .reception-actions-cell,
    .page:not(.is-desktop-device) .mobile-table-compact .party-actions-cell {
        padding-left: 0.15rem !important;
        padding-right: 0.2rem !important;
    }

    .page:not(.is-desktop-device) .mobile-table-compact .reception-action-buttons,
    .page:not(.is-desktop-device) .mobile-table-compact .party-action-buttons {
        gap: 0.25rem !important;
    }

    .page:not(.is-desktop-device) .mobile-table-compact .action-reception-btn,
    .page:not(.is-desktop-device) .mobile-table-compact .action-party-btn,
    .page:not(.is-desktop-device) .mobile-table-compact .action-party-btn-placeholder {
        width: 30px !important;
        height: 30px !important;
        min-width: 30px !important;
        min-height: 30px !important;
        padding: 0 !important;
    }

    .page:not(.is-desktop-device) .mobile-table-compact .action-reception-btn i,
    .page:not(.is-desktop-device) .mobile-table-compact .action-party-btn i {
        font-size: 1.15rem !important;
    }

    /* 案件カルテ関係者一覧：モバイルコンパクト時の列幅調整 */
    .page:not(.is-desktop-device) .mobile-table-compact .party-rel-cell {
        padding-left: 0.2rem !important;
        padding-right: 0.15rem !important;
        white-space: nowrap !important;
    }

    .page:not(.is-desktop-device) .mobile-table-compact .party-rel-badge {
        font-size: 0.64rem !important;
        padding: 2px 5px !important;
    }

    .page:not(.is-desktop-device) .mobile-table-compact .party-name-cell {
        max-width: 110px !important;
        padding-left: 0.15rem !important;
        padding-right: 0.15rem !important;
    }

    .page:not(.is-desktop-device) .mobile-table-compact .party-kana-text {
        max-width: 100px !important;
        font-size: 0.6rem !important;
    }

    .page:not(.is-desktop-device) .mobile-table-compact .report-action-grid {
        display: flex !important;
        flex-wrap: nowrap !important;
        justify-content: flex-end !important;
        width: 100% !important;
        gap: 0.2rem !important;
    }

    .page:not(.is-desktop-device) .mobile-table-compact .report-action-grid > div {
        width: 28px !important;
        height: 28px !important;
        flex: 0 0 28px !important;
    }

    .page:not(.is-desktop-device) .mobile-table-compact .report-action-grid .btn {
        width: 28px !important;
        height: 28px !important;
        padding: 0 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .page:not(.is-desktop-device) .mobile-table-compact .report-action-grid .btn i {
        margin-right: 0 !important;
        font-size: 1.08rem !important;
    }

    .page:not(.is-desktop-device) .mobile-table-compact .report-action-grid > div:empty,
    .page:not(.is-desktop-device) .mobile-table-compact .report-action-grid > div:not(:has(*)) {
        display: none !important;
    }

    /* 非表示対象列は他のどのクラス(.text-truncate等)と併用されていても確実に非表示にする */
    .page:not(.is-desktop-device) .mobile-table-compact > thead > tr > th.mobile-col-extra,
    .page:not(.is-desktop-device) .mobile-table-compact > tbody > tr > td.mobile-col-extra,
    .page:not(.is-desktop-device) .mobile-table-compact > tbody > tr > td.mobile-col-extra.text-truncate {
        display: none !important;
    }
}

/* ページネーション等のボタングループ内 span.btn がスマホ min-height 適用時に上ずらないよう上下中央揃えを強制 */
.btn-group > .btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}
