:root {
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-sub: #64748b;
  --text-muted: #94a3b8;
  --border-light: #e2e8f0;
  --border-focus: #cbd5e1;

  --navy-brand: #0f2b48;
  --navy-dark: #0a1e33;
  --sky-brand: #0284c7;
  --sky-light: #f0f9ff;
  --sky-border: #bae6fd;
  --emerald-brand: #059669;
  --emerald-light: #f0fdf4;
  --emerald-border: #a7f3d0;
  --amber-brand: #d97706;
  --amber-light: #fffbeb;
  --amber-border: #fde68a;
  --rose-brand: #e11d48;
  --rose-light: #fff1f2;
  --rose-border: #fecdd3;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.6;
  padding-bottom: 40px;
}

.app-container {
  max-width: 980px;
  margin: 0 auto;
  padding: 16px 20px;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0 16px 0;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 18px;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo-badge {
  background: var(--navy-brand);
  color: #ffffff;
  padding: 7px 13px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-sm);
}

.brand-badge-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.badge-main {
  font-weight: 800;
  font-size: 0.98rem;
  letter-spacing: 0.05em;
}

.badge-sub {
  font-weight: 700;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  opacity: 0.85;
}

.header-title-block h1 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.header-title-block p {
  font-size: 0.78rem;
  color: var(--text-sub);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-secondary {
  background: #ffffff;
  border: 1px solid var(--border-light);
  color: var(--text-main);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-secondary:hover {
  background: var(--sky-light);
  border-color: var(--sky-border);
  color: var(--sky-brand);
}

/* Nav Tabs */
.nav-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 18px;
}

.tab-btn {
  background: #ffffff;
  border: 1px solid var(--border-light);
  color: var(--text-sub);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.tab-btn.active {
  background: var(--navy-brand);
  border-color: var(--navy-brand);
  color: #ffffff;
}

/* Policy Banner */
.policy-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--border-light);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 18px;
  font-size: 0.82rem;
  box-shadow: var(--shadow-sm);
}

.policy-badge {
  background: #e2e8f0;
  color: var(--text-main);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  margin-right: 6px;
}

/* Card Common */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}

/* Worker View: User Bar */
.user-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.user-select-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-select-group label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-sub);
}

.select-input {
  padding: 6px 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  color: var(--text-main);
  background: #ffffff;
  font-weight: 600;
  outline: none;
}

.select-input:focus {
  border-color: var(--sky-brand);
}

.user-quick-stats {
  font-size: 0.82rem;
  color: var(--text-sub);
}

.user-quick-stats strong {
  color: var(--sky-brand);
  font-weight: 700;
}

/* Drill Card */
.drill-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
}

.category-tag {
  background: var(--sky-light);
  color: var(--sky-brand);
  border: 1px solid var(--sky-border);
  font-size: 0.74rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
}

.question-step {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-sub);
}

.question-text {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.5;
  margin-bottom: 18px;
}

/* Options List (Clean 3-Choice List) */
.options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.option-btn {
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  text-align: left;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.12s ease;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  line-height: 1.45;
}

.option-btn:hover:not(:disabled) {
  background: #f8fafc;
  border-color: var(--border-focus);
}

.option-btn:disabled {
  cursor: default;
}

.option-prefix {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background: #f1f5f9;
  color: var(--text-sub);
  font-size: 0.78rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}

/* Option States */
.option-btn.correct {
  background: var(--emerald-light);
  border-color: var(--emerald-border);
  color: #065f46;
  font-weight: 600;
}
.option-btn.correct .option-prefix {
  background: var(--emerald-brand);
  color: #ffffff;
}

.option-btn.incorrect {
  background: var(--rose-light);
  border-color: var(--rose-border);
  color: #9f1239;
}
.option-btn.incorrect .option-prefix {
  background: var(--rose-brand);
  color: #ffffff;
}

/* Explanation Box */
.explanation-box {
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-top: 16px;
  font-size: 0.86rem;
  line-height: 1.55;
  display: none;
}

.explanation-box.correct-box {
  background: var(--emerald-light);
  border: 1px solid var(--emerald-border);
  color: #065f46;
}

.explanation-box.incorrect-box {
  background: var(--amber-light);
  border: 1px solid var(--amber-border);
  color: #92400e;
}

.explanation-title {
  font-weight: 700;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.law-ref-note {
  font-size: 0.74rem;
  color: var(--text-sub);
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed rgba(0,0,0,0.1);
}

.drill-footer {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
}

.btn-primary {
  background: var(--navy-brand);
  color: #ffffff;
  border: none;
  padding: 9px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: opacity 0.15s ease;
}

.btn-primary:hover {
  opacity: 0.92;
}

/* Completion Card */
.complete-card {
  text-align: center;
  padding: 28px 20px;
  display: none;
}

.complete-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--emerald-light);
  color: var(--emerald-brand);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.complete-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
}

.complete-sub {
  font-size: 0.84rem;
  color: var(--text-sub);
  margin-bottom: 22px;
}

.score-banner-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 22px;
  text-align: left;
}

.stat-box {
  background: #f8fafc;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.stat-label {
  font-size: 0.74rem;
  color: var(--text-sub);
  font-weight: 600;
  margin-bottom: 2px;
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
}

.complete-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

/* Admin / Dashboard View */
.admin-view {
  display: none;
}

.dashboard-hero-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}

.hero-metric-card {
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 16px 18px;
}

.hero-metric-card.highlight {
  background: #f0f9ff;
  border-color: #bae6fd;
}

.metric-title {
  font-size: 0.78rem;
  color: var(--text-sub);
  font-weight: 600;
  margin-bottom: 4px;
}

.metric-number {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-main);
}

.metric-note {
  font-size: 0.74rem;
  color: var(--text-sub);
  margin-top: 4px;
}

/* Category Breakdown */
.breakdown-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

.category-card {
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 14px;
}

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

.category-card-title {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-main);
}

.category-card-score {
  font-size: 1.1rem;
  font-weight: 800;
}

.progress-bar-bg {
  width: 100%;
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-bar-fill {
  height: 100%;
  background: var(--navy-brand);
  border-radius: 3px;
}

.category-status-note {
  font-size: 0.74rem;
  color: var(--text-sub);
}

/* Table Card */
.table-card {
  padding: 0;
  overflow: hidden;
}

.table-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.table-title {
  font-size: 0.92rem;
  font-weight: 700;
}

.tracking-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
  text-align: left;
}

.tracking-table th {
  background: #f8fafc;
  color: var(--text-sub);
  font-weight: 600;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
}

.tracking-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-main);
}

.tracking-table tr:last-child td {
  border-bottom: none;
}

.badge-status {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
}

.status-good {
  background: var(--emerald-light);
  color: #065f46;
  border: 1px solid var(--emerald-border);
}

.status-warning {
  background: var(--amber-light);
  color: #92400e;
  border: 1px solid var(--amber-border);
}

.status-alert {
  background: var(--rose-light);
  color: #9f1239;
  border: 1px solid var(--rose-border);
}

/* Footer Note */
.disclaimer-card {
  background: #f8fafc;
  border: 1px dashed var(--border-light);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.76rem;
  color: var(--text-sub);
  line-height: 1.5;
  margin-top: 14px;
}

/* =================================================== */
/* A4 Print Styles (b2b-compass-ui 準拠)              */
/* =================================================== */
@media print {
  @page {
    size: A4 portrait;
    margin: 10mm 12mm;
  }

  body {
    background: #ffffff !important;
    color: #0f172a !important;
    padding: 0 !important;
    font-size: 11pt !important;
  }

  .app-container {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  /* 非表示要素 */
  .app-header,
  .nav-tabs,
  .btn-secondary,
  .user-bar,
  #worker-view,
  .btn-primary,
  .header-actions {
    display: none !important;
  }

  /* 管理者ビューを常時印刷表示 */
  .admin-view {
    display: block !important;
  }

  .card {
    border: 1px solid #cbd5e1 !important;
    box-shadow: none !important;
    padding: 12px !important;
    margin-bottom: 12px !important;
    page-break-inside: avoid;
  }

  .print-only-header {
    display: block !important;
    border-bottom: 2px solid #0f172a;
    padding-bottom: 8px;
    margin-bottom: 12px;
  }

  .print-header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
  }

  .print-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: #0f172a;
  }

  .print-date {
    font-size: 0.8rem;
    color: #475569;
  }

  .print-subtitle {
    font-size: 0.8rem;
    color: #475569;
    margin-top: 2px;
  }

  .dashboard-hero-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 8px !important;
  }

  .breakdown-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 8px !important;
  }

  .tracking-table th,
  .tracking-table td {
    padding: 6px 8px !important;
    font-size: 8.5pt !important;
  }

  .disclaimer-card {
    font-size: 7pt !important;
    padding: 8px !important;
    margin-top: 10px !important;
  }
}

.print-only-header {
  display: none;
}
