@import url('./tokens.css');

/* 段階1の画面（ログインと職員の管理）。色、余白、角丸、影は tokens.css の変数だけから取る。 */

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg-canvas);
  color: var(--fg-default);
  font-family: var(--font-sans);
  font-size: var(--text-std-16n-170-size);
  line-height: var(--text-std-16n-170-line-height);
  overflow-wrap: anywhere;
}

/* 上端の主色の帯（SPA のヘッダーと同じ顔） */
body::before {
  content: '';
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--space-4);
  background: var(--brand-mark);
  z-index: 100;
}

button,
input,
select {
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
  border: 0;
}

button:disabled {
  cursor: not-allowed;
}

a {
  color: var(--fg-link);
}

a:hover {
  color: var(--fg-link-hover);
}

/* フォーカスは主色（ユーザーの決定 2026-09-29）。キーボードで移動したときは主色の 2px の輪郭。 */
:focus-visible {
  outline: 0.125rem solid var(--focus-outline);
  outline-offset: 0.125rem;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: var(--text-std-28n-150-size);
  font-weight: 700;
  line-height: var(--text-std-28n-150-line-height);
}

h2 {
  font-size: var(--text-std-20n-150-size);
  font-weight: 700;
  line-height: var(--text-std-20n-150-line-height);
}

h3 {
  font-size: var(--text-std-16n-170-size);
  font-weight: 700;
}

.muted {
  color: var(--fg-muted);
}

.eyebrow {
  font-size: var(--text-dns-14n-130-size);
  letter-spacing: 0.08em;
  font-weight: 700;
  line-height: 1.5;
  color: var(--fg-muted);
}

/* ロゴ。前にロゴの図を置く（2026-10-01 にユーザーから受け取った図、装飾）。 */
.brand {
  font-size: var(--text-std-20n-150-size);
  font-weight: 700;
  line-height: var(--text-std-20n-150-line-height);
  letter-spacing: 0.08em;
  display: flex;
  align-items: center;
  gap: var(--space-8);
}

.brandmark {
  display: inline-block;
  flex-shrink: 0;
  width: var(--space-40);
  height: var(--space-40);
}

.boot {
  min-height: 100vh;
  display: grid;
  place-content: center;
  justify-items: center;
  text-align: center;
  gap: var(--space-16);
  padding: var(--space-16);
}

/* 画面の枠 */
.layout {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-subtle);
  border-right: 1px solid var(--border-subtle);
  padding: var(--space-32) var(--space-16);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  width: 15rem;
  z-index: 10;
  overflow-y: auto;
}

.workspace-label {
  margin: var(--space-24) 0 var(--space-16);
  padding: var(--space-12);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-8);
  background: var(--bg-surface);
  font-size: var(--text-dns-14n-130-size);
  line-height: 1.5;
  display: flex;
  gap: var(--space-12);
  align-items: center;
}

.workspace-label > span:first-child {
  background: var(--bg-action-subtle);
  color: var(--fg-link);
  font-weight: 700;
  padding: var(--space-4) var(--space-8);
  border-radius: var(--radius-4);
}

.nav-label {
  font-size: var(--text-dns-14n-130-size);
  letter-spacing: 0.08em;
  color: var(--fg-muted);
  margin: var(--space-8) var(--space-8) var(--space-8);
  line-height: 1.5;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.nav button {
  display: flex;
  align-items: center;
  gap: var(--space-12);
  min-height: var(--size-control-md);
  padding: var(--space-8) var(--space-12);
  background: transparent;
  color: var(--fg-default);
  border-radius: var(--radius-8);
  text-align: left;
  font-size: var(--text-std-16n-170-size);
  line-height: 1.5;
}

.nav button.active {
  background: var(--bg-action);
  color: var(--fg-on-action);
  font-weight: 700;
}

.nav button:not(.active):hover {
  background: var(--bg-action-subtle);
}

.sidebar-bottom {
  margin-top: auto;
  padding-top: var(--space-48);
}

.env {
  font-size: var(--text-dns-14n-130-size);
  line-height: 1.5;
  color: var(--fg-muted);
  display: flex;
  align-items: center;
  gap: var(--space-8);
}

.dot {
  width: 0.5rem;
  height: 0.5rem;
  background: var(--brand-mark);
  border-radius: var(--radius-full);
  display: inline-block;
}

.profile {
  display: flex;
  align-items: center;
  gap: var(--space-12);
  border-top: 1px solid var(--border-subtle);
  margin-top: var(--space-16);
  padding-top: var(--space-16);
  font-size: var(--text-dns-14n-130-size);
  line-height: 1.5;
}

.profile > div {
  min-width: 0;
}

.avatar {
  width: 2.5rem;
  height: 2.5rem;
  display: grid;
  place-items: center;
  background: var(--bg-action-subtle);
  border-radius: var(--radius-full);
  font-size: var(--text-std-16n-170-size);
  font-weight: 700;
  color: var(--fg-link);
  flex-shrink: 0;
}

.profile p {
  color: var(--fg-muted);
}

.main {
  grid-column: 2;
  min-width: 0;
}

.topbar {
  min-height: 4.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-8) var(--space-16);
  padding: var(--space-16) var(--space-40);
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--text-dns-14n-130-size);
  line-height: 1.5;
}

.topbar .right {
  display: flex;
  gap: var(--space-16);
  align-items: center;
}

.local-pill {
  display: inline-block;
  border: 1px solid var(--border-action);
  padding: var(--space-2) var(--space-8);
  border-radius: var(--radius-4);
  color: var(--fg-link);
  background: var(--bg-action-subtle);
  font-size: var(--text-dns-14n-130-size);
  font-weight: 700;
  line-height: 1.5;
}

.content {
  max-width: 90rem;
  margin: auto;
  padding: var(--space-32) var(--space-40) var(--space-48);
}

.page-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: var(--space-16);
  margin-bottom: var(--space-24);
}

.page-heading .muted {
  margin-top: var(--space-4);
}

/* ボタン。DADS に寄せ、角丸 8、高さは 44px 以上。地は白い文字で 4.5:1 を満たす bg.action。 */
.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-8);
  min-height: var(--size-control-md);
  background: var(--bg-action);
  color: var(--fg-on-action);
  border: 1px solid transparent;
  padding: var(--space-8) var(--space-20);
  border-radius: var(--radius-8);
  font-size: var(--text-std-16n-170-size);
  font-weight: 700;
  line-height: 1.5;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover {
  background: var(--bg-action-hover);
  color: var(--fg-on-action);
}

.btn:active {
  background: var(--bg-action-active);
}

.btn.secondary {
  background: var(--bg-canvas);
  color: var(--fg-link);
  border-color: var(--border-action);
}

.btn.secondary:hover {
  background: var(--bg-action-subtle);
  color: var(--fg-link);
}

.btn.secondary:active {
  background: var(--bg-action-subtle-hover);
}

.btn.small {
  min-height: 2.25rem;
  font-size: var(--text-dns-14n-130-size);
  padding: var(--space-4) var(--space-12);
}

.btn.danger {
  background: var(--bg-danger-subtle);
  color: var(--fg-danger);
  border-color: var(--border-danger);
}

.btn:disabled,
.text-button:disabled {
  background: var(--bg-subtle);
  color: var(--fg-muted);
  border-color: var(--border-subtle);
}

.text-button {
  background: transparent;
  color: var(--fg-link);
  font-size: var(--text-dns-14n-130-size);
  font-weight: 700;
  line-height: 1.5;
  min-height: 2.25rem;
  padding: var(--space-4) var(--space-8);
  border-radius: var(--radius-8);
  text-decoration: underline;
  text-underline-offset: 0.2em;
  white-space: nowrap;
}

.text-button:hover {
  background: var(--bg-action-subtle);
  color: var(--fg-link-hover);
}

.text-button:disabled {
  background: transparent;
  border-color: transparent;
  text-decoration: none;
}

/* カード */
.card {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-8);
  background: var(--bg-surface);
  overflow: hidden;
  margin-bottom: var(--space-24);
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-16) var(--space-24);
  gap: var(--space-12);
}

.card-footer {
  font-size: var(--text-dns-14n-130-size);
  line-height: 1.5;
  color: var(--fg-muted);
  padding: var(--space-12) var(--space-24);
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
}

/* 表。横にあふれるときは表の中だけでスクロールする。 */
.table-wrap {
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  width: 100%;
  text-align: left;
  font-size: var(--text-dns-14n-130-size);
  line-height: 1.5;
  white-space: nowrap;
}

th {
  font-size: var(--text-dns-14n-130-size);
  color: var(--fg-default);
  font-weight: 700;
  background: var(--bg-subtle);
  padding: var(--space-12) var(--space-16);
  border-block: 1px solid var(--border-subtle);
}

td {
  padding: var(--space-12) var(--space-16);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}

tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: var(--bg-action-subtle);
}

.sub {
  display: block;
  font-size: var(--text-dns-14n-130-size);
  color: var(--fg-muted);
  margin-top: var(--space-2);
}

.wrap {
  white-space: normal;
  min-width: 11rem;
}

.inline-actions {
  display: flex;
  align-items: center;
  gap: var(--space-8);
}

/* バッジ。色だけに頼らず、文字と枠で状態を伝える。 */
.badge {
  font-size: var(--text-dns-14n-130-size);
  font-weight: 700;
  line-height: 1.5;
  display: inline-flex;
  align-items: center;
  gap: var(--space-4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-4);
  padding: 0 var(--space-8);
  background: var(--bg-subtle);
  color: var(--fg-default);
  white-space: nowrap;
}

.badge::before {
  content: '';
  height: 0.5rem;
  width: 0.5rem;
  border-radius: var(--radius-full);
  background: currentColor;
}

.badge.active,
.badge.paid {
  background: var(--bg-success-subtle);
  color: var(--fg-success);
  border-color: var(--fg-success);
}

.badge.trial {
  background: var(--bg-action-subtle);
  color: var(--fg-link);
  border-color: var(--border-action);
}

.badge.grace,
.badge.open {
  background: var(--bg-warning-subtle);
  color: var(--fg-warning);
  border-color: var(--fg-warning);
}

.badge.suspended {
  background: var(--bg-danger-subtle);
  color: var(--fg-danger);
  border-color: var(--border-danger);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-16);
  padding: var(--space-4) var(--space-24) var(--space-24);
}

.detail-item {
  background: var(--bg-subtle);
  padding: var(--space-16);
  border-radius: var(--radius-8);
  font-size: var(--text-std-16n-170-size);
  line-height: var(--text-std-16n-170-line-height);
}

.detail-item > span:first-child {
  display: block;
  font-size: var(--text-dns-14n-130-size);
  color: var(--fg-muted);
  margin-bottom: var(--space-4);
  line-height: 1.5;
}

.empty {
  text-align: center;
  padding: var(--space-48) var(--space-20);
  color: var(--fg-muted);
}

/* ログイン */
.login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.login-story {
  background: var(--bg-action-subtle);
  color: var(--fg-default);
  padding: var(--space-64) 12%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--space-32);
  min-height: 100vh;
}

.login-story .eyebrow {
  margin-bottom: var(--space-16);
}

.login-story h1 {
  font-size: 2.5rem;
  line-height: 1.5;
  letter-spacing: 0.02em;
}

.login-story p {
  margin-top: var(--space-24);
}

.login-story footer {
  font-size: var(--text-dns-14n-130-size);
  line-height: 1.5;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
}

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-48);
}

.login-inner {
  width: 100%;
  max-width: 26rem;
}

.login-inner h2 {
  font-size: var(--text-std-28n-150-size);
  margin: var(--space-12) 0 var(--space-8);
}

.login-inner > .muted {
  margin-bottom: var(--space-24);
}

/* 入力欄。枠は 3:1 以上の border.default。 */
label.field,
fieldset.field {
  display: block;
  font-size: var(--text-std-16n-170-size);
  font-weight: 700;
  line-height: var(--text-std-16n-170-line-height);
  margin: var(--space-16) 0;
}

fieldset.field {
  border: 0;
  padding: 0;
  min-width: 0;
}

fieldset.field legend {
  padding: 0;
}

label.field input,
label.field select {
  display: block;
  width: 100%;
  min-height: var(--size-control-md);
  margin-top: var(--space-8);
  padding: var(--space-8) var(--space-12);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-8);
  background: var(--bg-canvas);
  color: var(--fg-default);
  font-weight: 400;
}

label.field input:hover,
label.field select:hover {
  border-color: var(--fg-default);
}

/* 入力欄は、クリックでも枠が主色の 2px になる。1px から太る分は内側の影で足し、中身をずらさない（ホバーの規則より後ろに置く）。 */
input:not([type="checkbox"], [type="radio"]):focus,
label.field input:focus,
label.field select:focus,
select:focus,
textarea:focus {
  border-color: var(--focus-outline);
  box-shadow: inset 0 0 0 1px var(--focus-outline);
  outline: none;
}

.checkbox {
  display: flex;
  align-items: flex-start;
  gap: var(--space-8);
  font-size: var(--text-std-16n-170-size);
  font-weight: 400;
  line-height: var(--text-std-16n-170-line-height);
  margin-top: var(--space-8);
}

.checkbox input {
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  margin: 0.1rem 0 0;
  accent-color: var(--bg-action);
}

.form-error {
  color: var(--fg-danger);
  font-weight: 700;
  margin-top: var(--space-12);
}

.form-error:empty {
  display: none;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-12);
  margin-top: var(--space-24);
}

/* トーストとダイアログ */
#toast {
  position: fixed;
  bottom: var(--space-24);
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  background: var(--fg-default);
  color: var(--bg-canvas);
  box-shadow: var(--shadow-elevation-4);
  padding: var(--space-12) var(--space-20);
  border-radius: var(--radius-8);
  width: max-content;
  max-width: min(37.5rem, calc(100vw - 2rem));
  display: none;
}

#toast.show {
  display: block;
}

#toast.error {
  background: var(--bg-danger);
  color: var(--fg-on-action);
}

dialog {
  padding: var(--space-24);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-12);
  max-width: 30rem;
  width: calc(100vw - 2rem);
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  background: var(--bg-surface);
  color: var(--fg-default);
  box-shadow: var(--shadow-elevation-5);
}

dialog::backdrop {
  background: var(--color-overlay);
}

dialog h2 {
  margin-bottom: var(--space-8);
}

dialog p {
  color: var(--fg-muted);
  margin-bottom: var(--space-16);
}

@media (max-width: 1150px) {
  .content {
    padding: var(--space-24);
  }

  .topbar {
    padding-inline: var(--space-24);
  }
}

@media (max-width: 760px) {
  .layout {
    display: block;
  }

  .sidebar {
    position: static;
    width: auto;
    padding: var(--space-16) var(--space-16) var(--space-12);
    border-right: 0;
    border-bottom: 1px solid var(--border-subtle);
    overflow: visible;
  }

  .workspace-label,
  .nav-label,
  .sidebar-bottom {
    display: none;
  }

  .nav {
    flex-direction: row;
    overflow-x: auto;
    margin-top: var(--space-12);
    padding-bottom: var(--space-4);
  }

  .nav button {
    white-space: nowrap;
  }

  .topbar {
    padding: var(--space-8) var(--space-16);
  }

  .topbar .right > span:first-child {
    display: none;
  }

  .content {
    padding: var(--space-24) var(--space-16);
  }

  h1 {
    font-size: var(--text-std-24n-150-size);
  }

  .page-heading {
    flex-direction: column;
    align-items: stretch;
  }

  .page-heading > .btn {
    align-self: flex-start;
  }

  .card-head {
    padding: var(--space-16);
  }

  .card-footer {
    padding: var(--space-12) var(--space-16);
  }

  .detail-grid {
    grid-template-columns: minmax(0, 1fr);
    padding: var(--space-4) var(--space-16) var(--space-16);
  }

  th,
  td {
    padding-inline: var(--space-12);
  }

  .login {
    grid-template-columns: minmax(0, 1fr);
  }

  .login-story {
    min-height: auto;
    padding: var(--space-24) var(--space-16);
  }

  .login-story h1 {
    font-size: var(--text-std-24n-150-size);
  }

  .login-story > div:nth-child(2) {
    padding-top: var(--space-16);
  }

  .login-story .eyebrow,
  .login-story footer,
  .login-story p {
    display: none;
  }

  .login-panel {
    padding: var(--space-24) var(--space-16);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .content,
  .login-inner {
    animation: appear 0.35s ease-out;
  }

  @keyframes appear {
    from {
      opacity: 0;
      transform: translateY(0.5rem);
    }

    to {
      opacity: 1;
      transform: none;
    }
  }
}

/* 初回登録の手順（guide.html）。ログイン前に読む1段の文書。 */
.guide {
  max-width: 46rem;
  margin: 0 auto;
  padding: var(--space-48) var(--space-16) var(--space-64);
}

.guide h1 {
  margin: var(--space-32) 0 var(--space-8);
}

.guide h2 {
  margin: var(--space-40) 0 var(--space-12);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
}

.guide figure {
  margin: var(--space-12) 0 var(--space-20);
}

.guide figure img {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-4);
}

.guide-note {
  margin: var(--space-16) 0;
  padding: var(--space-12) var(--space-16);
  background: var(--bg-subtle);
  border-radius: var(--radius-4);
}

.guide-note p {
  margin: 0;
}

.guide-table {
  white-space: normal;
}
