/* ============================================================
   Implant Cloud 試作版スタイル
   既存4アプリの配色 (#0076c8 → #21b6a8) を踏襲
   ============================================================ */

:root {
    --primary: #0076c8;
    --accent: #21b6a8;
    --grad: linear-gradient(135deg, #0076c8 0%, #21b6a8 100%);
    --bg: #f4f7fa;
    --card: #ffffff;
    --text: #1f2d3d;
    --muted: #7b8a99;
    --border: #dde5ec;
    --danger: #e05252;
    --done: #e8f8f2;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: "Noto Sans JP", "Inter", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
}

.hidden { display: none !important; }

/* 言語切替ボタン */
.lang-toggle {
    background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.55); color: #fff;
    border-radius: 999px; padding: 5px 14px; font-size: 12px; font-weight: 700; cursor: pointer;
    white-space: nowrap;
}
.lang-toggle:hover { background: rgba(255,255,255,.3); }
.login-lang { position: fixed; top: 18px; right: 18px; z-index: 20; }
.muted { color: var(--muted); font-size: 13px; }
.spacer { flex: 1; }

/* ---------- ログイン画面 ---------- */
.login-screen {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--grad);
    padding: 24px;
}

.login-brand { text-align: center; color: #fff; margin-bottom: 28px; }
.login-logo {
    width: 72px; height: 72px; margin: 0 auto 12px;
    background: rgba(255,255,255,.18); border: 2px solid rgba(255,255,255,.6);
    border-radius: 20px; display: flex; align-items: center; justify-content: center;
    font-size: 28px; font-weight: 700; letter-spacing: 1px;
}
.login-brand h1 { font-size: 30px; letter-spacing: 1px; }
.login-brand p { opacity: .9; margin-top: 4px; }
.badge-proto {
    background: #ffb454; color: #5b3a00; font-size: 12px; font-weight: 700;
    padding: 2px 10px; border-radius: 999px; vertical-align: middle;
}

.login-card {
    background: var(--card); border-radius: 16px; padding: 28px;
    width: 100%; max-width: 400px;
    box-shadow: 0 16px 48px rgba(0,0,0,.25);
}
.login-card h3 { margin-bottom: 16px; }

.demo-btn {
    width: 100%; padding: 14px; font-size: 16px; font-weight: 700;
    background: var(--grad); color: #fff; border: none; border-radius: 10px;
    cursor: pointer; transition: transform .15s;
}
.demo-btn:hover { transform: translateY(-2px); }

.divider {
    display: flex; align-items: center; gap: 10px; margin: 18px 0;
    color: var(--muted); font-size: 12px;
}
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.note { font-size: 12px; color: var(--muted); margin-top: 10px; }
.register-row { text-align: center; margin-top: 14px; font-size: 13px; }
.register-row a { color: var(--primary); }

.login-error {
    margin-top: 16px; background: #fff3f3; color: var(--danger);
    padding: 10px 18px; border-radius: 8px; font-size: 14px;
}

/* ---------- フォーム共通 ---------- */
.form-group { margin-bottom: 14px; flex: 1; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 9px 11px; border: 1px solid var(--border);
    border-radius: 8px; font-size: 14px; font-family: inherit; background: #fff;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: 2px solid var(--primary); border-color: transparent;
}
.form-row { display: flex; gap: 12px; }

.primary-btn {
    background: var(--grad); color: #fff; border: none; border-radius: 8px;
    padding: 10px 22px; font-size: 14px; font-weight: 700; cursor: pointer;
}
.primary-btn.wide { width: 100%; padding: 12px; }
.ghost-btn {
    background: transparent; border: 1px solid var(--border); color: var(--text);
    border-radius: 8px; padding: 8px 14px; font-size: 13px; cursor: pointer;
}
.ghost-btn:hover { border-color: var(--primary); color: var(--primary); }
.danger-btn {
    background: #fff; color: var(--danger); border: 1px solid var(--danger);
    border-radius: 8px; padding: 9px 16px; font-size: 13px; cursor: pointer;
}

/* ---------- アプリシェル ---------- */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.demo-banner {
    background: #fff7e6; color: #8a5a00; text-align: center;
    padding: 6px; font-size: 13px; font-weight: 600;
}
.trial-banner {
    background: linear-gradient(90deg, #eaf4fb, #e8f8f2);
    color: #0a5a86; text-align: center; padding: 8px;
    font-size: 13.5px; font-weight: 600; border-bottom: 1px solid #d5e8f0;
}
.trial-banner strong { color: var(--danger); font-size: 16px; margin: 0 2px; }
.owner-view-banner {
    background: #fff3d6; color: #7a5200; padding: 7px 16px;
    font-size: 13.5px; font-weight: 600; border-bottom: 1px solid #f0dca8;
    display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap;
}
.owner-view-banner .ghost-btn { padding: 4px 12px; font-size: 12px; }
.owner-actions { display: flex; gap: 8px; align-items: center; }

/* お試し終了オーバーレイ */
.expiry-screen {
    position: fixed; inset: 0; z-index: 500;
    background: var(--grad); display: flex; align-items: center; justify-content: center; padding: 24px;
}
.expiry-card {
    background: #fff; border-radius: 20px; padding: 40px 36px; max-width: 460px; text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.expiry-icon { font-size: 60px; margin-bottom: 8px; }
.expiry-card h2 { font-size: 24px; margin-bottom: 14px; color: var(--text); }
.expiry-card p { font-size: 15px; line-height: 1.7; margin-bottom: 12px; }
.expiry-card .ghost-btn { margin-top: 14px; }

/* オーナー管理画面 */
.owner-screen { min-height: 100vh; background: var(--bg); }
.owner-main { max-width: 820px; margin: 0 auto; padding: 28px 20px; }
.owner-main h2 { margin-bottom: 8px; }
.owner-clinic-list { margin-top: 18px; display: flex; flex-direction: column; gap: 10px; }
.owner-row {
    display: flex; align-items: center; gap: 12px;
    background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 14px 18px;
}
.owner-info { flex: 1; min-width: 0; }
.owner-clinic-name { font-weight: 700; font-size: 16px; }
.owner-meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.ostatus { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.ostatus.active { background: var(--done); color: #0a7a5e; }
.ostatus.trial { background: #eaf4fb; color: #0a5a86; }
.ostatus.expired { background: #fdecec; color: var(--danger); }

.topbar {
    background: var(--grad); color: #fff;
    display: flex; align-items: center; gap: 18px; padding: 12px 20px;
}
.topbar-brand { font-weight: 700; font-size: 18px; letter-spacing: .5px; }
.topbar-clinic {
    background: rgba(255,255,255,.18); padding: 4px 14px; border-radius: 999px;
    font-size: 14px; font-weight: 600;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.user-label { font-size: 13px; opacity: .9; }
.topbar .ghost-btn { border-color: rgba(255,255,255,.5); color: #fff; }

.layout { display: flex; flex: 1; min-height: 0; }

/* ---------- ナビ ---------- */
.navbar {
    width: 200px; background: #fff; border-right: 1px solid var(--border);
    padding: 14px 10px; display: flex; flex-direction: column; gap: 4px;
}
.nav-item {
    text-align: left; background: transparent; border: none; border-radius: 8px;
    padding: 11px 12px; font-size: 14px; font-weight: 600; cursor: pointer; color: var(--text);
}
.nav-item:hover { background: var(--bg); }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item.disabled { color: #b7c2cc; cursor: default; }
.nav-item.disabled:hover { background: transparent; }
.nav-item small { font-size: 10px; font-weight: 400; }

/* ---------- 工程管理レイアウト ---------- */
.module-view { display: flex; flex: 1; min-width: 0; }

.sidebar {
    width: 250px; background: #fff; border-right: 1px solid var(--border);
    padding: 14px; display: flex; flex-direction: column; gap: 10px;
}
.search-box {
    padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
}
.patient-list-header { font-size: 12px; font-weight: 700; color: var(--muted); }
.patient-list { list-style: none; overflow-y: auto; flex: 1; }
.patient-item {
    padding: 10px 12px; border-radius: 8px; cursor: pointer;
    display: flex; flex-direction: column; gap: 2px;
}
.patient-item:hover { background: var(--bg); }
.patient-item.active { background: var(--primary); color: #fff; }
.patient-item.active .patient-item-id { color: rgba(255,255,255,.8); }
.patient-item-name { font-weight: 600; }
.patient-item-id { font-size: 12px; color: var(--muted); }

.main-content { flex: 1; padding: 22px; overflow-y: auto; min-width: 0; }

.empty-state { text-align: center; margin-top: 12vh; color: var(--muted); }
.empty-icon { font-size: 52px; margin-bottom: 12px; }

.dashboard-header { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.dashboard-header h2 { font-size: 22px; }
.badge {
    background: var(--accent); color: #fff; padding: 3px 12px;
    border-radius: 999px; font-size: 12px; font-weight: 700;
}

.tabs { display: flex; gap: 6px; border-bottom: 2px solid var(--border); margin-bottom: 16px; }
.tab-btn {
    background: transparent; border: none; padding: 10px 16px; font-size: 14px;
    font-weight: 600; cursor: pointer; color: var(--muted);
    border-bottom: 3px solid transparent; margin-bottom: -2px;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- ケース・工程 ---------- */
.case-selector { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.case-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.case-tab {
    background: #fff; border: 1px solid var(--border); border-radius: 999px;
    padding: 6px 16px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.case-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.progress-container { background: #fff; border-radius: 12px; padding: 14px 18px; margin-bottom: 16px; }
.progress-header { display: flex; justify-content: space-between; margin-bottom: 8px; }
.progress-header h3 { font-size: 14px; }
#progress-percentage { font-weight: 700; color: var(--primary); }
.progress-bar-bg { height: 10px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.progress-bar-fill { height: 100%; width: 0; background: var(--grad); transition: width .4s; border-radius: 999px; }

.steps-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.step-card {
    background: #fff; border-radius: 12px; padding: 12px;
    display: flex; gap: 10px; align-items: center; border: 1px solid var(--border);
}
.step-card.done { background: var(--done); border-color: var(--accent); }
.step-num {
    width: 30px; height: 30px; border-radius: 50%; background: var(--bg);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.step-card.done .step-num { background: var(--accent); color: #fff; }
.step-body { flex: 1; min-width: 0; }
.step-title { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.step-date { border: 1px solid var(--border); border-radius: 6px; padding: 3px 6px; font-size: 12px; }
.step-check {
    width: 34px; height: 34px; border-radius: 8px; border: 2px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; font-weight: 700; color: var(--accent); cursor: pointer; flex-shrink: 0;
    background: #fff;
}
.step-card.done .step-check { border-color: var(--accent); background: var(--accent); color: #fff; }

/* ---------- 歯式チャート ---------- */
.card { background: #fff; border-radius: 12px; padding: 18px; margin-bottom: 16px; }
.card h3 { font-size: 15px; margin-bottom: 6px; }

.tooth-chart {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px 18px;
    margin-top: 14px; max-width: 720px;
}
.quadrant { display: flex; gap: 4px; }
#quad-ur, #quad-lr { justify-content: flex-end; }
.tooth {
    width: 36px; height: 40px; border: 1px solid var(--border); border-radius: 8px;
    background: #fff; font-size: 13px; font-weight: 600; cursor: pointer;
}
.tooth:hover { border-color: var(--primary); color: var(--primary); }
.tooth.has-record { background: var(--grad); color: #fff; border: none; }

.records-grid { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.record-card {
    display: flex; gap: 12px; align-items: center; padding: 10px 14px;
    border: 1px solid var(--border); border-radius: 10px; cursor: pointer; background: #fff;
}
.record-card:hover { border-color: var(--primary); }
.record-tooth {
    width: 40px; height: 40px; border-radius: 10px; background: var(--grad); color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0;
}
.record-system { font-weight: 600; font-size: 14px; }
.record-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- チップ ---------- */
.chip-group { display: flex; flex-wrap: wrap; gap: 6px; max-height: 180px; overflow-y: auto; padding: 2px; }
.chip {
    border: 1px solid var(--border); background: #fff; border-radius: 999px;
    padding: 6px 13px; font-size: 13px; cursor: pointer;
}
.chip.fav { border-color: #f0b429; }
.chip.selected { background: var(--primary); color: #fff; border-color: var(--primary); }
.chip:hover:not(.selected) { border-color: var(--primary); }

/* ---------- マスター設定 ---------- */
.settings-content { max-width: 720px; }
.settings-content h2 { margin-bottom: 8px; }
#master-list { margin-top: 18px; }
.master-maker { background: #fff; border-radius: 12px; padding: 14px 18px; margin-bottom: 12px; }
.master-maker h4 { font-size: 14px; margin-bottom: 8px; color: var(--primary); }
.master-row {
    display: flex; align-items: center; gap: 10px; padding: 7px 0;
    border-top: 1px solid var(--bg);
}
.master-name { font-weight: 600; font-size: 14px; }
.master-sizes { margin-left: auto; font-size: 12px; color: var(--muted); }
.fav-toggle {
    background: transparent; border: none; font-size: 24px; cursor: pointer;
    color: #d3dbe2; line-height: 1; padding: 4px 8px;
}
.fav-toggle.on { color: #f0b429; }
.master-row.clickable { cursor: pointer; }
.master-row.clickable:hover .master-name { color: var(--primary); }
.expand-mark { font-size: 10px; color: var(--muted); }
.master-details { padding: 10px 0 14px 44px; border-top: 1px dashed var(--bg); }
.chip.readonly { cursor: default; background: var(--bg); border-color: transparent; }

/* ---------- 在庫管理 ---------- */
.inv-toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.inv-toolbar .search-box { flex: 1; min-width: 160px; }
.inv-toolbar .badge { background: var(--danger); }

.inv-card {
    display: flex; align-items: center; gap: 10px;
    background: #fff; border: 1px solid var(--border); border-radius: 10px;
    padding: 10px 14px;
}
.inv-card.low { border-color: var(--danger); background: #fff8f8; }
.inv-info { flex: 1; min-width: 0; }
.inv-name { font-weight: 600; font-size: 14px; }
.inv-size { color: var(--primary); font-weight: 700; margin-left: 4px; }
.inv-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.link-btn {
    background: none; border: none; color: var(--primary); cursor: pointer;
    font-size: 12px; padding: 0; text-decoration: underline;
}
.inv-stock-controls { display: flex; align-items: center; gap: 6px; }
.stock-btn {
    width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border);
    background: #fff; font-size: 18px; font-weight: 700; cursor: pointer;
}
.stock-btn:hover { border-color: var(--primary); color: var(--primary); }
.inv-stock { min-width: 36px; text-align: center; font-size: 17px; font-weight: 700; }
.danger-text { color: var(--danger); }

/* ---------- ドリル管理 ---------- */
.max-usage-banner {
    background: linear-gradient(135deg, #eaf4fb, #e8f8f2);
    border: 1px solid var(--border); border-radius: 12px;
    padding: 14px 16px; margin-bottom: 16px;
}
.max-usage-banner > label { display: block; font-weight: 700; font-size: 14px; margin-bottom: 10px; }
.max-usage-row { display: flex; align-items: center; gap: 12px; }
.max-usage-num { font-size: 30px; font-weight: 700; color: var(--primary); min-width: 52px; text-align: center; }

.drill-row {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 0; border-top: 1px solid var(--bg);
}
.drill-row.worn { background: #fff8f8; border-radius: 8px; padding: 9px 8px; }
.drill-info { flex: 1; min-width: 0; }
.drill-name { font-weight: 600; font-size: 14px; }
.drill-usage-bar { height: 7px; background: var(--bg); border-radius: 999px; overflow: hidden; margin: 5px 0 3px; max-width: 360px; }
.drill-usage-fill { height: 100%; background: var(--grad); border-radius: 999px; transition: width .3s; }
.drill-usage-fill.warn { background: #f0b429; }
.drill-usage-fill.full { background: var(--danger); }
.drill-usage-text { font-size: 12px; color: var(--muted); }
.use-btn {
    border: 1px solid var(--primary); color: var(--primary); background: #fff;
    border-radius: 10px; padding: 9px 14px; font-size: 13px; font-weight: 700; cursor: pointer;
    white-space: nowrap;
}
.use-btn:hover:not(:disabled) { background: var(--primary); color: #fff; }
.use-btn:disabled { opacity: .35; cursor: default; }
.replace-btn { padding: 9px 14px; font-size: 13px; white-space: nowrap; }

#toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px);
    background: var(--text); color: #fff; padding: 11px 20px; border-radius: 999px;
    font-size: 13px; font-weight: 600; z-index: 200; opacity: 0;
    transition: all .3s; pointer-events: none; max-width: 90vw;
}
#toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ---------- 工程テンプレート・分院設定 ---------- */
.template-row {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 0; border-top: 1px solid var(--bg);
}
.template-num {
    width: 26px; height: 26px; border-radius: 50%; background: var(--bg);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.template-input {
    flex: 1; padding: 7px 10px; border: 1px solid var(--border);
    border-radius: 8px; font-size: 14px; font-family: inherit; min-width: 0;
}
.template-input:focus { outline: 2px solid var(--primary); border-color: transparent; }
.mini-btn {
    width: 32px; height: 32px; border: 1px solid var(--border); background: #fff;
    border-radius: 8px; cursor: pointer; font-size: 14px; flex-shrink: 0;
}
.mini-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.mini-btn:disabled { opacity: .3; cursor: default; }
.mini-btn.danger:hover { border-color: var(--danger); color: var(--danger); }

.branch-filter { display: flex; flex-wrap: wrap; gap: 5px; }

/* ---------- モーダル ---------- */
.modal {
    position: fixed; inset: 0; background: rgba(15,30,45,.5);
    display: none; align-items: center; justify-content: center; z-index: 100; padding: 18px;
}
.modal.open { display: flex; }
.modal-content {
    background: #fff; border-radius: 16px; width: 100%; max-width: 460px;
    max-height: 90vh; display: flex; flex-direction: column;
}
.modal-content.large { max-width: 640px; }
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; }
.close-modal { background: none; border: none; font-size: 26px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-actions { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.modal-actions .primary-btn { margin-left: auto; }

/* ---------- インプラントカード ---------- */
.implant-card {
    background: #fff; border-radius: 16px; border: 1px solid var(--border);
    max-width: 560px; padding: 22px 26px;
    box-shadow: 0 8px 28px rgba(0, 60, 110, .12);
}
.card-head { display: flex; justify-content: space-between; align-items: flex-start; }
.card-title { font-size: 19px; font-weight: 700; color: var(--primary); }
.card-clinic { font-size: 13px; color: var(--muted); margin-top: 2px; }
.card-logo {
    width: 44px; height: 44px; border-radius: 12px; background: var(--grad); color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.card-patient { margin: 14px 0 10px; font-size: 17px; font-weight: 700; display: flex; gap: 10px; align-items: baseline; }
.card-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.card-table th {
    text-align: left; color: var(--muted); font-weight: 600; font-size: 11px;
    border-bottom: 2px solid var(--border); padding: 4px 6px;
}
.card-table td { border-bottom: 1px solid var(--bg); padding: 6px; }
.card-foot { display: flex; gap: 14px; align-items: center; margin-top: 14px; }
#card-qr img, #card-qr canvas { border: 4px solid #fff; }
.card-foot-text { font-size: 12px; flex: 1; }

/* ---------- インプラントカード(シンプル表面): 名前・ID・QRのみ ---------- */
.implant-card.simple { max-width: 620px; padding: 26px 30px; }
.implant-card.simple .card-head { flex-direction: column; align-items: flex-start; gap: 4px; }
.card-brand-row { display: flex; align-items: center; gap: 10px; }
.implant-card.simple .card-logo { width: 40px; height: 40px; border-radius: 11px; font-size: 17px; }
.card-brand { font-size: 22px; font-weight: 700; color: var(--primary); }
.implant-card.simple .card-title { font-size: 27px; margin-top: 6px; }
.card-body { display: flex; gap: 22px; align-items: stretch; margin: 18px 0 14px; }
.card-idbox { flex: 1; background: #f4f9fd; border: 1px solid #d5e4f0; border-radius: 14px; padding: 16px 20px; }
.card-idbox-label { font-size: 13px; color: var(--muted); }
.card-idbox-name { font-size: 30px; font-weight: 700; color: #1f2d3d; margin: 2px 0 10px; line-height: 1.1; }
.card-idbox-id { font-size: 15px; color: #1f2d3d; }
.card-idbox-clinic { font-size: 13px; color: var(--muted); margin-top: 12px; }
.card-qrwrap { text-align: center; align-self: center; }
.card-qrwrap #card-qr { display: inline-block; }
.card-qr-cap { font-size: 12px; color: var(--muted); margin-top: 6px; }
.card-instr { font-size: 14px; color: #1f2d3d; line-height: 1.6; border-top: 1px solid var(--border); padding-top: 12px; }
.card-details-ref { max-width: 620px; margin-top: 16px; background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 14px 20px; }
.card-details-ref h4 { margin: 0 0 8px; font-size: 13px; color: var(--muted); font-weight: 600; }

/* ---------- 見積書・同意書 ---------- */
.estimate-row {
    display: flex; align-items: center; gap: 10px;
    padding: 7px 0; border-top: 1px solid var(--bg);
}
.est-check { flex: 1; display: flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.est-price { width: 90px; text-align: right; color: var(--muted); font-size: 13px; }
.est-qty { display: flex; align-items: center; gap: 3px; font-size: 13px; color: var(--muted); }
.est-qty-input { width: 52px; padding: 4px 6px; border: 1px solid var(--border); border-radius: 6px; }
.fee-price-input { width: 110px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; font-family: inherit; font-size: 14px; text-align: right; }
.estimate-total-bar {
    margin-top: 12px; padding: 12px 16px; background: var(--bg); border-radius: 10px;
    text-align: right; font-size: 16px; font-weight: 700;
}
.estimate-total-bar span { color: var(--primary); font-size: 20px; margin-left: 8px; }
.consent-preview {
    white-space: pre-wrap; font-size: 13px; line-height: 1.7;
    background: var(--bg); border-radius: 10px; padding: 16px; max-height: 50vh; overflow-y: auto;
}

/* 工程3の書類ボタン */
.step-docs {
    grid-column: 1 / -1;
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    margin: -2px 0 6px; padding: 8px 12px;
    background: #eef6fc; border: 1px dashed var(--primary); border-radius: 10px;
}
.step-docs-label { font-size: 13px; font-weight: 600; color: var(--primary); }

/* 印刷ドキュメント (見積書・同意書の共通体裁) */
#print-area { position: fixed; left: -10000px; top: 0; width: 720px; }
.doc-sheet { font-family: "Meiryo", "Noto Sans JP", sans-serif; color: #000; padding: 24px; }
.doc-title { text-align: center; font-size: 24px; font-weight: 700; letter-spacing: 6px; margin-bottom: 20px; }
.doc-meta { display: flex; justify-content: space-between; font-size: 15px; margin-bottom: 14px; }
.doc-lead { font-size: 14px; margin-bottom: 12px; }
.doc-table { width: 100%; border-collapse: collapse; font-size: 14px; margin-bottom: 10px; }
.doc-table th, .doc-table td { border: 1px solid #888; padding: 7px 10px; }
.doc-table th { background: #eee; }
.doc-table .r { text-align: right; }
.doc-table .c { text-align: center; }
.doc-note { font-size: 12px; color: #333; margin-top: 8px; }
.doc-body { font-size: 13.5px; line-height: 1.9; }
.doc-sign { margin-top: 28px; font-size: 14px; }
.doc-sign .sign-line { margin-bottom: 14px; }
.doc-clinic { margin-top: 20px; text-align: right; font-size: 15px; font-weight: 700; }

@media print {
    /* インプラントカードの印刷 */
    body.printing-card * { visibility: hidden; }
    body.printing-card .implant-card, body.printing-card .implant-card * { visibility: visible; }
    body.printing-card .implant-card {
        position: fixed; left: 0; top: 0; box-shadow: none; border: 1px solid #999; max-width: 100%;
    }
    /* 見積書・同意書の印刷 */
    body.printing-doc * { visibility: hidden; }
    body.printing-doc #print-area, body.printing-doc #print-area * { visibility: visible; }
    body.printing-doc #print-area { left: 0; width: 100%; }
    .no-print { display: none !important; }
}

/* ---------- レスポンシブ ---------- */
@media (max-width: 900px) {
    .layout { flex-direction: column; }
    .navbar { width: 100%; flex-direction: row; overflow-x: auto; padding: 8px; }
    .nav-item { white-space: nowrap; }
    .module-view { flex-direction: column; }
    .sidebar { width: 100%; max-height: 280px; }
    .tooth { width: 32px; height: 36px; font-size: 12px; }
    .tooth-chart { gap: 6px 8px; }
}

/* ==== 患者ログイン(患者用ポータル)発行パネル ==== */
.card-portal {
    border: 1px solid #d7e6f2; background: #f2f8fd; border-radius: 14px;
    padding: 16px 18px; margin-bottom: 16px; max-width: 640px;
}
.card-portal h4 { margin: 0 0 6px; color: #0076c8; font-size: 16px; }
.card-portal .primary-btn { margin-top: 12px; }
.portal-out { margin-top: 14px; border-top: 1px dashed #c6dcef; padding-top: 14px; }
.portal-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.portal-key { min-width: 120px; font-weight: 600; color: #1f2d3d; font-size: 14px; }
.portal-row input {
    flex: 1; min-width: 200px; padding: 8px 12px; border: 1px solid #cdd9e3;
    border-radius: 8px; font-size: 13px; background: #fff;
}
.portal-pin { font-size: 22px; letter-spacing: 4px; color: #0076c8; }

/* ==== 口腔内写真・レントゲン (発行パネル内) ==== */
.media-block { margin-top: 14px; border-top: 1px dashed #c6dcef; padding-top: 14px; }
.media-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.media-add-btn { cursor: pointer; }
.media-thumbs { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.media-thumb { position: relative; width: 128px; }
.media-thumb img {
    width: 128px; height: 92px; object-fit: cover; border-radius: 8px;
    border: 1px solid #cdd9e3; background: #fff; display: block;
}
.media-badge {
    position: absolute; left: 6px; bottom: 6px; background: rgba(31,45,61,.82); color: #fff;
    font-size: 11px; padding: 2px 7px; border-radius: 6px;
}
.media-del {
    position: absolute; top: -8px; right: -8px; width: 24px; height: 24px; border-radius: 50%;
    border: none; background: #e0524e; color: #fff; font-size: 15px; line-height: 1; cursor: pointer;
}

/* ==== 骨造成・鎮静など チェックボックス群 (埋入記録) ==== */
.surgery-checks { display: flex; flex-wrap: wrap; gap: 10px 16px; margin-top: 4px; }
.surgery-checks label {
    display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
    border: 1px solid var(--border); border-radius: 10px; padding: 8px 14px; font-size: 14px;
    background: #fff; user-select: none;
}
.surgery-checks label:hover { border-color: var(--primary); background: #f2f8fd; }
.surgery-checks input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--primary); }

/* ==== お試し終了画面の カード決済(お支払い)ブロック ==== */
.subscribe-plans { margin: 18px 0 6px; text-align: left; }
.sub-heading { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 10px; text-align: center; }
.sub-btn { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 10px; text-decoration: none; }
.sub-price { font-weight: 700; opacity: .95; }
.sub-note { font-size: 12px; color: var(--muted); line-height: 1.6; margin-top: 4px; text-align: center; }

/* ==== 月額/年額 切替トグル ==== */
.bill-toggle { display: flex; gap: 6px; background: #eef3f7; border-radius: 999px; padding: 4px; margin: 0 auto 12px; max-width: 360px; }
.bill-opt { flex: 1; border: none; background: transparent; border-radius: 999px; padding: 8px 10px; font-size: 13px; font-weight: 700; color: var(--muted); cursor: pointer; }
.bill-opt.active { background: #fff; color: var(--primary); box-shadow: 0 2px 6px rgba(0,60,110,.12); }
