html {
    font-size: 14px;
}

@media (min-width: 768px) {
    html {
        font-size: 16px;
    }
}

/* =========================
   カラーテーマ（紺ベース）
   ========================= */
:root {
    --sd-bg: #0d1324;
    --sd-bg-soft: #f3f5fb;
    --sd-surface: #ffffff;
    --sd-border-subtle: #d7deef;
    --sd-primary: #1f3b63; /* 基本の紺 */
    --sd-primary-bright: #345c8f; /* 少し明るい紺 */
    --sd-primary-strong: #122241; /* 濃い紺 */
    --sd-primary-soft: #e4ecff; /* 薄い紺（背景用） */

    --sd-text-main: #1a2240;
    --sd-text-muted: #6c7a99;
}

/* =========================
   全体レイアウト
   ========================= */
html {
    position: relative;
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--sd-bg-soft);
    color: var(--sd-text-main);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.sd-body {
    background: var(--sd-bg-soft);
}

.sd-app-shell {
    background: var(--sd-bg-soft);
}

/* =========================
   サイドバー
   ========================= */
.sd-sidebar {
    width: 240px;
    padding: 1.75rem 1.5rem;
    background: radial-gradient(circle at 0 0, #334a7a 0, #141b33 50%, #050713 100%);
    color: #fff;
    box-shadow: 4px 0 18px rgba(8, 12, 28, 0.4);
    z-index: 20;
}

@media (max-width: 767.98px) {
    .sd-sidebar {
        width: 100%;
        padding: 1rem 1.25rem;
        box-shadow: 0 4px 18px rgba(8, 12, 28, 0.4);
        display: flex;
        align-items: center;
    }
}

/* ブランドロゴ的な部分 */
.sd-brand-mark {
    width: 28px;
    height: 28px;
    border-radius: 10px;
    background: conic-gradient(from 210deg, #8fd6ff, #4f7dff, #9d89ff, #8fd6ff);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, .18);
}

.sd-brand-text {
    color: #fff;
    font-weight: 600;
    letter-spacing: 0.02em;
    font-size: 1.05rem;
}

/* ナビゲーションリンク */
.sd-nav {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
}

.sd-nav-link {
    position: relative;
    padding: 0.4rem 0.2rem 0.4rem 0.4rem;
    margin-bottom: 0.25rem;
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.95rem;
    border-radius: 999px;
    display: flex;
    align-items: center;
    transition: background-color .15s ease, color .15s ease, transform .05s ease;
}

    .sd-nav-link .sd-nav-dot {
        width: 8px;
        height: 8px;
        border-radius: 999px;
        margin-right: 0.6rem;
        background: rgba(255, 255, 255, 0.32);
    }

    .sd-nav-link:hover {
        background: rgba(255, 255, 255, 0.08);
        color: #fff;
        transform: translateX(2px);
    }

    .sd-nav-link.active {
        background: rgba(255, 255, 255, 0.15);
        color: #fff;
        font-weight: 600;
    }

        .sd-nav-link.active .sd-nav-dot {
            background: #8fd6ff;
        }

/* サイドバー下部 */
.sd-sidebar-foot {
    font-size: 0.85rem;
}

.sd-login-link,
.sd-logout-link {
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.9rem;
    text-decoration: none;
}

    .sd-login-link:hover,
    .sd-logout-link:hover {
        color: #fff;
        text-decoration: underline;
    }

/* 処理対象会社フォーム */
.using-company-wrapper {
    font-size: 0.8rem;
}

.using-company-label {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 0.25rem;
}

.using-company-badge {
    background: rgba(0, 0, 0, 0.28) !important;
}

.using-company-form {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap; /* ★幅が足りないときは折り返す */
}

.using-company-input {
    flex: 1 1 100%; /* ★狭いときは横幅100%で1行専有 */
    min-width: 0;
    max-width: 100%;
}


/* ボタン */
.using-company-button {
    flex: 0 0 auto;
    padding-left: 12px;
    padding-right: 12px;
    min-width: 55px;
    white-space: nowrap;
    margin-top: 0.25rem; /* 折り返した時に少し余白 */
}
/* =========================
   メインエリア
   ========================= */
.sd-main {
    background: var(--sd-bg-soft);
}

.sd-header {
    background: linear-gradient(to bottom, rgba(255,255,255,0.9), rgba(255,255,255,0.6));
    border-bottom: 1px solid var(--sd-border-subtle);
    backdrop-filter: blur(12px);
}

.sd-header-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--sd-primary-strong);
}

.sd-main-inner {
    max-width: 1200px;
}

/* フッター */
.sd-footer {
    border-top: 1px solid var(--sd-border-subtle);
    background: #f8f9ff;
}

/* =========================
   ボタン（色統一）
   ========================= */

.btn {
    border-radius: 999px;
    font-weight: 500;
}

/* すべて紺系に寄せる（濃さだけ違う） */
.btn-primary,
.btn-success,
.btn-warning,
.btn-danger,
.btn-info {
    background-color: var(--sd-primary);
    border-color: var(--sd-primary);
    color: #fff;
}

    .btn-primary:hover,
    .btn-success:hover,
    .btn-warning:hover,
    .btn-danger:hover,
    .btn-info:hover {
        background-color: var(--sd-primary-strong);
        border-color: var(--sd-primary-strong);
    }

/* アウトライン系も紺＋濃さ違い */
.btn-outline-primary,
.btn-outline-secondary,
.btn-outline-success,
.btn-outline-warning,
.btn-outline-danger,
.btn-outline-info {
    color: var(--sd-primary);
    border-color: var(--sd-primary-bright);
    background-color: transparent;
}

    .btn-outline-primary:hover,
    .btn-outline-secondary:hover,
    .btn-outline-success:hover,
    .btn-outline-warning:hover,
    .btn-outline-danger:hover,
    .btn-outline-info:hover {
        color: #fff;
        background-color: var(--sd-primary);
        border-color: var(--sd-primary);
    }

/* フォーカスリング（紺） */
.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-check-input:focus {
    box-shadow: 0 0 0 0.1rem #ffffff, 0 0 0 0.25rem rgba(37, 82, 155, 0.75);
}

/* =========================
   テーブル & 入力系
   ========================= */

.table-responsive {
    overflow-x: auto;
}

/* 横スクロール前提の nowrap テーブル */
.table-nowrap th,
.table-nowrap td {
    white-space: nowrap;
}

/* テーブルの見た目を少し落ち着かせる */
.table {
    background: #ffffff;
    border-radius: 12px;
    overflow: hidden;
}

    .table thead {
        background: var(--sd-primary-soft);
    }

        .table thead th {
            border-bottom: 1px solid var(--sd-border-subtle);
            font-size: 0.85rem;
            color: var(--sd-primary-strong);
        }

    .table tbody tr:hover {
        background-color: #f7f8ff;
    }

/* セル内の input 幅調整 */
td input.form-control {
    min-width: 10rem;
}

.acc-input {
    min-width: 16rem;
}

/* =========================
   その他細かい調整
   ========================= */

.text-muted {
    color: var(--sd-text-muted) !important;
}

/* ログイン画面を少し整える場合の補助クラス（任意で使用） */
.sd-auth-wrapper {
    max-width: 520px;
    margin: 4rem auto;
}

.sd-card {
    background: #ffffff;
    border-radius: 18px;
    padding: 2.25rem 2rem;
    box-shadow: 0 18px 40px rgba(17, 30, 60, 0.15);
}

/* スマホ用ヘッダー */
.sd-mobile-navbar {
    background: radial-gradient(circle at 0 0, #334a7a 0, #141b33 50%, #050713 100%);
}

/* モバイルメニューの背景をサイドバーと同じトーンに */
.sd-mobile-offcanvas {
    background: radial-gradient(circle at 0 0, #334a7a 0, #141b33 50%, #050713 100%);
    color: #fff;
}

    .sd-mobile-offcanvas .offcanvas-header {
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }

    .sd-mobile-offcanvas .sd-nav-link {
        color: rgba(255, 255, 255, 0.8);
    }

        .sd-mobile-offcanvas .sd-nav-link.active {
            color: #fff;
        }


.temp-table-wrapper {
    overflow-x: auto;
    width: 100%;
    display: block;
}

#ci-address, #ci-head-office {
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;

}

.addr-cell {
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere; /* ★追加：長い英数字やURLも折れる */
    max-width: 250px;
}

.sd-brand-logo {
    height: auto; /* 好みで調整 */
    width: 120px;
    display: block;
}

.sd-mobile-navbar .sd-brand-logo {
    width: 80px;
}

.sd-sidebar .sd-brand-logo {
    width: 120px;
}

/* =========================
   Agent 処理中インジケーター
   ========================= */
.agent-bottom {
    position: relative;
}

.agent-busy-overlay {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 10px;
    background: transparent;
    z-index: 30;
    pointer-events: none;
}

    .agent-busy-overlay.show {
        display: flex;
    }

.agent-busy-spinner {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 3px solid rgba(143, 214, 255, 0.2);
    border-top-color: #8fd6ff;
    border-right-color: rgba(143, 214, 255, 0.55);
    background: transparent;
    animation: agent-spin 0.85s linear infinite;
}

.agent-busy-text {
    color: #5faed6;
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: 0.02em;
}

.agent-root.busy .chat-input button,
.agent-root.busy .chat-input input {
    pointer-events: none;
}

@keyframes agent-spin {
    to {
        transform: rotate(360deg);
    }
}

/* =========================
   Invoice Feature
   ========================= */
.sd-card h4 {
    color: var(--sd-primary-strong);
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

textarea.form-control {
    min-height: 100px;
}

.table td,
.table th {
    vertical-align: middle;
}

.invoice-kv {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 0.75rem 1rem;
}

@media (max-width: 767.98px) {
    .invoice-kv {
        grid-template-columns: 1fr;
    }
}

.top-menu-page {
    min-height: 70vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.top-menu-grid {
    width: 100%;
    max-width: 980px;
    display: grid;
    grid-template-columns: repeat(3, minmax(220px, 1fr));
    gap: 24px;
}

.top-menu-card {
    background: #fff;
    border: 1px solid var(--sd-border-subtle);
    border-radius: 24px;
    padding: 36px 24px;
    text-decoration: none;
    color: var(--sd-text-main);
    text-align: center;
    box-shadow: 0 12px 30px rgba(17, 30, 60, 0.08);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

    .top-menu-card:hover {
        transform: translateY(-4px);
        box-shadow: 0 18px 36px rgba(17, 30, 60, 0.14);
        color: var(--sd-primary-strong);
    }

.top-menu-icon {
    font-size: 64px;
    line-height: 1;
    margin-bottom: 16px;
}

.top-menu-title {
    font-size: 1.15rem;
    font-weight: 700;
}

@media (max-width: 767.98px) {
    .top-menu-grid {
        grid-template-columns: 1fr;
        max-width: 420px;
    }

    .top-menu-card {
        padding: 28px 20px;
    }

    .top-menu-icon {
        font-size: 52px;
    }
}


.sd-sidebar,
.sd-main {
    transition: all 0.25s ease;
}

/* トグルボタン */
.sd-sidebar-toggle {
    border: 1px solid var(--sd-border-subtle);
    background: #fff;
    color: var(--sd-primary-strong);
    width: 42px;
    height: 42px;
    border-radius: 12px;
    padding: 0;
    font-size: 1.2rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

    .sd-sidebar-toggle:hover {
        background: var(--sd-primary-soft);
        color: var(--sd-primary-strong);
    }

/* PC時の通常 */
@media (min-width: 768px) {
    .sd-sidebar {
        width: 240px;
        overflow: hidden;
    }

    body.sd-sidebar-collapsed .sd-sidebar {
        display: none !important;
    }

        body.sd-sidebar-collapsed .sd-sidebar .sd-brand {
            justify-content: center;
        }

        body.sd-sidebar-collapsed .sd-sidebar .sd-brand-logo {
            width: 42px;
        }

        body.sd-sidebar-collapsed .sd-sidebar .sd-nav-link {
            justify-content: center;
            padding-left: 0;
            padding-right: 0;
        }

            body.sd-sidebar-collapsed .sd-sidebar .sd-nav-link .sd-nav-dot {
                margin-right: 0;
            }

            body.sd-sidebar-collapsed .sd-sidebar .sd-nav-link span:not(.sd-nav-dot) {
                display: none;
            }

        body.sd-sidebar-collapsed .sd-sidebar .sd-sidebar-foot {
            display: none;
        }
}