/* =============================================================================
   日報・労務原価管理システム（モック） スタイル
   - 従業員画面: スマートフォン優先（大きめのタップ領域・入力欄）
   - 管理・経理画面: PC 優先（テーブル・フィルタ）
   ============================================================================= */

:root {
  --color-bg: #f4f6f8;
  --color-surface: #ffffff;
  --color-border: #d8dee6;
  --color-text: #1f2933;
  --color-muted: #6b7280;
  --color-primary: #1f4e79;
  --color-primary-dark: #16395a;
  --color-primary-light: #e8f1f9;
  --color-approved: #1b7f4b;
  --color-approved-bg: #e3f6ec;
  --color-submitted: #1d5fa8;
  --color-submitted-bg: #e6f0fb;
  --color-draft: #6b7280;
  --color-draft-bg: #eef1f4;
  --color-rejected: #b3261e;
  --color-rejected-bg: #fdeceb;
  --color-warning: #a5640a;
  --color-warning-bg: #fdf3e2;
  --color-mock: #8a5a00;
  --color-mock-bg: #fff4d6;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 10px 24px rgba(16, 24, 40, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', 'Yu Gothic', Meiryo,
    sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
}

/* --- モックバナー --- */
.mock-banner {
  background: var(--color-mock-bg);
  color: var(--color-mock);
  border-bottom: 1px solid #f0d999;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.04em;
}

.mock-banner .mock-banner__sub {
  font-weight: 400;
  color: #6b5300;
  margin-left: 8px;
}

.app-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 12px 96px;
}

.app-shell--wide {
  max-width: 1320px;
}

/* --- ヘッダー --- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--color-primary);
  color: #fff;
  margin: 0 -12px 16px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
}

.app-header__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.app-header__title {
  font-size: 17px;
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-header__role {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.app-header__role select {
  font-size: 14px;
  padding: 6px 8px;
  border-radius: 8px;
  border: none;
  background: #fff;
  color: var(--color-text);
  max-width: 60vw;
}

.nav {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.nav__item {
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
}

.nav__item:hover {
  background: rgba(255, 255, 255, 0.26);
}

.nav__item--active {
  background: #fff;
  color: var(--color-primary);
  font-weight: 700;
}

/* --- カード --- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}

.card__title {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.card__title .card__title-sub {
  font-size: 13px;
  font-weight: 400;
  color: var(--color-muted);
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  margin: 4px 0 12px;
}

.section-note {
  font-size: 13px;
  color: var(--color-muted);
  margin: 0 0 12px;
}

/* --- ボタン --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  background: #fff;
  color: var(--color-text);
  border-color: var(--color-border);
  transition: background 0.15s, opacity 0.15s;
}

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

.btn--primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

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

.btn--danger {
  background: var(--color-rejected);
  color: #fff;
  border-color: var(--color-rejected);
}

.btn--ghost {
  background: transparent;
  border-color: var(--color-border);
}

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

.btn--lg {
  padding: 16px 20px;
  font-size: 18px;
  border-radius: 12px;
}

.btn--xl {
  padding: 22px 20px;
  font-size: 20px;
  border-radius: 14px;
}

.btn--sm {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 6px;
}

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* --- フォーム --- */
.field {
  margin-bottom: 16px;
}

.field__label {
  display: block;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 6px;
}

.field__label .req {
  color: var(--color-rejected);
  margin-left: 4px;
  font-size: 12px;
}

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

.field__error {
  font-size: 13px;
  color: var(--color-rejected);
  margin-top: 4px;
  font-weight: 600;
}

input[type='text'],
input[type='date'],
input[type='number'],
input[type='month'],
input[type='search'],
select,
textarea {
  width: 100%;
  font-size: 16px;
  padding: 12px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: #fff;
  color: var(--color-text);
  font-family: inherit;
}

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

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
  border-color: var(--color-primary);
}

input.has-error,
select.has-error,
textarea.has-error {
  border-color: var(--color-rejected);
  background: #fff8f8;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 640px) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 640px) {
  .grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

@media (min-width: 768px) {
  .grid-4 {
    grid-template-columns: repeat(4, 1fr);
  }
}

.time-input {
  display: flex;
  align-items: center;
  gap: 8px;
}

.time-input input {
  width: 90px;
  text-align: right;
}

.time-input span {
  font-size: 15px;
  color: var(--color-muted);
}

/* --- 作業時間の入力方式切替 --- */
.mode-switch {
  display: inline-flex;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
}

.mode-switch__btn {
  border: none;
  background: #fff;
  color: var(--color-muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  cursor: pointer;
}

.mode-switch__btn + .mode-switch__btn {
  border-left: 1px solid var(--color-border);
}

.mode-switch__btn.is-active {
  background: var(--color-primary);
  color: #fff;
}

.range-input {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.range-input input[type='time'] {
  width: auto;
  min-width: 124px;
}

.range-input__sep {
  font-size: 15px;
  color: var(--color-muted);
}

.range-input__calc {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-primary);
  white-space: nowrap;
}

/* --- 統計のバー表示 --- */
.bar-track {
  width: 100%;
  min-width: 80px;
  height: 10px;
  background: #eef1f4;
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 999px;
  transition: width 0.2s ease;
}

.bar-fill--warn {
  background: var(--color-rejected);
}

/* --- 状態バッジ --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid transparent;
  white-space: nowrap;
}

.tone-draft {
  background: var(--color-draft-bg);
  color: var(--color-draft);
  border-color: #d5dbe1;
}

.tone-submitted {
  background: var(--color-submitted-bg);
  color: var(--color-submitted);
  border-color: #bcd6f2;
}

.tone-approved {
  background: var(--color-approved-bg);
  color: var(--color-approved);
  border-color: #a8e0c2;
}

.tone-rejected {
  background: var(--color-rejected-bg);
  color: var(--color-rejected);
  border-color: #f3c3c0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 600;
}

.chip--warn {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.chip--muted {
  background: #eef1f4;
  color: var(--color-muted);
}

.chip--danger {
  background: var(--color-rejected-bg);
  color: var(--color-rejected);
}

/* --- 統計カード --- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

@media (min-width: 768px) {
  .stat-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}

.stat__label {
  font-size: 13px;
  color: var(--color-muted);
  margin-bottom: 6px;
}

.stat__value {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.2;
}

.stat__value--sm {
  font-size: 20px;
}

.stat__unit {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-muted);
  margin-left: 4px;
}

.stat--warn .stat__value {
  color: var(--color-warning);
}

.stat--danger .stat__value {
  color: var(--color-rejected);
}

.stat--primary .stat__value {
  color: var(--color-primary);
}

/* --- テーブル --- */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 560px;
}

table.data-table th,
table.data-table td {
  border-bottom: 1px solid var(--color-border);
  padding: 10px 10px;
  text-align: left;
  vertical-align: top;
}

table.data-table th {
  background: #f7f9fb;
  font-size: 13px;
  color: var(--color-muted);
  font-weight: 700;
  position: sticky;
  top: 0;
}

table.data-table td.num,
table.data-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

table.data-table tr.clickable {
  cursor: pointer;
}

table.data-table tr.clickable:hover {
  background: var(--color-primary-light);
}

/* --- リスト --- */
.list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: #fff;
  cursor: pointer;
  text-align: left;
  width: 100%;
  font: inherit;
  color: inherit;
}

.list-item:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.list-item__main {
  min-width: 0;
}

.list-item__date {
  font-weight: 700;
}

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

.list-item__side {
  text-align: right;
  white-space: nowrap;
}

.list-item__total {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--color-muted);
}

.empty-state__title {
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 6px;
}

/* --- 明細エディタ --- */
.line-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  background: #fbfcfd;
}

.line-card__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.line-card__no {
  font-weight: 700;
  font-size: 14px;
}

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

.total-bar {
  position: sticky;
  bottom: 0;
  z-index: 15;
  background: var(--color-surface);
  border-top: 2px solid var(--color-primary);
  padding: 12px;
  margin: 0 -16px -16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  box-shadow: 0 -4px 12px rgba(16, 24, 40, 0.08);
}

.total-bar__value {
  font-size: 24px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.total-bar__value.is-warn {
  color: var(--color-warning);
}

.total-bar__value.is-danger {
  color: var(--color-rejected);
}

/* --- アラート --- */
.alert {
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 14px;
  margin-bottom: 12px;
  border: 1px solid transparent;
}

.alert--error {
  background: var(--color-rejected-bg);
  color: var(--color-rejected);
  border-color: #f3c3c0;
  font-weight: 600;
}

.alert--warn {
  background: var(--color-warning-bg);
  color: var(--color-warning);
  border-color: #f0dcb4;
  font-weight: 600;
}

.alert--info {
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-color: #cfe2f3;
}

.alert ul {
  margin: 6px 0 0;
  padding-left: 20px;
}

/* --- トースト --- */
.toast-stack {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 16px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(560px, calc(100vw - 24px));
}

.toast {
  border-radius: 10px;
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  font-weight: 600;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.toast--success {
  background: #e8f7ee;
  color: #14532d;
  border: 1px solid #a8e0c2;
}

.toast--error {
  background: var(--color-rejected-bg);
  color: #7a1c17;
  border: 1px solid #f3c3c0;
}

.toast--info {
  background: #eef2f7;
  color: #23303d;
  border: 1px solid #cfd8e3;
}

/* --- モーダル --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, 0.5);
  z-index: 90;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

@media (min-width: 640px) {
  .modal-backdrop {
    align-items: center;
    padding: 20px;
  }
}

.modal {
  background: #fff;
  width: 100%;
  max-width: 560px;
  border-radius: 16px 16px 0 0;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

@media (min-width: 640px) {
  .modal {
    border-radius: 14px;
  }
}

.modal__head {
  padding: 16px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 2;
}

.modal__title {
  font-size: 17px;
  font-weight: 700;
  margin: 0;
}

.modal__body {
  padding: 16px;
}

.modal__foot {
  padding: 16px;
  border-top: 1px solid var(--color-border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
  position: sticky;
  bottom: 0;
  background: #fff;
}

/* --- 履歴タイムライン --- */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
}

.timeline__item {
  border-left: 2px solid var(--color-border);
  padding: 0 0 16px 14px;
  position: relative;
}

.timeline__item::before {
  content: '';
  position: absolute;
  left: -6px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-primary);
}

.timeline__head {
  font-size: 14px;
  font-weight: 700;
}

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

.timeline__detail {
  font-size: 13px;
  margin-top: 4px;
}

.timeline__reason {
  font-size: 13px;
  margin-top: 4px;
  color: var(--color-rejected);
  font-weight: 600;
  background: var(--color-rejected-bg);
  padding: 6px 8px;
  border-radius: 6px;
}

.timeline__diff {
  font-size: 12px;
  color: var(--color-muted);
  margin-top: 4px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* --- フィルタバー --- */
.filter-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

@media (min-width: 768px) {
  .filter-bar {
    grid-template-columns: repeat(5, 1fr);
  }
}

.filter-bar .field {
  margin-bottom: 0;
}

/* --- タブ --- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--color-border);
  margin-bottom: 16px;
  overflow-x: auto;
}

.tab {
  border: none;
  background: transparent;
  padding: 10px 14px;
  font-size: 15px;
  font-weight: 600;
  color: var(--color-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
}

.tab--active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

/* --- ユーティリティ --- */
.muted {
  color: var(--color-muted);
}

.small {
  font-size: 13px;
}

.tiny {
  font-size: 12px;
}

.bold {
  font-weight: 700;
}

.right {
  text-align: right;
}

.mt-8 {
  margin-top: 8px;
}

.mt-16 {
  margin-top: 16px;
}

.mb-0 {
  margin-bottom: 0;
}

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.inline-chip-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.hero-button {
  margin-bottom: 16px;
}

.sticky-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.scroll-search {
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  margin-top: 6px;
}

.scroll-search__item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: #fff;
  padding: 12px;
  font: inherit;
  cursor: pointer;
  border-bottom: 1px solid var(--color-border);
}

.scroll-search__item:hover {
  background: var(--color-primary-light);
}

.scroll-search__item.is-selected {
  background: var(--color-primary-light);
  font-weight: 700;
}

.code-block {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 8px;
  padding: 12px;
  font-size: 12px;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre;
}

.warn-text {
  color: var(--color-warning);
  font-weight: 700;
}

.danger-text {
  color: var(--color-rejected);
  font-weight: 700;
}

.approved-text {
  color: var(--color-approved);
  font-weight: 700;
}

@media print {
  .mock-banner,
  .app-header,
  .toast-stack {
    display: none;
  }
}
