/* basesystem 共通（ログイン画面は login-v2.css） */
:root {
    --primary: #52C9A8;
    --primary-dark: #3AA88F;
    --primary-pale: #E0F7F0;
    --bg: #F0FBF7;
    --text: #1A3A35;
    --sub: #4A6B65;
    --border: #D6E8E2;
    --danger: #C62828;
}

[hidden] { display: none !important; }

/* ---- ログイン画面の追加分 ---- */
.brand-content h1.brand-title { display: block; }
.sub-link { text-align: center; margin: .9rem 0 0; font-size: .9rem; }
.sub-link a { color: var(--primary-dark); text-decoration: underline; }.admin-badge {
    display: inline-flex; align-items: center; gap: .4rem;
    background: #FFF3E0; color: #E65100; border: 1px solid #FFCC80;
    border-radius: 999px; padding: .25rem .8rem; font-size: .8rem; font-weight: 700; margin-bottom: .8rem;
}
.admin-badge svg { width: 16px; height: 16px; }

/* ---- 一般画面 ---- */
body.app {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Yu Gothic", sans-serif;
    background: var(--bg); color: var(--text); line-height: 1.6;
}
body.app * { box-sizing: border-box; }
.topbar {
    background: #fff; border-bottom: 1px solid var(--border);
    padding: .7rem 1rem; display: flex; align-items: center; gap: .8rem; flex-wrap: wrap;
}
.topbar .title { font-weight: 700; font-size: 1.05rem; }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--sub); font-size: .9rem; }
.wrap { max-width: 960px; margin: 0 auto; padding: 1rem; }
.wrap.narrow { max-width: 560px; }
.card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 1.1rem 1.2rem; margin-bottom: 1rem; }
.card h1, .card h2 { margin: 0 0 .6rem; font-size: 1.2rem; }
.muted { color: var(--sub); font-size: .9rem; }
.notice { background: #FFF8E1; border-left: 4px solid #f59e0b; padding: .7rem .9rem; border-radius: 8px; font-size: .9rem; color: #6b4f00; margin: .8rem 0; }
.err { color: var(--danger); font-weight: 600; margin-top: .6rem; min-height: 1.2em; }
.okmsg { color: var(--primary-dark); font-weight: 600; margin-top: .6rem; }

label.f { display: block; font-size: .88rem; color: var(--sub); margin: .8rem 0 .25rem; font-weight: 600; }
label.f .req { color: var(--danger); font-size: .78rem; margin-left: .3rem; }
input.in, select.in {
    width: 100%; padding: .65rem .7rem; border: 1px solid var(--border); border-radius: 8px;
    font-size: 1.05rem; font-family: inherit; background: #fff;
}
.ymd { display: flex; gap: .4rem; align-items: center; }
.ymd select { flex: 1; min-width: 0; }
.ymd span { font-size: .9rem; color: var(--sub); }

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: .7rem 1.2rem; border-radius: 8px; border: 1px solid var(--border);
    background: #fff; color: var(--text); font-size: 1rem; font-family: inherit;
    cursor: pointer; min-height: 44px; text-decoration: none;
}
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }

.menu { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .8rem; }
.menu a {
    display: block; background: #fff; border: 1px solid var(--border); border-radius: 12px;
    padding: 1rem; color: var(--text); text-decoration: none;
}
.menu a:hover { border-color: var(--primary); }
.menu a b { display: block; margin-bottom: .2rem; }
.menu a.soon { opacity: .55; pointer-events: none; }

/* ---- 管理画面の一覧 ---- */
.topbar a.home { color: var(--text); text-decoration: none; font-weight: 700; }
.page-head { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin: .4rem 0 1rem; }
.page-head h1 { margin: 0; font-size: 1.3rem; }
.page-head .spacer { flex: 1; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.stat {
    background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: .7rem .9rem;
    cursor: pointer; text-align: left; font-family: inherit; color: var(--text);
}
.stat.active { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-pale); }
.stat b { display: block; font-size: 1.4rem; }
.stat span { font-size: .85rem; color: var(--sub); }
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .8rem; }
.toolbar input.in { max-width: 320px; }
.table-wrap { background: #fff; border: 1px solid var(--border); border-radius: 12px; overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.list th, table.list td { padding: .6rem .7rem; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
table.list th { background: var(--primary-pale); font-weight: 700; color: var(--sub); }
table.list tr:last-child td { border-bottom: none; }
table.list td.empty { text-align: center; color: var(--sub); padding: 2rem; }
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.badge.ok { background: #E0F7F0; color: #1B7A5E; }
.badge.off { background: #F1F1F1; color: #777; }
.badge.admin { background: #FFF3E0; color: #E65100; }
.badge.line { background: #06C755; color: #fff; }
.badge.warn { background: #FFF8E1; color: #8a6100; }
.row-actions { display: flex; gap: .3rem; }
.btn.small { min-height: 32px; padding: .25rem .7rem; font-size: .85rem; }
.btn.danger { color: var(--danger); border-color: #f2c4c4; }
.pager { display: flex; gap: .4rem; justify-content: center; align-items: center; margin: 1rem 0; flex-wrap: wrap; }
.pager .muted { margin: 0 .4rem; }

dialog.form-dialog { border: none; border-radius: 14px; padding: 0; width: min(520px, calc(100vw - 32px)); }
dialog.form-dialog::backdrop { background: rgba(26, 58, 53, .45); }
dialog.form-dialog form { padding: 1.2rem 1.3rem; }
dialog.form-dialog h2 { margin: 0 0 .4rem; font-size: 1.15rem; }
dialog.form-dialog .actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1.1rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .8rem; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }

.toast {
    position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
    background: var(--text); color: #fff; padding: .7rem 1.1rem; border-radius: 10px; z-index: 1000;
    box-shadow: 0 6px 20px rgba(0,0,0,.2); font-size: .95rem;
}

/* ---- アンケート（回答フォーム） ---- */
.wrap.narrow-wide { max-width: 820px; }
textarea.in { width: 100%; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 8px; font: inherit; resize: vertical; }
.sv-desc { white-space: pre-line; margin: .3rem 0 .6rem; }
.sv-section { background: var(--primary-pale); border-left: 5px solid var(--primary); border-radius: 10px; padding: .8rem 1rem; margin: 1.4rem 0 .8rem; }
.sv-section-no { font-size: .8rem; font-weight: 700; color: var(--primary-dark); }
.sv-section-title { font-size: 1.1rem; font-weight: 700; }
.sv-section-desc { white-space: pre-line; font-size: .92rem; margin-top: .3rem; }
.sv-heading { font-weight: 700; margin: 1.2rem 0 .5rem; padding-bottom: .3rem; border-bottom: 2px solid var(--border); }
.sv-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 1rem 1.1rem; margin-bottom: .8rem; }
.sv-card.invalid { border-color: var(--danger); box-shadow: 0 0 0 2px #fde2e2; }
.sv-num { display: inline-block; background: var(--primary); color: #fff; font-weight: 700; font-size: .8rem; padding: .05rem .55rem; border-radius: 6px; margin-bottom: .4rem; }
.sv-label { font-weight: 600; margin-bottom: .6rem; line-height: 1.6; }
.sv-req { display: inline-block; background: var(--danger); color: #fff; font-size: .72rem; padding: 0 .4rem; border-radius: 4px; margin-left: .4rem; vertical-align: middle; font-weight: 700; }
.sv-err { color: var(--danger); font-size: .88rem; font-weight: 600; margin-top: .3rem; }
.sv-choices { display: grid; gap: .35rem; }
.sv-choice { display: flex; align-items: center; gap: .5rem; padding: .45rem .6rem; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.sv-choice:has(input:checked) { border-color: var(--primary); background: var(--primary-pale); }
.sv-choice input { width: 18px; height: 18px; flex: none; }
.sv-table-wrap { overflow-x: auto; }
table.sv-table { border-collapse: collapse; width: 100%; font-size: .9rem; }
table.sv-table th, table.sv-table td { border: 1px solid var(--border); padding: .4rem .5rem; text-align: center; }
table.sv-table thead th { background: var(--primary-pale); }
table.sv-table tbody th { text-align: left; font-weight: 600; min-width: 8em; }
table.sv-table input[type=radio] { width: 20px; height: 20px; }
table.sv-table input.in { min-width: 6em; }
.sv-actions { display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; margin: 1rem 0 2rem; }
a.sv-list-item { display: block; color: inherit; text-decoration: none; }
a.sv-list-item:hover { border-color: var(--primary); }
.sv-list-title { font-weight: 700; font-size: 1.05rem; }

/* ---- 管理画面（タブ・集計・編集） ---- */
.tabs { display: flex; gap: .3rem; border-bottom: 2px solid var(--border); margin: .5rem 0 1rem; overflow-x: auto; }
.tab { background: none; border: none; padding: .6rem 1rem; font: inherit; font-weight: 700; color: var(--sub); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.tab.active { color: var(--primary-dark); border-bottom-color: var(--primary); }
table.list td.wrap-cell { white-space: normal; min-width: 14em; }
table.list a { color: var(--primary-dark); font-weight: 600; }
.st-section { font-size: 1.1rem; margin: 1.4rem 0 .6rem; }
.st-bars { display: grid; gap: .35rem; margin: .5rem 0; }
.st-bar-row { display: grid; grid-template-columns: minmax(8em, 1.2fr) 2fr auto; gap: .6rem; align-items: center; font-size: .92rem; }
.st-bar { background: #eef5f3; border-radius: 6px; height: 16px; overflow: hidden; }
.st-bar span { display: block; height: 100%; background: var(--primary); }
.st-bar-num { white-space: nowrap; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) { .st-bar-row { grid-template-columns: 1fr auto; } .st-bar { grid-column: 1 / -1; grid-row: 2; } }
.st-texts { margin: .4rem 0; padding-left: 1.6rem; }
.st-texts li { white-space: pre-wrap; padding: .15rem 0; border-bottom: 1px dashed var(--border); }
input.url-in { min-width: 22em; font-size: .8rem; }
dialog.form-dialog.wide { width: min(860px, calc(100vw - 32px)); }
label.check { display: inline-flex; align-items: center; gap: .35rem; margin-top: .8rem; font-size: .92rem; cursor: pointer; }
.ed-head { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.ed-head .spacer { flex: 1; }
.ed-head label.check { margin-top: 0; }
select.ed-type, select.ed-secsel { width: auto; min-height: 34px; padding: .2rem .5rem; }
.ed-section { border-left: 5px solid var(--primary); }
.ed-item { margin-left: 1rem; }
@media (max-width: 560px) { .ed-item { margin-left: 0; } }
.save-bar { position: sticky; bottom: 0; display: flex; align-items: center; gap: .5rem; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: .7rem 1rem; margin: 1rem 0; box-shadow: 0 -4px 14px rgba(0,0,0,.06); }
.save-bar .spacer { flex: 1; }
.save-bar .err { margin: 0; }

/* ---- 問診票 ---- */
.wrap.wide { max-width: 1200px; }
.q-desc { white-space: pre-line; margin: -.3rem 0 .5rem; }
.q-postal { display: grid; grid-template-columns: 9em 1fr; gap: .4rem; }
@media (max-width: 520px) { .q-postal { grid-template-columns: 1fr; } }
.resume-code { font-size: 1.6rem; font-weight: 700; letter-spacing: .12em; text-align: center; background: var(--primary-pale); border-radius: 10px; padding: .6rem; font-family: ui-monospace, monospace; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 .8rem; }
@media (max-width: 700px) { .grid3 { grid-template-columns: 1fr; } }
.row-actions.wrap { flex-wrap: wrap; }
.btn.primary-outline { border-color: var(--primary); color: var(--primary-dark); font-weight: 700; }
.ed-adv { margin-top: .8rem; border-top: 1px dashed var(--border); padding-top: .5rem; }
.ed-adv summary { cursor: pointer; color: var(--sub); font-weight: 600; font-size: .9rem; }
.ed-rule { margin: .5rem 0; padding: .5rem .7rem; background: #fafdfc; border: 1px solid var(--border); border-radius: 8px; }
.ed-rule-body { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-top: .4rem; }
.ed-rule-vals { display: flex; flex-wrap: wrap; gap: 0 .8rem; }
.ed-rule-vals label.check { margin-top: 0; }
select.ed-rule-q { width: auto; max-width: 100%; min-height: 34px; padding: .2rem .5rem; }
table.info-table { border-collapse: collapse; width: 100%; font-size: .93rem; }
table.info-table th, table.info-table td { text-align: left; vertical-align: top; padding: .45rem .6rem; border-bottom: 1px solid var(--border); }
table.info-table th { width: 32%; color: var(--sub); font-weight: 600; }
.ans-section h2 { font-size: 1.05rem; }
.ans-list { margin: 0; padding-left: 1.2rem; }
.pre { white-space: pre-wrap; }
.print-only { display: none; }
@media print {
    .no-print, .toast { display: none !important; }
    .print-only { display: block; }
    body.app { background: #fff; }
    .card { border: none; padding: 0; margin-bottom: .6rem; break-inside: avoid-page; }
    .wrap { max-width: none; padding: 0; }
    table.info-table th, table.info-table td { padding: .25rem .4rem; }
}

/* ---- 予約 ---- */
.cal { max-width: 420px; margin: .8rem 0; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .4rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: .25rem; }
.cal-wd { text-align: center; font-size: .8rem; color: var(--sub); }
.cal-cell { aspect-ratio: 1; border: 1px solid var(--border); border-radius: 8px; background: #fafafa; color: #bbb; font: inherit; }
.cal-cell.empty { border: none; background: none; }
.cal-cell.ok { background: #fff; color: var(--text); border-color: var(--primary); font-weight: 700; cursor: pointer; }
.cal-cell.sel { background: var(--primary); color: #fff; }
.slot-times h3 { font-size: 1rem; margin: .6rem 0; }
.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .4rem; }
.slot { display: flex; flex-direction: column; align-items: center; padding: .5rem; border: 1px solid var(--primary); border-radius: 8px; background: #fff; font: inherit; cursor: pointer; }
.slot span { font-size: .8rem; color: var(--sub); }
.slot.off { border-color: var(--border); color: #aaa; cursor: default; background: #fafafa; }
.confirm-box { background: var(--primary-pale); border-radius: 10px; padding: .8rem 1rem; margin: .8rem 0; }
.confirm-box h3 { margin: 0 0 .4rem; font-size: 1.05rem; }
.today-item { border-top: 1px dashed var(--border); padding: .6rem 0; }
.today-item:first-of-type { border-top: none; }
.today-time { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; font-size: 1.05rem; }
details.msg { border-bottom: 1px solid var(--border); padding: .4rem 0; }
details.msg summary { cursor: pointer; }
details.msg.unread summary { font-weight: 700; }
details.msg.unread summary::after { content: '●'; color: var(--danger); margin-left: .4rem; font-size: .7rem; }
.card-no { font-family: ui-monospace, monospace; font-size: 1.2rem; letter-spacing: .1em; margin: .3rem 0 0; }
#cardImg { max-width: 100%; background: #fff; }
.temp-box { display: grid; gap: .5rem; margin: 1rem 0; }
.temp-box > div { display: flex; justify-content: space-between; align-items: center; background: var(--primary-pale); border-radius: 10px; padding: .6rem 1rem; }
.temp-box b { font-family: ui-monospace, monospace; font-size: 1.6rem; letter-spacing: .1em; }
.temp-id { font-family: ui-monospace, monospace; font-size: 1.2rem; letter-spacing: .08em; }
code.secret { font-family: ui-monospace, monospace; background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: .1rem .4rem; word-break: break-all; user-select: all; }
span.f { display: block; font-size: .88rem; color: var(--sub); margin: .8rem 0 .25rem; font-weight: 600; }
span.f .req { color: var(--danger); font-size: .78rem; margin-left: .3rem; }

/* ==== klc のデザイン（admin/styles.css・includes/header.php・dashboard.php を移したもの） ==== */
:root {
    --primary-light: #7DD9BA;
    --surface: #FFFFFF;
    --text-primary: #1A3A35;
    --text-secondary: #4A6B65;
    --shadow-sm: 0 2px 4px rgba(26, 58, 53, 0.06);
    --shadow: 0 4px 12px rgba(26, 58, 53, 0.08);
    --shadow-lg: 0 8px 24px rgba(26, 58, 53, 0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
body.app {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', Meiryo, sans-serif;
    font-size: 15px; min-height: 100vh; display: flex; flex-direction: column;
}
body.app > .wrap { flex: 1; width: 100%; padding: 1.5rem 1rem 2rem; }
/* ヘッダーに置き換わるまでの仮の帯（ちらつきを抑える） */
.topbar { visibility: hidden; min-height: 70px; }

/* ヘッダー */
.app-header { background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 2rem; position: sticky; top: 0; z-index: 100; box-shadow: var(--shadow-sm); }
.app-header .header-content { max-width: 1400px; margin: 0 auto; display: flex; align-items: center; gap: 1rem; height: 70px; }
.app-header .logo { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--primary-dark); margin-right: auto; min-width: 0; }
.app-header .logo-mark { width: 40px; height: 40px; flex: none; display: grid; place-items: center; background: var(--primary-pale); border-radius: 12px; color: var(--primary-dark); }
.app-header .logo-mark svg { width: 26px; height: 26px; }
.app-header .logo-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.app-header .logo-text small { align-self: flex-start; background: var(--primary); color: #fff; font-size: .68rem; font-weight: 700; padding: .05rem .5rem; border-radius: 4px; letter-spacing: .08em; }
.app-header .logo-text b { font-size: 1.25rem; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-header .header-actions { display: flex; align-items: center; gap: 1rem; }
.app-header .who { display: inline-flex; align-items: center; gap: .3rem; color: var(--text-secondary); font-size: .94rem; }
.app-header .who .ic svg, .btn .ic svg { width: 18px; height: 18px; display: block; }
.btn.btn-text { border-color: transparent; background: transparent; color: var(--text-secondary); gap: .35rem; min-height: 38px; padding: .45rem .9rem; }
.btn.btn-text:hover { background: var(--primary-pale); color: var(--primary-dark); }
.header-nav { max-width: 1400px; margin: 0 auto; padding: .6rem 0 .75rem; border-top: 1px solid var(--border); }
.nav-row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.nav-pill { padding: .5rem .9rem; border-radius: var(--radius-sm); color: var(--text-secondary); text-decoration: none; font-size: .94rem; transition: var(--transition); }
.nav-pill:hover { background: var(--primary-pale); color: var(--primary-dark); }
.nav-pill.active { background: var(--primary); color: #fff; }

/* 患者のメニュー（アイコン） */
.user-nav-menu { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.user-nav-icon { display: flex; flex-direction: column; align-items: center; gap: .25rem; padding: .5rem; text-decoration: none; color: var(--text-secondary); border-radius: var(--radius-md); transition: all .2s ease; min-width: 64px; }
.user-nav-icon:hover { background: var(--primary-pale); color: var(--primary-dark); transform: translateY(-2px); }
.user-nav-icon.active { background: var(--primary); color: #fff; }
.user-nav-icon-symbol { font-size: 1.5rem; line-height: 1.2; }
.user-nav-icon-label { font-size: .75rem; white-space: nowrap; }

/* 管理者メニュー（ドロップダウン） */
.admin-menu-wrapper { position: relative; margin-left: auto; }
.admin-menu-trigger { display: flex; align-items: center; gap: .5rem; padding: .62rem 1.25rem; background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%); color: #fff; border: none; border-radius: var(--radius-md); cursor: pointer; font: inherit; font-weight: 500; box-shadow: 0 2px 8px rgba(82, 201, 168, .2); transition: all .2s ease; }
.admin-menu-trigger:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(82, 201, 168, .3); }
.admin-menu-trigger .ic svg { width: 18px; height: 18px; display: block; }
.admin-menu-trigger .caret { transition: transform .2s ease; }
.admin-menu-wrapper.open .caret { transform: rotate(180deg); }
.admin-dropdown { display: none; position: absolute; top: calc(100% + .5rem); right: 0; background: var(--surface); min-width: 280px; max-height: calc(100vh - 150px); overflow-y: auto; box-shadow: 0 8px 24px rgba(0,0,0,.12); border-radius: var(--radius-md); border: 1px solid var(--border); padding: .5rem; z-index: 200; }
.admin-menu-wrapper.open .admin-dropdown { display: block; }
.admin-dropdown-item { display: flex; align-items: center; gap: .75rem; padding: .7rem 1rem; color: var(--text-primary); text-decoration: none; border-radius: var(--radius-sm); transition: var(--transition); font-size: .94rem; }
.admin-dropdown-item:hover { background: var(--primary-pale); color: var(--primary-dark); }
.admin-dropdown-item.active { background: var(--primary-pale); color: var(--primary-dark); font-weight: 700; }
.admin-dropdown-item-icon { font-size: 1.15rem; width: 1.5rem; text-align: center; }
.admin-dropdown-subitem { display: block; padding: .4rem 1rem .4rem 3.25rem; color: var(--text-secondary); text-decoration: none; font-size: .87rem; border-radius: var(--radius-sm); }
.admin-dropdown-subitem:hover, .admin-dropdown-subitem.active { color: var(--primary-dark); background: #f6fcfa; }

/* スマートフォン（klc と同じく 968px 以下はメニューボタンで開く） */
.mobile-menu-toggle { display: none; background: none; border: none; color: var(--text-primary); cursor: pointer; padding: .4rem; width: 44px; height: 44px; }
.mobile-menu-toggle svg { width: 26px; height: 26px; }
@media (max-width: 968px) {
    .app-header { padding: 0 1rem; }
    .mobile-menu-toggle { display: block; order: 3; }
    .app-header .header-actions .who { display: none; }
    .app-header .logo-text b { font-size: 1.05rem; }
    .header-nav { display: none; border-top: 1px solid var(--border); padding: .5rem 0 1rem; }
    .header-nav.mobile-open { display: block; }
    .nav-row, .user-nav-menu { flex-direction: column; align-items: stretch; gap: .25rem; }
    .user-nav-icon { flex-direction: row; justify-content: flex-start; padding: .9rem 1rem; gap: 1rem; }
    .user-nav-icon-label { font-size: 1rem; }
    .admin-menu-wrapper { margin-left: 0; }
    .admin-menu-trigger { width: 100%; justify-content: center; }
    .admin-dropdown { position: static; box-shadow: none; margin-top: .5rem; min-width: 0; max-height: none; }
}
@media (max-width: 480px) { .app-header .header-actions .btn-text { padding: .45rem .5rem; font-size: .9rem; } }

/* フッター */
.app-footer { text-align: center; color: var(--text-secondary); font-size: .8rem; padding: 1.5rem 1rem; border-top: 1px solid var(--border); background: var(--surface); }

/* ボタン・カード（klc の btn-primary・カードの影） */
.btn { border-radius: var(--radius-sm); transition: var(--transition); }
.btn:hover:not(:disabled) { border-color: var(--primary-light); }
.btn.primary { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%); border: none; box-shadow: 0 2px 8px rgba(82, 201, 168, .25); }
.btn.primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(82, 201, 168, .35); }
.card { border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.page-head h1 { color: var(--text-primary); font-size: 1.5rem; }
.wrap > p > a, .card a:not(.btn):not(.sv-list-item) { color: var(--primary-dark); }

/* ホーム（klc の dashboard） */
.dashboard-welcome { background: linear-gradient(135deg, var(--primary-pale) 0%, var(--surface) 100%); border-radius: var(--radius-lg); padding: 2.2rem 2.5rem; margin-bottom: 1.6rem; border: 1px solid var(--border); position: relative; overflow: hidden; }
.dashboard-welcome::before { content: ""; position: absolute; top: -50%; right: -10%; width: 300px; height: 300px; background: radial-gradient(circle, rgba(82, 201, 168, .12) 0%, transparent 70%); border-radius: 50%; }
.dashboard-welcome h1 { color: var(--primary-dark); font-size: 1.7rem; margin: 0 0 .4rem; position: relative; }
.dashboard-welcome p { color: var(--text-secondary); margin: 0; position: relative; }
.rsv-top-card { display: flex; align-items: center; gap: 1rem; background: linear-gradient(135deg, var(--primary) 0%, #20C997 100%); color: #fff; border-radius: var(--radius-lg); padding: 1.1rem 1.4rem; margin: 0 0 1.25rem; text-decoration: none; box-shadow: 0 4px 14px rgba(82, 201, 168, .25); transition: var(--transition); }
.rsv-top-card:hover { filter: brightness(1.05); transform: translateY(-2px); }
.rsv-top-card .ic { font-size: 2rem; line-height: 1; }
.rsv-top-card .tt { display: block; font-size: 1.2rem; font-weight: 700; }
.rsv-top-card .ds { font-size: .88rem; opacity: .95; margin-top: .15rem; }
.rsv-top-card .ar { margin-left: auto; font-size: 1.4rem; opacity: .9; }
.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.25rem; margin-bottom: 2rem; }
.menu-card { background: var(--surface); border-radius: var(--radius-lg); border: 1px solid var(--border); text-decoration: none; color: inherit; display: flex; flex-direction: column; padding: 1.5rem; position: relative; overflow: hidden; transition: var(--transition); }
.menu-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%); transform: scaleX(0); transition: transform .3s ease; }
.menu-card:hover { transform: translateY(-4px); box-shadow: 0 12px 24px rgba(82, 201, 168, .15); border-color: var(--primary-light); }
.menu-card:hover::before { transform: scaleX(1); }
.menu-card-icon { display: flex; align-items: center; justify-content: center; width: 60px; height: 60px; background: linear-gradient(135deg, var(--primary-pale) 0%, var(--primary-light) 100%); border-radius: var(--radius-md); font-size: 1.9rem; margin-bottom: 1rem; transition: all .3s ease; }
.menu-card:hover .menu-card-icon { transform: scale(1.08) rotate(5deg); }
.menu-card-title { font-size: 1.12rem; font-weight: 700; color: var(--text-primary); margin-bottom: .35rem; }
.menu-card-desc { font-size: .9rem; color: var(--text-secondary); line-height: 1.6; flex: 1; }
.menu-card-footer { margin-top: 1rem; color: var(--primary-dark); font-weight: 600; font-size: .9rem; }
.menu-card .badge { position: absolute; top: 1rem; right: 1rem; }
.dashboard-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 1rem; margin-bottom: 1.6rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.25rem; display: flex; align-items: center; gap: 1rem; text-decoration: none; color: inherit; transition: var(--transition); }
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.stat-icon { width: 48px; height: 48px; display: grid; place-items: center; background: var(--primary-pale); border-radius: var(--radius-md); font-size: 1.5rem; flex: none; }
.stat-content h3 { margin: 0; font-size: .82rem; color: var(--text-secondary); font-weight: 600; }
.stat-content p { margin: 0; font-size: 1.6rem; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.stat-card.alert .stat-content p { color: var(--danger); }
.info-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.5rem 1.75rem; }
.info-section h2 { display: flex; align-items: center; gap: .5rem; font-size: 1.1rem; margin: 0 0 .75rem; color: var(--text-primary); }
.info-section ul { margin: 0; padding-left: 1.3rem; color: var(--text-secondary); line-height: 1.9; }
.section-title { font-size: 1.05rem; color: var(--text-secondary); margin: 1.6rem 0 .8rem; }
@media (max-width: 600px) { .dashboard-welcome { padding: 1.5rem 1.25rem; } .dashboard-welcome h1 { font-size: 1.35rem; } }

/* LINE 連携 */
.line-card { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.line-card-body { display: flex; align-items: center; gap: .9rem; }
.line-card-icon { width: 48px; height: 48px; border-radius: 12px; background: #06C755; color: #fff; font-weight: 800; font-size: .8rem; display: grid; place-items: center; flex: none; }
.btn.line-btn { background: #06C755; border-color: #06C755; color: #fff; font-weight: 700; }
.btn.line-btn:hover { background: #05B04D; }

/* 設定: ロゴのプレビュー */
.logo-preview { display: flex; align-items: center; justify-content: center; min-height: 110px; border: 1px dashed var(--border); border-radius: var(--radius); background: #fafdfc; margin: .6rem 0; padding: .8rem; }
.logo-preview img { max-width: 100%; max-height: 110px; object-fit: contain; }

/* ==== 画面の幅を広く使う（管理画面はヘッダーと同じ 1400px まで） ==== */
body.app > .wrap { max-width: 1400px; padding: 1.5rem 2rem 2.5rem; }
body.app > .wrap.wide { max-width: 1400px; }
body.app > .wrap.mid { max-width: 1100px; }
body.app > .wrap.narrow-wide { max-width: 820px; padding: 1.5rem 1rem 2rem; }   /* 患者向けの入力・一覧は読みやすい幅のまま */
body.app > .wrap.narrow { max-width: 560px; padding: 1.5rem 1rem 2rem; }
@media (max-width: 968px) { body.app > .wrap { padding: 1.25rem 1rem 2rem; } }

/* タブ: 下線のはみ出しで縦のスクロールバーが出ないように */
.tabs { overflow-y: hidden; scrollbar-width: thin; padding-top: 2px; }

/* 絞り込み・検索の欄は横に伸ばす */
.toolbar { align-items: center; }
.toolbar input.in[type=search] { flex: 1 1 280px; max-width: 520px; }
.toolbar select.in { width: auto; min-width: 9em; }

/* 一覧の表: 操作ボタンは折り返さず1行に */
table.list .row-actions:not(.wrap) { flex-wrap: nowrap; }
table.list td.wrap-cell { min-width: 16em; }

/* 設定: 広い画面では項目を2列に並べる */
@media (min-width: 1100px) {
    #genFields .card { display: grid; grid-template-columns: 1fr 1fr; gap: 0 2rem; align-items: start; }
    #genFields .card > h2 { grid-column: 1 / -1; }
}

/* 編集画面: 質問の欄は広く、表の行・列は横に3つまで */
@media (min-width: 1100px) {
    .ed-item .grid2 { grid-template-columns: 1fr 1fr; }
    .grid3 { grid-template-columns: repeat(3, 1fr); }
}

/* 患者さんの Web アプリ: 通知・ホーム画面への追加 */
.push-card, .pwa-card { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.push-card-body { display: flex; align-items: center; gap: .9rem; flex: 1 1 320px; }
.push-icon { width: 48px; height: 48px; border-radius: 12px; background: var(--primary-pale); display: grid; place-items: center; font-size: 1.5rem; flex: none; }
.pwa-card > div { flex: 1 1 320px; }
.pwa-card > .pwa-steps { flex: 1 1 100%; background: var(--primary-pale); border-radius: 10px; padding: .8rem 1rem; }
.pwa-steps-title { font-weight: 600; margin-bottom: .3rem; }
.pwa-steps ol { margin: 0; padding-left: 1.4em; line-height: 1.8; }
/* ホーム画面から開いたとき（アプリとして）は、iPhone の上の帯にかからないように */
@media (display-mode: standalone) { .app-header { padding-top: env(safe-area-inset-top); } }
