:root {
  --bg: oklch(98% 0.004 250);
  --surface: oklch(99% 0.002 250);
  --border: oklch(90% 0.008 250);
  --border-strong: oklch(82% 0.012 250);
  --text: oklch(22% 0.02 255);
  --text-muted: oklch(48% 0.02 255);
  --text-faint: oklch(62% 0.015 255);
  --accent: oklch(53% 0.16 264);
  --accent-hover: oklch(46% 0.16 264);
  --danger: oklch(55% 0.19 26);
  --neutral-soft: oklch(94% 0.006 255);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Noto Sans JP', system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: 'Zen Kaku Gothic New', 'Noto Sans JP', system-ui, sans-serif;
  margin: 0;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
}

input {
  font-family: inherit;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 34px;
  padding: 0 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
}

.btn:hover {
  text-decoration: none;
}

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

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

.btn-block {
  width: 100%;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-secondary:hover {
  background: var(--neutral-soft);
  color: var(--text);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.field label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.field input {
  height: 34px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}

.field input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.field input.field-error {
  border-color: var(--danger);
}

.error-text {
  font-size: 12px;
  color: var(--danger);
}

/* ログイン画面 */

.auth-page main {
  width: 100%;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.auth-card {
  width: 360px;
  max-width: 100%;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.logo-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.auth-header h1 {
  font-size: 17px;
}

/* ナビゲーションバー */

.navbar {
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.navbar-brand .logo-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.navbar-title {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.02em;
}

.navbar-user {
  position: relative;
  min-width: 0;
}

.navbar-user summary {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  list-style: none;
}

.navbar-user summary::-webkit-details-marker {
  display: none;
}

.navbar-user .navbar-user-name {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}

.navbar-user-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  display: flex;
  flex-direction: column;
  min-width: 160px;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
}

.navbar-user-menu a,
.navbar-user-menu button {
  display: flex;
  align-items: center;
  width: 100%;
  height: 28px;
  padding: 0 8px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  box-sizing: border-box;
}

.navbar-user-menu a:hover,
.navbar-user-menu button:hover {
  background: var(--neutral-soft);
}

/* パンくずナビゲーション */

.breadcrumb {
  height: 30px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 18px;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
}

.breadcrumb .current {
  color: var(--text);
}

/* ダッシュボード */

.page-main {
  padding: 20px 18px 80px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.page-main h1 {
  font-size: 19px;
}

.stat-cards {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.stat-card {
  padding: 13px;
  width: 260px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-card-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.stat-card-value {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.stat-card-value .active {
  font-size: 28px;
  font-weight: 700;
  font-family: 'Zen Kaku Gothic New';
}

.stat-card-value .total {
  font-size: 16px;
  color: var(--text-faint);
}

.stat-card-note {
  font-size: 11px;
  color: var(--text-faint);
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
}

/* 課題一覧の見出し行。見出しを左端に置き、ボタンと担当者セレクタを右へ寄せて並べる。 */
.page-header-issue-list {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.page-header-issue-list h1 {
  margin-right: auto;
}

.assignee-filter {
  height: 34px;
  min-width: 180px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
}

.assignee-filter:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.list-table-wrap {
  overflow-x: auto;
}

.list-table {
  width: 100%;
  border-collapse: collapse;
}

.list-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  padding-bottom: 6px;
}

.list-table td {
  font-size: 13px;
  padding-top: 2px;
  padding-bottom: 2px;
  border-top: 1px solid var(--border);
}

.list-table td.cell-td-editable {
  padding: 0;
  position: relative;
}

/* table-layout: autoでは、テーブル全体の幅(100%)に余りがあると、max-widthだけでは
   列がその上限を超えて広がる。widthを併記して初めて上限として機能する。 */
.list-table-cell-issue-id {
  width: 28ex;
  max-width: 28ex;
}

.list-table-cell-issue-summary {
  width: 60ex;
  max-width: 60ex;
  overflow-wrap: break-word;
}

.list-table-cell-drag-handle {
  width: 24px;
  padding-left: 2px;
  padding-right: 2px;
  text-align: center;
  vertical-align: middle;
}

.drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-faint);
  cursor: grab;
}

.drag-handle:hover {
  background: var(--neutral-soft);
  color: var(--text-muted);
}

/* 課題単位のtbodyをドラッグしている間、元の位置に残る行を薄く見せる。 */
tbody[data-issue-group].is-dragging {
  opacity: 0.45;
}

tbody[data-issue-group].is-dragging .drag-handle {
  cursor: grabbing;
}

.work-order-warning {
  font-weight: 500;
  color: var(--danger);
}

.cell-editable {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  box-sizing: border-box;
  /* .list-table tdの余白(padding-top/bottom: 2px、左右は指定せずブラウザ既定のまま)と
     揃える。編集可能セルはtd自体の余白を0にしてボタンをinset: 0で重ねているため、
     ここで別途指定しないとtd側の余白を詰めてもこのボタンには反映されない。 */
  padding: 2px 1px;
  border: none;
  border-radius: 4px;
  background: transparent;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.cell-editable:hover {
  background: var(--neutral-soft);
}

.hours-mismatch {
  color: var(--danger);
}

.cell-editable-input {
  position: absolute;
  inset: 0;
  box-sizing: border-box;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font: inherit;
  color: inherit;
}

.list-actions {
  display: flex;
  gap: 5px;
  justify-content: flex-end;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  border: none;
}

.icon-btn:hover {
  background: var(--neutral-soft);
  color: var(--text);
}

.icon-btn.danger:hover {
  background: oklch(96% 0.03 26);
  color: var(--danger);
}

.icon-btn-backlog:hover {
  background: oklch(96% 0.05 145);
}

.icon-btn-external:hover {
  background: oklch(96% 0.04 255);
  color: var(--accent);
}

.list-cards {
  display: none;
  flex-direction: column;
  gap: 6px;
}

.company-card {
  padding: 8px;
}

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

.company-card-name {
  font-size: 13px;
  font-weight: 600;
}

.company-card-short {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-role-admin {
  background: oklch(90% 0.03 264);
  color: oklch(40% 0.16 264);
}

.badge-role-company_admin {
  background: oklch(92% 0.02 200);
  color: oklch(42% 0.1 200);
}

.badge-role-member {
  background: var(--neutral-soft);
  color: var(--text-muted);
}

.badge-status-active {
  background: oklch(93% 0.05 150);
  color: oklch(40% 0.12 150);
}

.badge-status-resigned {
  background: var(--neutral-soft);
  color: var(--text-faint);
}

.filter-tabs {
  display: flex;
  gap: 3px;
}

.filter-tabs a {
  display: inline-flex;
  align-items: center;
  height: 25px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.filter-tabs a:hover {
  background: var(--neutral-soft);
  text-decoration: none;
}

.filter-tabs a.active {
  background: var(--accent);
  color: #fff;
}

tr[data-member-row] {
  cursor: pointer;
}

tr[data-member-row]:hover {
  background: var(--neutral-soft);
}

tr[data-work-plan-row] {
  cursor: pointer;
}

tr[data-work-plan-row]:hover {
  background: var(--neutral-soft);
}

tr[data-issue-row] {
  cursor: pointer;
}

tr[data-issue-row]:hover {
  background: var(--neutral-soft);
}

.member-card {
  padding: 8px;
  cursor: pointer;
}

.member-card:hover {
  background: var(--neutral-soft);
}

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

.member-card-identity {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.member-card-name {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}

.member-card-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 5px;
}

.member-card-member-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  margin-top: 5px;
  padding-top: 5px;
  border-top: 1px solid var(--border);
}

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

.detail-header-identity {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.detail-header h1 {
  font-size: 18px;
}

.detail-groups {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.detail-header + .detail-groups {
  margin-top: 13px;
}

.detail-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin: 0 0 6px;
}

.group + .detail-group-title {
  margin-top: 14px;
}

.detail-group-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.detail-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
}

.detail-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 160px;
}

.detail-field-label {
  font-size: 11px;
  color: var(--text-muted);
}

.detail-field-value {
  font-size: 13px;
}

.form-card {
  padding: 18px;
}

.group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.unit {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: 100%;
}

.unit input,
.unit select {
  max-width: 100%;
}

.unit input[type="date"],
.unit input[type="month"],
.unit input[type="number"] {
  width: 120px;
}

.unit input[type="text"],
.unit input[type="password"],
.unit select {
  width: 260px;
}

.unit.unit-narrow input,
.unit.unit-narrow select {
  width: 140px;
}

.unit.unit-wide input,
.unit.unit-wide select {
  width: 360px;
}

.unit label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.unit input,
.unit select {
  height: 32px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}

.unit select[multiple] {
  height: auto;
  padding: 4px 8px;
}

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

.unit input.field-error {
  border-color: var(--danger);
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 14px 0;
}

.form-actions {
  display: flex;
  gap: 8px;
}

.toast-container {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 5px;
  z-index: 100;
}

.toast {
  background: var(--text);
  color: #fff;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 12px;
}

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

.modal {
  width: 360px;
  max-width: calc(100% - 48px);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-body {
  margin: 0;
  font-size: 13px;
}

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

.btn-danger {
  background: var(--danger);
}

.btn-danger:hover {
  background: oklch(48% 0.19 26);
}

/* フィードバック */

.feedback-fab {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  z-index: 90;
}

.feedback-fab:hover {
  background: var(--accent-hover);
}

.modal-overlay[hidden] {
  display: none;
}

.feedback-modal {
  width: 480px;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
}

.feedback-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.feedback-form input[readonly] {
  background: var(--neutral-soft);
}

.feedback-radios {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin: 0;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.feedback-radios legend {
  padding: 0 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.feedback-radios label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.feedback-content {
  width: 100%;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  resize: vertical;
}

.feedback-content:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

@media (max-width: 600px) {
  .navbar {
    height: 42px;
    padding: 0 12px;
  }

  .navbar-brand {
    gap: 5px;
  }

  .navbar-brand .logo-icon {
    width: 26px;
    height: 26px;
    border-radius: 7px;
  }

  .navbar-title {
    font-size: 14px;
  }

  .navbar-user .navbar-user-name {
    font-size: 11px;
    color: var(--text-muted);
    max-width: 120px;
  }

  .breadcrumb {
    height: 28px;
    padding: 0 12px;
    font-size: 11px;
  }

  .page-main {
    padding: 14px 12px 76px;
    gap: 10px;
  }

  .page-main h1 {
    font-size: 17px;
  }

  .stat-card {
    padding: 11px;
    width: 100%;
  }

  .stat-card-value .active {
    font-size: 26px;
  }

  .stat-card-value .total {
    font-size: 15px;
  }


  .list-table-wrap {
    display: none;
  }

  .list-cards {
    display: flex;
  }

  .form-card {
    padding: 11px;
  }

  .detail-fields {
    gap: 9px 14px;
  }

  .detail-header h1 {
    font-size: 16px;
  }

  .group {
    gap: 9px;
  }

  .form-actions {
    justify-content: center;
  }
}
