*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f4f6f8;
  --bg2: #ffffff;
  --bg3: #f8f9fa;
  --border: #e2e5e9;
  --border2: #eceef1;
  --accent: #2563eb;
  --accent-dim: #1d4ed8;
  --accent-bg: #eff6ff;
  --text: #111827;
  --text-mid: #4b5563;
  --text-dim: #9ca3af;
  --green: #059669;
  --green-bg: #ecfdf5;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --orange: #d97706;
  --orange-bg: #fffbeb;
  --purple: #7c3aed;
  --purple-bg: #f5f3ff;
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

/* Header */
.header {
  background: var(--bg2);
  border-bottom: 2px solid var(--accent);
  padding: 0 24px;
  display: flex;
  align-items: center;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon {
  width: 34px; height: 34px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: white;
}
.logo-name { font-size: 15px; font-weight: 700; color: var(--text); letter-spacing: 0.02em; }
.logo-sub { font-size: 10px; color: var(--text-dim); margin-left: 4px; }

.header-right {
  margin-left: auto;
  display: flex; align-items: center; gap: 16px;
  font-size: 13px; color: var(--text-mid);
}

.header-right .user-name { font-weight: 600; color: var(--text); }

.btn-logout {
  background: none; border: 1px solid var(--border);
  padding: 4px 12px; border-radius: 4px;
  font-size: 12px; color: var(--text-mid);
  cursor: pointer; font-family: inherit;
}
.btn-logout:hover { background: var(--bg3); }

/* Main Container */
.container { max-width: 1200px; margin: 0 auto; padding: 24px; }
.container-narrow { max-width: 900px; margin: 0 auto; padding: 24px; }

/* Cards */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 12px;
}

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-size: 11px; letter-spacing: 0.12em; color: var(--text-dim);
  text-transform: uppercase; font-weight: 600;
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px; border-radius: 6px;
  font-size: 13px; font-weight: 500;
  cursor: pointer; font-family: inherit;
  border: 1px solid transparent;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--accent); color: white; border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-dim); }

.btn-secondary {
  background: var(--bg2); color: var(--text-mid); border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg3); }

.btn-success {
  background: var(--green); color: white; border-color: var(--green);
}
.btn-success:hover { opacity: 0.9; }

.btn-danger {
  background: var(--red); color: white; border-color: var(--red);
}
.btn-danger:hover { opacity: 0.9; }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { padding: 6px 8px; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Forms */
.form-group { margin-bottom: 14px; }

.form-label {
  display: block; font-size: 11px; font-weight: 600;
  color: var(--text-mid); margin-bottom: 4px;
  letter-spacing: 0.04em;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 5px;
  font-size: 13px; font-family: inherit;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent);
}

.form-textarea { resize: vertical; min-height: 60px; }
.form-input-sm { padding: 5px 8px; font-size: 12px; }

/* Table */
.table-wrap { overflow-x: auto; }

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

thead th {
  background: var(--bg3);
  padding: 8px 10px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border2);
  vertical-align: middle;
}

tbody tr:hover { background: var(--bg3); }

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-a { background: var(--green-bg); color: var(--green); }
.badge-b { background: var(--accent-bg); color: var(--accent); }
.badge-c { background: var(--orange-bg); color: var(--orange); }
.badge-d { background: var(--red-bg); color: var(--red); }
.badge-active { background: var(--accent-bg); color: var(--accent); }
.badge-completed { background: var(--green-bg); color: var(--green); }
.badge-ebay { background: var(--purple-bg); color: var(--purple); }
.badge-yahoo { background: var(--orange-bg); color: var(--orange); }
.badge-discard { background: var(--red-bg); color: var(--red); }
.badge-pending { background: var(--bg3); color: var(--text-dim); }

/* Steps Bar */
.steps-bar {
  display: flex;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 20px;
}

.step-tab {
  flex: 1;
  padding: 10px 8px;
  text-align: center;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dim);
  cursor: pointer;
  border-right: 1px solid var(--border);
  transition: all 0.15s;
  position: relative;
  background: var(--bg3);
}

.step-tab:last-child { border-right: none; }
.step-tab:hover { background: var(--bg2); color: var(--text-mid); }

.step-tab.active {
  background: var(--accent);
  color: white;
  font-weight: 700;
}

.step-tab.done {
  background: var(--green-bg);
  color: var(--green);
}

.step-tab .step-num {
  display: block;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 2px;
}

/* Radio Group (Inspection) */
.radio-group { display: flex; flex-wrap: wrap; gap: 4px; }

.radio-group input[type="radio"],
.radio-group input[type="checkbox"] { display: none; }

.radio-group label {
  padding: 4px 10px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 4px;
  font-size: 11px;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
}

.radio-group input[type="radio"]:checked + label,
.radio-group input[type="checkbox"]:checked + label {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}

/* Condition Grid */
.cond-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.cond-item { display: flex; flex-direction: column; gap: 4px; }
.cond-label { font-size: 11px; font-weight: 600; color: var(--text-mid); }

/* Modal */
.modal-overlay {
  display: none; position: fixed;
  inset: 0; background: rgba(0,0,0,0.4);
  z-index: 200;
  align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }

.modal {
  background: var(--bg2);
  border-radius: 10px;
  padding: 24px;
  width: 90%; max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal-title {
  font-size: 16px; font-weight: 700;
  margin-bottom: 16px;
}

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

/* Inspection Modal (wider) */
.modal-wide {
  max-width: 720px;
  max-height: 85vh;
  overflow-y: auto;
}

/* Top Page Cards */
.purchase-card {
  display: flex; align-items: center;
  padding: 14px 18px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.purchase-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(37,99,235,0.08);
}

.purchase-card .pc-info { flex: 1; }
.purchase-card .pc-name { font-size: 15px; font-weight: 600; }
.purchase-card .pc-meta { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.purchase-card .pc-stats { text-align: right; }
.purchase-card .pc-count { font-size: 18px; font-weight: 700; color: var(--accent); }
.purchase-card .pc-count-label { font-size: 10px; color: var(--text-dim); }

/* Price inputs */
.price-input {
  width: 110px;
  padding: 5px 8px;
  font-size: 13px;
  text-align: right;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 4px;
  font-family: inherit;
  outline: none;
}
.price-input:focus { border-color: var(--accent); }

/* Destination select */
.dest-select {
  padding: 4px 8px;
  font-size: 12px;
  border: 1px solid var(--border2);
  border-radius: 4px;
  background: var(--bg3);
  font-family: inherit;
  cursor: pointer;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  padding: 10px 20px;
  background: var(--text);
  color: white;
  border-radius: 6px;
  font-size: 13px;
  z-index: 300;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-dim);
}
.empty-state .empty-icon { font-size: 36px; margin-bottom: 12px; }
.empty-state .empty-text { font-size: 14px; }

/* Checkbox columns (Excel export) */
.col-check { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.col-check label {
  display: flex; align-items: center; gap: 4px;
  font-size: 12px; color: var(--text-mid); cursor: pointer;
}
.col-check input[type="checkbox"] { accent-color: var(--accent); }

/* Summary bar */
.summary-bar {
  display: flex; gap: 20px;
  padding: 12px 16px;
  background: var(--bg3);
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 13px;
}
.summary-item { display: flex; gap: 6px; align-items: center; }
.summary-label { color: var(--text-dim); }
.summary-value { font-weight: 700; color: var(--text); }

/* Step navigation */
.step-nav {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 20px; padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* Login Page */
.login-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
}
.login-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  width: 360px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.06);
  text-align: center;
}
.login-box .logo-icon {
  width: 48px; height: 48px; font-size: 18px;
  margin: 0 auto 12px;
}
.login-box h1 { font-size: 20px; margin-bottom: 4px; }
.login-box .sub { font-size: 12px; color: var(--text-dim); margin-bottom: 24px; }
.login-box .form-group { text-align: left; }
.login-box .btn { width: 100%; justify-content: center; margin-top: 8px; }
.login-error { color: var(--red); font-size: 12px; margin-top: 8px; display: none; }

/* Responsive */
@media (max-width: 768px) {
  .container, .container-narrow { padding: 12px; }
  .header { padding: 0 12px; }
  .steps-bar { flex-wrap: wrap; }
  .step-tab { flex: none; width: 50%; }
  .cond-grid { grid-template-columns: 1fr; }
  table { font-size: 12px; }
  .purchase-card { flex-direction: column; align-items: flex-start; gap: 8px; }
  .purchase-card .pc-stats { text-align: left; }
}
