/* ═══════════════════════════════════════════════════
   らくらく入浴管理 - 共通スタイル
   らくらくイノベーション
═══════════════════════════════════════════════════ */

/* ─── 変数 ─────────────────────────────────────── */
:root {
  --sb:  #1e2d3d;
  --sb2: #253545;
  --sb3: #1a2736;
  --ac:  #1abc9c;
  --ac2: #16a085;
  --bl:  #2980b9;
  --bl2: #1f6aa5;
  --rd:  #e74c3c;
  --rd2: #c0392b;
  --yw:  #f39c12;
  --gr:  #27ae60;
  --bg:  #f0f2f5;
  --wh:  #fff;
  --bd:  #dde2e8;
  --bd2: #c8d0d8;
  --tx:  #2c3e50;
  --tx2: #6c7a89;
  --tx3: #95a5a6;
  --f:   'Noto Sans JP', sans-serif;
  --r:   6px;
  --sh:  0 2px 8px rgba(0,0,0,.09);
  --sh2: 0 4px 20px rgba(0,0,0,.13);
}

/* ─── リセット ──────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  height: 100%;
  font-family: var(--f);
  font-size: 14px;
  color: var(--tx);
  background: var(--bg);
}

/* ─── レイアウト ────────────────────────────────── */
.app { display: flex; height: 100vh; overflow: hidden; }
.sb  { width: 220px; min-width: 220px; background: var(--sb); display: flex; flex-direction: column; height: 100vh; overflow-y: auto; flex-shrink: 0; }
.mn  { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* ─── サイドバー ────────────────────────────────── */
.sb-logo { padding: 18px 16px 14px; border-bottom: 1px solid rgba(255,255,255,.08); display: flex; align-items: center; gap: 11px; flex-shrink: 0; }
.sb-logo .li { width: 44px; height: 44px; background: linear-gradient(135deg, var(--ac), var(--bl)); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.sb-logo .lt { color: #fff; font-size: 11.5px; font-weight: 700; line-height: 1.4; }
.sb-logo .lt span { display: block; font-size: 9.5px; color: rgba(255,255,255,.38); font-weight: 400; margin-top: 2px; }

.sb-user { padding: 12px 16px; border-bottom: 1px solid rgba(255,255,255,.07); display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.sb-user .av { width: 32px; height: 32px; background: var(--ac2); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; color: #fff; font-weight: 700; flex-shrink: 0; }
.sb-user .uinfo .urole { font-size: 9px; color: rgba(255,255,255,.38); letter-spacing: .04em; }
.sb-user .uinfo .uname { font-size: 12.5px; color: #fff; font-weight: 600; margin-top: 1px; }
.sb-user .uinfo .ucity { font-size: 10px; color: var(--ac); margin-top: 1px; }

.sb-nav { flex: 1; padding: 6px 0; }
.nb { padding: 12px 16px 4px; font-size: 10px; color: rgba(255,255,255,.24); letter-spacing: .1em; font-weight: 600; }
.ni { display: flex; align-items: center; gap: 9px; padding: 9px 18px; color: rgba(255,255,255,.58); font-size: 12.5px; font-weight: 500; cursor: pointer; border-left: 3px solid transparent; transition: .14s; user-select: none; text-decoration: none; }
.ni:hover { background: rgba(255,255,255,.06); color: #fff; }
.ni.on { background: rgba(26,188,156,.13); color: #fff; border-left-color: var(--ac); }
.ni .ic { font-size: 14px; width: 18px; text-align: center; flex-shrink: 0; }

.sb-foot { padding: 10px 16px 14px; border-top: 1px solid rgba(255,255,255,.07); flex-shrink: 0; }
.sb-foot .logout-btn { width: 100%; padding: 8px; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12); border-radius: var(--r); color: rgba(255,255,255,.6); font-size: 12px; cursor: pointer; font-family: var(--f); transition: .14s; display: flex; align-items: center; justify-content: center; gap: 6px; }
.sb-foot .logout-btn:hover { background: rgba(255,255,255,.12); color: #fff; }

/* ─── トップバー ────────────────────────────────── */
.topbar { background: var(--wh); border-bottom: 1px solid var(--bd); height: 52px; padding: 0 24px; display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; box-shadow: 0 1px 3px rgba(0,0,0,.06); z-index: 10; }
.tb-left { display: flex; align-items: center; gap: 12px; }
.tb-pgname { font-size: 15px; font-weight: 700; color: var(--tx); }
.tb-right { display: flex; align-items: center; gap: 14px; }
.tb-city { display: flex; align-items: center; gap: 8px; }
.tb-city .cl { width: 28px; height: 28px; background: linear-gradient(135deg, var(--ac), var(--bl)); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; }
.tb-city .cn { font-size: 13px; font-weight: 700; color: var(--tx); }
.tb-userinfo { font-size: 12px; color: var(--tx2); }
.demo-lbl { background: #fff3cd; color: #856404; font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 20px; border: 1px solid #ffc107; }

/* ─── ページラッパー ─────────────────────────────── */
.pw { flex: 1; overflow-y: auto; padding: 22px 24px; }

/* ─── ページヘッダー ─────────────────────────────── */
.ph { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; gap: 12px; }
.ph h2 { font-size: 19px; font-weight: 700; color: var(--tx); }
.ph .desc { font-size: 12px; color: var(--tx2); margin-top: 3px; }
.pha { display: flex; gap: 8px; flex-shrink: 0; align-items: center; }

/* ─── ボタン ─────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 5px; padding: 8px 18px; border-radius: var(--r); font-size: 13px; font-weight: 600; cursor: pointer; border: none; font-family: var(--f); transition: .15s; white-space: nowrap; text-decoration: none; }
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: scale(.97); }
.b-ac  { background: var(--ac);  color: #fff; }
.b-bl  { background: var(--bl);  color: #fff; }
.b-rd  { background: var(--rd);  color: #fff; }
.b-gr  { background: var(--gr);  color: #fff; }
.b-yw  { background: var(--yw);  color: #fff; }
.b-ou  { background: var(--wh);  color: var(--tx); border: 1.5px solid var(--bd2); }
.b-ou:hover { background: var(--bg); }
.b-sm  { padding: 5px 12px; font-size: 12px; }
.b-lg  { padding: 11px 28px; font-size: 14px; }

/* ─── 統計カード ─────────────────────────────────── */
.sg  { display: grid; gap: 14px; margin-bottom: 20px; }
.sg4 { grid-template-columns: repeat(4, 1fr); }
.sg3 { grid-template-columns: repeat(3, 1fr); }
.sg2 { grid-template-columns: 1fr 1fr; }

.stc { background: var(--wh); border-radius: var(--r); padding: 16px 18px; box-shadow: var(--sh); border: 1px solid var(--bd); position: relative; overflow: hidden; transition: .2s; }
.stc:hover { box-shadow: var(--sh2); }
.stc::after { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.stc.c-ac::after { background: var(--ac); }
.stc.c-bl::after { background: var(--bl); }
.stc.c-yw::after { background: var(--yw); }
.stc.c-rd::after { background: var(--rd); }
.stc .row1 { display: flex; justify-content: space-between; align-items: flex-start; }
.stc .lbl  { font-size: 11.5px; color: var(--tx2); font-weight: 500; margin-bottom: 6px; }
.stc .ico  { font-size: 20px; opacity: .6; }
.stc .val  { font-size: 30px; font-weight: 800; color: var(--tx); line-height: 1; }
.stc .val .u { font-size: 13px; font-weight: 400; }
.stc .sub  { font-size: 11px; color: var(--tx3); margin-top: 5px; }

/* ─── カード ─────────────────────────────────────── */
.card { background: var(--wh); border-radius: var(--r); box-shadow: var(--sh); border: 1px solid var(--bd); overflow: hidden; }
.card + .card { margin-top: 16px; }
.ch { padding: 13px 18px; border-bottom: 1px solid var(--bd); display: flex; align-items: center; justify-content: space-between; background: var(--wh); }
.ch h3 { font-size: 13.5px; font-weight: 700; color: var(--tx); }
.cb { padding: 18px; }

/* ─── テーブル ───────────────────────────────────── */
.tb-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 18px; background: var(--bg); border-bottom: 1px solid var(--bd); flex-wrap: wrap; gap: 8px; }
.tb-head .show-sel { font-size: 12px; color: var(--tx2); }
.tb-head .show-sel select { padding: 3px 8px; border: 1px solid var(--bd); border-radius: 4px; font-size: 12px; }
.tb-head .srch { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--tx2); }
.tb-head .srch input { padding: 5px 10px; border: 1px solid var(--bd); border-radius: 4px; font-size: 12px; font-family: var(--f); outline: none; width: 180px; }
.tb-head .srch input:focus { border-color: var(--ac); }
.tw { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { background: #2c3e50; color: #fff; font-size: 12px; font-weight: 600; padding: 10px 13px; text-align: left; white-space: nowrap; }
th .sort { opacity: .5; margin-left: 4px; font-size: 10px; }
td { padding: 9px 13px; font-size: 12.5px; border-bottom: 1px solid #f0f2f5; vertical-align: middle; }
tr:hover td { background: #f8fafb; }
.tr2 { text-align: right; }
.tb-foot { padding: 9px 18px; font-size: 12px; color: var(--tx2); border-top: 1px solid var(--bd); display: flex; justify-content: space-between; align-items: center; }

/* ─── フィルターバー ─────────────────────────────── */
.fb { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.fb input, .fb select { padding: 7px 11px; border: 1.5px solid var(--bd); border-radius: var(--r); font-size: 12.5px; font-family: var(--f); color: var(--tx); background: var(--wh); outline: none; transition: .14s; }
.fb input:focus, .fb select:focus { border-color: var(--ac); }
.fb input[type=text] { min-width: 200px; }

/* ─── バッジ ─────────────────────────────────────── */
.bdg { display: inline-flex; align-items: center; gap: 3px; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.bdg::before { content: '●'; font-size: 7px; }
.bv { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.bu { background: #f3f4f6; color: #374151; border: 1px solid #d1d5db; }
.be { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.bs { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.br { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.bo { background: #ede9fe; color: #5b21b6; border: 1px solid #c4b5fd; }

/* ─── 詳細パネル ─────────────────────────────────── */
.det { border: 1px solid var(--bd); border-radius: var(--r); overflow: hidden; }
.dr  { display: flex; border-bottom: 1px solid #f0f2f5; }
.dr:last-child { border-bottom: none; }
.dk  { width: 130px; padding: 9px 14px; font-size: 11.5px; color: var(--tx2); font-weight: 500; background: var(--bg); flex-shrink: 0; }
.dv  { padding: 9px 14px; font-size: 13px; color: var(--tx); font-weight: 500; }

/* ─── モーダル ───────────────────────────────────── */
.modal-bg { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); backdrop-filter: blur(2px); z-index: 500; align-items: center; justify-content: center; }
.modal-bg.on { display: flex; }
.modal { background: var(--wh); border-radius: 10px; padding: 26px; width: 90%; max-width: 520px; max-height: 88vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.2); animation: mIn .2s ease; }
.modal.wide { max-width: 720px; }
@keyframes mIn { from { transform: translateY(-18px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.mh { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; padding-bottom: 13px; border-bottom: 1px solid var(--bd); }
.mh h3 { font-size: 15px; font-weight: 700; color: var(--tx); }
.mcl { width: 26px; height: 26px; border-radius: 50%; border: none; background: var(--bg); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--tx2); transition: .14s; }
.mcl:hover { background: var(--bd); }

/* ─── フォーム ───────────────────────────────────── */
.fg { margin-bottom: 16px; }
.fg label { display: block; font-size: 12px; font-weight: 600; color: var(--tx2); margin-bottom: 5px; }
.fg input, .fg select, .fg textarea { width: 100%; padding: 10px 13px; border: 1.5px solid var(--bd); border-radius: var(--r); font-size: 14px; font-family: var(--f); color: var(--tx); outline: none; transition: .15s; background: var(--wh); }
.fg input:focus, .fg select:focus, .fg textarea:focus { border-color: var(--ac); }
.fr { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ─── インフォ帯 ─────────────────────────────────── */
.info-s  { background: #dbeafe; border: 1px solid #93c5fd; color: #1e40af; border-radius: var(--r); padding: 9px 13px; font-size: 12px; margin-bottom: 12px; display: flex; gap: 7px; align-items: center; }
.ok-s    { background: #d1fae5; border-color: #6ee7b7; color: #065f46; }
.warn-s  { background: #fef3c7; border-color: #fcd34d; color: #92400e; }
.err-s   { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }

/* ─── ランキングバー ─────────────────────────────── */
.rb-row  { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.rb-num  { width: 22px; height: 22px; border-radius: 50%; background: var(--sb); color: #fff; font-size: 10px; font-weight: 800; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.rb-name { width: 90px; font-size: 12.5px; color: var(--tx2); flex-shrink: 0; }
.rb-track { flex: 1; height: 20px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.rb-fill { height: 100%; background: linear-gradient(90deg, var(--sb), var(--bl2)); border-radius: 3px; display: flex; align-items: center; padding: 0 7px; transition: width .9s ease; }
.rb-fill span { font-size: 10px; color: #fff; font-weight: 700; }
.rb-cnt  { width: 28px; font-size: 12px; font-weight: 700; color: var(--tx2); text-align: right; }

/* ─── エクスポートボタン ─────────────────────────── */
.export-row { display: flex; gap: 8px; padding: 10px 18px; border-bottom: 1px solid var(--bd); }
.export-btn { padding: 5px 14px; border: 1px solid; border-radius: 4px; font-size: 12px; font-weight: 600; cursor: pointer; font-family: var(--f); transition: .14s; }
.e-csv   { background: #217346; color: #fff; border-color: #1a5c38; }
.e-pdf   { background: #dc3545; color: #fff; border-color: #b02a37; }
.e-print { background: #6c757d; color: #fff; border-color: #565e64; }

/* ─── 精算ヒーロー ───────────────────────────────── */
.settle-hero { background: linear-gradient(135deg, var(--sb), #2e4a66); color: #fff; border-radius: var(--r); padding: 20px 24px; margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; }
.sh-lbl  { font-size: 12px; opacity: .6; }
.sh-val  { font-size: 38px; font-weight: 900; letter-spacing: -.03em; margin: 4px 0; line-height: 1; }
.sh-sub  { font-size: 12px; opacity: .5; }
.sh-right { text-align: right; }
.sh-stat { font-size: 13px; font-weight: 600; color: var(--ac); }

/* ─── 入浴券カードプレビュー ─────────────────────── */
.vcard { background: linear-gradient(135deg, #fffef8, #fff); border: 2px solid var(--sb); border-radius: 10px; padding: 16px 18px; max-width: 300px; font-family: var(--f); }
.vcard .vc-head { text-align: center; border-bottom: 2px dashed var(--bl2); padding-bottom: 10px; margin-bottom: 10px; }
.vcard .vct { font-size: 15px; font-weight: 800; color: var(--sb); }
.vcard .vco { font-size: 10px; color: var(--tx2); margin-top: 2px; }
.vcard .vcb { display: flex; gap: 12px; align-items: flex-start; }
.vcard .vci .vrow { margin-bottom: 6px; }
.vcard .vl { font-size: 10px; color: var(--tx2); }
.vcard .vv { font-size: 12.5px; font-weight: 600; color: var(--tx); }
.vcard .vcf { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--bd2); display: flex; justify-content: space-between; font-size: 10px; color: var(--tx2); }

/* ─── トースト ───────────────────────────────────── */
#toast-c { position: fixed; bottom: 20px; right: 20px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 11px 17px; border-radius: var(--r); font-size: 13px; max-width: 300px; box-shadow: var(--sh2); animation: tIn .3s ease; display: flex; align-items: center; gap: 8px; }
@keyframes tIn { from { transform: translateX(110%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.t-ok { background: var(--gr); color: #fff; }
.t-wn { background: var(--yw); color: #fff; }
.t-er { background: var(--rd); color: #fff; }
.t-in { background: var(--sb); color: #fff; }

/* ─── ユーティリティ ─────────────────────────────── */
.g2   { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.g3   { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.mt16 { margin-top: 16px; }
.mt20 { margin-top: 20px; }
.mb14 { margin-bottom: 14px; }
.mb20 { margin-bottom: 20px; }
.fw7  { font-weight: 700; }
.fw8  { font-weight: 800; }
.fs11 { font-size: 11px; }
.fs12 { font-size: 12px; }
.cgr  { color: var(--tx2); }
.ctx  { color: var(--tx); }

/* ─── ローディング ───────────────────────────────── */
.loading-row td { text-align: center; padding: 30px; color: var(--tx3); font-size: 13px; }
.empty-row  td { text-align: center; padding: 30px; color: var(--tx3); font-size: 13px; }

/* ─── ソート可能なヘッダー ─────────────────────────── */
th.sortable { position: relative; padding-right: 22px !important; transition: background .12s; }
th.sortable:hover { background: rgba(0,0,0,.04); }
th.sortable::after {
  content: '⇅'; position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  font-size: 10px; opacity: .35; color: var(--tx2);
}
th.sortable.s-asc::after  { content: '▲'; opacity: 1; color: var(--bl2); }
th.sortable.s-desc::after { content: '▼'; opacity: 1; color: var(--bl2); }

/* ═══════════════════════════════════════════════════
   レスポンシブ対応（タブレット縦・スマホ）
   ═══════════════════════════════════════════════════ */

/* テーブルは常に横スクロール可能に */
.tw { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tw table { min-width: 600px; }

/* ──────────── タブレット縦 (max 1024px) ──────────── */
@media (max-width: 1024px) {
  .g2 { grid-template-columns: 1fr; }
  .g3 { grid-template-columns: 1fr 1fr; }
  .pw { padding: 16px; }
  .ph { flex-wrap: wrap; gap: 12px; }
  .fb { flex-wrap: wrap; }
  .fb input[type=text], .fb select { min-width: 0; flex: 1 1 200px; }
}

/* ──────────── スマホ・狭幅 (max 768px) ──────────── */
@media (max-width: 768px) {
  /* サイドバー: 上部に横並びの細いバーに変身 */
  .app { flex-direction: column; height: auto; min-height: 100vh; }
  .sb {
    width: 100%; min-width: 0; height: auto;
    flex-direction: row; overflow-x: auto; overflow-y: hidden;
    border-bottom: 1px solid rgba(255,255,255,.08);
    padding: 6px 8px;
  }
  .sb-logo { padding: 8px 10px; border-bottom: none; border-right: 1px solid rgba(255,255,255,.08); flex-shrink: 0; }
  .sb-logo .lt { display: none; } /* テキスト省略、アイコンのみ */
  .sb-user { display: none; } /* ユーザー名はトップバーに集約 */
  .sb-nav {
    flex: 1; padding: 0; display: flex; flex-direction: row;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
  }
  .ni {
    flex-shrink: 0; padding: 8px 12px; border-radius: 6px; margin: 4px 2px;
    flex-direction: column; gap: 2px; font-size: 10px; min-width: 64px;
  }
  .ni .ic { font-size: 18px; width: auto; }
  .sb-foot { display: none; } /* ログアウトはトップバー側 */

  .mn { overflow: visible; }

  /* トップバー: 縮める */
  .tb { padding: 10px 12px; flex-wrap: wrap; gap: 8px; }
  .tb h1 { font-size: 15px; }
  .tb-city { font-size: 11px; }
  .tb-head { gap: 6px; }
  .tb-head .srch input { width: 120px; }

  /* メイン領域 */
  .pw { padding: 12px; }
  .ph h2 { font-size: 18px; }
  .ph .desc { font-size: 11px; }
  .pha { width: 100%; }
  .pha .btn { width: 100%; }

  /* カード */
  .card { padding: 12px; }
  .ch { flex-wrap: wrap; gap: 8px; }
  .ch h3 { font-size: 13px; }

  /* フィルター */
  .fb { flex-direction: column; align-items: stretch; }
  .fb input[type=text], .fb select { width: 100%; min-width: 0; flex: none; }

  /* 統計カード等のグリッド */
  .g3 { grid-template-columns: 1fr; }

  /* テーブル: フォントを小さく */
  table th, table td { padding: 8px 10px; font-size: 12px; }

  /* モーダル */
  .modal { padding: 18px; max-height: 92vh; }
  .modal.wide { max-width: 95vw; }
  .fr { flex-direction: column; gap: 0; }

  /* 詳細レイアウト */
  .det .dr { flex-direction: column; align-items: stretch; }
  .dk { width: auto; padding: 8px 10px; background: var(--bg); }
  .dv { padding: 8px 10px; }

  /* 出力ボタンを縦に */
  .export-row { flex-direction: column; gap: 6px; }
  .export-btn { width: 100%; }
}

/* ──────────── 極小スマホ (max 480px) ──────────── */
@media (max-width: 480px) {
  .tb-time, .tb-date { display: none; } /* 時計・日付は省略 */
  .ni { min-width: 56px; padding: 6px 8px; font-size: 9.5px; }
  .ni .ic { font-size: 16px; }
  table th, table td { padding: 6px 8px; font-size: 11.5px; }
  .vcard { max-width: 100%; }
}
