:root {
  --color-bg: #f4f6f9;
  --color-surface: #ffffff;
  --color-primary: #1a56db;
  --color-primary-dark: #123a99;
  --color-text: #1f2937;
  --color-muted: #6b7280;
  --color-border: #e5e7eb;
  --color-mark-bg: #fde68a;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Hiragino Sans", "Yu Gothic", "Segoe UI", sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
}

[hidden] {
  display: none !important;
}

/* ---------- ログイン画面 ---------- */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-box {
  width: 100%;
  max-width: 380px;
  background: var(--color-surface);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 40px 32px;
}

.login-box h1 {
  font-size: 20px;
  margin: 0 0 4px;
  text-align: center;
}

.login-box .subtitle {
  text-align: center;
  color: var(--color-muted);
  font-size: 13px;
  margin: 0 0 28px;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--color-muted);
}

.field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 14px;
}

.field input:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}

.btn-primary {
  width: 100%;
  padding: 11px;
  border: none;
  border-radius: 8px;
  background: var(--color-primary);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
}

.btn-primary:hover {
  background: var(--color-primary-dark);
}

.error-message {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* ---------- ダッシュボード ---------- */

.app-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header h1 {
  font-size: 16px;
  margin: 0;
}

.app-header .header-sub {
  font-size: 12px;
  color: var(--color-muted);
  margin-top: 2px;
}

.btn-secondary {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  cursor: pointer;
  font-size: 13px;
}

.btn-secondary:hover {
  background: #f3f4f6;
}

.admin-tabs {
  max-width: 1080px;
  margin: 16px auto 0;
  padding: 0 24px;
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--color-border);
}

.tab-btn {
  padding: 10px 18px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--color-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab-btn.active {
  color: var(--color-primary);
  font-weight: 700;
  border-bottom-color: var(--color-primary);
}

.tab-btn:hover {
  color: var(--color-text);
}

.search-bar {
  max-width: 1080px;
  margin: 20px auto 0;
  padding: 0 24px;
}

.search-input-wrap {
  position: relative;
}

.search-bar input {
  width: 100%;
  padding: 12px 40px 12px 16px;
  font-size: 14px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-surface);
  box-shadow: var(--shadow);
}

.search-bar input:focus {
  outline: 2px solid var(--color-primary);
}

.search-clear-btn {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--color-muted);
  opacity: 0.5;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-clear-btn:hover {
  opacity: 0.9;
  background: #f3f4f6;
}

.search-summary {
  font-size: 13px;
  color: var(--color-muted);
  margin-top: 8px;
}

.cards-container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px 24px 60px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.upload-card {
  background: var(--color-surface);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.upload-card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.carrier-badge {
  background: #e8f0fe;
  color: var(--color-primary-dark);
  font-weight: 700;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
}

.upload-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--color-muted);
}

.table-wrap {
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
  white-space: nowrap;
}

thead th {
  text-align: left;
  background: #f9fafb;
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-muted);
  font-weight: 600;
  position: sticky;
  top: 0;
}

tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border);
}

tbody tr:hover {
  background: #f9fafb;
}

.row-partner-input-wrap {
  position: relative;
  display: inline-block;
}

.row-partner-input {
  min-width: 240px;
  padding: 6px 26px 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
  background: var(--color-surface);
}

.row-partner-clear-btn {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--color-muted);
  opacity: 0.5;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.row-partner-clear-btn:hover {
  opacity: 0.9;
  background: #f3f4f6;
}

mark {
  background: var(--color-mark-bg);
  color: inherit;
  padding: 0 2px;
  border-radius: 3px;
}

.empty-state {
  text-align: center;
  color: var(--color-muted);
  padding: 60px 20px;
  font-size: 14px;
}

.role-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.role-badge.role-admin {
  background: #fef3c7;
  color: #92400e;
}

.role-badge.role-partner {
  background: #dbeafe;
  color: #1e40af;
}

.card-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-csv,
.btn-delete {
  font-size: 12px;
  padding: 6px 12px;
}

.btn-delete {
  color: #b91c1c;
  border-color: #fecaca;
}

.btn-delete:hover {
  background: #fef2f2;
}

/* ---------- 管理者パネル ---------- */

.admin-panel {
  max-width: 1080px;
  margin: 20px 24px 0;
  padding: 20px 24px;
  background: var(--color-surface);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

@media (min-width: 1128px) {
  .admin-panel {
    margin-left: auto;
    margin-right: auto;
  }
}

.admin-panel h2 {
  font-size: 15px;
  margin: 0 0 16px;
}

.admin-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.admin-form-grid.three-col {
  grid-template-columns: 1fr 1fr 1fr;
  margin-bottom: 16px;
}

.admin-subsection h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-muted);
  margin: 0 0 12px;
}

.admin-divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 24px 0;
}

.admin-panel select,
.admin-panel input[type="text"],
.admin-panel input[type="file"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: var(--color-surface);
}

.field-hint {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--color-muted);
}

.upload-message {
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-top: 16px;
  margin-bottom: 12px;
}

.upload-message.success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.upload-message.error {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.upload-message.info {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

.admin-submit {
  width: auto;
  padding: 10px 24px;
}

.section-divider {
  max-width: 1080px;
  margin: 24px auto 0;
  padding: 0 24px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-muted);
}

.usage-table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* ---------- 利用状況レポート ---------- */

.usage-period-presets {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.usage-preset-btn {
  font-size: 12px;
  padding: 6px 12px;
}

.usage-period-label {
  margin-top: 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
}

.usage-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 8px;
}

.usage-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 140px;
  padding: 12px 16px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: #f9fafb;
}

.usage-stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-primary-dark);
}

.usage-stat-label {
  font-size: 12px;
  color: var(--color-muted);
}

/* ---------- 確認モーダル ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}

.modal-box {
  background: var(--color-surface);
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 900px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

#preview-modal .modal-box {
  max-width: 1400px;
  width: 95vw;
  max-height: 92vh;
}

.modal-box h2 {
  margin: 0 0 12px;
  font-size: 16px;
}

.modal-meta {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--color-muted);
  margin-bottom: 16px;
}

.modal-table-wrap {
  overflow: auto;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  flex: 1;
  min-height: 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 20px;
}

.modal-actions .btn-primary,
.modal-actions .btn-secondary {
  width: auto;
  padding: 10px 24px;
}
