:root {
    --primary-color: #2c3e50;
    --secondary-color: #34495e;
    --accent-color: #3498db;
    --bg-color: #f4f7f6;
    --sidebar-bg: #ffffff;
    --sidebar-text: #2c3e50;
    --text-color: #333333;
    --text-muted: #7f8c8d;
    --border-color: #e0e0e0;
    --white: #ffffff;
    --error-color: #e74c3c;
    --success-color: #27ae60;
    --danger-color: #dc3545;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

/* =====================================================
   ページロード時のトランジションフラッシュ防止
   ページロード中はtransitionとanimationを全停止し、
   ロード完了後にJSでこのクラスを外して復元する
   ===================================================== */
.preload-no-transition *,
.preload-no-transition *::before,
.preload-no-transition *::after {
    transition: none !important;
    animation: none !important;
}

/* =====================================================
   Font Awesomeアイコンのレイアウトシフト防止
   フォントファイル読み込み前後でレイアウトが変わらないよう、
   アイコン要素に最小幅を事前に確保する
   ===================================================== */
.fas,
.far,
.fab,
.fal,
.fad,
.fa {
    display: inline-block;
    min-width: 1em;
    /* フォント読み込み前はfallbackで文字が出ないように */
    font-style: normal;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    overflow-x: hidden;
    width: 100%;
}

body {
    font-family: "Yu Gothic Medium", "Yu Gothic", "Meiryo", 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

a {
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
}

/* Login Page Styles */
.login-page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-color: var(--bg-color);
}

.login-container {
    display: flex;
    flex: 1;
    /* Take up available space to push footer down */
    justify-content: center;
    align-items: center;
    padding: 60px 20px;
}

.login-card {
    background: var(--white);
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
    width: 100%;
    max-width: 400px;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    font-size: 24px;
    color: var(--primary-color);
    margin-bottom: 10px;
}



.login-header p {
    color: var(--text-muted);
    font-size: 14px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-block;
    text-align: center;
    vertical-align: middle;
    line-height: 1.5;
}

/* アイコンとテキストの上下中央揃え＆余白調整 */
.btn i,
.btn svg {
    display: inline-block;
    line-height: inherit;
    vertical-align: middle;
    margin-right: 0.2rem;
    transform: translateY(-1px);
}

.btn-primary {
    background-color: var(--accent-color);
    color: var(--white);
}

.btn-primary:hover {
    background-color: #2980b9;
}

.btn-danger {
    background-color: var(--error-color);
    color: var(--white);
}

.btn-danger:hover {
    background-color: #c0392b;
}

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.5;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success {
    background-color: #d1e7dd;
    color: #0f5132;
    border: 1px solid #badbcc;
}

.alert-danger {
    background-color: #f8d7da;
    color: #842029;
    border: 1px solid #f5c2c7;
}

/* Utility Classes */
.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -15px;
    margin-left: -15px;
}

/* --- Search / Filter Form (Centralized) --- */
.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: flex-end;
    justify-content: flex-start;
}

.filter-form.pc-one-line {
    flex-wrap: nowrap;
}

.search-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
}

.search-group.flex-grow-1 {
    flex: 2;
}

.search-actions {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.search-actions .btn {
    height: 46px;
    padding: 0 25px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.btn-clear {
    height: 46px;
    width: 46px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #ddd;
    border-radius: 6px;
    color: #666;
    background: #fff;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-clear:hover {
    background: #f8f9fa;
    color: var(--primary-color);
    border-color: #ccc;
}

.row.g-2 {
    margin-right: -4px;
    margin-left: -4px;
}

.row.g-2>[class*="col-"] {
    padding-right: 4px;
    padding-left: 4px;
}

.row.g-3 {
    margin-right: -8px;
    margin-left: -8px;
}

.row.g-3>[class*="col-"] {
    padding-right: 8px;
    padding-left: 8px;
}

.form-label {
    display: block !important;
    margin-bottom: 8px !important;
    font-size: 14px;
    font-weight: 500;
}

.form-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-top: 2.5rem;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #f1f5f9;
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-section-title:first-child {
    margin-top: 0;
}

.form-section-title i {
    color: var(--accent-color);
}

[class*="col-"] {
    position: relative;
    width: 100%;
    padding-right: 15px;
    padding-left: 15px;
}

@media (min-width: 768px) {
    .col-md-4 {
        flex: 0 0 33.333333%;
        max-width: 33.333333%;
    }

    .col-md-6 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    .col-md-8 {
        flex: 0 0 66.666667%;
        max-width: 66.666667%;
    }

    .col-md-12 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

.mb-3 {
    margin-bottom: 1rem;
}

.ml-1 {
    margin-left: 0.25rem;
}

.ml-2 {
    margin-left: 0.5rem;
}

.ml-3 {
    margin-left: 1rem;
}

.mt-1 {
    margin-top: 0.25rem;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mt-3 {
    margin-top: 1rem;
}

.mt-4 {
    margin-top: 1.5rem;
}

/* Layout Styles */
.admin-badge {
    color: var(--error-color);
    font-weight: bold;
    font-size: 12px;
    text-transform: uppercase;
    display: block;
    margin-top: 5px;
}

.login-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 13px;
    color: var(--text-muted);
}

.login-footer a {
    color: var(--accent-color);
}

/* Responsive Sidebar Layout Styles */
.main-wrapper {
    display: flex;
    min-height: 100vh;
    max-width: 100vw;
    overflow-x: hidden;
}

.sidebar {
    width: 256px;
    background: var(--primary-color);
    color: var(--white);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 1000;
    transition: var(--transition);
}

.sidebar-header {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 12px 25px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    transition: var(--transition);
}

.menu-item:hover,
.menu-item.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
}

.menu-item i {
    margin-right: 15px;
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 20px 20px 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.1);
}

.user-info {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-color);
    margin-right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
}

.user-details {
    flex: 1;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    display: block;
}

.user-role {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
}

.btn-logout {
    display: block;
    width: 100%;
    padding: 10px;
    text-align: center;
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
    border-radius: 6px;
    font-size: 14px;
    transition: var(--transition);
}

.btn-logout:hover {
    background: var(--error-color);
}

.content-area {
    flex: 1;
    margin-left: 256px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    max-width: calc(100% - 256px);
}

.top-bar {
    display: none;
    /* Hidden on PC */
    height: 60px;
    background: var(--white);
    border-bottom: 1px solid var(--border-color);
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 900;
}

.mobile-nav-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--primary-color);
}

.page-content {
    padding: 40px;
}

.page-header h1 {
    font-size: 22px;
    color: var(--primary-color);
    margin: 0 !important;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
    min-height: 60px;
    /* アイコンフォント読み込み前後でヘッダー高さが変わらないよう固定 */
}

/* PC: 固定ヘッダー */
@media (min-width: 992px) {
    .page-header {
        position: sticky !important;
        top: 0 !important;
        z-index: 1000 !important;
        background: var(--bg-color) !important;
        margin-left: -40px;
        margin-right: -40px;
        padding: 0 40px;
        /* Vertically centered by height + flex */
        height: 60px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        border-bottom: 1px solid var(--border-color);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    }
}

.btn-back {
    display: inline-flex;
    align-items: center;
    margin-top: 0;
    margin-bottom: 2px;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
}

.btn-back:hover {
    color: var(--primary-color);
}

.page-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Adjust .page-content to handle new header better */
.page-content {
    padding: 0px 40px 15px;
}

.card {
    background: var(--white);
    border-radius: 12px;
    padding: 25px;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
}

/* Alerts */
.alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 25px;
    font-size: 0.95rem;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-danger {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Tables */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    margin-bottom: 1rem;
    background-color: transparent;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 12px 15px;
    vertical-align: middle;
    border-top: 1px solid var(--border-color);
}

.table thead th {
    vertical-align: bottom;
    border-bottom: 2px solid var(--border-color);
    background-color: #f8f9fa;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    text-align: left;
}

.table-hover tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

.table-light {
    background-color: #f8f9fa;
}

.bg-light {
    background-color: #f8f9fa !important;
}

/* Form Checks */
.form-check {
    display: block;
    min-height: 1.5rem;
    padding-left: 1.5em;
    margin-bottom: 0.125rem;
}

.form-check-input {
    width: 1rem;
    height: 1rem;
    margin-top: 0.25em;
    vertical-align: top;
    background-color: #fff;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    border: 1px solid rgba(0, 0, 0, 0.25);
    appearance: none;
    print-color-adjust: exact;
}

.form-check-input:checked {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10l3 3l6-6'/%3e%3c/svg%3e");
}

/* Utilities */
.text-error {
    color: var(--error-color) !important;
}

.bg-white {
    background-color: var(--white) !important;
}

.text-center {
    text-align: center !important;
}

.text-end {
    text-align: right !important;
}

.w-100 {
    width: 100% !important;
}

.mb-0 {
    margin-bottom: 0 !important;
}

.mb-4 {
    margin-bottom: 1.5rem !important;
}

.p-0 {
    padding: 0 !important;
}

.d-flex {
    display: flex !important;
}

.justify-content-center {
    justify-content: center !important;
}

.align-items-center {
    align-items: center !important;
}

.gap-3 {
    gap: 1rem !important;
}

@media (max-width: 768px) {
    .content-area {
        margin-left: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
    }

    .sidebar {
        transform: translateX(-100%);
        width: 250px;
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .table th,
    .table td {
        padding: 8px 6px !important;
        font-size: 0.8rem;
    }
}

.toast-container {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
}

.toast {
    background: #334155;
    color: #fff;
    padding: 12px 24px;
    border-radius: 50px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s ease;
    min-width: 280px;
    border: none;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-success {
    background: var(--primary-color);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.toast-error {
    background: #dc2626;
    /* Red */
}

.toast-info {
    background: #334155;
}

.toast i {
    font-size: 1.1rem;
    color: #fff !important;
}

.toast-message {
    font-size: 0.95rem;
    font-weight: 500;
    color: #fff;
    flex: 1;
}

.toast-close {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 4px;
    margin-left: 10px;
    opacity: 0.6;
    transition: all 0.2s;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.toast-close:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.2);
}

/* Modals */
.modal,
.modal-overlay {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    overflow: hidden;
    align-items: center;
    justify-content: center;
}

.modal.show,
.modal.active,
.modal-overlay.show {
    display: flex;
}

.modal-content,
.modal-content-box {
    background-color: var(--white);
    margin: 0;
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
    border: none;
    position: relative;
    animation: modalScale 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-content {
    padding: 30px;
}

.modal-content-box {
    padding: 0;
}

@keyframes modalScale {
    from {
        transform: scale(0.95);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--primary-color);
}

.close,
.modal-close,
#closeModal {
    display: none !important;
}

.close:hover,
.modal-close:hover,
#closeModal:hover {
    display: none !important;
}

/* Modal Form Refinements */
.modal-content .form-group {
    margin-bottom: 22px;
}

.modal-content .form-group label {
    display: block;
    margin-bottom: 7px;
    font-weight: 700;
    font-size: 0.82rem;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.modal-content .form-control {
    background-color: var(--white);
    border: 1px solid #cbd5e1;
    padding: 11px 16px;
    border-radius: 9px;
    font-size: 0.95rem;
    color: var(--text-color);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.modal-content .form-control:hover {
    border-color: #94a3b8;
    background-color: #fcfcfc;
}

.modal-content .form-control:focus {
    background-color: var(--white);
    border-color: var(--accent-color);
    box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.08), 0 4px 12px rgba(0, 0, 0, 0.04);
    outline: none;
    transform: translateY(-1px);
}

.modal-content select.form-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2364748b'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd' /%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 18px;
    padding-right: 40px;
    appearance: none;
    cursor: pointer;
}

.modal-body {
    padding: 0;
    margin-bottom: 0;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 30px;
    padding-top: 20px;
}

.modal-footer .btn {
    width: auto;
    padding: 10px 25px;
    font-weight: 600;
    border-radius: 8px;
}

/* User Selection List Styles (Premium Chat Style) */
.user-select-list {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
}

.user-select-list::-webkit-scrollbar {
    width: 6px;
}

.user-select-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.user-select-item {
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    border-bottom: 1px solid #f1f5f9;
    transition: all 0.2s ease;
    cursor: pointer;
}

.user-select-item:hover {
    background-color: #f8fafc;
}

.user-select-item:last-child {
    border-bottom: none;
}

.avatar-circle {
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}

/* Custom File Input Styles */
.file-upload-wrapper {
    position: relative;
    width: 100%;
}

.file-upload-input {
    width: 100%;
    height: 120px;
    opacity: 0;
    cursor: pointer;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
}

.file-upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 120px;
    background-color: #f8fafc;
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    color: #64748b;
    transition: all 0.25s ease;
    gap: 8px;
}

.file-upload-wrapper:hover .file-upload-label {
    border-color: var(--accent-color);
    background-color: #f1f5f9;
    color: var(--accent-color);
}

.file-upload-label i {
    font-size: 2rem;
}

.file-upload-info {
    font-size: 0.85rem;
    font-weight: 500;
}

/* Refined File List Styles */
.file-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 12px;
    border-bottom: 1px solid #f1f5f9;
    transition: all 0.2s ease;
    border-radius: 8px;
    margin-bottom: 4px;
}

.file-item:hover {
    background-color: #f8fafc;
    transform: translateX(4px);
}

.file-item:last-child {
    border-bottom: none;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
}

.file-icon-wrapper {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    font-size: 1.25rem;
    background-color: #f1f5f9;
}

.file-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.file-name {
    font-weight: 600;
    color: var(--secondary-color);
    text-decoration: none;
    font-size: 0.95rem;
    transition: var(--transition);
}

.file-name:hover {
    color: var(--accent-color);
}

.file-meta {
    font-size: 0.8rem;
    color: #94a3b8;
}

.file-actions {
    display: flex;
    gap: 8px;
}

.btn-action {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: var(--white);
    color: #64748b;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn-action:hover {
    background: #f1f5f9;
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-action.btn-delete:hover {
    background: #fee2e2;
    color: var(--error-color);
    border-color: var(--error-color);
}

/* Department Header Styles */
.dept-header-card {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: var(--white);
    padding: 30px;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    margin-bottom: 25px;
    position: relative;
    overflow: hidden;
}

.dept-header-card::before {
    content: "";
    position: absolute;
    top: -50px;
    right: -50px;
    width: 200px;
    height: 200px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 50%;
}

.dept-header-content {
    display: flex;
    align-items: center;
    gap: 25px;
    position: relative;
    z-index: 1;
}

.dept-icon-box {
    width: 70px;
    height: 70px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.dept-title-group h2 {
    font-size: 2rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.02em;
}

.dept-stats {
    display: flex;
    gap: 20px;
    margin-top: 10px;
    font-size: 0.9rem;
    opacity: 0.85;
}

.dept-stats span {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Back button in header */
.btn-back-header {
    margin-bottom: 15px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-color);
    transition: var(--transition);
}

.btn-back-header:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    transform: translateY(-1px);
}

/* --- Mobile Responsiveness --- */
@media (max-width: 991px) {
    .sidebar {
        left: -256px;
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.1);
        z-index: 1001;
    }

    .sidebar.active {
        left: 0;
    }

    .content-area {
        margin-left: 0;
        width: 100%;
        max-width: 100%;
    }

    .top-bar {
        display: flex;
        width: 100%;
        height: 50px;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        background: var(--white);
        border-bottom: 1px solid var(--border-color);
    }

    .mobile-nav-toggle {
        display: block;
    }

    .page-content {
        padding-top: 70px;
        /* 50px top-bar + 20px spacing */
        padding-right: 15px;
        padding-bottom: 70px;
        padding-left: 15px;
        width: 100%;
        overflow-x: hidden;
    }

    /* スマホでは .row のネガティブマージンを無効化して左右余白を確保 */
    .page-content .row {
        margin-right: 0;
        margin-left: 0;
    }

    .page-content .row>[class*="col-"] {
        padding-right: 0;
        padding-left: 0;
    }

    .page-header {
        margin: 0 0 25px 0;
        padding: 10px 0 20px 0;
        display: block !important;
        width: 100%;
        border-bottom: 2px solid #f1f5f9;
        /* スマホでは画面を広く使うため sticky を解除 */
        position: relative;
        z-index: 10;
    }

    .page-header h1 {
        font-size: 1.25rem;
        font-weight: 800;
        color: #1e293b;
        margin: 0 0 10px 0;
    }

    .page-header-actions {
        display: flex;
        gap: 8px;
        flex-wrap: wrap;
    }

    .page-header-actions {
        align-items: center;
    }

    .page-header-actions .btn {
        width: 100%;
        text-align: center;
    }

    .card {
        padding: 15px 15px 15px 15px;
        margin-bottom: 20px;
    }

    /* Adjust grids for mobile */
    .members-grid {
        grid-template-columns: 1fr !important;
    }

    /* Notice details / headers */
    .dept-header-card {
        padding: 20px;
    }

    .dept-header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .dept-title-group h2 {
        font-size: 1.5rem;
    }

    .dept-stats {
        transition: all 0.2s ease;
        text-decoration: none;
    }

    .btn-action:hover {
        background: #f1f5f9;
        color: var(--primary-color);
        border-color: var(--primary-color);
    }

    .btn-action.btn-delete:hover {
        background: #fee2e2;
        color: var(--error-color);
        border-color: var(--error-color);
    }

    .wiki-bot-container {
        width: calc(100% - 40px);
        right: 20px;
        left: 20px;
        bottom: 130px;
        /* 固定バーとボタンの上に配置 */
    }

    .wiki-bot-toggle {
        bottom: 70px;
        /* 固定バーの上に配置 */
        right: 20px;
    }

    /* Search Bar Mobile Refresh */
    .filter-form {
        gap: 3px !important;
    }

    .filter-form.pc-one-line {
        flex-wrap: wrap !important;
    }

    .search-group {
        width: 100% !important;
        flex: none !important;
        gap: 2px !important;
        /* Reduced from 5px to ~half */
        margin-bottom: 8px !important;
        /* Consistent row spacing */
    }

    /* Reduce label-to-input spacing on mobile */
    .filter-form .form-label {
        margin-bottom: 4px !important;
        /* Reduced from 8px to half */
    }

    .search-actions {
        width: 100% !important;
        margin-top: 0px !important;
        /* Remove extra top margin */
    }

    .search-actions .btn {
        flex: 1;
        height: 36px !important;
        /* Standardized button height */
        padding: 0 15px !important;
        font-size: 13px !important;
    }

    /* Compact inputs for search */
    .filter-form .form-control,
    .filter-form .form-select {
        padding: 6px 12px !important;
        font-size: 13px !important;
        height: 32px !important;
    }

    .btn-clear {
        height: 36px !important;
        /* Match search button height */
        width: 36px !important;
    }

    /* Members page - separate search and department on mobile */
    .search-group {
        width: 100% !important;
        flex: none !important;
    }

    /* Members table - adjust column widths on mobile */
    .table th:nth-child(1),
    .table td:nth-child(1) {
        min-width: 90px !important;
    }

    /* Reports table - override first column to auto width */
    .reports-table th:nth-child(1),
    .reports-table td:nth-child(1) {
        width: auto !important;
        min-width: auto !important;
        max-width: none !important;
    }

    .table th:nth-child(2),
    .table td:nth-child(2) {
        min-width: 100px !important;
    }

    .table th:nth-child(3),
    .table td:nth-child(3) {
        min-width: 150px !important;
    }

    .table th:nth-child(4),
    .table td:nth-child(4),
    .table th:nth-child(5),
    .table td:nth-child(5) {
        min-width: 150px !important;
    }
}

/* Small Screens (Phones) */
@media (max-width: 768px) {
    body {
        font-size: 14px;
    }

    .login-header h1 {
        font-size: 22px;
    }

    .page-header {
        position: relative;
        margin-bottom: 20px;
        justify-content: flex-start !important;
        text-align: left !important;
    }

    .login-header p {
        font-size: 13px;
    }

    .form-group label {
        font-size: 13px;
    }

    .form-control {
        font-size: 14px;
    }

    .btn {
        font-size: 14px;
    }

    .alert {
        font-size: 13px;
    }

    .admin-badge {
        font-size: 12px;
    }

    .login-footer {
        font-size: 12px;
    }

    .sidebar-header h2 {
        font-size: 18px;
    }

    .menu-item {
        font-size: 14px;
        padding: 9px 25px;
    }

    .user-avatar {
        font-size: 14px;
    }

    .user-name {
        font-size: 13px;
    }

    .user-role {
        font-size: 12px;
    }

    .btn-logout {
        font-size: 13px;
    }

    .mobile-nav-toggle {
        font-size: 22px;
    }

    /* Override previous media query settings (was 20px) */
    .page-header h1 {
        font-size: 22px;
    }

    .btn-back {
        font-size: calc(0.9rem - 1px);
    }

    /* Toast */
    .toast i {
        font-size: calc(1.2rem - 1px);
    }

    .toast-message {
        font-size: calc(0.95rem - 1px);
    }

    /* Modals */
    .modal-header h3 {
        font-size: 18px;
    }

    .modal-content {
        margin: auto;
    }

    .close {
        font-size: 26px;
    }

    .modal-content .form-group label {
        font-size: calc(0.82rem - 1px);
    }

    .modal-content .form-control {
        font-size: calc(0.95rem - 1px);
    }

    /* File Upload */
    .file-upload-label i {
        font-size: calc(2rem - 1px);
    }

    .file-upload-info {
        font-size: calc(0.85rem - 1px);
    }

    .file-icon-wrapper {
        font-size: calc(1.25rem - 1px);
    }

    .file-name {
        font-size: calc(0.95rem - 1px);
    }

    .file-meta {
        font-size: calc(0.8rem - 1px);
    }

    /* Department Header */
    .dept-icon-box {
        font-size: calc(2rem - 1px);
    }

    /* Override previous media query settings (was 1.5rem) */
    .dept-title-group h2 {
        font-size: 30px;
    }

    .dept-stats {
        font-size: calc(0.9rem - 1px);
    }

    .btn-back-header {
        font-size: calc(0.9rem - 1px);
    }

    /* Mobile Header Actions - Fixed Bottom Bar */
    .page-header-left {
        text-align: left !important;
        width: 100%;
    }

    .page-header h1 {
        text-align: left !important;
        font-size: 1.25rem !important;
        margin-bottom: 0px !important;
    }

    .page-header-actions {
        display: none !important;
        /* スマホではヘッダー内のアクションを隠す（下部固定バーに移行） */
    }

    /* Adjust main content padding */
    .page-content {
        padding: 70px 15px 120px 15px !important;
        /* フッターと固定バーの分を確保 */
        /* top: 50px top-bar + 20px spacing */
    }
}

/* --- Wiki Chatbot Styles --- */
.wiki-bot-toggle {
    position: fixed;
    bottom: 140px;
    /* Above fixed footer on PC */
    right: 30px;
    width: 60px;
    height: 60px;
    background-color: var(--accent-color);
    color: var(--white);
    border-radius: 50%;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    z-index: 9999;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    opacity: 0;
    transform: scale(0);
}

@media (max-width: 768px) {
    .wiki-bot-toggle {
        bottom: 90px;
        /* Positioned above fixed page actions */
        right: 20px;
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
}

.wiki-bot-toggle.show {
    opacity: 1;
    transform: scale(1);
}

.wiki-bot-toggle:hover {
    transform: scale(1.1);
}

.wiki-bot-container {
    position: fixed;
    bottom: 210px;
    /* Above button on PC */
    right: 30px;
    width: 380px;
    height: 550px;
    max-height: calc(100vh - 120px);
    background-color: var(--white);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    z-index: 9999;
    overflow: hidden;
    transform-origin: bottom right;
    transform: scale(0);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
}

@media (max-width: 768px) {
    .wiki-bot-container {
        bottom: 150px;
        /* Positioned above toggle button */
        right: 10px;
        left: 10px;
        width: auto;
        height: 60vh;
        /* Slightly smaller height to fit */
    }
}

.wiki-bot-container.open {
    transform: scale(1);
    opacity: 1;
    pointer-events: all;
}

.wiki-bot-container.expanded {
    width: 33vw;
    min-width: 450px;
    height: 80vh;
    max-height: 800px;
}

@media (max-width: 768px) {
    .wiki-bot-container.expanded {
        width: auto;
        min-width: 0;
    }
}

/* Choice Bubble */
.bot-bubble-menu {
    position: fixed;
    bottom: 210px;
    /* Above PC toggle */
    right: 30px;
    background: white;
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    display: none;
    flex-direction: column;
    gap: 10px;
    width: 180px;
    transform: translateY(10px);
    transition: all 0.2s ease;
}

.bot-bubble-menu.show {
    display: flex;
    transform: translateY(0);
}

.bot-bubble-menu::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 20px;
    border-width: 8px 8px 0 8px;
    border-style: solid;
    border-color: white transparent transparent transparent;
}

.bot-bubble-menu .btn {
    padding: 8px;
    font-size: 14px;
    text-align: center;
}

@media (max-width: 768px) {
    .bot-bubble-menu {
        bottom: 150px;
        /* Above Mobile toggle */
        right: 20px;
        width: 160px;
    }
}

.wiki-bot-header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: var(--white);
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.wiki-bot-header h4 {
    margin: 0;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.close-bot {
    cursor: pointer;
    opacity: 0.8;
    transition: 0.2s;
    font-size: 18px;
}

.close-bot:hover {
    opacity: 1;
}

.wiki-bot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background-color: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.bot-msg,
.user-msg {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
}

.bot-msg {
    align-self: flex-start;
    background-color: var(--white);
    color: var(--text-color);
    border-bottom-left-radius: 2px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.user-msg {
    align-self: flex-end;
    background-color: var(--accent-color);
    color: var(--white);
    border-bottom-right-radius: 2px;
    box-shadow: 0 2px 5px rgba(52, 152, 219, 0.3);
}

.user-msg a {
    color: var(--white);
    text-decoration: underline;
}

.wiki-bot-links {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.wiki-bot-link {
    display: block;
    background: #f1f5f9;
    padding: 8px 12px;
    border-radius: 6px;
    color: var(--primary-color);
    text-decoration: none;
    font-size: 13px;
    transition: 0.2s;
}

.wiki-bot-link:hover {
    background: #e2e8f0;
    color: var(--accent-color);
}

.wiki-bot-input {
    padding: 15px;
    background-color: var(--white);
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
}

.wiki-bot-input input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 10px 15px;
    outline: none;
    transition: 0.2s;
}

.wiki-bot-input input:focus {
    border-color: var(--accent-color);
}

.wiki-bot-input button {
    background-color: var(--accent-color);
    color: var(--white);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wiki-bot-input button:hover {
    background-color: #2980b9;
    transform: scale(1.05);
}

/* Typing Indicator */
.typing {
    align-self: flex-start;
    background-color: var(--white);
    padding: 12px 16px;
    border-radius: 12px;
    border-bottom-left-radius: 2px;
    display: flex;
    gap: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    margin-bottom: 10px;
}

.dot {
    width: 6px;
    height: 6px;
    background-color: #aaa;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) {
    animation-delay: -0.32s;
}

.dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* Grid System (Basic) */
.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -10px;
    margin-left: -10px;
}

.row>* {
    flex-shrink: 0;
    width: 100%;
    max-width: 100%;
    padding-right: 10px;
    padding-left: 10px;
}

.col-md-2 {
    flex: 0 0 auto;
    width: 16.66666667%;
}

.col-md-3 {
    flex: 0 0 auto;
    width: 25%;
}

.col-md-4 {
    flex: 0 0 auto;
    width: 33.33333333%;
}

.col-md-6 {
    flex: 0 0 auto;
    width: 50%;
}

.col-md-8 {
    flex: 0 0 auto;
    width: 66.66666667%;
}

.col-md-12 {
    flex: 0 0 auto;
    width: 100%;
}

.g-3 {
    --gutter-x: 1rem;
    --gutter-y: 1rem;
}

.g-3>* {
    margin-top: var(--gutter-y);
}

.row.g-3 {
    margin-top: calc(-1 * var(--gutter-y));
}

/* Form Utilities */
.form-label {
    display: inline-block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-color);
}

.form-control {
    display: block;
    width: 100%;
    padding: 10px 15px;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: var(--text-color);
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid var(--border-color);
    appearance: none;
    border-radius: 8px;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus {
    color: var(--text-color);
    background-color: #fff;
    border-color: var(--primary-color);
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(37, 99, 235, 0.1);
}

.form-section-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 30px 0 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f0f0;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-group {
    margin-bottom: 1rem;
}

.shadow-sm {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075) !important;
}

.rounded-circle {
    border-radius: 50% !important;
}

.py-5 {
    padding-top: 3rem !important;
    padding-bottom: 3rem !important;
}

.mx-auto {
    margin-right: auto !important;
    margin-left: auto !important;
}

/* Notification Badge */
.notification-badge {
    background-color: #ff4757;
    color: white;
    border-radius: 99px;
    /* Pill shape by default */
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
    line-height: 1;
    margin-left: auto;
    /* Push to right if in flex container */
}

/* Ensure it looks like a circle for single digits */
/* Ensure it looks like a circle for single digits */
.notification-badge:empty {
    display: none;
}

/* Helper Flex Classes for Chat UI */
.d-flex {
    display: flex !important;
}

.flex-column {
    flex-direction: column !important;
}

.align-items-center {
    align-items: center !important;
}

.justify-content-center {
    justify-content: center !important;
}

.gap-3 {
    gap: 1rem !important;
}

.text-center {
    text-align: center !important;
}

.mb-3 {
    margin-bottom: 1rem !important;
}

.m-0 {
    margin: 0 !important;
}

@media (min-width: 768px) {
    .flex-md-row {
        flex-direction: row !important;
    }

    .mb-md-0 {
        margin-bottom: 0 !important;
    }

    .text-md-start {
        text-align: left !important;
    }

    .justify-content-md-start {
        justify-content: flex-start !important;
    }
}

.flex-md-row {
    flex-direction: row !important;
}

.mb-md-0 {
    margin-bottom: 0 !important;
}

.text-md-start {
    text-align: left !important;
}

/* PC specific styles for buttons in page header */
@media (min-width: 769px) {

    .page-header-actions .btn,
    .page-header-actions .btn-primary,
    .page-header-actions button.btn {
        width: auto !important;
        height: 50px !important;
        line-height: normal !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 0 20px !important;
        min-width: 60px !important;
        font-size: 16px !important;
        box-sizing: border-box !important;
        white-space: nowrap !important;
    }

    .page-header-actions .btn i {
        margin-right: 8px;
        font-size: 18px;
    }

    /* Ensure btn-group displays correctly and buttons inside inherit height */
    .page-header-actions .btn-group {
        display: flex !important;
    }

    /* Force btn-group children to match height */
    .page-header-actions .btn-group .btn,
    .page-header-actions .btn-group a.btn {
        width: auto !important;
        height: 50px !important;
        line-height: normal !important;
        padding: 0 20px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
}

/* Additional override for larger screens */
@media (min-width: 992px) {

    .page-header-actions .btn-group .btn,
    .page-header-actions .btn-group a.btn,
    .page-header-actions .btn-group a {
        width: auto !important;
        height: 50px !important;
        min-width: 60px !important;
        font-size: 16px !important;
        padding: 0 20px !important;
    }
}

/* Button group styles */
.btn-group {
    margin-right: 15px;
    display: inline-flex;
    gap: 0;
}

.btn-group .btn {
    border-radius: 0;
}

.btn-group .btn:first-child {
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
}

.btn-group .btn:last-child {
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
}


/* Password Toggle Styles */
.password-wrapper {
    position: relative;
    width: 100%;
}

.password-wrapper input {
    width: 100% !important;
    /* Ensure it takes full width of wrapper */
    padding-right: 40px !important;
    /* Space for the icon */
}

/* Adjust if using .form-control inside wrapper */
.password-wrapper .form-control {
    width: 100%;
}

.password-toggle-btn {
    position: absolute;
    right: 2px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: #999;
    padding: 8px;
    /* Hit area */
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none !important;
    height: 90%;
    /* Fit within input */
}

.password-toggle-btn:hover {
    color: #333;
}

.password-toggle-btn i {
    font-size: 16px;
}

/* Utilities: Padding & Margin */
.m-1 {
    margin: 0.25rem !important;
}

.m-2 {
    margin: 0.5rem !important;
}

.m-3 {
    margin: 1rem !important;
}

.m-4 {
    margin: 1.5rem !important;
}

.mt-0 {
    margin-top: 0 !important;
}

.mt-1 {
    margin-top: 0.25rem !important;
}

.mt-2 {
    margin-top: 0.5rem !important;
}

.mt-3 {
    margin-top: 1rem !important;
}

.mt-4 {
    margin-top: 1.5rem !important;
}

.mb-0 {
    margin-bottom: 0 !important;
}

.mb-1 {
    margin-bottom: 0.25rem !important;
}

.mb-2 {
    margin-bottom: 0.5rem !important;
}

.mb-4 {
    margin-bottom: 1.5rem !important;
}

.p-0 {
    padding: 0 !important;
}

.p-1 {
    padding: 0.25rem !important;
}

.p-2 {
    padding: 0.5rem !important;
}

.p-3 {
    padding: 1rem !important;
}

.p-4 {
    padding: 1.5rem !important;
}

.px-0 {
    padding-left: 0 !important;
    padding-right: 0 !important;
}

.px-1 {
    padding-left: 0.25rem !important;
    padding-right: 0.25rem !important;
}

.px-2 {
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
}

.px-3 {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
}

.px-4 {
    padding-left: 1.5rem !important;
    padding-right: 1.5rem !important;
}

.py-0 {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

.py-1 {
    padding-top: 0.25rem !important;
    padding-bottom: 0.25rem !important;
}

.py-2 {
    padding-top: 0.5rem !important;
    padding-bottom: 0.5rem !important;
}

.py-3 {
    padding-top: 1rem !important;
    padding-bottom: 1rem !important;
}

.py-4 {
    padding-top: 1.5rem !important;
    padding-bottom: 1.5rem !important;
}

.pl-5 {
    padding-left: 3rem !important;
}

.gap-4 {
    gap: 1.5rem !important;
}

.font-weight-bold {
    font-weight: 700 !important;
}

/* Task Event Styles */
.event-task {
    background-color: #d1f2eb !important;
    color: #0c5460 !important;
    border-left: 4px solid #17a2b8 !important;
    padding: 2px 4px !important;
    display: flex !important;
    align-items: center !important;
    font-size: 0.85rem;
}

.event-task .event-icon {
    margin-right: 6px;
    color: #17a2b8;
    font-size: 1em;
    font-weight: bold;
}

.event-task .event-title {
    font-weight: 500;
}

.event-task:hover {
    background-color: #b8e6dd !important;
    cursor: pointer;
}

/* =====================================================
   スマホ向けレスポンシブ調整（フォントサイズ縮小・レイアウト修正）
   ===================================================== */
@media (max-width: 480px) {

    /* 全体的な文字サイズを縮小（おおよそ2px程度） */
    html {
        font-size: 14px;
    }

    /* デフォルト16px -> 14px */
    body {
        font-size: 0.85rem;
        padding: 0;
    }

    .page-content {
        padding: 70px 10px 100px 10px !important;
        /* top: 50px top-bar + 20px spacing */
        /* 横の余白をさらに削る */
    }

    .card {
        padding: 15px 10px !important;
        /* カード内の余白も削る */
    }

    /* ヘッダー・タイトル */
    .page-header h1 {
        font-size: 1.15rem !important;
    }

    /* フォルダ行（index.php）のレスポンシブ化 */
    .folder-row-card {
        padding: 12px 14px;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .folder-row-left {
        width: 100%;
        justify-content: flex-start;
    }

    .folder-row-right {
        width: 100%;
        justify-content: space-between;
        margin-top: 4px;
        border-top: 1px dotted #e2e8f0;
        padding-top: 8px;
    }

    .folder-row-card .folder-name {
        font-size: 0.95rem;
    }

    /* ファイルアイテム（index.php）のレスポンシブ化 */
    .file-item {
        padding: 12px 14px;
        gap: 10px;
    }

    .file-name {
        font-size: 0.85rem;
    }

    .file-meta {
        font-size: 0.7rem;
    }

    .file-actions {
        /* アクションボタンが多すぎると溢れるので調整 */
        gap: 2px;
    }

    .btn-action {
        padding: 4px 6px;
    }

    /* テーブルの表示崩れを修正：標準的なレスポンシブテーブルに戻す */
    .table-responsive {
        overflow-x: auto !important;
    }

    .table thead {
        display: table-header-group;
    }

    .table tr {
        display: table-row;
    }

    .table td,
    .table th {
        display: table-cell;
    }




    /* モーダル */
    .modal-content {
        padding: 20px 18px;
        width: 98%;
    }

    .modal-header {
        padding: 10px 10px 15px;
    }

    .modal-body {
        padding: 10px;
    }

    .modal-footer {
        padding: 15px 10px;
    }

    /* カラーピッカー */
    .color-picker-group {
        gap: 8px;
    }

    .color-label {
        width: 30px;
        height: 30px;
    }

    /* フォームセクション */
    .form-section-title {
        margin-top: 1.5rem;
        font-size: 0.95rem;
        padding-bottom: 0.3rem;
    }

    /* 入力フォームのスタック対応 */
    .row.g-3>[class*="col-"],
    .col-md-3,
    .col-md-6,
    .col-md-12 {
        width: 100% !important;
        flex: 0 0 100% !important;
        max-width: 100% !important;
        margin-bottom: 15px;
        padding-left: 0;
        padding-right: 0;
    }

    .password-wrapper .password-toggle-btn {
        padding: 10px;
    }

    /* 管理権限カード（employee_edit.php） */
    .perm-cards-row {
        flex-direction: column;
        gap: 12px;
    }

    .perm-card {
        max-width: 100%;
        min-width: 0;
    }

    .perm-card-inner {
        padding: 12px 15px;
        gap: 12px;
    }

    .perm-icon-wrap {
        width: 38px;
        height: 38px;
        font-size: 1.1rem;
    }

    .perm-title {
        font-size: 0.9rem;
    }

    .perm-desc {
        white-space: normal;
        line-height: 1.3;
    }

    .perm-badge .badge-on,
    .perm-badge .badge-off {
        font-size: 0.65rem;
        padding: 3px 8px;
    }

    /* 保存・戻るボタンのスマホ最適化（下部固定） */
    .page-header-actions {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 100% !important;
        background: #fff !important;
        padding: 5px 15px !important;
        display: flex !important;
        gap: 10px !important;
        box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.08) !important;
        z-index: 1000 !important;
        border-top: 1px solid #e2e8f0 !important;
    }

    .page-header-actions .btn {
        flex: 1 !important;
        justify-content: center !important;
        height: 38px !important;
        font-size: 0.9rem !important;
        display: flex !important;
        align-items: center !important;
        border-radius: 8px !important;
        margin: 0 !important;
        font-weight: 600 !important;
    }

    .btn-back {
        margin-top: 5px;
        margin-bottom: 15px;
    }

    .file-item {
        padding: 0px !important;
    }

    .page-header-left {
        text-align: left !important;
        width: 100%;
    }

    .table-responsive .table {
        background: transparent;
    }

    .table tr {
        display: block;
        background: #fff;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        margin-bottom: 16px;
        padding: 12px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
        position: relative;
    }

    .table td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        padding: 8px 0 !important;
        border: none !important;
        font-size: 0.9rem;
        gap: 10px;
        word-break: break-all;
    }

    .table td[data-label] span,
    .table td[data-label] {
        overflow-wrap: anywhere;
    }

    .table td::before {
        content: attr(data-label);
        font-weight: 700;
        color: #94a3b8;
        font-size: 0.72rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        white-space: nowrap;
        margin-top: 3px;
        flex-shrink: 0;
    }

    .table td[data-label="氏名"] {
        font-size: 1.1rem;
        border-bottom: 1.5px solid #f1f5f9 !important;
        padding-bottom: 10px !important;
        margin-bottom: 8px;
        color: #1e293b;
    }

    .table td[data-label="氏名"]::before {
        display: none;
    }

    .table td[data-label="管理権限"] {
        background: #f8fafc;
        margin-top: 8px;
        padding: 8px !important;
        border-radius: 6px;
    }



    /* モーダル */
    .modal-content {
        padding: 20px 18px;
        width: 98%;
    }

    .modal-header {
        padding: 10px 10px 15px;
    }

    .modal-body {
        padding: 10px;
    }

    .modal-footer {
        padding: 15px 10px;
    }

    /* カラーピッカー */
    .color-picker-group {
        gap: 8px;
    }

    .color-label {
        width: 30px;
        height: 30px;
    }

    /* フォームセクション */
    .form-section-title {
        margin-top: 1.5rem;
        font-size: 0.95rem;
        padding-bottom: 0.3rem;
    }

    /* 入力フォームのスタック対応 */
    .row.g-3>[class*="col-"],
    .col-md-3,
    .col-md-6,
    .col-md-12 {
        width: 100% !important;
        flex: 0 0 100% !important;
        max-width: 100% !important;
        margin-bottom: 15px;
        padding-left: 0;
        padding-right: 0;
    }

    .password-wrapper .password-toggle-btn {
        padding: 10px;
    }

    /* 管理権限カード（employee_edit.php） */
    .perm-cards-row {
        flex-direction: column;
        gap: 12px;
    }

    .perm-card {
        max-width: 100%;
        min-width: 0;
    }

    .perm-card-inner {
        padding: 12px 15px;
        gap: 12px;
    }

    .perm-icon-wrap {
        width: 38px;
        height: 38px;
        font-size: 1.1rem;
    }

    .perm-title {
        font-size: 0.9rem;
    }

    .perm-desc {
        white-space: normal;
        line-height: 1.3;
    }

    .perm-badge .badge-on,
    .perm-badge .badge-off {
        font-size: 0.65rem;
        padding: 3px 8px;
    }

    /* 保存・戻るボタンのスマホ最適化（下部固定） */
    .page-header-actions {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 100% !important;
        background: #fff !important;
        padding: 5px 15px !important;
        display: flex !important;
        gap: 10px !important;
        box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.08) !important;
        z-index: 1000 !important;
        border-top: 1px solid #e2e8f0 !important;
    }

    .page-header-actions .btn {
        flex: 1 !important;
        justify-content: center !important;
        height: 38px !important;
        font-size: 0.9rem !important;
        display: flex !important;
        align-items: center !important;
        border-radius: 8px !important;
        margin: 0 !important;
        font-weight: 600 !important;
    }

    .btn-back {
        margin-top: 5px;
        margin-bottom: 15px;
    }

    .file-item {
        padding: 0px !important;
    }

    .page-header-left {
        text-align: left !important;
        width: 100%;
        /* margin-bottom: 5px; */
    }
}

/* PC specific styles for buttons in page header */
@media (min-width: 769px) {

    .page-header-actions .btn,
    .page-header-actions .btn-primary,
    .page-header-actions button.btn {
        width: auto !important;
        height: 40px !important;
        line-height: normal !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 0 20px !important;
        min-width: 60px !important;
        font-size: 14px !important;
        box-sizing: border-box !important;
        white-space: nowrap !important;
    }

    .page-header-actions .btn i {
        margin-right: 8px;
        font-size: 18px;
    }
}

@media (min-width: 992px) {

    .page-header-actions .btn,
    .page-header-actions .btn-primary,
    .page-header-actions button.btn,
    .page-header-actions a,
    .page-header-actions a.btn {
        width: auto !important;
        height: 40px !important;
        min-width: 60px !important;
        font-size: 14px !important;
        padding: 0 20px !important;
    }
}