:root {
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --success-color: #10b981;
  --success-hover: #059669;
  --warning-color: #f59e0b;
  --danger-color: #ef4444;
  --bg-color: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
}

* {
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Sans", "Meiryo", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-color);
  margin: 0;
  padding: 12px;
  color: var(--text-main);
}

.app-container {
  max-width: 500px;
  margin: 0 auto;
  background: var(--card-bg);
  border-radius: 14px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  overflow: hidden;
}

/* ヘッダー */
.app-header {
  background: #0f172a;
  color: #ffffff;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.btn-portal-back {
  display: inline-block;
  color: #94a3b8;
  text-decoration: none;
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 6px;
  transition: color 0.15s;
}

.btn-portal-back:hover {
  color: #ffffff;
}

.machine-title-badge {
  font-size: 10px;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: #94a3b8;
  margin-bottom: 2px;
}

.app-header h1 {
  font-size: 17px;
  margin: 0;
  font-weight: 700;
  color: #f8fafc;
}

.machine-memo {
  font-size: 11px;
  color: #cbd5e1;
  margin-top: 2px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-profile {
  text-align: right;
}

.user-name {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #f1f5f9;
}

.btn-admin-open {
  background: #dc2626;
  color: #ffffff;
  border: none;
  font-size: 10px;
  font-weight: bold;
  padding: 3px 6px;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 3px;
}

/* ステータスバナー */
.status-banner {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-color);
  background: #f8fafc;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: #94a3b8;
  display: inline-block;
}

.status-banner.is-available .status-dot { background-color: var(--success-color); }
.status-banner.is-busy .status-dot { background-color: var(--warning-color); }
.status-banner.is-warning .status-dot { background-color: var(--danger-color); }

.status-detail {
  font-size: 12px;
  color: var(--text-muted);
}

/* タブナビゲーション */
.tabs-nav {
  display: flex;
  border-bottom: 2px solid var(--border-color);
  background: #f1f5f9;
}

.tab-btn {
  flex: 1;
  padding: 12px 6px;
  font-size: 13px;
  font-weight: 700;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn.active {
  color: var(--primary-color);
  background: #ffffff;
  border-bottom: 3px solid var(--primary-color);
}

/* コンテンツエリア */
.tab-content {
  display: none;
  padding: 18px 16px;
}

.tab-content.active {
  display: block;
}

.section-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.section-title-row h3 {
  margin: 0;
  font-size: 14px;
  color: var(--text-main);
}

.btn-refresh {
  background: #f1f5f9;
  border: 1px solid var(--border-color);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  color: var(--text-muted);
}

/* フォーム関連 */
.form-group {
  margin-bottom: 15px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #334155;
}

.badge-req {
  background: #fee2e2;
  color: #dc2626;
  font-size: 10px;
  padding: 1px 4px;
  border-radius: 4px;
  font-weight: normal;
}

input, select, textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 15px;
  color: var(--text-main);
  background-color: #ffffff;
  transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.input-readonly {
  background-color: #f1f5f9;
  color: #475569;
  border-color: #cbd5e1;
}

textarea {
  resize: vertical;
  min-height: 60px;
}

.help-text {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ボタン */
.form-actions {
  margin-top: 20px;
}

.btn {
  width: 100%;
  padding: 13px;
  font-size: 15px;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary { background: var(--primary-color); color: #ffffff; }
.btn-primary:active { background: var(--primary-hover); }

.btn-success { background: var(--success-color); color: #ffffff; }
.btn-success:active { background: var(--success-hover); }

.btn:disabled {
  background: #94a3b8 !important;
  cursor: not-allowed;
}

.inline-loader {
  display: none;
  text-align: center;
  padding: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-color);
}

/* 履歴カード */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-card {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px 12px;
  background: #ffffff;
  font-size: 13px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.history-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
  font-size: 12px;
}

.history-user {
  font-weight: 700;
  color: var(--text-main);
}

.history-date {
  color: var(--text-muted);
}

.history-sub {
  font-size: 12px;
  color: #475569;
  margin-bottom: 4px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.badge-category {
  background: #e0f2fe;
  color: #0369a1;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.badge-filament {
  background: #f1f5f9;
  color: #334155;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
}

.history-issue {
  background: #fef2f2;
  border-left: 3px solid var(--danger-color);
  padding: 4px 8px;
  color: #991b1b;
  font-size: 11px;
  border-radius: 2px;
  margin-top: 4px;
}

.history-photo-link {
  display: inline-block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 600;
}

/* 写真プレビュー */
.photo-preview-box {
  margin-top: 8px;
  display: none;
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: #000;
  text-align: center;
}

#photoPreviewImg {
  max-width: 100%;
  max-height: 200px;
  display: block;
  margin: 0 auto;
}

.preview-badge {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
}

/* モーダル */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  display: none;
  justify-content: center;
  align-items: center;
  padding: 16px;
  z-index: 999;
}

.modal-card {
  background: #ffffff;
  border-radius: 14px;
  padding: 20px;
  width: 100%;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.modal-wide {
  max-width: 500px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.modal-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.modal-header-row h3 {
  margin: 0;
  font-size: 15px;
}

.btn-close {
  background: transparent;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-muted);
}

.admin-active-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-row {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.btn-force-end {
  background: #dc2626;
  color: #ffffff;
  border: none;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.loading-box {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: 13px;
}

/* トースト通知 */
.toast-notification {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: #0f172a;
  color: #ffffff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
  z-index: 9999;
  transition: transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28), opacity 0.3s;
  opacity: 0;
  pointer-events: none;
  max-width: 90%;
  text-align: center;
}

.toast-notification.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast-success { background: #059669; }
.toast-error { background: #dc2626; }