:root {
  --primary: #0066b3;
  --primary-dark: #004d87;
  --bg: #f5f7fa;
  --card: #ffffff;
  --border: #d8dde3;
  --text: #1f2937;
  --muted: #6b7280;
  --danger: #c0392b;
  --success: #16a34a;
  --warning: #d97706;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
}

header {
  background: var(--primary);
  color: #fff;
  padding: 14px 16px;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

header h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

header nav {
  margin-top: 6px;
  font-size: 13px;
}

header nav a {
  color: #fff;
  text-decoration: none;
  margin-right: 12px;
  opacity: 0.9;
}

header nav a:hover { opacity: 1; text-decoration: underline; }

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.card h2 {
  margin-top: 0;
  font-size: 16px;
  border-bottom: 2px solid var(--primary);
  padding-bottom: 6px;
}

label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}

label .required {
  color: var(--danger);
  margin-left: 4px;
}

input[type="text"],
input[type="number"],
input[type="url"],
input[type="email"],
input[type="date"],
input[type="month"],
select,
textarea {
  width: 100%;
  padding: 12px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  -webkit-appearance: none;
  appearance: none;
}

textarea { min-height: 80px; resize: vertical; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,102,179,0.15);
}

.field { margin-bottom: 14px; }

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.row-3 {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 8px;
}

@media (max-width: 540px) {
  .row, .row-3 { grid-template-columns: 1fr; }
}

button, .btn {
  display: inline-block;
  padding: 14px 18px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  -webkit-appearance: none;
  appearance: none;
}

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

button:disabled { background: #9ca3af; cursor: not-allowed; }

.btn-secondary { background: #6b7280; }
.btn-secondary:hover { background: #4b5563; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #922b1c; }
.btn-success { background: var(--success); }
.btn-success:hover { background: #128138; }

.btn-block { display: block; width: 100%; }

.muted { color: var(--muted); font-size: 13px; }

.line-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
  background: #fafbfc;
  position: relative;
}

.line-item .remove-line {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-size: 16px;
  cursor: pointer;
  padding: 0;
  line-height: 28px;
}

.total {
  text-align: right;
  font-size: 18px;
  font-weight: 700;
  margin-top: 10px;
  color: var(--primary);
}

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
}

.status-承認待ち { background: var(--warning); }
.status-再承認待ち { background: #b45309; }
.status-承認済 { background: #0ea5e9; }
.status-発注済 { background: #6366f1; }
.status-納品済 { background: var(--success); }
.status-取消 { background: var(--muted); }

.order-row {
  display: block;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  background: #fff;
  text-decoration: none;
  color: var(--text);
}

.order-row:hover { background: #f9fafb; }

.order-row .meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 100;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 12px;
  overflow-y: auto;
}

.modal.open { display: flex; }

.modal-content {
  background: #fff;
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  padding: 20px;
  outline: none;
}

.alert {
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 14px;
}

.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid #fff;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

@keyframes spin { to { transform: rotate(360deg); } }

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

th, td {
  text-align: left;
  padding: 8px;
  border-bottom: 1px solid var(--border);
}

th { background: #f3f4f6; font-weight: 600; }

.hidden { display: none !important; }

/* 印刷用 */
@media print {
  header, nav, .no-print, button { display: none !important; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 1px solid #999; page-break-inside: avoid; }
  @page { size: A4 portrait; margin: 12mm; }
}
