/* ===== 全体 ===== */
* { box-sizing: border-box; }
:root {
  /* 業務用のシックな配色（紺系） */
  --blue: #2c3e50;
  --blue-d: #1f2d3a;
  --green: #2e7d32;
  --green-d: #1b5e20;
  --gray: #888;
  --line: #cbd5e1;
  --bg: #f4f5f7;
  --result-adopt: #E8F5E9;
  --result-reject: #FFEBEE;
  --result-consider: #FFF9C4;
  --result-other: #E3F2FD;
}
html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  background: var(--bg);
  color: #1e293b;
  font-size: 15px;
}
#app { max-width: 1180px; margin: 0 auto; padding: 8px 10px 80px; }

/* ===== ヘッダー ===== */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: #fff; border-radius: 10px;
  padding: 10px 12px; margin-bottom: 10px;
  box-shadow: 0 1px 6px rgba(0,0,0,.08);
}
.brand { margin-bottom: 8px; }
.brand-logo-wrap { display: flex; align-items: center; gap: 10px; }
.brand-logo-svg { width: 52px; height: auto; flex-shrink: 0; }
.brand-name-wrap { display: flex; flex-direction: column; gap: 1px; }
.brand-company-ja { font-size: 17px; font-weight: 700; color: #1e293b; letter-spacing: 0.5px; font-family: "Hiragino Mincho ProN","Yu Mincho",serif; }
.brand-kabu { font-size: 10px; vertical-align: super; margin-right: 1px; }
.brand-sub-en { font-size: 11px; color: #64748b; font-weight: 500; }
.selectors { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.sel { display: flex; flex-direction: column; font-size: 12px; color: #64748b; gap: 3px; }
.sel select, .sel input {
  font-size: 16px; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; min-height: 42px;
}

/* ===== レイアウト ===== */
.layout { display: grid; grid-template-columns: 1fr 280px; gap: 10px; }

/* ===== 訪問先テーブル ===== */
.visits-pane { background: #fff; border-radius: 10px; padding: 6px; overflow-x: auto;
  box-shadow: 0 1px 6px rgba(0,0,0,.06); }
table.visits { width: 100%; border-collapse: collapse; min-width: 560px; }
table.visits thead th {
  background: var(--blue); color: #fff; font-size: 12px; font-weight: 600;
  padding: 8px 4px; position: sticky; top: 0;
}
table.visits td { border-bottom: 1px solid #eef2f7; padding: 3px; }
.c-hide { width: 28px; text-align: center; }
.hide-btn { background: none; border: 1px solid #cbd5e1; border-radius: 4px; width: 22px; height: 22px; cursor: pointer; font-size: 14px; line-height: 1; color: #94a3b8; padding: 0; }
.hide-btn:hover { background: #f1f5f9; color: #475569; }
tr.row-hidden td:not(.c-hide) { display: none; }
tr.row-hidden { opacity: 0.4; }
/* 日付・曜日 統合枠 */
.date-wd-wrap {
  display: flex !important; align-items: center;
  border: 1px solid var(--line); border-radius: 8px;
  overflow: hidden; background: #fff;
}
.date-wd-wrap input[type="date"] {
  flex: 1; border: none !important; border-right: 1px solid var(--line) !important;
  border-radius: 0 !important; background: transparent !important; min-height: 42px;
  font-size: 16px; padding: 8px 10px; box-shadow: none !important;
}
.weekday-badge {
  display: flex; align-items: center; justify-content: center;
  padding: 0 14px; font-size: 16px; font-weight: 700;
  color: var(--blue); background: #f1f5f9;
  border-left: 1px solid var(--line);
  min-height: 42px; white-space: nowrap;
}
.c-no { width: 34px; } .c-clinic { width: 110px; } .c-result { width: 92px; }
.c-time { width: 64px; }
table.visits .rowno { text-align: center; color: #94a3b8; font-size: 13px; }
table.visits input, table.visits select {
  width: 100%; border: 1px solid var(--line); border-radius: 6px;
  padding: 9px 7px; font-size: 16px; background: #fff; min-height: 40px;
}
table.visits input:focus, table.visits select:focus { outline: 2px solid var(--blue); border-color: var(--blue); }
tr.r-採用 { background: var(--result-adopt); }
tr.r-不採用 { background: var(--result-reject); }
tr.r-検討 { background: var(--result-consider); }
tr.r-他商品 { background: var(--result-other); }

/* ===== 売上パネル ===== */
.sales-pane { background: #fff; border-radius: 10px; padding: 12px;
  box-shadow: 0 1px 6px rgba(0,0,0,.06); align-self: start; }
.sales-pane h2 { font-size: 14px; margin: 4px 0 10px; color: var(--blue); border-bottom: 2px solid #e2e8f0; padding-bottom: 5px; }
.field { margin-bottom: 10px; }
.field > label { display: block; font-size: 12px; color: #64748b; margin-bottom: 3px; }
.field input { width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 16px; min-height: 44px; }
.field.highlight input.big { font-size: 20px; font-weight: 700; text-align: right; color: #1e293b; }
.num { text-align: right; }
.field.two { display: flex; gap: 8px; }
.field.two > div { flex: 1; }
.diff { font-size: 18px; font-weight: 700; text-align: center; padding: 8px; background: #f8fafc; border-radius: 8px; }
.diff.plus { color: var(--green); } .diff.minus { color: #d32f2f; }
.sales-pane hr { border: none; border-top: 1px solid #e2e8f0; margin: 14px 0; }

/* ===== フッター入力 ===== */
.footer-inputs { display: flex; flex-wrap: wrap; gap: 10px; background: #fff;
  border-radius: 10px; padding: 12px; margin-top: 10px; box-shadow: 0 1px 6px rgba(0,0,0,.06); }
.footer-inputs .field { margin: 0; min-width: 130px; }
.footer-inputs .field.grow { flex: 1; min-width: 200px; }
.sec-title { width: 100%; font-size: 14px; font-weight: 700; color: var(--blue);
  margin: 0 0 4px; border-bottom: 2px solid #e2e8f0; padding-bottom: 5px; }

/* ===== ボタンバー ===== */
.actionbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  background: rgba(255,255,255,.96); backdrop-filter: blur(6px);
  padding: 8px 12px; box-shadow: 0 -2px 10px rgba(0,0,0,.1); }
.actionbar .spacer { flex: 1; }
.btn { font-size: 16px; font-weight: 600; padding: 12px 18px; border: none;
  border-radius: 8px; cursor: pointer; min-height: 48px; }
.btn-sub { background: #eceff3; color: #334155; border: 1px solid #d6dde6; }
.btn-sub:active { background: #d6dde6; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:active { background: var(--blue-d); }
.btn-pdf { background: #fff; color: var(--blue); border: 1px solid #94a3b8; }
.btn-pdf:active { background: #e2e8f0; }

.status-msg { position: fixed; bottom: 78px; left: 50%; transform: translateX(-50%);
  background: #334155; color: #fff; padding: 10px 18px; border-radius: 20px;
  font-size: 14px; opacity: 0; transition: opacity .3s; pointer-events: none; z-index: 40; }
.status-msg.show { opacity: 1; }

/* ===== スマホ対応 ===== */
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sales-pane { order: -1; }
  .brand { font-size: 16px; }
  table.visits { min-width: 520px; }
}

/* ===== 行追加ボタン ===== */
.addrow { margin: 8px 6px 0; }

/* ===== ログイン前はアプリ本体を隠す（auth.js がログイン完了時に解除）===== */
body.auth-pending #app,
body.auth-pending #mgr-app { visibility: hidden; }

/* ===== ログイン画面 ===== */
#loginOverlay {
  align-items: flex-start !important;
  padding-top: 60px;
}
.login-box {
  background: #fff; border-radius: 12px; padding: 32px;
  width: min(92vw, 380px);
  box-shadow: 0 4px 24px rgba(0,0,0,.08);
}
.login-box h1 { font-size: 20px; margin: 0; color: var(--blue); text-align: center; }
.login-sub { text-align: center; margin: 4px 0 24px; color: #64748b; font-size: 13px; }
.login-box label { display: block; margin-bottom: 14px; font-weight: 600; font-size: 14px; }
.login-box select, .login-box input {
  width: 100%; margin-top: 4px; padding: 10px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 8px; font-weight: 400;
}
.login-note { font-size: 12px; color: #94a3b8; margin: 14px 0 0; line-height: 1.6; }
.login-btn { width: 100%; margin-top: 4px; }

/* ===== 設定モーダル ===== */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center;
  justify-content: center; background: rgba(0,0,0,.45); padding: 16px; }
.modal.hidden { display: none; }
.modal-box { background: #fff; border-radius: 14px; padding: 20px; width: min(92vw, 420px);
  max-height: 88vh; overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.modal-box h2 { font-size: 17px; margin: 0 0 4px; color: var(--blue); }
.set-staff { font-size: 14px; color: #475569; font-weight: 600; }
.modal-note { font-size: 12px; color: #94a3b8; margin: 0 0 14px; }
.modal-box .field { margin-bottom: 12px; }
.modal-box .field input { width: 100%; padding: 11px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 16px; min-height: 44px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* ===== 使い方ガイド ===== */
.help-section { margin-bottom: 18px; }
.help-section h3 { font-size: 15px; color: var(--blue); margin: 0 0 8px;
  border-bottom: 2px solid #e2e8f0; padding-bottom: 5px; }
.help-list { margin: 0; padding-left: 20px; font-size: 13.5px; line-height: 1.7; color: #334155; }
.help-list li { margin-bottom: 8px; }
.help-list strong { color: #1e293b; }
.help-warn { color: #d32f2f; font-size: 12.5px; }
.help-tip  { color: #64748b; font-size: 12.5px; }

/* ===== 印刷用：営業日報 A4縦 ===== */
#printArea { display: none; }

@media print {
  @page { size: A4 portrait; margin: 8mm; }
  body { background: #fff; }
  #app { display: none !important; }
  .modal { display: none !important; }
  #printArea { display: block !important; }

  .sheet { font-family: "Hiragino Mincho ProN", "Yu Mincho", serif; color: #000; padding-left: 7mm; }
  .ptitle { text-align: center; font-weight: 700; font-size: 14pt; padding: 2mm 0 1.5mm;
            font-family: "Hiragino Kaku Gothic ProN", sans-serif; }

  table.pmain, table.pftr, table.psum {
    width: 187mm; border-collapse: collapse; table-layout: fixed; font-size: 7.5pt;
  }
  table.pmain td, table.pftr td, table.psum td {
    border: 0.4pt solid #000; padding: 0.4mm 1mm; vertical-align: middle;
    overflow: hidden; word-break: break-all; line-height: 1.25;
  }
  table.pmain { border: 0.8pt solid #000; }
  .pmain .prow-hdr td { height: 6.5mm; background: #F2F2F2; }
  .pmain .pcolhdr td  { height: 6mm; background: #D9D9D9; }
  .pmain tr td.rhdr   { background: #BFBFBF; }
  .pmain td.lbl       { background: #F2F2F2; }
  /* データ行 */
  .pmain .pno  { text-align: center; white-space: nowrap; padding: 0.4mm 0.3mm; }
  .pmain td.blank { border: none !important; background: #fff; }
  .pmain .pmk  { text-align: center; font-family: sans-serif; font-weight: 700; }
  .pmain .ptm  { text-align: center; }
  .pmain .prv  { text-align: right; }
  .pmain tr:nth-child(n+4) td { height: 5.2mm; }
  .b   { font-weight: 700; font-family: "Hiragino Kaku Gothic ProN", sans-serif; }
  .ctr { text-align: center; }
  .rgt { text-align: right; }

  table.pftr { margin-top: 1mm; }
  table.pftr td { height: 5.5mm; padding-left: 4mm; }

  table.psum { margin-top: 1mm; }
  table.psum td { height: 5.5mm; }
  table.psum td.lbl { background: #F2F2F2; font-weight: 700; }

  .pmemo-box { width: 187mm; border: 0.8pt solid #000; box-sizing: border-box;
               margin-top: 1mm; min-height: 9mm; padding: 2mm 4mm; font-size: 7.5pt; }

  /* 月間：出勤簿・運転日報 */
  .monthly-sheet { padding: 0 10mm; }
  .m-head { display: flex; justify-content: space-between; font-size: 9pt; margin: 1mm 0 2mm; }
  .m-table { width: 100%; border-collapse: collapse; font-size: 8pt; border: 0.8pt solid #000; }
  .m-table td { border: 0.4pt solid #000; padding: 0.5mm 1mm; text-align: center; height: 5.6mm; }
  .m-table tr.hd td { background: #D9D9D9; font-weight: 700; }
  .m-table tr.ft td { font-weight: 700; background: #F2F2F2; }
  .m-table tr.wend td { background: #f3f4f6; }
  .v-info { border-collapse: collapse; font-size: 8.5pt; margin-bottom: 2mm; }
  .v-info td { border: 0.4pt solid #000; padding: 1mm 3mm; }
  .v-info td.k, .v-info td.k2 { background: #D9D9D9; font-weight: 700; }
}
