:root {
  color-scheme: light;
  --bg: #f3f6fb;
  --surface: #ffffff;
  --border: #d8e0ec;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --success: #059669;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --shell-max-width: 1180px;
  --shell-padding-x: 20px;
}

* {
  box-sizing: border-box;
}

body:not([data-developer="true"]) .developer-only {
  display: none !important;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Hiragino Sans", "Yu Gothic UI", sans-serif;
  background: linear-gradient(180deg, #eef4ff 0%, var(--bg) 240px);
  color: var(--text);
}

.layout,
.admin-shell {
  width: 100%;
  max-width: min(var(--shell-max-width), calc(100vw - var(--shell-padding-x) * 2));
  margin: 0 auto;
  padding: 32px var(--shell-padding-x) 48px;
}

.admin-body {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.admin-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: sticky;
  top: 20px;
}

.nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  box-shadow: var(--shadow);
}

.nav-link:hover {
  border-color: #bfd0ef;
  background: #f8fbff;
}

.nav-link.is-active {
  border-color: #93c5fd;
  background: #eff6ff;
  color: #1d4ed8;
}

.nav-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e5e7eb;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.nav-link.is-active .nav-badge {
  background: #dbeafe;
  color: #1d4ed8;
}

.admin-main {
  min-width: 0;
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.menu-card {
  display: block;
  padding: 24px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.menu-card:hover {
  transform: translateY(-2px);
  border-color: #93c5fd;
}

.menu-card.is-placeholder {
  opacity: 0.92;
}

.menu-card-label {
  display: block;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--primary);
  font-weight: 700;
  margin-bottom: 8px;
}

.menu-card-title {
  display: block;
  font-size: 22px;
  margin-bottom: 10px;
}

.menu-card-desc {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
}

.placeholder-card {
  position: relative;
}

.placeholder-badge {
  display: inline-block;
  margin-bottom: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
  font-size: 12px;
  font-weight: 700;
}

.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status-badge.is-connected {
  background: #dcfce7;
  color: #166534;
}

.status-badge.is-disconnected {
  background: #e5e7eb;
  color: #4b5563;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
  font-weight: 700;
}

h1, h2 {
  margin: 0;
}

.header-actions {
  display: flex;
  gap: 12px;
}

.card,
.stat-card,
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.card,
.auth-card {
  padding: 24px;
  margin-bottom: 20px;
}

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

.card-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  flex-shrink: 0;
}

.client-sort-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.client-sort-control select {
  width: auto;
  min-width: 10.5rem;
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 600;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  padding: 18px 20px;
}

.stat-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}

.has-tooltip {
  cursor: help;
  outline: none;
}

.has-tooltip:hover,
.has-tooltip:focus-visible {
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}

/* data-tooltip 用フローティング説明 */
.admin-tooltip {
  position: fixed;
  z-index: 10000;
  width: max-content;
  max-width: min(28rem, calc(100vw - 24px));
  padding: 6px 10px;
  border-radius: 8px;
  background: #111827;
  color: #f9fafb;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
  text-align: left;
  white-space: normal;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.18);
  pointer-events: none;
}

.btn-tooltip-wrap {
  display: inline-flex;
  max-width: 100%;
}

.btn-tooltip-wrap .btn:disabled {
  pointer-events: none;
}

.btn-tooltip-wrap:has(.btn:disabled) {
  cursor: not-allowed;
}

.admin-tooltip[hidden] {
  display: none !important;
}

.toggle-cell {
  white-space: nowrap;
}

.toggle-cell--center {
  text-align: center;
}

.th-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.data-table th.th-center,
.data-table td.toggle-cell--center {
  text-align: center;
}

.toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  cursor: pointer;
}

.status-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.status-pill.is-online {
  background: #dcfce7;
  color: #166534;
}

.status-pill.is-offline {
  background: #f3f4f6;
  color: #6b7280;
}

.status-pill.is-verified {
  background: #dcfce7;
  color: #166534;
}

.status-pill.is-unverified {
  background: #fef3c7;
  color: #92400e;
}

.version-outdated {
  color: var(--danger);
  font-weight: 700;
}

.clients-table .col-connection,
.clients-table .col-auth,
.clients-table .col-employee-id,
.clients-table .col-notification-target {
  white-space: nowrap;
}

.clients-table .col-connection,
.clients-table .col-auth {
  width: 2.6rem;
  padding-left: 6px;
  padding-right: 6px;
}

.clients-table .col-employee-id {
  width: 4.5rem;
  padding-left: 8px;
  padding-right: 8px;
  font-variant-numeric: tabular-nums;
}

.clients-table .col-notification-target {
  width: 5.5rem;
}

.clients-table td.col-connection .status-pill,
.clients-table td.col-auth .status-pill,
.pending-review-list .status-pill {
  writing-mode: vertical-rl;
  text-orientation: upright;
  padding: 8px 3px;
  letter-spacing: 0.02em;
  line-height: 1;
  border-radius: 999px;
}

.pending-review-panel {
  margin-top: 16px;
}

.pending-review-list {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pending-review-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.overtime-clients-table th.col-employee-id {
  white-space: normal;
  line-height: 1.25;
  font-size: 12px;
}

.stat-card strong {
  font-size: 22px;
}

.field,
.field-row {
  margin-bottom: 18px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(0, 1fr);
  gap: 14px 24px;
  align-items: start;
}

.form-grid > label {
  margin-bottom: 0;
  padding-top: 10px;
}

.field-wide {
  grid-column: 1 / -1;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="time"],
input[type="month"],
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
}

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

.time-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.time-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.time-row.trigger-row {
  grid-template-columns: 140px 132px auto;
  justify-content: start;
}

.trigger-value {
  min-width: 0;
}

.settings-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-group-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.settings-group {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px 18px;
  background: #fff;
}

.settings-group-header {
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.settings-group-kicker {
  display: inline-flex;
  align-items: center;
  margin: 0 0 8px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.settings-group-header h3,
.settings-subgroup h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.settings-group-header .hint,
.settings-subgroup .hint {
  margin-top: 6px;
}

.settings-group--deemed {
  background: #f8fbff;
  border-color: #bfdbfe;
  box-shadow: inset 5px 0 0 #2563eb;
}

.settings-group--deemed .settings-group-kicker {
  background: #dbeafe;
  color: #1d4ed8;
}

.settings-group--late-night {
  background: #faf7ff;
  border-color: #ddd6fe;
  box-shadow: inset 5px 0 0 #7c3aed;
}

.settings-group--late-night .settings-group-kicker {
  background: #ede9fe;
  color: #6d28d9;
}

.settings-group--special {
  background: #fffbeb;
  border-color: #fde68a;
  box-shadow: inset 5px 0 0 #d97706;
}

.settings-group--special .settings-group-kicker {
  background: #fef3c7;
  color: #b45309;
}

.settings-limit-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 8px;
}

.settings-limit-row .field {
  margin-bottom: 0;
}

.settings-subgroup {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed rgba(15, 23, 42, 0.12);
}

.settings-group--interval {
  max-width: 280px;
  padding: 14px 16px;
}

.settings-group--interval input {
  width: 140px;
}

.clock-duration,
.percent-input-wrap {
  display: inline-flex;
  align-items: center;
  width: 140px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  box-sizing: border-box;
}

.clock-duration:focus-within,
.percent-input-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
}

.clock-duration-colon,
.percent-suffix {
  color: var(--muted);
  font-weight: 700;
  font-size: 14px;
  user-select: none;
}

.clock-duration-colon {
  margin: 0 4px;
}

.percent-suffix {
  margin-left: 4px;
}

.clock-duration input[type="text"],
.percent-input-wrap input[type="text"] {
  min-width: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  outline: none;
}

.clock-duration input[type="text"] {
  flex: 1;
  width: auto;
}

.clock-duration-hours {
  text-align: right;
}

.clock-duration-minutes {
  text-align: left;
}

.percent-input-wrap input[type="text"] {
  flex: 1;
  width: auto;
  text-align: center;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-small {
  padding: 8px 12px;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

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

.btn-secondary {
  background: #e5edf9;
  color: #1e3a8a;
}

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

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

.field-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1200;
  min-width: 280px;
  max-width: 420px;
  padding: 14px 16px;
  border-radius: 12px;
  color: white;
  box-shadow: var(--shadow);
}

.toast.success {
  background: var(--success);
}

.toast.error {
  background: var(--danger);
}

code {
  background: #eef2ff;
  padding: 2px 6px;
  border-radius: 6px;
}

.jobcan-test-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.jobcan-test-result {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f8fbff;
  padding: 16px;
  font-size: 13px;
  line-height: 1.6;
}

.jobcan-test-result h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.jobcan-test-result .result-summary {
  margin: 0 0 12px;
  color: var(--muted);
}

.jobcan-test-result .result-error {
  color: var(--danger);
  margin: 0;
}

.jobcan-test-result .result-warning {
  color: #9a6700;
  margin: 0 0 12px;
}

.jobcan-test-result .probe-source + .probe-source {
  margin-top: 20px;
}

.account-purpose-input {
  width: 100%;
  min-width: 10rem;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.probe-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
}

.probe-filter-field {
  max-width: 16rem;
  margin-bottom: 12px;
}

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

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

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

.data-table th {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.data-table tbody tr:hover {
  background: #f8fbff;
}

.empty-cell {
  text-align: center;
  color: var(--muted);
  padding: 24px !important;
}

.field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  resize: vertical;
  min-height: 96px;
}

.remarks-cell {
  max-width: 220px;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--muted);
  font-size: 13px;
}

@media (min-width: 960px) {
  .settings-group-grid,
  .settings-limit-row {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 1280px) {
  :root {
    --shell-max-width: 1440px;
    --shell-padding-x: 28px;
  }

  .field-grid {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  }

  .status-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }

  .menu-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  }

  .form-grid {
    grid-template-columns: minmax(180px, 260px) minmax(0, 1fr);
    gap: 16px 32px;
  }

  .remarks-cell {
    max-width: 360px;
  }
}

@media (min-width: 1600px) {
  :root {
    --shell-max-width: 1720px;
    --shell-padding-x: 36px;
  }

  .field-grid {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  }

  .remarks-cell {
    max-width: 520px;
  }
}

@media (min-width: 1920px) {
  :root {
    --shell-max-width: 1880px;
    --shell-padding-x: 40px;
  }

  .remarks-cell {
    max-width: none;
    min-width: 240px;
  }
}

.action-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.managed-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 11px;
  font-weight: 600;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

.modal-card {
  position: relative;
  width: min(480px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 24px;
}

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

.form-actions-inline {
  display: flex;
  align-items: end;
}

/* ログイン画面（シェル・ナビなし） */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.login-shell {
  width: min(420px, calc(100vw - 32px));
}

.login-card h1 {
  margin-bottom: 8px;
}

.login-form {
  margin-top: 20px;
}

.login-submit {
  width: 100%;
}

.login-error {
  color: var(--danger);
  font-size: 14px;
  margin: 0 0 12px;
}

.minute-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 28px;
  margin-bottom: 8px;
}

.minute-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef2ff;
  color: #1e3a8a;
  font-size: 13px;
}

.minute-add-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.button-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
}

@media (max-width: 720px) {
  .header {
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
  }

  .header-actions .btn {
    flex: 1;
  }

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

  .admin-nav {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .nav-link {
    flex: 1 1 calc(50% - 8px);
  }
}

.card--presentation {
  border: 2px dashed #d97706;
  background: #fffbeb;
}

.card--presentation .card-header h2 {
  color: #b45309;
}

/* PRESENTATION-TEMP: プレゼン用残業通知テスト送信 */
.preview-duration-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  margin: 4px 0 8px;
}

.preview-duration-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  padding: 14px 16px 16px;
}

.preview-duration-card h3 {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.preview-duration-value {
  margin: 0 0 12px;
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  line-height: 1.2;
}

.preview-duration-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.preview-duration-row + .preview-duration-row {
  margin-top: 8px;
}

.preview-duration-row-label {
  width: 2.5em;
  flex: none;
  font-size: 13px;
  color: var(--muted);
}

.preview-duration-row .btn {
  min-width: 64px;
}

.toast.info {
  background: #b45309;
}

/* 手動の長時間処理。進捗は出さず、点が上下して処理中だと分かるようにする。 */
body.is-busy {
  overflow: hidden;
}

.busy-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.45);
}

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

.busy-card {
  width: min(420px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 28px 24px 24px;
  text-align: center;
}

.busy-visual {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 10px;
  height: 28px;
  margin-bottom: 14px;
}

.busy-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  animation: busy-bounce 0.9s ease-in-out infinite;
}

.busy-dot:nth-child(2) {
  animation-delay: 0.15s;
}

.busy-dot:nth-child(3) {
  animation-delay: 0.3s;
}

.busy-status {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.08em;
}

.busy-message {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.5;
}

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

.busy-hint {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

@keyframes busy-bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.35;
  }

  40% {
    transform: translateY(-12px);
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .busy-dot {
    animation: none;
    opacity: 1;
  }
}
