/* mado-kit My Page — shared dashboard (light SaaS) */

:root {
    /* ブランド: ロゴの濃紺ネイビー */
    --dash-primary: #002d57;
    --dash-primary-hover: #1a4f7a;
    --dash-accent-silver: #b8c0c8;
    --dash-bg: #f0f2f5;
    --dash-surface: #ffffff;
    --dash-border: #e4e7ec;
    --dash-text: #1c1e21;
    --dash-muted: #6b7280;
    --dash-sidebar: #fafbfc;
    --dash-radius: 10px;
    --dash-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    --dash-focus-ring: rgba(0, 45, 87, 0.2);
    --dash-primary-soft: rgba(0, 45, 87, 0.08);
    --dash-primary-soft-mid: rgba(0, 45, 87, 0.12);
    --dash-primary-border: rgba(0, 45, 87, 0.35);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Noto Sans JP", system-ui, -apple-system, sans-serif;
    background: var(--dash-bg);
    color: var(--dash-text);
    line-height: 1.6;
    min-height: 100vh;
}

/**
 * マイページ index のみ（body に .mypage-auth-pending を付与）:
 * auth.js の requireAuth() でトークン確認後に解除するまで UI を隠し、未ログイン時のチラ見えを防ぐ。
 * login.html ではこのクラスを付けないこと。
 */
body.mypage-auth-pending {
    display: none !important;
}

a {
    color: var(--dash-primary);
}

.dashboard {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--dash-sidebar);
    border-right: 1px solid var(--dash-border);
    padding: 28px 0 24px;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    padding: 8px 20px 28px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: transparent;
    width: 100%;
}

.sidebar-brand-link {
    display: block;
    line-height: 0;
    text-decoration: none;
    flex-shrink: 0;
    background-color: transparent;
    border: none;
    box-shadow: none;
    margin-left: auto;
    margin-right: auto;
    width: fit-content;
    max-width: 100%;
}

/* 共通: ロゴ画像（表示サイズを指定してレティナ対応の基準に） */
.logo-img {
    display: block;
    object-fit: contain;
}

/* サイドバー: 正方形ロゴ（1:1、歪み防止・中央配置） */
.logo-img--sidebar {
    width: 132px;
    height: 132px;
    aspect-ratio: 1 / 1;
    max-width: 100%;
    object-fit: contain;
    background: none;
    background-color: transparent;
    box-shadow: none;
    border: none;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.sidebar-brand-link:hover {
    background-color: transparent;
}

.sidebar-brand-link:focus-visible {
    background-color: transparent;
    outline: 2px solid var(--dash-primary-border);
    outline-offset: 3px;
    border-radius: 8px;
}

.sidebar-brand-link:hover .logo-img--sidebar,
.sidebar-brand-link:focus .logo-img--sidebar {
    background-color: transparent;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0 12px;
}

.sidebar-nav a {
    display: block;
    padding: 10px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--dash-text);
    font-weight: 500;
    font-size: 0.95rem;
}

.sidebar-nav a:hover {
    background: var(--dash-primary-soft);
}

.sidebar-nav a.is-active {
    background: var(--dash-primary-soft-mid);
    color: var(--dash-primary);
}

/* 拠点一覧（マルチテナント） */
.sidebar-facilities-wrap {
    padding: 4px 12px 12px;
    border-bottom: 1px solid var(--dash-border);
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    max-height: min(42vh, 300px);
}

.sidebar-facilities-heading {
    margin: 0 0 6px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--dash-muted);
    letter-spacing: 0.02em;
}

.facility-list {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

.facility-list li {
    margin: 0 0 2px;
}

.facility-list-link {
    display: block;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 500;
    text-decoration: none;
    color: var(--dash-text);
    overflow: hidden;
    white-space: normal;
}

.facility-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
    width: 100%;
}

.facility-item-name {
    font-weight: 700;
    line-height: 1.35;
    word-break: break-word;
}

.facility-item-location {
    font-size: 0.85em;
    color: #888;
    margin-top: 2px;
    line-height: 1.35;
    word-break: break-word;
    font-weight: 400;
}

.facility-list-link:hover {
    background: var(--dash-primary-soft);
}

.facility-list-link:hover .facility-item-location {
    color: #777;
}

.facility-list-link.active {
    background: var(--dash-primary-soft-mid);
    color: var(--dash-primary);
    font-weight: 600;
}

.facility-list-link.active .facility-item-name {
    font-weight: 700;
}

.facility-list-link.active .facility-item-location {
    color: #5c6b78;
}

.facility-add-btn {
    display: block;
    margin-top: 8px;
    padding: 8px 10px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--dash-primary);
    text-decoration: none;
    border-radius: 8px;
    border: 1px dashed var(--dash-primary-border);
    text-align: center;
    transition: background 0.15s, border-color 0.15s;
    box-sizing: border-box;
}

.facility-add-btn:hover {
    background: var(--dash-primary-soft);
    border-style: solid;
}

.facility-add-section {
    margin-top: 4px;
    padding-top: 10px;
    border-top: 1px dashed var(--dash-border);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.facility-add-heading {
    margin: 0;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--dash-muted);
    letter-spacing: 0.02em;
}

.facility-add-section .facility-add-btn {
    margin-top: 0;
}

.sidebar-meta {
    padding: 16px 20px 12px;
    border-top: 1px solid var(--dash-border);
    margin-top: 8px;
}

.sidebar-plan-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--dash-muted);
    margin-bottom: 6px;
}

.sidebar-plan-value {
    display: block;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--dash-text);
    line-height: 1.4;
    word-break: break-word;
}

.sidebar-billing {
    display: inline-block;
    margin-top: 14px;
    padding: 8px 0;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--dash-muted);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}

.sidebar-billing:hover {
    color: var(--dash-primary);
    border-bottom-color: var(--dash-primary-border);
}

.sidebar-actions {
    padding: 8px 16px 4px;
}

.btn-sidebar-logout {
    width: 100%;
    background: transparent;
    border: 1px solid var(--dash-border);
    color: var(--dash-muted);
    font-size: 0.88rem;
    font-weight: 500;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    transition: border-color 0.15s, color 0.15s;
}

.btn-sidebar-logout:hover {
    border-color: var(--dash-primary);
    color: var(--dash-primary);
}

.sidebar-foot {
    margin-top: auto;
    padding: 16px 20px;
    font-size: 0.8rem;
    color: var(--dash-muted);
}

/* Login page */
.login-body {
    min-height: 100vh;
}

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--dash-surface);
    border: 1px solid var(--dash-border);
    border-radius: var(--dash-radius);
    box-shadow: var(--dash-shadow);
    padding: 32px 28px;
}

.login-logo-wrap {
    text-align: center;
    margin: 0;
}

/* ログイン: 正方形ロゴ */
.logo-img--login {
    height: 180px;
    width: auto;
    max-width: min(100%, 180px);
    margin-bottom: 28px;
    margin-left: auto;
    margin-right: auto;
    object-fit: contain;
}

.login-title {
    margin: 0 0 8px;
    font-size: 1.35rem;
    font-weight: 700;
}

.login-lead {
    margin: 0 0 24px;
    color: var(--dash-muted);
    font-size: 0.95rem;
}

/* ログイン画面: インラインエラー / 成功メッセージ（#error-message） */
.login-inline-msg {
    display: block;
    margin: 0 0 16px;
    padding: 12px 14px;
    border-radius: 8px;
    font-size: 0.9rem;
    line-height: 1.5;
    word-break: break-word;
}

.login-inline-msg[hidden] {
    display: none !important;
}

.login-inline-msg--error {
    color: #991b1b;
    background: #fef2f2;
    border: 1px solid #fecaca;
}

.login-inline-msg--success {
    color: #047857;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
}

.login-inline-msg--info {
    color: var(--dash-primary);
    background: rgba(0, 45, 87, 0.06);
    border: 1px solid rgba(0, 45, 87, 0.15);
}

.new-password-section {
    margin-top: 8px;
}

.new-password-title {
    margin: 0 0 8px;
    font-size: 1.15rem;
    font-weight: 700;
}

.new-password-lead {
    margin: 0 0 20px;
    color: var(--dash-muted);
    font-size: 0.95rem;
}

.btn-login-submit {
    width: 100%;
    margin-top: 4px;
}

.login-forgot-wrap {
    margin: 16px 0 0;
    text-align: center;
}

.login-link-btn {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    color: var(--dash-primary);
    text-decoration: underline;
    cursor: pointer;
}

.login-link-btn:hover {
    color: var(--dash-primary-hover);
}

.login-dialog {
    max-width: calc(100vw - 32px);
    width: min(420px, 100%);
    padding: 0;
    border: none;
    border-radius: var(--dash-radius);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}

.login-dialog::backdrop {
    background: rgba(15, 23, 42, 0.45);
}

.login-dialog-card {
    position: relative;
    padding: 28px 24px 24px;
    background: var(--dash-surface);
    border-radius: var(--dash-radius);
    border: 1px solid var(--dash-border);
}

.login-dialog-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--dash-muted);
    cursor: pointer;
    border-radius: 8px;
}

.login-dialog-close:hover {
    background: var(--dash-primary-soft);
    color: var(--dash-text);
}

.login-dialog-title {
    margin: 0 32px 12px 0;
    font-size: 1.2rem;
    font-weight: 700;
}

.login-dialog-lead {
    margin: 0 0 16px;
    color: var(--dash-muted);
    font-size: 0.92rem;
    line-height: 1.5;
}

#forgot-dialog-msg {
    margin-top: 12px;
}

.main {
    flex: 1;
    min-width: 0;
    padding: 28px 32px 120px;
    position: relative;
}

.main-header {
    margin-bottom: 28px;
}

.main-header h1 {
    margin: 0 0 8px;
    font-size: 1.5rem;
    font-weight: 700;
}

.main-header p {
    margin: 0;
    color: var(--dash-muted);
    font-size: 0.95rem;
}

.password-change-form {
    margin-top: 12px;
}

.password-change-msg {
    display: block;
    margin: 0 0 12px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    line-height: 1.5;
    border: 1px solid transparent;
}

.password-change-msg[hidden] {
    display: none !important;
}

.password-change-msg--success {
    color: #047857;
    background: #ecfdf5;
    border-color: #a7f3d0;
}

.password-change-msg--error {
    color: #991b1b;
    background: #fef2f2;
    border-color: #fecaca;
}

.panel {
    background: var(--dash-surface);
    border: 1px solid var(--dash-border);
    border-radius: var(--dash-radius);
    box-shadow: var(--dash-shadow);
    margin-bottom: 20px;
    overflow: hidden;
}

.panel-head {
    padding: 16px 20px;
    border-bottom: 1px solid var(--dash-border);
    font-weight: 600;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-head::before {
    content: "";
    width: 4px;
    height: 1.1em;
    background: var(--dash-primary);
    border-radius: 2px;
}

.panel-head--toolbar {
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.panel-head--toolbar::before {
    display: none;
}

.panel-head-label {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.panel-head-label::before {
    content: "";
    width: 4px;
    height: 1.1em;
    background: var(--dash-primary);
    border-radius: 2px;
    flex-shrink: 0;
}

.panel-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.panel-subhead {
    margin: 0 0 14px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--dash-text);
}

.panel-body .panel-subhead:not(:first-child) {
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--dash-border);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.85rem;
    border-radius: 8px;
}

input[type="text"]:disabled,
input[type="url"]:disabled,
input[type="number"]:disabled,
input[type="password"]:disabled,
input[type="email"]:disabled {
    background: #f3f4f6;
    color: #6b7280;
    cursor: not-allowed;
    opacity: 0.95;
}

.panel-body {
    padding: 20px;
}

.panel--contract-readonly .panel-body {
    padding-top: 16px;
}

.contract-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px 16px;
    margin-bottom: 14px;
}

.contract-row:last-child {
    margin-bottom: 0;
}

.contract-row label,
.contract-k {
    flex: 0 0 120px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--dash-muted);
}

.contract-static {
    flex: 1 1 200px;
    font-size: 0.95rem;
    color: var(--dash-text);
    min-width: 0;
}

.form-row {
    margin-bottom: 18px;
}

.form-row:last-child {
    margin-bottom: 0;
}

label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--dash-text);
    margin-bottom: 6px;
}

.hint {
    font-size: 0.8rem;
    color: var(--dash-muted);
    margin-top: 4px;
}

input[type="text"],
input[type="url"],
input[type="number"],
input[type="password"],
input[type="email"] {
    width: 100%;
    max-width: 480px;
    padding: 10px 12px;
    border: 1px solid var(--dash-border);
    border-radius: 8px;
    font-size: 0.95rem;
    background: #fff;
}

input:focus {
    outline: none;
    border-color: var(--dash-primary);
    box-shadow: 0 0 0 3px var(--dash-focus-ring);
}

.url-copy-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: stretch;
    max-width: 640px;
}

.url-copy-row input[readonly] {
    flex: 1;
    min-width: 200px;
    background: #f9fafb;
    color: var(--dash-muted);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-decoration: none;
    font-family: inherit;
    transition: background 0.15s, color 0.15s;
}

.btn-primary {
    background: var(--dash-primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--dash-primary-hover);
}

.btn-primary:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--dash-focus-ring);
}

.btn-secondary {
    background: #fff;
    color: var(--dash-text);
    border: 1px solid var(--dash-border);
}

.btn-secondary:hover {
    background: #f9fafb;
}

.btn-stripe {
    background: #635bff;
    color: #fff;
}

.btn-stripe:hover {
    background: #5248e8;
}

.form-actions {
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--dash-border);
}

.save-bar-spacer {
    height: 48px;
}

.save-bar-fixed {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 200;
    padding: 0;
}

.save-bar-fixed .btn-save-lg {
    padding: 14px 28px;
    font-size: 1rem;
    border-radius: 10px;
    box-shadow: 0 8px 28px rgba(0, 45, 87, 0.28);
}

.save-bar-fixed .btn-save-lg:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
}

.status-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    background: var(--dash-primary-soft-mid);
    color: var(--dash-primary);
}

.status-badge.is-inactive {
    background: #fef2f2;
    color: #b91c1c;
}

.flash {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.9rem;
    display: none;
}

.flash.is-visible {
    display: block;
}

.flash-success {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
}

.flash-error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.flash-info {
    background: rgba(0, 45, 87, 0.06);
    color: var(--dash-primary);
    border: 1px solid rgba(0, 45, 87, 0.15);
}

/* 施設ID未付与など — サイドバー調の落ち着いた注意 */
.flash-note {
    background: var(--dash-sidebar);
    color: var(--dash-text);
    border: 1px solid var(--dash-border);
    border-left: 3px solid var(--dash-primary);
}

.hotel-id-bar {
    font-size: 0.85rem;
    color: var(--dash-muted);
    margin-bottom: 8px;
}

.hotel-id-bar code {
    background: #f3f4f6;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.9em;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

/* サイドバー: 利用規約リンク（マイページ専用） */
.sidebar-legal {
    padding: 12px 20px 0;
}

.sidebar-legal-link {
    font-size: 0.8rem;
    color: var(--dash-muted);
    text-decoration: none;
}

.sidebar-legal-link:hover {
    color: var(--dash-primary);
    text-decoration: underline;
}

/* SNS パネル: セクション見出し・連携バッジ・手動同期 */
.sns-section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px 16px;
    margin: 20px 0 12px;
}

.sns-section-head:first-of-type {
    margin-top: 8px;
}

.sns-section-head-left {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    min-width: 0;
}

.sns-section-title {
    margin: 0;
}

.sns-linked-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    color: #2ecc71;
    background: #e6f7ed;
    border: 1px solid #2ecc71;
    border-radius: 999px;
    padding: 2px 10px;
    line-height: 1.4;
}

.sns-section-head-actions {
    flex-shrink: 0;
}

.sns-link-btn {
    white-space: nowrap;
}

.btn.sns-link-btn.sns-link-btn--linked {
    background: #2ecc71 !important;
    color: #ffffff !important;
    border: none !important;
    cursor: default;
}

.btn.sns-link-btn.sns-link-btn--linked:hover,
.btn.sns-link-btn.sns-link-btn--linked:focus {
    background: #2ecc71 !important;
    color: #ffffff !important;
}

.sns-manual-sync-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 12px 20px;
    margin-top: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--dash-border);
}

.sns-manual-sync-label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--dash-text);
    min-width: 140px;
    padding-top: 6px;
}

.sns-manual-sync-actions {
    flex: 1;
    min-width: 200px;
}

.sns-manual-sync-btn-wrap {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.sns-sync-count-display {
    font-size: 0.8rem;
    color: var(--dash-muted);
}

.sns-sync-count-display--zero {
    color: #c0392b;
    font-weight: 600;
}

.btn-sns-sync-manual {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 18px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
    background: var(--dash-primary);
    border: 1px solid var(--dash-primary);
    border-radius: var(--dash-radius);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

.btn-sns-sync-manual:hover:not(:disabled) {
    background: var(--dash-primary-hover);
    border-color: var(--dash-primary-hover);
}

.btn-sns-sync-manual:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-sns-sync-text {
    line-height: 1.2;
}

.btn-sns-sync-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: sns-sync-spin 0.7s linear infinite;
    flex-shrink: 0;
}

.btn-sns-sync-spinner[hidden] {
    display: none !important;
}

.sns-manual-sync-hint {
    margin: 8px 0 0;
}

@keyframes sns-sync-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 900px) {
    .dashboard {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--dash-border);
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        padding: 20px 16px 16px;
    }

    .sidebar-brand {
        padding: 4px 12px 8px;
        width: 100%;
        justify-content: center;
    }

    .sidebar-nav {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .sidebar-facilities-wrap {
        width: 100%;
        max-height: min(40vh, 260px);
    }

    .sidebar-foot {
        width: 100%;
        padding: 12px 0 0;
    }

    .sidebar-legal {
        width: 100%;
        padding: 8px 0 0;
    }

    .main {
        padding: 20px 16px 100px;
    }

    .save-bar-fixed {
        right: 12px;
        bottom: 12px;
        left: 12px;
        display: flex;
        justify-content: flex-end;
    }

    .save-bar-fixed .btn-save-lg {
        width: 100%;
        max-width: 100%;
    }
}