/* ベストナー作業報告 v2 — デジタル庁ダッシュボードガイドライン準拠のBlue系 */
:root {
  --primary: #3460FB;
  --primary-dark: #0017C1;
  --bg: #F8F8FB;
  --control: #F1F1F4;
  --text: #1A1A1C;
  --label: #626264;
  --line: #D8D8DB;
  --success: #197A4B;
  --error: #CE0000;
  --white: #fff;
  --nav-bg: #171C36;
  --radius: 6px;
  --appbar-h: 52px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "BIZ UDPGothic", "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.6;
}
a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- app chrome ---------- */
.appbar {
  display: none; position: fixed; top: 0; left: 0; right: 0; height: var(--appbar-h);
  background: var(--nav-bg); color: #fff; z-index: 40;
  align-items: center; gap: 12px; padding: 0 12px;
}
.appbar-title { font-weight: 700; font-size: 15px; flex: 1; }
.appbar-user { font-size: 13px; opacity: .85; }
.appbar-menu {
  width: 40px; height: 40px; background: none; border: 0; cursor: pointer;
  display: flex; flex-direction: column; justify-content: center; gap: 5px; align-items: center;
}
.appbar-menu span { display: block; width: 20px; height: 2px; background: #fff; }

.layout { display: flex; min-height: 100vh; }
.sidenav {
  width: 220px; background: var(--nav-bg); color: #fff; flex-shrink: 0;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidenav-brand { font-weight: 700; font-size: 17px; line-height: 1.4; padding: 20px 18px 16px; }
.sidenav ul { list-style: none; flex: 1; }
.sidenav li a {
  display: block; padding: 12px 18px; color: #E6E8F5; font-size: 14px;
  border-left: 3px solid transparent;
}
.sidenav li a:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.sidenav li.active a { background: rgba(52,96,251,.25); border-left-color: var(--primary); color: #fff; font-weight: 700; }
.sidenav-foot { padding: 14px 18px 18px; border-top: 1px solid rgba(255,255,255,.15); font-size: 13px; }
.sidenav-user { font-weight: 700; margin-bottom: 8px; }
.sidenav-link { display: block; color: #C3C8E0; padding: 4px 0; }
.sidenav-logout { display: block; margin-top: 10px; text-align: center; background: rgba(255,255,255,.12); color: #fff; padding: 8px; border-radius: var(--radius); }
.sidenav-logout:hover { background: rgba(255,255,255,.2); text-decoration: none; }
.backdrop { display: none; }

.main { flex: 1; padding: 24px 28px 120px; max-width: 1080px; }
.main-noauth { max-width: none; padding: 0; }

/* ---------- common ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; }
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.card-title { font-size: 15px; font-weight: 700; color: var(--label); border-bottom: 1px solid var(--line); padding-bottom: 8px; margin-bottom: 16px; }

.flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-weight: 600; border: 1px solid; }
.flash-ok { background: #EEF7F2; color: var(--success); border-color: #BEE0CE; }
.flash-error { background: #FCEEEE; color: var(--error); border-color: #F2C4C4; }
.flash-info { background: #EEF2FE; color: var(--primary-dark); border-color: #C9D4FA; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 18px; border-radius: var(--radius);
  font-size: 15px; font-weight: 700; font-family: inherit; cursor: pointer;
  border: 1px solid transparent; text-decoration: none !important; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #fff; color: var(--primary-dark); border-color: var(--primary); }
.btn-secondary:hover { background: #EEF2FE; }
.btn-green { background: var(--success); color: #fff; }
.btn-green:hover { background: #135E3A; }
.btn-ghost { background: var(--control); color: var(--text); }
.btn-ghost:hover { background: #E4E4E9; }
.btn-danger-ghost { background: #fff; color: var(--error); border-color: var(--error); }
.btn-danger-ghost:hover { background: #FCEEEE; }
.btn-small { min-height: 34px; padding: 4px 12px; font-size: 13px; }
.btn-lg { min-height: 52px; padding: 12px 40px; font-size: 17px; }
.btn-block { width: 100%; }

/* form fields */
.field { display: block; margin-bottom: 16px; }
.field-label { display: block; font-size: 13px; font-weight: 700; color: var(--label); margin-bottom: 6px; }
.req { font-style: normal; color: var(--error); font-size: 11px; border: 1px solid var(--error); border-radius: 3px; padding: 0 4px; margin-left: 6px; vertical-align: 1px; }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=search],
input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; font-size: 16px; font-family: inherit; color: var(--text);
  padding: 10px 12px; border: 1px solid #9E9EA3; border-radius: var(--radius); background: #fff;
  min-height: 44px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: var(--primary); }
.field-narrow { max-width: 260px; }
.field-note { font-size: 12.5px; color: var(--label); margin-top: 4px; }
.field-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-narrow { max-width: 640px; }
.form-actions { display: flex; gap: 12px; margin-top: 8px; flex-wrap: wrap; }
.check { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; white-space: nowrap; }
.inline-form { display: inline; }
.inline-input { min-height: 38px; padding: 6px 10px; font-size: 15px; width: auto; max-width: 280px; }
.inline-price { width: 110px; text-align: right; }
.inline-mail { width: 230px; }

/* segmented radio */
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg-item input { position: absolute; opacity: 0; }
.seg-item span {
  display: inline-flex; align-items: center; min-height: 44px; padding: 6px 18px;
  border: 1px solid #9E9EA3; border-radius: 22px; background: #fff; cursor: pointer; font-size: 15px;
}
.seg-item input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }
.seg-item input:focus-visible + span { outline: 2px solid var(--primary-dark); }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: var(--bg); }
.login-card { width: 100%; max-width: 380px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 32px 28px; }
.login-brand { font-size: 22px; font-weight: 700; text-align: center; margin-bottom: 24px; }
.login-brand span { display: block; font-size: 13px; color: var(--label); font-weight: 400; margin-top: 2px; }

/* ---------- report form ---------- */
.report-form { max-width: 760px; }
.cust-row { display: flex; gap: 8px; }
.cust-row input { flex: 1; }
.history-panel { margin-top: 10px; border: 1px solid #C9D4FA; background: #F5F7FE; border-radius: var(--radius); padding: 10px 14px; }
.history-head { font-size: 12.5px; font-weight: 700; color: var(--primary-dark); margin-bottom: 6px; }
.history-list { list-style: none; font-size: 13px; }
.history-list li { padding: 3px 0; border-top: 1px dashed #C9D4FA; }
.history-list li:first-child { border-top: 0; }
.history-list .hl-date { color: var(--label); margin-right: 8px; }
.history-list a { font-weight: 600; }

.item-row {
  display: grid; grid-template-columns: 1fr 90px 120px 110px 40px;
  gap: 8px; align-items: end; padding: 10px 0; border-bottom: 1px dashed var(--line);
}
.mini-label { display: block; font-size: 11.5px; color: var(--label); margin-bottom: 3px; }
.ir-amount { text-align: right; font-weight: 700; padding-bottom: 10px; white-space: nowrap; }
.ir-amountView { margin-right: 2px; }
.ir-del {
  width: 40px; height: 44px; border: 1px solid var(--line); background: #fff; color: var(--error);
  border-radius: var(--radius); font-size: 20px; cursor: pointer;
}
.ir-del:hover { background: #FCEEEE; }
#addItemRow { margin-top: 12px; }

.fee-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.totals { margin-top: 8px; text-align: right; line-height: 2; border-top: 1px solid var(--line); padding-top: 10px; }
.totals span { color: var(--label); margin-right: 14px; font-size: 14px; }
.totals strong { font-size: 17px; min-width: 110px; display: inline-block; }
.totals-grand strong { font-size: 22px; color: var(--primary-dark); }

.sign-box { border: 2px solid #9E9EA3; border-radius: var(--radius); background: #fff; overflow: hidden; }
#signPad { display: block; width: 100%; height: 160px; touch-action: none; background: #fff; }
.sign-actions { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-top: 1px dashed var(--line); background: var(--control); }
.sign-hint { font-size: 12.5px; color: var(--label); }
.sign-view { max-width: 300px; border: 1px solid var(--line); border-radius: var(--radius); }

.savebar {
  position: fixed; bottom: 0; left: 220px; right: 0; z-index: 30;
  background: #fff; border-top: 2px solid var(--primary);
  display: flex; align-items: center; justify-content: flex-end; gap: 20px; padding: 10px 28px;
}
.savebar-total { font-size: 14px; color: var(--label); }
.savebar-total strong { font-size: 20px; color: var(--primary-dark); margin-left: 6px; }

.draftbar {
  background: #FFF6DE; border: 1px solid #E0C36B; border-radius: var(--radius);
  padding: 10px 16px; margin-bottom: 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.draftbar[hidden] { display: none; }

/* ---------- lists ---------- */
.filterbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.filter-q { flex: 1; min-width: 200px; max-width: 380px; }
.filterbar select, .filterbar input[type=date] { width: auto; }
.filter-tilde { color: var(--label); }
.filter-note { font-size: 13px; margin-bottom: 8px; color: var(--label); }
.list-count { font-size: 13px; color: var(--label); margin-bottom: 8px; }

.report-table-wrap { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.report-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.report-table th {
  text-align: left; font-size: 12.5px; color: var(--label); font-weight: 700;
  padding: 10px 12px; border-bottom: 2px solid var(--line); background: var(--control); white-space: nowrap;
}
.report-table td { padding: 10px 12px; border-bottom: 1px solid #ECECEF; vertical-align: middle; }
.report-table tbody tr:hover { background: #F5F7FE; }
.rowlink { cursor: pointer; }
.row-inactive { opacity: .55; }
.report-no { font-weight: 700; }
.td-sub { font-size: 12px; color: var(--label); }
.td-cust { font-weight: 600; }
.ta-r { text-align: right; }
.ta-c { text-align: center; }
.td-badges { white-space: nowrap; }
.td-actions { white-space: nowrap; display: flex; gap: 6px; align-items: center; }
.badge {
  display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 8px;
  border-radius: 10px; background: var(--control); color: var(--label); margin-right: 4px;
}
.badge-blue { background: #E3EAFE; color: var(--primary-dark); }
.badge-green { background: #E3F2EA; color: var(--success); }

.pager { display: flex; align-items: center; gap: 14px; justify-content: center; margin: 18px 0; }
.pager-btn { background: #fff; border: 1px solid var(--primary); color: var(--primary-dark); padding: 8px 20px; border-radius: var(--radius); font-weight: 700; }
.pager-info { font-size: 13px; color: var(--label); }

/* ---------- detail ---------- */
.actionbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.meta-row { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--label); margin-bottom: 14px; align-items: center; }
.detail-table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.detail-table th {
  width: 140px; text-align: left; color: var(--label); font-size: 13px; font-weight: 700;
  padding: 9px 10px 9px 0; vertical-align: top; border-bottom: 1px solid #ECECEF;
}
.detail-table td { padding: 9px 0; border-bottom: 1px solid #ECECEF; }
.detail-cust { font-size: 17px; font-weight: 700; }
.link-small { font-size: 12.5px; font-weight: 400; margin-left: 10px; }
.items-table { width: 100%; border-collapse: collapse; font-size: 14px; margin-bottom: 14px; }
.items-table th { background: var(--control); font-size: 12.5px; color: var(--label); text-align: left; padding: 8px 10px; border: 1px solid var(--line); }
.items-table td { padding: 8px 10px; border: 1px solid var(--line); }
.fees-table { width: 100%; max-width: 420px; margin-left: auto; border-collapse: collapse; font-size: 14.5px; }
.fees-table th { text-align: left; font-weight: 400; color: var(--label); padding: 6px 0; }
.fees-table td { padding: 6px 0; }
.fees-sub th, .fees-sub td { border-top: 1px solid var(--line); font-weight: 700; }
.fees-total th, .fees-total td { border-top: 2px solid var(--text); font-weight: 700; font-size: 18px; color: var(--primary-dark); }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(23,28,54,.55); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-card { background: #fff; border-radius: 8px; width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; padding: 22px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-head h2 { font-size: 17px; }
.modal-close { background: none; border: 0; font-size: 26px; line-height: 1; cursor: pointer; color: var(--label); padding: 4px 8px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

/* ---------- items page ---------- */
.newitem-row { display: grid; grid-template-columns: 1fr 140px; gap: 8px; margin-bottom: 8px; max-width: 520px; }
.postal-row { display: flex; align-items: center; gap: 6px; }
.postal-in { width: 70px; }
.postal-in4 { width: 84px; }
.user-add-grid { display: grid; grid-template-columns: 1fr 1fr 1.2fr 130px auto; gap: 12px; align-items: end; }

/* ---------- responsive ---------- */
@media (max-width: 1023px) {
  .appbar { display: flex; }
  .layout { display: block; }
  .sidenav {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 50; height: 100%;
    transform: translateX(-100%); transition: transform .2s ease; width: 250px;
  }
  .sidenav.open { transform: translateX(0); }
  .backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 45; }
  .backdrop.show { display: block; }
  .main { padding: calc(var(--appbar-h) + 16px) 16px 130px; }
  .savebar { left: 0; padding: 10px 16px; }
  .fee-grid { grid-template-columns: repeat(2, 1fr); }
  .user-add-grid { grid-template-columns: 1fr 1fr; }
  .item-row { grid-template-columns: 1fr 70px 100px 90px 36px; }
}
@media (max-width: 600px) {
  .field-grid2 { grid-template-columns: 1fr; gap: 0; }
  .item-row { grid-template-columns: 1fr 1fr 40px; }
  .ir-name { grid-column: 1 / -1; }
  .ir-amount { grid-column: 1 / 2; text-align: left; }
  .ir-del { justify-self: end; }
  .page-head h1 { font-size: 19px; }
  .actionbar .btn { flex: 1 1 45%; }
  #signPad { height: 140px; }
}
