:root {
  --ink: #162022;
  --muted: #5c6b70;
  --line: #1a1f21;
  --soft-line: #cfd8dc;
  --paper: #f7f9f9;
  --panel: #ffffff;
  --blue: #5a9bd3;
  --blue-deep: #23618e;
  --cream: #fff2c9;
  --peach: #f8e2d5;
  --mint: #dbeee2;
  --gray-row: #d9e0e6;
  --gold: #ffe59b;
  --green: #2f7d5b;
  --danger: #b94343;
  --shadow: 0 18px 40px rgba(31, 52, 58, 0.14);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(22, 32, 34, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(22, 32, 34, 0.045) 1px, transparent 1px),
    #eef3f4;
  background-size: 28px 28px;
  font-size: 14px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  grid-template-rows: 72px minmax(0, calc(100vh - 72px));
  min-height: 100vh;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 22px;
  background: #ffffff;
  border-bottom: 1px solid #d4dfe2;
  position: sticky;
  top: 0;
  z-index: 20;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--blue-deep);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.layout-toggle-group {
  display: inline-flex;
  align-items: center;
  border: 1px solid #b8c8cd;
  background: #f4f8f9;
}

.layout-toggle {
  height: 34px;
  border: 0;
  border-right: 1px solid #b8c8cd;
  background: #fff;
  color: var(--muted);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 900;
}

.layout-toggle:last-child {
  border-right: 0;
}

.layout-toggle.active {
  background: var(--blue-deep);
  color: #fff;
}

.layout-toggle:hover {
  color: var(--ink);
}

.layout-toggle.active:hover {
  color: #fff;
}

.mobile-appbar,
.mobile-drawer-head,
.mobile-drawer-backdrop {
  display: none;
}

.mobile-menu-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  gap: 4px;
  border: 1px solid #b8c8cd;
  background: #fff;
  padding: 10px;
}

.mobile-menu-button span {
  display: block;
  width: 19px;
  height: 2px;
  background: var(--ink);
}

.session-actor {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.icon-button,
.text-button {
  height: 36px;
  border: 1px solid #b8c8cd;
  background: #ffffff;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-button {
  width: 36px;
  padding: 0;
}

.text-button {
  padding: 0 12px;
  font-weight: 700;
}

.icon-button:hover,
.text-button:hover,
.staff-card:hover {
  border-color: var(--blue-deep);
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.file-button input {
  display: none;
}

.evaluator-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(16, 28, 32, 0.68);
}

.evaluator-gate.hidden {
  display: none;
}

.evaluator-gate-panel {
  width: min(420px, 100%);
  background: #fff;
  border: 3px solid #111;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
  padding: 22px;
  display: grid;
  gap: 14px;
}

.gate-title {
  margin: 0;
  font-size: 22px;
  font-weight: 900;
}

.gate-error {
  min-height: 18px;
  margin: 0;
  color: var(--danger);
  font-size: 12px;
  font-weight: 800;
}

.toast-host {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 120;
  display: grid;
  gap: 8px;
  width: min(380px, calc(100vw - 36px));
}

.toast {
  background: #102024;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.22);
  padding: 11px 13px;
  font-weight: 800;
}

.toast.leaving {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.sidebar {
  grid-column: 1;
  grid-row: 2;
  overflow: auto;
  padding: 16px;
  background: rgba(255, 255, 255, 0.92);
  border-right: 1px solid #d4dfe2;
}

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 14px;
}

.mode-tab {
  border: 1px solid #b8c8cd;
  background: #fff;
  color: var(--muted);
  height: 36px;
  font-weight: 700;
}

.mode-tab.active {
  background: var(--blue-deep);
  border-color: var(--blue-deep);
  color: #fff;
}

.control-block,
.control-grid,
.sidebar-summary {
  margin-bottom: 12px;
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

select,
input[type="search"],
input[type="number"],
textarea {
  width: 100%;
  min-height: 34px;
  border: 1px solid #b8c8cd;
  background: #fff;
  color: var(--ink);
  padding: 6px 8px;
  border-radius: 0;
}

input[type="number"] {
  text-align: right;
  padding-right: 5px;
}

.sidebar-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.metric {
  background: #f3f7f8;
  border: 1px solid #d6e1e4;
  padding: 9px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 2px;
  font-size: 18px;
}

.staff-list {
  display: grid;
  gap: 8px;
}

.staff-card {
  border: 1px solid #c9d6da;
  background: #fff;
  padding: 10px;
  text-align: left;
  width: 100%;
}

.staff-card.active {
  outline: 3px solid rgba(47, 125, 91, 0.22);
  border-color: var(--green);
}

.staff-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.staff-name {
  font-weight: 800;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  background: #e8f1f2;
  border: 1px solid #cbdce0;
  color: #29484f;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.card-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.progress-track {
  height: 7px;
  margin-top: 9px;
  background: #e7ecee;
  border: 1px solid #d1dcdf;
}

.progress-fill {
  height: 100%;
  background: var(--green);
}

.main-panel {
  grid-column: 2;
  grid-row: 2;
  overflow: auto;
  padding: 18px;
}

.app-shell.layout-hide-staff {
  grid-template-columns: minmax(0, 1fr);
}

.app-shell.layout-hide-staff .sidebar {
  display: none;
}

.app-shell.layout-hide-staff .main-panel {
  grid-column: 1 / -1;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 130px);
  text-align: center;
  color: var(--muted);
}

.empty-title {
  margin: 0;
  color: var(--ink);
  font-size: 22px;
  font-weight: 800;
}

.review-layout {
  display: grid;
  grid-template-columns: 360px minmax(760px, 1fr);
  gap: 18px;
  align-items: start;
}

.app-shell.layout-hide-summary .summary-pane {
  display: none;
}

.app-shell.layout-hide-summary .review-layout {
  grid-template-columns: minmax(760px, 1fr);
}

.app-shell.layout-hide-sheet .eval-sheet {
  display: none;
}

.app-shell.layout-hide-sheet .review-layout {
  grid-template-columns: minmax(320px, 520px);
}

.app-shell.layout-hide-summary.layout-hide-sheet .review-layout {
  display: none;
}

.summary-pane {
  position: sticky;
  top: 90px;
  display: grid;
  gap: 14px;
}

.sheet-card {
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow);
  border: 1px solid #cbd7da;
}

.person-header {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  border: 3px solid #111;
  background: #fff;
}

.person-header div {
  padding: 10px 12px;
  border-right: 3px solid #111;
  font-weight: 800;
}

.person-header div:last-child {
  border-right: 0;
}

.overall-box {
  border: 3px solid #111;
  background: #fff;
}

.overall-title {
  background: var(--gold);
  border-bottom: 3px solid #111;
  padding: 12px;
  text-align: center;
  font-weight: 900;
}

.score-grid {
  display: grid;
  grid-template-columns: 80px repeat(5, 1fr);
  border-bottom: 3px solid #111;
}

.score-grid div {
  min-height: 28px;
  padding: 5px 6px;
  border-right: 1px solid #111;
  border-bottom: 1px solid #111;
  text-align: right;
  font-weight: 700;
}

.score-grid div:nth-child(6n + 1) {
  text-align: left;
  background: #fff8dc;
}

.score-grid div:nth-child(-n + 6) {
  background: var(--blue);
  color: #06151d;
  text-align: center;
}

.score-grid div:nth-last-child(-n + 6) {
  border-bottom: 0;
}

.score-grid div:nth-child(6n) {
  border-right: 0;
}

.total-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.total-row div {
  padding: 10px;
  border-right: 3px solid #111;
  font-weight: 900;
  background: var(--gold);
}

.total-row div:last-child {
  border-right: 0;
  text-align: right;
}

.radar-card,
.notes-card {
  background: #fff;
  border: 1px solid #cbd7da;
  padding: 14px;
}

.radar-card h2,
.notes-card h2 {
  margin: 0 0 10px;
  color: #555;
  font-size: 18px;
  text-align: center;
}

.radar-wrap {
  display: grid;
  place-items: center;
}

.radar-grid polygon,
.radar-grid line {
  fill: none;
  stroke: #dce3e5;
  stroke-width: 1;
}

.radar-grid text {
  fill: #55666c;
  font-size: 12px;
  font-weight: 700;
}

.radar-score {
  fill: rgba(47, 125, 91, 0.28);
  stroke: var(--green);
  stroke-width: 2;
}

.notes-card textarea {
  min-height: 130px;
  resize: vertical;
}

.eval-sheet {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #cbd7da;
  box-shadow: var(--shadow);
  padding: 14px;
  overflow: auto;
}

.sheet-title {
  display: grid;
  grid-template-columns: 160px 1fr 210px;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
}

.sheet-title-cell {
  border: 3px solid #111;
  padding: 9px 12px;
  background: #fff;
  font-weight: 900;
  min-height: 40px;
}

.evaluation-label {
  background: var(--blue);
  border: 3px solid #111;
  text-align: center;
  font-weight: 900;
  padding: 9px;
}

.section-table {
  width: 100%;
  min-width: 1240px;
  border-collapse: collapse;
  table-layout: fixed;
  margin-bottom: 18px;
  background: #fff;
}

.section-table th,
.section-table td {
  border: 2px solid #111;
  padding: 4px 5px;
  height: 38px;
  vertical-align: middle;
}

.section-table .section-head th {
  background: var(--blue);
  color: #06151d;
  text-align: left;
  font-weight: 900;
}

.section-table .note-row td {
  background: var(--cream);
  height: 28px;
}

.section-table .code-col {
  width: 46px;
  text-align: center;
  font-weight: 800;
}

.section-table .label-col {
  width: 260px;
  font-weight: 700;
}

.section-table .score-col {
  width: 52px;
  text-align: center;
  padding: 0;
}

.section-table .weight-col {
  width: 92px;
  text-align: right;
  font-weight: 700;
}

.section-table .memo-col {
  width: 210px;
  color: #1f3136;
  font-size: 12px;
}

.section-table .criteria-row:nth-child(even) .label-col,
.section-table .criteria-row:nth-child(even) .memo-col {
  background: var(--gray-row);
}

.section-table .missing-row .code-col,
.section-table .missing-row .label-col,
.section-table .missing-row .memo-col {
  background: #fff7d8;
}

.section-table .footer-row td {
  background: var(--peach);
  font-weight: 900;
}

.score-input {
  width: 100%;
  min-width: 0;
  height: 100%;
  min-height: 34px;
  border: 1px solid #b8ccd2;
  background: #fff;
  text-align: right;
  font-weight: 800;
  color: #102024;
  display: block;
  padding: 0 7px 0 4px;
  border-radius: 0;
  appearance: textfield;
}

.score-input::-webkit-outer-spin-button,
.score-input::-webkit-inner-spin-button {
  appearance: none;
  margin: 0;
}

.score-input:focus {
  outline: 3px solid rgba(47, 125, 91, 0.32);
  outline-offset: -3px;
  border-color: var(--green);
}

.score-input:disabled {
  background: #eef3f4;
  color: #758489;
  cursor: not-allowed;
  opacity: 1;
}

.locked-score-cell {
  background: #f4f7f8;
}

.input-mode-representative .locked-score-cell,
.input-mode-supervisor .locked-score-cell {
  background: #e4eaed;
}

.input-mode-note {
  display: block;
  margin-top: 3px;
  color: #6d5550;
  font-size: 11px;
  font-weight: 800;
}

.not-needed {
  display: grid;
  place-items: center;
  min-height: 34px;
  color: #7a878b;
  font-size: 11px;
  font-weight: 800;
}

.representative-wide-cell {
  padding: 4px 8px;
  background: #e7ecef;
}

.representative-wide-cell .score-input {
  display: inline-block;
  width: 96px;
  height: 34px;
  margin-left: 10px;
  vertical-align: middle;
}

.rep-label,
.rep-message {
  color: #506166;
  font-size: 12px;
  font-weight: 900;
}

.locked-score {
  display: inline-flex;
  min-width: 30px;
  justify-content: center;
  color: #6b767a;
}

.active-score-cell {
  background: #effaf3;
  outline: 3px solid rgba(47, 125, 91, 0.22);
  outline-offset: -3px;
}

.editable-score-cell .score-input {
  background: #ffffff;
}

.mobile-section {
  display: none;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.admin-card {
  background: #fff;
  border: 1px solid #cbd7da;
  box-shadow: var(--shadow);
  padding: 14px;
}

.admin-card span {
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
}

.admin-card strong {
  display: block;
  margin-top: 4px;
  font-size: 26px;
}

.admin-section {
  background: #fff;
  border: 1px solid #cbd7da;
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 14px;
  overflow: auto;
}

.admin-section h2 {
  margin: 0 0 10px;
  font-size: 17px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.data-table th,
.data-table td {
  border: 1px solid #c8d4d8;
  padding: 7px 8px;
  text-align: left;
}

.data-table th {
  background: #e8f1f2;
  font-weight: 800;
}

.data-table td.num,
.data-table th.num {
  text-align: right;
}

.danger {
  color: var(--danger);
  font-weight: 800;
}

.staff-form {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) minmax(140px, 1fr) minmax(140px, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
  padding: 12px;
  background: #f3f7f8;
  border: 1px solid #d6e1e4;
}

.mini-button {
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid #b8c8cd;
  background: #fff;
  font-weight: 800;
}

.danger-button {
  color: var(--danger);
  border-color: #d6aaa8;
}

.danger-button:hover {
  background: #fff1f1;
}

.staff-manager-table .badge {
  margin-left: 6px;
}

@media (max-width: 767px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 56px minmax(0, 1fr);
  }

  .topbar {
    display: none;
  }

  .mobile-appbar {
    grid-column: 1 / -1;
    position: sticky;
    top: 0;
    z-index: 55;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    height: 56px;
    padding: 7px 10px;
    background: rgba(255, 255, 255, 0.98);
    border-bottom: 1px solid #c9d6da;
  }

  .mobile-appbar-title {
    min-width: 0;
    display: grid;
    gap: 1px;
  }

  .mobile-appbar-title strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 18px;
    line-height: 1.15;
  }

  .mobile-appbar-title span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
  }

  .mobile-progress-pill {
    min-width: 58px;
    height: 34px;
    display: inline-grid;
    place-items: center;
    padding: 0 8px;
    background: #e8f1f2;
    border: 1px solid #cbdce0;
    color: #16333b;
    font-weight: 900;
  }

  .mobile-drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 70;
    background: rgba(16, 28, 32, 0.42);
  }

  body.mobile-drawer-open .mobile-drawer-backdrop {
    display: block;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 80;
    grid-column: auto;
    grid-row: auto;
    width: min(360px, 92vw);
    transform: translateX(-104%);
    transition: transform 180ms ease;
    border-right: 0;
    border-bottom: 0;
    box-shadow: 18px 0 42px rgba(14, 30, 35, 0.22);
  }

  .app-shell.layout-hide-staff .sidebar {
    display: block;
  }

  body.mobile-drawer-open .sidebar {
    transform: translateX(0);
  }

  .mobile-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
  }

  .mobile-drawer-head strong {
    font-size: 18px;
  }

  .review-layout {
    display: block;
  }

  .summary-pane {
    display: none;
  }

  .main-panel {
    grid-column: 1;
    grid-row: 2;
    padding: 0;
  }

  .eval-sheet {
    border: 0;
    box-shadow: none;
    overflow: visible;
    padding: 0;
    background: rgba(255, 255, 255, 0.96);
  }

  .app-shell.layout-hide-sheet .eval-sheet {
    display: block;
  }

  .app-shell.layout-hide-summary.layout-hide-sheet .review-layout {
    display: block;
  }

  .sheet-title {
    display: none;
  }

  .section-table {
    display: none;
  }

  .mobile-section {
    display: block;
    background: #fff;
    border: 0;
    border-bottom: 1px solid #c9d6da;
    margin-bottom: 0;
  }

  .mobile-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--blue);
    border-bottom: 1px solid #1a1f21;
    padding: 8px 12px;
    font-weight: 900;
    min-height: 40px;
  }

  .mobile-criterion {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 108px;
    align-items: stretch;
    border-bottom: 1px solid #cfd8dc;
    min-height: 58px;
  }

  .mobile-criterion:nth-child(even) {
    background: #f4f7f8;
  }

  .mobile-criterion.missing-row {
    background: #fff7d8;
  }

  .mobile-criterion-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 8px 10px 8px 12px;
    min-width: 0;
  }

  .mobile-criterion-head strong {
    line-height: 1.35;
    font-size: 14px;
  }

  .mobile-criterion-head span,
  .mobile-section-head span {
    white-space: nowrap;
    font-weight: 900;
  }

  .mobile-code {
    display: inline-grid;
    place-items: center;
    min-width: 22px;
    height: 22px;
    margin-right: 7px;
    background: #eef3f4;
    border: 1px solid #d2dde0;
    font-size: 12px;
  }

  .mobile-score-line {
    display: grid;
    grid-template-rows: auto 1fr;
    align-items: center;
    gap: 3px;
    padding: 7px 10px;
    border-left: 1px solid #cfd8dc;
    background: #fff;
  }

  .mobile-score-label {
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    text-align: right;
  }

  .mobile-score-line .score-input {
    min-height: 36px;
    height: 36px;
    font-size: 18px;
    padding-right: 9px;
  }

  .mobile-section-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--peach);
    border-top: 1px solid #c9b6aa;
    padding: 8px 12px;
    font-weight: 900;
  }

  .mobile-skip-badge {
    display: inline-grid;
    place-items: center;
    min-height: 36px;
    border: 1px solid #d2dde0;
    background: #eef3f4;
    color: #65757a;
    font-size: 12px;
    font-weight: 900;
  }

  .admin-grid {
    grid-template-columns: 1fr 1fr;
  }

  .staff-form {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 620px) {
  .control-grid,
  .sidebar-summary,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .staff-form {
    grid-template-columns: 1fr;
  }

  .main-panel,
  .sidebar {
    padding: 10px;
  }

  .main-panel {
    padding: 0;
  }

  .person-header {
    grid-template-columns: 1fr;
  }

  .person-header div {
    border-right: 0;
    border-bottom: 3px solid #111;
  }

  .person-header div:last-child {
    border-bottom: 0;
  }
}
