/* Design tokens (from monthly_utilization_app) */
:root {
  --bg:#EEF2F4; --surface:#FFFFFF; --ink:#16282F; --muted:#5C727B;
  --hair:#E0E7EA; --accent:#0E8F8A; --accent-soft:#E2F1F0;
  --low:#9DB2BC; --mid:#4FA59B; --high:#147D74; --hot:#E0A23B;
  --shadow:0 1px 2px rgba(16,40,48,.04),0 8px 24px rgba(16,40,48,.06);
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
  line-height: 1.55; -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1;
}
#apo-dash-root { max-width: 1100px; margin: 0 auto; padding: 24px 20px 64px; }
header h1 { font-size: clamp(22px, 3vw, 28px); margin: 0 0 4px; font-weight: 800; letter-spacing: -.01em; }
header .note { font-size: 12px; color: var(--muted); margin: 0 0 14px; }

/* top tabs */
.top-tabs { display: inline-flex; background: transparent; border-radius: 11px; padding: 4px; gap: 6px; margin: 8px 0 16px; }
.top-tab {
  border: 1px solid var(--accent); background: #fff; font: inherit; font-weight: 700; font-size: 14px;
  color: var(--accent); padding: 9px 22px; border-radius: 8px; cursor: pointer;
  transition: background .15s, color .15s;
}
.top-tab.active { background: var(--accent); color: #fff; box-shadow: var(--shadow); }

.pane { display: none; }
.pane.active { display: block; }

/* Sub tabs */
.sub-tabs { display: inline-flex; gap: 4px; margin: 8px 0 16px; background: #F4F7F8; padding: 4px; border-radius: 9px; }
.sub-tabs .apo-agg-tab {
  background: #fff; border: 1px solid var(--accent); padding: 6px 16px; border-radius: 6px;
  font-size: 13px; font-weight: 600; color: var(--accent); cursor: pointer;
}
.sub-tabs .apo-agg-tab.active { background: var(--accent); color: #fff; box-shadow: var(--shadow); }

.subpane { display: none; }
.subpane.active { display: block; }

.apo-agg-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.apo-agg-btn {
  background: var(--accent); color: #fff; border: none; padding: 7px 14px;
  border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600;
}
.apo-agg-btn:hover { background: #0c7c77; }
.apo-agg-btn.secondary { background: #fff; color: var(--accent); border: 1px solid var(--hair); }
.apo-agg-btn.secondary:hover { background: var(--accent-soft); }
.apo-agg-month { padding: 8px 12px; border: 1px solid var(--hair); border-radius: 8px; background: #fff; font: inherit; font-weight: 600; }

/* Summary block */
.summary {
  display: grid; grid-template-columns: auto 1fr; gap: 22px; margin-top: 4px; align-items: center;
  background: var(--surface); border: 1px solid var(--hair); border-radius: 14px; padding: 22px;
  box-shadow: var(--shadow);
}
.gauge { position: relative; width: 130px; height: 130px; flex-shrink: 0; }
.gauge .pct { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.gauge .pct b { font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.gauge .pct small { font-size: 11px; color: var(--muted); font-weight: 700; letter-spacing: .04em; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat .k { font-size: 11px; letter-spacing: .05em; color: var(--muted); font-weight: 700; text-transform: uppercase; }
.stat .v { font-size: 20px; font-weight: 800; margin-top: 2px; }
.stat .v small { font-size: 13px; color: var(--muted); font-weight: 600; }

.block { background: var(--surface); border: 1px solid var(--hair); border-radius: 14px; padding: 20px; box-shadow: var(--shadow); margin-top: 16px; }
.block h2 { font-size: 15px; margin: 0 0 16px; font-weight: 800; }
.block h2 .sub { font-weight: 600; color: var(--muted); font-size: 12px; }

/* Insights */
.insights { margin: 0; padding-left: 20px; }
.insights li { font-size: 14px; margin-bottom: 10px; line-height: 1.65; }
.insights li:last-child { margin-bottom: 0; }
.insights b { color: var(--ink); font-weight: 800; }

/* Weekday bars */
.wdrow { display: flex; align-items: center; gap: 12px; margin-bottom: 9px; }
.wdrow .lab { width: 46px; font-weight: 800; font-size: 13px; }
.wdrow .lab small { font-weight: 600; color: var(--muted); font-size: 11px; margin-left: 3px; }
.wdrow .bar { position: relative; flex: 1; height: 20px; background: #EFF3F4; border-radius: 6px; overflow: hidden; }
.wdrow .bar > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 6px; transition: width .5s cubic-bezier(.2,.7,.2,1); }
.wdrow .val { width: 54px; text-align: right; font-weight: 800; font-size: 13px; }

/* Daily trend */
.trend { display: flex; align-items: flex-end; gap: 4px; height: 80px; overflow-x: auto; padding-bottom: 4px; }
.tbar { flex: 1 0 22px; display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 22px; cursor: pointer; border-radius: 7px; padding: 3px 0 2px; transition: background .15s; }
.tbar .col { width: 100%; max-width: 26px; border-radius: 4px 4px 0 0; transition: height .5s ease; }
.tbar .col:hover { filter: brightness(1.08); }
.tbar .d { font-size: 10px; color: var(--muted); font-weight: 700; line-height: 1.1; text-align: center; }
.tbar .d em { font-style: normal; display: block; font-size: 9px; color: #A4B4BB; }
.tbar.sel { background: var(--accent-soft); }
/* Trend bar value labels with white outline */
.tbar .tval {
  font-size: 11px; font-weight: 800; color: #16282F;
  line-height: 1.1; text-align: center;
  text-shadow:
    0 0 4px rgba(255,255,255,1),
    0 0 4px rgba(255,255,255,1),
    0 0 8px rgba(255,255,255,0.95);
}
/* px-based trend (タワー型) */
.trend.trend-px {
  height: auto; align-items: flex-end; padding-bottom: 4px;
}
.trend.trend-px .tbar { justify-content: flex-end; }
.tbar.sel .col { outline: 2.5px solid var(--accent); outline-offset: 1px; }
.tbar.sel .d { color: var(--accent); font-weight: 800; }
.tbar.sel .d em { color: var(--accent); }

/* Heatmap */
.hstrip { display: flex; gap: 1px; height: 36px; border-radius: 6px; overflow: hidden; border: 1px solid var(--hair); }
.hcell { flex: 1; min-width: 0; }
.hlabels { display: flex; gap: 1px; margin-top: 5px; }
.hlab { flex: 1; min-width: 0; font-size: 10px; color: var(--muted); font-weight: 700; text-align: left; }

/* Unit table */
.tblhead { display: flex; align-items: baseline; justify-content: space-between; margin: 24px 2px 12px; }
.tblhead h2 { font-size: 16px; margin: 0; font-weight: 800; }
.csv { border: none; background: none; color: var(--accent); font-weight: 700; cursor: pointer; font-size: 13px; }
.csv:hover { text-decoration: underline; }
.utbl { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--hair); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); }
.utbl th, .utbl td { text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--hair); font-size: 14px; }
.utbl th { font-size: 11px; letter-spacing: .05em; color: var(--muted); text-transform: uppercase; font-weight: 700; background: #FAFBFB; white-space: nowrap; }
.utbl td { white-space: nowrap; }
#pane-sales, #pane-staff, #pane-util { overflow-x: auto; }
.subpane { overflow-x: auto; }
.utbl tr:last-child td { border-bottom: none; }
.utbl td.num, .utbl th.num { text-align: right; font-weight: 700; }
.utbl td.name { font-weight: 700; white-space: nowrap; }
.utbl .barcell { width: 38%; }
.bar2 { position: relative; height: 22px; background: #EFF3F4; border-radius: 6px; overflow: hidden; }
.bar2 > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 6px; transition: width .5s cubic-bezier(.2,.7,.2,1); }
.bar2 > em {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-style: normal; font-size: 12px; font-weight: 800;
  color: #16282F;
  text-shadow:
    0 0 6px rgba(255,255,255,1),
    0 0 6px rgba(255,255,255,1),
    0 0 10px rgba(255,255,255,0.95),
    0 0 14px rgba(255,255,255,0.8);
}
.legend { display: flex; flex-wrap: wrap; gap: 16px; margin: 13px 2px 0; font-size: 12px; color: var(--muted); font-weight: 600; }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* Clinic settings panel */
.clinic-settings {
  display: flex; flex-wrap: wrap; align-items: end; gap: 14px;
  background: var(--surface); border: 1px solid var(--hair); border-radius: 12px;
  padding: 14px 18px; margin-bottom: 12px; box-shadow: var(--shadow);
}
/* ブロック内に入った場合は外殻スタイルを抑制し、下にボーダー区切りを置く */
.heatmap-block .clinic-settings {
  background: transparent; border: none; border-radius: 0;
  padding: 0 0 12px; margin-bottom: 16px; box-shadow: none;
  border-bottom: 1px dashed var(--hair);
}
.heatmap-block { margin-bottom: 24px; }
.cs-field { display: flex; flex-direction: column; gap: 5px; }
.cs-field label { font-size: 11px; letter-spacing: .06em; color: var(--muted); font-weight: 700; text-transform: uppercase; }
.cs-field input[type=time] {
  font: inherit; font-weight: 700; padding: 6px 10px;
  border: 1px solid var(--hair); border-radius: 8px; background: #FBFCFC; color: var(--ink);
}
.cs-field input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.cs-sep { align-self: center; color: #AEBEC4; font-weight: 700; padding-bottom: 6px; }

/* Sales import dropzone */
#sales-drop {
  border: 1.5px dashed #B7C7CD; border-radius: 14px; background: var(--surface);
  padding: 32px 22px; text-align: center; cursor: pointer; transition: all .15s;
}
#sales-drop:hover, #sales-drop.over { border-color: var(--accent); background: var(--accent-soft); }
#sales-imported-list div { padding: 2px 0; }

/* Sortable table headers */
.utbl th.sortable { cursor: pointer; user-select: none; }
.utbl th.sortable:hover { background: var(--accent-soft); }
.utbl th.sortable.active { color: var(--accent); background: var(--accent-soft); }
.utbl th .sort-ind { font-size: 10px; }
.utbl td.col-active { background: rgba(14, 143, 138, 0.08); font-weight: 700; }
.utbl.compact-pivot { table-layout: auto; width: 100%; font-size: 11px; }
.utbl.compact-pivot th, .utbl.compact-pivot td {
  padding: 4px 6px; font-size: 11px; white-space: nowrap;
}
.utbl.compact-pivot th { font-size: 10px; letter-spacing: 0; }
.utbl.compact-pivot td.name { font-size: 11px; font-weight: 700; }
.utbl.compact-pivot td.name small { font-size: 9px; }
.utbl tbody tr:hover td.col-active { background: rgba(14, 143, 138, 0.14); }

/* Day nav */
.daynav { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; }
.daynav button { width: 38px; height: 38px; border: 1px solid var(--hair); background: #fff; border-radius: 10px; font-size: 18px; font-weight: 700; cursor: pointer; color: var(--ink); flex-shrink: 0; }
.daynav button:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--accent); }
.daynav button:disabled { opacity: .35; cursor: default; }
.daynav select { flex: 1; min-width: 0; font: inherit; font-weight: 700; font-size: 14px; padding: 9px 12px; border: 1px solid var(--hair); border-radius: 10px; background: #fff; color: var(--ink); }

/* History list */
.apo-agg-history-list { list-style: none; padding: 0; margin: 0; }
.apo-agg-history-list li { padding: 8px 12px; border-bottom: 1px solid var(--hair); display: flex; align-items: center; gap: 10px; }
.apo-agg-history-list li:last-child { border-bottom: none; }
.apo-agg-history-list a { color: var(--accent); cursor: pointer; font-weight: 700; }
.apo-agg-history-list .del { margin-left: auto; color: #B85850; cursor: pointer; font-size: 12px; font-weight: 600; }
.apo-agg-history-list .del:hover { text-decoration: underline; }

/* キャンセル日別ブロック */
.day-block { background: var(--surface); border: 1px solid var(--hair); border-radius: 12px; margin-bottom: 12px; box-shadow: var(--shadow); }
.day-block h4 { margin: 0; padding: 10px 14px; background: #FAFBFB; font-size: 14px; font-weight: 800; border-bottom: 1px solid var(--hair); border-radius: 12px 12px 0 0; }
.day-block .body { padding: 10px 14px; }

/* 汎用テーブル (キャンセルなど) */
.apo-agg-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.apo-agg-table th, .apo-agg-table td { border-bottom: 1px solid var(--hair); padding: 6px 8px; text-align: left; }
.apo-agg-table th { font-size: 11px; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; font-weight: 700; background: #FAFBFB; }
.apo-agg-table tfoot td { font-weight: 800; background: #F4F7F8; }
.apo-agg-card { background: var(--surface); border: 1px solid var(--hair); border-radius: 12px; padding: 12px; box-shadow: var(--shadow); margin-bottom: 12px; }
.apo-agg-card h3 { margin: 0 0 8px; font-size: 14px; font-weight: 800; }
.apo-agg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
@media(max-width: 800px) { .apo-agg-grid { grid-template-columns: 1fr; } .stats { grid-template-columns: repeat(2, 1fr); } .summary { grid-template-columns: 1fr; justify-items: center; text-align: center; } }
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--hair); border-radius: 10px; padding: 14px; text-align: center; }
.kpi-label { font-size: 12px; color: var(--muted); font-weight: 700; }
.kpi-val { font-size: 28px; font-weight: 800; color: var(--brand); margin: 6px 0 2px; }
.kpi-sub { font-size: 10px; color: var(--muted); }
@media(max-width: 800px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
.kpi-grid.kpi-5 { grid-template-columns: repeat(5, 1fr); }
.kpi.kpi-hl { background: linear-gradient(135deg, #0E8F8A11, #0E8F8A22); border-color: var(--brand); }
.kpi.kpi-hl .kpi-val { color: var(--brand); }
@media(max-width: 800px) { .kpi-grid.kpi-5 { grid-template-columns: repeat(2, 1fr); } }
/* 共通: モード切替ボタン (active=緑+白文字 / inactive=白+緑文字) */
.work-mode-btn, .treat-mode-btn, .mode-btn, .rate-mode-btn {
  padding: 6px 14px; font-size: 12px; font-weight: 700;
}
.apo-agg-btn:not(.secondary) { background: var(--accent); color: #fff; }
/* 全てのボタンをアクセントカラー (緑+白) に統一 */
#apo-dash-root button {
  background: var(--accent); color: #fff; border: none;
  padding: 6px 12px; border-radius: 8px; cursor: pointer;
  font-size: 13px; font-weight: 600;
}
#apo-dash-root button:hover { background: #0c7c77; }
#apo-dash-root button.secondary { background: #fff; color: var(--accent); border: 1px solid var(--hair); }
#apo-dash-root button.secondary:hover { background: var(--accent-soft); }
#apo-dash-root button:disabled { background: #d8e0e2 !important; color: #fff !important; cursor: not-allowed; }
.apo-agg-table td.col-active, .apo-agg-table th.col-active { background: rgba(14, 143, 138, 0.08); font-weight: 700; }
.apo-agg-table tbody tr:hover td.col-active { background: rgba(14, 143, 138, 0.14); }
.apo-agg-table th.active { color: var(--accent); }
.shihyou-goal::-webkit-inner-spin-button, .shihyou-goal::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.shihyou-goal { -moz-appearance: textfield; }
/* 全モード切替ボタンの統一スタイル (アクティブ=緑+白文字 / 非アクティブ=白+緑文字+緑枠) */
#apo-dash-root .apo-agg-btn:not(.secondary),
#apo-dash-root button.work-mode-btn:not(.secondary),
#apo-dash-root button.treat-mode-btn:not(.secondary),
#apo-dash-root button.mode-btn:not(.secondary),
#apo-dash-root button.rate-mode-btn:not(.secondary),
#apo-dash-root button.shihyou-mode-btn:not(.secondary) {
  background: var(--accent) !important; color: #fff !important; border: 1px solid var(--accent) !important;
}
#apo-dash-root .apo-agg-btn.secondary,
#apo-dash-root button.work-mode-btn.secondary,
#apo-dash-root button.treat-mode-btn.secondary,
#apo-dash-root button.mode-btn.secondary,
#apo-dash-root button.rate-mode-btn.secondary,
#apo-dash-root button.shihyou-mode-btn.secondary {
  background: #fff !important; color: var(--accent) !important; border: 1px solid var(--accent) !important;
}
#apo-dash-root button.rate-mode-btn { padding: 8px 16px !important; font-size: 13px !important; font-weight: 700 !important; }
@media print {
  body { background: #fff !important; }
  /* 評価シート以外を非表示 */
  .top-tabs, #pane-cancel, #pane-work, #pane-sales, #pane-patients, #pane-treat,
  #pane-maint, #pane-shihyou, #pane-dropout, #pane-history,
  #pane-hyouka .apo-agg-row,
  #pane-hyouka .hyouka-no-print { display: none !important; }
  .hyouka-print-only { display: block !important; }
  #pane-hyouka { display: block !important; }
  #pane-hyouka .apo-agg-card { box-shadow: none !important; border: none !important; padding: 0 !important; margin: 0 !important; }
  table { page-break-inside: auto; }
  tr { page-break-inside: avoid; page-break-after: auto; }
  textarea, input, select { border: 1px solid #888 !important; }
  /* セレクト/インプットの値を出力 */
  textarea { min-height: auto !important; }
  /* 余白圧縮 */
  #apo-dash-root { padding: 0 !important; max-width: 100% !important; }
}
@media print { #apo-logo { display: none !important; } }
