/* 契約者管理画面・ログイン画面 */
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, system-ui, sans-serif;
  background: #f3f4f6;
  color: #1f2937;
  font-size: 15px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  background: #111827;
  color: #fff;
  padding: 0 20px;
  height: 52px;
}
.topbar .brand { color: #fff; font-weight: bold; text-decoration: none; font-size: 17px; }
.topbar nav { display: flex; gap: 16px; flex: 1; }
.topbar nav a { color: #d1d5db; text-decoration: none; padding: 4px 0; }
.topbar nav a:hover { color: #fff; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.account-name { color: #9ca3af; font-size: 13px; }
.member-badge { margin-left: 8px; vertical-align: 1px; }
.topbar-right select { background: #1f2937; color: #e5e7eb; border: 1px solid #374151; border-radius: 4px; padding: 4px 8px; font-size: 12px; }

.container { max-width: 1400px; margin: 0 auto; padding: 24px 16px 64px; }
h1 { font-size: 22px; margin: 8px 0 16px; }
h2 { font-size: 16px; margin: 20px 0 8px; }
.breadcrumbs { font-size: 13px; }
.breadcrumbs a { color: #2563eb; text-decoration: none; }

.card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 16px;
}
.card h2:first-child { margin-top: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }

.notice {
  background: #ecfdf5;
  border: 1px solid #6ee7b7;
  color: #065f46;
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 12px;
}
.error {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #991b1b;
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 12px;
}
.hint { color: #6b7280; font-size: 13px; }
.sub { color: #6b7280; font-size: 12px; }
.empty { color: #6b7280; text-align: center; padding: 24px !important; }

.contract-ok { color: #047857; font-weight: bold; }
.contract-ng { color: #b91c1c; font-weight: bold; }

.btn {
  display: inline-block;
  border: 1px solid #d1d5db;
  background: #fff;
  color: #1f2937;
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: #f9fafb; }
.btn-primary { background: #2563eb; border-color: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-primary:disabled { background: #9ca3af; border-color: #9ca3af; cursor: not-allowed; }
.btn-warn { background: #dc2626; border-color: #dc2626; color: #fff; }
.btn-ghost { background: transparent; border-color: #4b5563; color: #d1d5db; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn:disabled { background: #f3f4f6; border-color: #e5e7eb; color: #9ca3af; cursor: not-allowed; }
/* 一覧の操作ボタンは文字数が違っても幅を揃える */
.col-actions .btn { min-width: 84px; text-align: center; }

.billing-notice {
  background: #fffbeb;
  border: 1.5px solid #f59e0b;
  color: #92400e;
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-weight: 600;
}
.billing-notice a { color: #b45309; margin-left: 8px; }

.status-filter { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; padding: 10px 14px; }
.filter-label { font-size: 13px; color: #374151; font-weight: bold; }
.filter-check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.filter-check input { cursor: pointer; }

.status-counts { display: flex; gap: 16px; flex-wrap: wrap; margin: 10px 0 14px; }
.status-count { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.btn-block { width: 100%; }
.inline-form { display: inline-block; margin: 0; }
.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.status-line { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

.btn-danger { background: #fff; border-color: #fca5a5; color: #b91c1c; }
.btn-danger:hover { background: #fef2f2; }

/* 確認ダイアログ */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.confirm-dialog {
  background: #fff;
  border-radius: 12px;
  padding: 24px 28px;
  width: min(420px, calc(100vw - 32px));
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}
.confirm-message { margin: 0 0 20px; white-space: pre-wrap; line-height: 1.7; }
.confirm-buttons { display: flex; justify-content: flex-end; gap: 10px; }
.confirm-buttons .btn-danger { background: #dc2626; border-color: #dc2626; color: #fff; }
.confirm-buttons .btn-danger:hover { background: #b91c1c; }

.badge { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: bold; }
.badge-draft { background: #f3f4f6; color: #374151; border: 1px solid #d1d5db; }
.badge-published { background: #dcfce7; color: #166534; }
.badge-closed { background: #fee2e2; color: #991b1b; }
.badge-warn { background: #fef3c7; color: #92400e; }

/* ダッシュボード俯瞰カレンダー(週単位・6ヶ月×2段) */
.overview-cal .hint { margin-top: -4px; margin-bottom: 12px; }
.cal-band {
  position: relative;
  display: grid;
  column-gap: 0;
  row-gap: 2px;
  margin-bottom: 20px;
  overflow-x: auto;
}
.cal-band:last-child { margin-bottom: 0; }
.cal-month { font-size: 11px; color: #9ca3af; border-left: 1px solid #f1f5f9; padding-left: 3px; align-self: end; }
.cal-label {
  font-size: 12px;
  padding-right: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  align-self: center;
}
.cal-label a { color: #374151; text-decoration: none; }
.cal-label a:hover { color: #2563eb; text-decoration: underline; }
.cal-bar { border-radius: 4px; height: 16px; align-self: center; margin: 0 1px; }
.cal-bar-published { background: #4ade80; }
.cal-bar-closed { background: #d1d5db; }
.cal-empty { font-size: 12px; color: #9ca3af; align-self: center; }
.cal-today { border-left: 2px solid #ef4444; pointer-events: none; }

/* 応募状況 */
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-tile { background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; padding: 14px 16px; }
.stat-label { font-size: 12px; color: #6b7280; }
.stat-value { font-size: 28px; font-weight: bold; margin-top: 2px; }
.chart { width: 100%; height: auto; display: block; }
.chart .bar:hover { opacity: 0.75; }
.pie-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.pie-wrap .pie-chart { width: 180px; flex: 0 0 auto; }
.pie-legend { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 160px; }
.pie-legend li { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 13px; }
.legend-chip { width: 12px; height: 12px; border-radius: 3px; flex: 0 0 auto; }
.legend-label { color: #374151; }
.legend-value { color: #6b7280; margin-left: auto; font-variant-numeric: tabular-nums; }
.breakdown-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.breakdown-grid .card { margin-bottom: 0; }
.breakdown-grid { margin-bottom: 16px; }

.detail-table { width: 100%; border-collapse: collapse; }
.detail-table th, .detail-table td { padding: 9px 8px; border-bottom: 1px solid #e5e7eb; text-align: left; vertical-align: top; }
.detail-table th { width: 220px; font-size: 13px; color: #374151; }
.receipt-grid { display: flex; gap: 16px; flex-wrap: wrap; }
.receipt-grid figure { margin: 0; }
.receipt-grid img { max-width: 220px; max-height: 300px; border: 1px solid #e5e7eb; border-radius: 8px; object-fit: contain; background: #fafafa; }
.pager { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; align-items: center; }
.pager a, .pager-current, .pager-disabled { padding: 4px 10px; border-radius: 6px; text-decoration: none; border: 1px solid #d1d5db; color: #2563eb; }
.pager-current { background: #2563eb; color: #fff; border-color: #2563eb; }
.pager-disabled { color: #9ca3af; border-color: #e5e7eb; }
.pager-ellipsis { color: #9ca3af; padding: 4px 2px; }

/* 公開URLのコピー */
.url-box {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: #eff6ff;
  border: 1.5px solid #93c5fd;
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
}
.url-label { font-size: 12px; font-weight: bold; color: #1d4ed8; white-space: nowrap; }
.url-text { font-size: 14px; background: #fff; border: 1px solid #bfdbfe; border-radius: 6px; padding: 6px 12px; overflow-wrap: anywhere; flex: 1; min-width: 200px; }
.btn-copy { background: #2563eb; border-color: #2563eb; color: #fff; font-weight: bold; white-space: nowrap; }
.btn-copy:hover { background: #1d4ed8; }
.btn-copy.copied, .copy-mini.copied { background: #16a34a; border-color: #16a34a; color: #fff; }
.copy-mini {
  border: 1px solid #d1d5db;
  background: #fff;
  border-radius: 4px;
  font-size: 12px;
  padding: 0 6px;
  cursor: pointer;
  color: #2563eb;
  vertical-align: 1px;
}
.copy-mini:hover { background: #eff6ff; }

/* デザイン編集の画像グリッド */
.visual-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.visual-box { border: 1px solid #e5e7eb; border-radius: 8px; padding: 12px; }
.visual-box h3 { font-size: 13px; margin: 0 0 8px; color: #374151; }
.visual-box .inline-form { display: block; margin-top: 8px; }

.table-wrap { overflow-x: auto; background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; }
.list-table { width: 100%; border-collapse: collapse; background: #fff; }
.list-table th, .list-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #e5e7eb; vertical-align: top; }
.list-table tr:last-child td { border-bottom: none; }
.list-table th { background: #f9fafb; font-size: 13px; color: #374151; white-space: nowrap; }
.list-table a { color: #2563eb; text-decoration: none; font-weight: bold; }
.list-table .col-status { white-space: nowrap; }
.list-table .col-date { white-space: nowrap; }
.list-table .col-period { min-width: 150px; font-size: 13px; }
.list-table .col-period .period { display: inline-block; white-space: nowrap; }
.list-table .col-period .period-sep { margin: 0 2px; color: #9ca3af; }
.list-table .col-actions .row-actions { margin-top: 0; flex-wrap: nowrap; }
.badge { white-space: nowrap; }

@media (max-width: 720px) {
  .list-table .col-period .period { display: block; }
  .list-table .col-period .period-sep { display: none; }
  .list-table .col-actions .row-actions { flex-wrap: wrap; }
  .container { padding: 16px 10px 48px; }
}

.create-form { display: flex; gap: 8px; flex-wrap: wrap; }
.create-form input { flex: 1; min-width: 200px; }

.settings-form label { display: block; margin: 10px 0; font-size: 14px; }
.inline-check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.inline-check input[type="checkbox"] { margin: 0; }
.inline-check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.inline-check input[type="checkbox"] { margin: 0; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="tel"], input[type="datetime-local"], select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  margin-top: 4px;
  background: #fff;
}
textarea { resize: vertical; }
.period-inputs { display: flex; gap: 8px; align-items: center; }
.period-inputs input { width: auto; flex: 1; }

.color-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.color-grid label { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 6px; padding: 8px 12px; }
.color-grid input[type="color"] { width: 44px; height: 30px; padding: 0; border: 1px solid #d1d5db; border-radius: 4px; margin: 0; }

.fields-table { width: 100%; border-collapse: collapse; }
.fields-table th, .fields-table td { padding: 6px 8px; border-bottom: 1px solid #e5e7eb; text-align: left; vertical-align: top; }
.fields-table th { font-size: 12px; color: #6b7280; }
.fields-table textarea { min-width: 160px; }
.fields-table tr.dragging { opacity: 0.4; background: #eff6ff; }
.drag-cell { width: 28px; }
.drag-handle { cursor: grab; color: #9ca3af; font-size: 18px; user-select: none; }
.drag-handle:hover { color: #374151; }

th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { background: #f3f4f6; }
th.sortable::after { content: ' ↕'; color: #c4c8cf; font-size: 11px; }
th.sortable[data-sort-dir="asc"]::after { content: ' ▲'; color: #2563eb; }
th.sortable[data-sort-dir="desc"]::after { content: ' ▼'; color: #2563eb; }

.visual-thumb { max-width: 100%; max-height: 240px; border: 1px solid #e5e7eb; border-radius: 6px; display: block; margin-bottom: 10px; }

/* ログイン */
body.plain { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box { background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 32px; width: 360px; }
.login-box h1 { margin: 0; text-align: center; }
.login-sub { text-align: center; color: #6b7280; font-size: 13px; margin-top: 4px; }
.login-box label { display: block; margin: 12px 0; font-size: 14px; }
.login-box button { margin-top: 8px; }
.login-alt { text-align: center; font-size: 13px; color: #6b7280; margin-top: 16px; }
.login-alt a { color: #2563eb; }

/* オーナー管理画面(契約者画面と区別する配色) */
.topbar-owner { background: #4c1d95; }
.topbar-owner .btn-ghost { border-color: #a78bfa; color: #ede9fe; }

/* 危険操作 */
.danger-card { border-color: #fca5a5; }
.danger-card h2 { color: #b91c1c; }
.danger-text { color: #991b1b; }

/* プラン */
.plan-box { border: 1.5px solid #e5e7eb; border-radius: 10px; padding: 16px 20px; margin: 12px 0; }
.plan-box h3 { margin: 0 0 4px; }
.plan-prices { margin: 8px 0 12px; padding-left: 20px; font-size: 14px; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 4px 16px; }
.invoice-total { margin-left: auto; font-size: 18px; }
.card-check-section { border-top: 1px solid #e5e7eb; margin-top: 16px; padding-top: 8px; }
.card-check-section label { display: block; max-width: 420px; font-size: 14px; margin: 8px 0 12px; }
.badge-outlier { background: #ede9fe; color: #5b21b6; }
